Repository navigation
refactor(nav): single pathBinding(for:) factory owned by GameRootViewModel (#1042) - #1043
Conversation
…Model (#1042) GameRoot bound per-tab paths through `setPath(_:for:persistJoin:)` while both apps' Live+TabRoots.swift built a second Binding over the same storage calling `setPath(_:for:)` with no TerminalPersistJoin — two teardown contracts over one state (the #823 race guard was bypassed for hub-originated writes). Opus review of #1038, m4. - GameRootViewModel now OWNS the TerminalPersistJoin (defaulted init param so tests can pass a short-timeout join) and exposes `pathBinding(for:)` — the one place a per-tab path Binding is built. Lives in GameRootViewModel+PathBinding.swift (the VM file sits at 396 lines against SwiftLint's 400 ceiling). - GameRoot drops its `@State persistJoin`; environment injection, `dismissGame(persistJoin:)` and RootShellView's `path:` all read the VM's join / factory. Both apps' private `pathBinding` helpers deleted; `rg "setPath\("` now shows only the VM itself + UITestRouteModifier. - New GameRootViewModelTabPathTests case: a hub-originated pop through `pathBinding(for:)` defers the teardown bump until the registered terminal-persist task lands (fails if the factory drops the join). - memoizedTabRoots: DEBUG-only os_signpost interval + Logger line reporting how long the eager 3-tab build takes (issue item 3, measurement only — numbers in the PR body). part of #1014 Co-Authored-By: Claude <[email protected]>
|
T6 ACCEPT (fresh-context, throwaway detached worktree @ 6be6f36)\n\nA. ✅ pathBinding(for:) single factory. rg "setPath(" Packages App on head: only GameRootViewModel.swift (definition/push/popToRoot), GameRootViewModel+PathBinding.swift (the factory), UITestRouteModifier.swift (deep-link hook), and tests — no per-app binding construction. Both apps' Live+TabRoots.swift diffs confirmed: private pathBinding() helpers deleted, calls now rootViewModel.pathBinding(for:). GameRoot.swift diff is small but not exactly as stated: numstat shows +12/-16 (PR body says -14/+10) — minor inaccuracy, still a small single-purpose diff.\n\nB. ✅ TerminalPersistJoin owned by GameRootViewModel (public let persistJoin, GameRoot drops its @State). New test: GameRootViewModelTabPathTests.swift pathBindingRoutesThroughPersistJoin() (#Test "#1042: pathBinding(for:) routes a hub-originated pop through the persist join") — ran green, proves a hub-originated write via pathBinding(for:) defers sessionTeardownCount until the registered join task completes.\n\nC. |
What
Opus review of #1038 (m4):
GameRootbound per-tab paths throughsetPath(_:for:persistJoin:)while both apps'Live+TabRoots.swiftbuilt a secondBindingover the same storage callingsetPath(_:for:)with noTerminalPersistJoin— two teardown contracts over one state, and the #823 race guard silently bypassed for hub-originated writes.How
GameRootViewModelowns theTerminalPersistJoin(public let persistJoin, defaulted init param so tests can pass a short-timeout join) and exposespathBinding(for:)— the one place a per-tab pathBindingis built (GameRootViewModel+PathBinding.swift; the VM file sits at 396/400 SwiftLintfile_length).GameRootdrops its@State persistJoin; the environment injection,dismissGame(persistJoin:)andRootShellView'spath:all read the VM's join / factory. MinimalGameRoot.swiftdiff (−14/+10, one hunk per use) for feat(nav): iPad/macOS Settings as a fixed sidebar item per design.md §3.7 (#1020 follow-up) #1041's rebase.pathBindinghelpers deleted.rg "setPath\(" Packages App(production) → onlyGameRootViewModel.swift(definition +push/popToRoot), the factory itself, and the DEBUG-onlyUITestRouteModifier.swift:88deep-link hook.TerminalPersistJoin.swiftheader updated (it described the join as aGameRoot@State). No other doc describes the old two-binding shape (rgoverdocs/+meetings/).memoizedTabRoots(item 3):#if DEBUGOSSignposterinterval +os.LoggerlinememoizedTabRoots built 3 tab roots in <ms> ms(subsystemcom.wei18.GameAppKit, categorylaunch). Measurement only — no optimization.Tests
#1042: pathBinding(for:) routes a hub-originated pop through the persist join(gated save + pop through the binding →sessionTeardownCountstays 0 until the gate opens; fails if the factory dropspersistJoin:) + the existing #1020 tab-path suite (C-34 / N-AB / popToRoot / #912 filter)autoDismiss_firesAfterDuration, the #849live startOrResume() lands in the reachable Ready windowflake already noted in #1038) — both green re-run in isolation (0.21 s/BoardLeaveOrPauseStateTests7/7)swiftlint --strictCode review (mandatory — touches AppComposition): 2 reviewers reading the working tree — sonnet APPROVE-WITH-NITS (2 informational MINORs: redundant self-pass-through at
GameRoot.swift:150, DEBUG-onlyUITestRouteModifierleftover — both left as-is for the minimal diff), haiku APPROVE-WITH-NITS (staleTerminalPersistJoin.swiftheader → fixed; test doc wording → fixed).Cold-launch cost of
memoizedTabRoots(issue item 3)DEBUG build, iPad Pro 11-inch (M5) simulator, fresh install, launched via XCUITest, read from
log stream --level info --predicate 'subsystem == "com.wei18.GameAppKit"':memoizedTabRoots(3 tab roots: hub VMs +StatsViewModel+LastSelectionStore.load()×2 (+ MSLiveMinesweeperDailyProvider))Not pathological (well under one frame of launch budget, simulator Debug numbers are an upper bound) — no follow-up issue opened; the signpost stays so Instruments can watch it if a future hub VM gets heavier.
iPad simulator drive (idb, both apps, build at this PR's head minus the two comment-only review fixes)
Today/Practice/Progress+game.tab.settingsResume Easy, 0:00(seeded via the DEBUG-uitest-clear-cache-failsynthetic in-progress game); tap pushes onto the Today path →GameBoardRedirect→ boardfullScreenCoverpresented (loader shows the expected "Couldn't load puzzle" — that fake'sloadOrCreatethrows by design); Close → back on Today root with the pillfetchResumereads the MS-nativeMinesweeperSavedGameStore, which no DEBUG hook seedspathBinding(for:))dismissGame(persistJoin: viewModel.persistJoin)with the board's task registered on the VM-owned join from the environment)game.pause.resume/game.pause.leave; Leave → Practice hubcloses #1042
part of #1014
🤖 Generated with Claude Code