refactor(content-view): extract harness launch + lifecycle coordinators#271
Merged
Conversation
Splits the launch and lifecycle flows out of ContentView (974 lines before, the highest-churn file in the audit's god-object list at §2G) into two @observable coordinators held via @State. - HarnessLaunchCoordinator owns: pendingLaunch, launchSheetTarget, launchWorkingDirectory, launchWorktreeBranch, cardBeforeHarness state, the PendingLaunch + LaunchSheetTarget types, and the requestLaunch / tryResolvePendingLaunch / launchHarness / dismiss / clearAllSelection / captureCardBeforeHarness functions. - HarnessLifecycleCoordinator owns: installCardIDs, uninstallCardNames, harnessNameToFork/Update, showForkSheet/UpdateSheet/InstallSheet state, and the installHarness / uninstallHarness / updateHarness / exportHarness / forkHarness / handleTransientSessionExit / handleForkCompleted functions. Both take their service dependencies via constructor injection (default to the existing .shared instances) so tests can drive them directly. Pattern follows the SettingsStore + Lane A approach: @observable + @State, not new singletons. The audit (§2A) flagged singleton-style services as load-bearing bug class #1; adding more would regress. ContentView is now 792 lines (-182). Every reference to the extracted state goes through a coordinator — no half-migration. Sub-views participate via the @State-held coordinator instances. The ContentView+HarnessLaunch.swift and ContentView+HarnessFork.swift extension files are deleted; their content moved into the coordinators or inlined into ContentView's harness sub-view extension. handlePendingTerminal (URL-driven) stays on ContentView — different entry point from the coordinator-driven flows. Adds 13 tests covering both coordinators (initial state, fork/update sheet state, transient-session-exit dispatch, dismiss clears state, captureCardBeforeHarness, clearAllSelection). Tests: 1705 (was 1692). Lint, format, build all clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Splits the launch and lifecycle flows out of
ContentView(974 lines pre-PR — the highest-churn file in the audit's god-object list at §2G) into two@Observablecoordinators. Lane C item from.claude/plans/remediation-sequencing-2026-05-03.md.What moves
HarnessLaunchCoordinatorowns:pendingLaunch,launchSheetTarget,launchWorkingDirectory,launchWorktreeBranch,cardBeforeHarnessPendingLaunch,LaunchSheetTarget(moved out of the deleted extension file)requestLaunch,tryResolvePendingLaunch,launchHarness,dismissLaunchSheet,dismissHarnessDetail,clearAllSelection,captureCardBeforeHarnessHarnessLifecycleCoordinatorowns:installCardIDs,uninstallCardNames,harnessNameToFork/Update,showForkSheet/UpdateSheet/InstallSheetinstallHarness,uninstallHarness,updateHarness,exportHarness,forkHarness,handleTransientSessionExit,handleForkCompletedPattern
Both are
@Observable final class, held byContentViewvia@State, with service dependencies (HarnessRepository, BoardViewModel, YNHDetector, VendorService, YNHPersistence) constructor-injected with.shareddefaults. Sub-views participate by reading the same coordinator instance.Not singletons. The audit (§2A) flagged singleton-style services as load-bearing bug class #1; adding
HarnessLaunchCoordinator.sharedwould regress.@Observable + @Stateis the same patternSettingsStoreand the testability seams use — testable directly from XCTest with mocked dependencies, no global state to reset between tests.Constraints honoured
ContentViewhas zero direct references to any of the extracted state or functions. Every line goes throughlaunchCoordinator.orlifecycleCoordinator.. Verified by grep.ContentView+HarnessLaunch.swift(78 lines) andContentView+HarnessFork.swift(64 lines) are gone. Their@ViewBuilderhelpers (harnessDetailView,updateSheet,forkSheet) inlined into ContentView; their logic moved into coordinators.BoardViewModel.shareddependencies, did not touchTerminalActions/handlePaletteAction, did not move sheets into sub-views, did not touchhandlePendingTerminal(URL-driven, separate concern).Numbers
Test plan
🤖 Generated with Claude Code