Commit 2393b71
authored
refactor: extract command-palette helpers and dethunk ContentView.body (CV1, CV2) (#65)
CV1 — ContentView was a single 7000-line struct with ~4,000 lines of
command-palette orchestration written as private funcs mutating @State
directly. Moves 52 pure/computation functions (fuzzy-search corpus
building, result fingerprinting/diffing, shortcut resolution, switcher
entry construction, context-snapshot building — none of which touch
@State) into a new extension file, Sources/ContentView+CommandPalette.swift.
This is the conservative extraction: SwiftUI's @State can't be split
across files, so the @State/@ObservedObject properties, the view body,
and the @State-mutating activation-dispatch / rename / edit-description
flow orchestration all remain on ContentView in ContentView.swift. 19
members the moved functions touch (10 nested command-palette model
types, 6 small helper funcs, 3 computed properties) were widened from
private to internal so the extension can see them; behavior is
unchanged. Full controller-based extraction of the @State-owning
orchestration is a follow-up.
CV2 — ContentView.body reassigned a local through 15+
AnyView(view.onReceive(...)) steps to work around Swift's type checker
(each step needed a stable erased type to reassign into a var). Splits
the ~30 onChange/onReceive attachments into 9 ViewBuilder-composed
helper functions chained via a small number of local let bindings,
removing all AnyView type erasure from the body while keeping every
closure body byte-for-byte identical.
The body's window-accessor closure also mutated AppKit window state
(identifier, titlebar, movability, transparency, glass effect, window
decorations) directly from the view layer. Moves that logic into a new
AppDelegate.configureMainWindow(...) method; the view now makes one
call and keeps only the @State bookkeeping (observedWindow,
isFullScreen, titlebarPadding) it actually owns. makeViewHierarchyTransparent
became a static func on ContentView since it never touched instance state.
project.pbxproj: registers ContentView+CommandPalette.swift (file
reference + build file, mirroring ContentView.swift's 4 entries).1 parent 10d8f12 commit 2393b71
4 files changed
Lines changed: 1584 additions & 1557 deletions
File tree
- GhosttyTabs.xcodeproj
- Sources
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
225 | 226 | | |
226 | 227 | | |
227 | 228 | | |
| 229 | + | |
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
| |||
487 | 489 | | |
488 | 490 | | |
489 | 491 | | |
| 492 | + | |
490 | 493 | | |
491 | 494 | | |
492 | 495 | | |
| |||
808 | 811 | | |
809 | 812 | | |
810 | 813 | | |
| 814 | + | |
811 | 815 | | |
812 | 816 | | |
813 | 817 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10392 | 10392 | | |
10393 | 10393 | | |
10394 | 10394 | | |
| 10395 | + | |
| 10396 | + | |
| 10397 | + | |
| 10398 | + | |
| 10399 | + | |
| 10400 | + | |
| 10401 | + | |
| 10402 | + | |
| 10403 | + | |
| 10404 | + | |
| 10405 | + | |
| 10406 | + | |
| 10407 | + | |
| 10408 | + | |
| 10409 | + | |
| 10410 | + | |
| 10411 | + | |
| 10412 | + | |
| 10413 | + | |
| 10414 | + | |
| 10415 | + | |
| 10416 | + | |
| 10417 | + | |
| 10418 | + | |
| 10419 | + | |
| 10420 | + | |
| 10421 | + | |
| 10422 | + | |
| 10423 | + | |
| 10424 | + | |
| 10425 | + | |
| 10426 | + | |
| 10427 | + | |
| 10428 | + | |
| 10429 | + | |
| 10430 | + | |
| 10431 | + | |
| 10432 | + | |
| 10433 | + | |
| 10434 | + | |
| 10435 | + | |
| 10436 | + | |
| 10437 | + | |
| 10438 | + | |
| 10439 | + | |
| 10440 | + | |
| 10441 | + | |
| 10442 | + | |
| 10443 | + | |
| 10444 | + | |
| 10445 | + | |
| 10446 | + | |
| 10447 | + | |
| 10448 | + | |
| 10449 | + | |
| 10450 | + | |
| 10451 | + | |
| 10452 | + | |
| 10453 | + | |
| 10454 | + | |
| 10455 | + | |
| 10456 | + | |
| 10457 | + | |
| 10458 | + | |
| 10459 | + | |
| 10460 | + | |
| 10461 | + | |
| 10462 | + | |
| 10463 | + | |
| 10464 | + | |
| 10465 | + | |
| 10466 | + | |
| 10467 | + | |
| 10468 | + | |
| 10469 | + | |
| 10470 | + | |
| 10471 | + | |
| 10472 | + | |
| 10473 | + | |
| 10474 | + | |
| 10475 | + | |
| 10476 | + | |
| 10477 | + | |
| 10478 | + | |
| 10479 | + | |
| 10480 | + | |
| 10481 | + | |
| 10482 | + | |
| 10483 | + | |
| 10484 | + | |
| 10485 | + | |
10395 | 10486 | | |
10396 | 10487 | | |
10397 | 10488 | | |
| |||
0 commit comments