Skip to content

chore(appcomposition): delete all 6 dead VM factories - #44

Merged
wei18 merged 1 commit into
mainfrom
chore/dead-vm-factories-audit-cleanup
May 20, 2026
Merged

wei18 merged 1 commit into
mainfrom
chore/dead-vm-factories-audit-cleanup

Conversation

@wei18

@wei18 wei18 commented May 20, 2026

Copy link
Copy Markdown
Owner

Closes #34. All 6 ViewModelFactory entries (post-#33) are dead — verified by per-factory consumer grep. AppComposition collapses to one-field struct wrapping rootViewModel. 364/364 tests unchanged.

§未決 (flagged for Leader follow-up): design.md §How.1 DI architecture deserves a re-read. Factory pattern was plumbed but never connected to Views — either regression OR factories were never the intended pattern. Separate decision.

🤖 Claude Code

Closes #34. Per-factory audit confirmed all 6 remaining factories
(dailyHub / practiceHub / game / completion / leaderboard / settings)
have ZERO consumers outside their own setter sites in
AppComposition.swift / Live.swift / Preview.swift / CompositionTests.

Only `composition.rootViewModel` is read by anything
(App/SudokuApp.swift:11). RootView uses `destination: { _ in EmptyView() }`,
and grep for DailyHubView(/GameView(/... constructor calls returns zero
hits. The factory pattern was plumbed but never connected.

Changes:
- AppComposition.swift: removed 6 properties + 6 init params + 6
  assignments; pruned now-unused imports (GameCenterClient, GameState,
  Persistence, PuzzleStore, SudokuEngine, Telemetry). Now a one-field
  struct wrapping rootViewModel.
- Live.swift: removed all 6 factory args from AppComposition(...) call;
  removed orphaned leaderboardId(for:) helper; pruned imports.
- Preview.swift: removed all 6 factory args + orphaned provider local;
  pruned imports.
- CompositionTests.swift: removed 6 _ = composition.xxxFactory touch
  lines; adjusted comment.

364/364 tests, 0 warnings.

§未決 (FOLLOW-UP for Leader): All 7 VM factories (counting #33's
homeViewModelFactory) were dead from the start. AppComposition is now
a one-field struct. design.md §How.1 DI architecture deserves a re-read:
either VM factories were intended and Views never got wired (regression),
or inline VM construction (RootView/HomeView pattern) is the de facto
choice and §How.1 spec should be amended to drop the factory pattern.
Separate refactor decision.

impl-notes: meetings/2026-05-20_dead-vm-factories-audit.impl-notes.md
@wei18
wei18 merged commit 47f94c9 into main May 20, 2026
@wei18
wei18 deleted the chore/dead-vm-factories-audit-cleanup branch May 20, 2026 09:34
wei18 added a commit that referenced this pull request May 20, 2026
…apper (#45) (#48)

Closes #45. Critical v1 navigation gap — RootView.destination returned
EmptyView, so tapping any HomeView card past Home led to a blank screen
on device. Every View renders standalone in snapshots; the NavigationStack
glue was never wired.

Option A chosen: RootView.init grows to take the 4 protocol deps
(puzzleProvider / persistence / gameCenter / telemetry) alongside its
existing RootViewModel. Destination becomes a real switch over the 7
AppRoute cases, each constructing the matching View + VM inline.

BoardView async-puzzle challenge resolved with shape (iii):
- NEW BoardLoaderView.swift (110 lines): @mainactor View with
  LoadState .loading / .loaded(GameViewModel) / .failed(String)
- .task(id: puzzleId) calls persistence.loadOrCreate + GameSession.restore
  + GameViewModel live ctor on success → .loaded
- .failed surfaces Retry button that re-runs load()
- GameViewModel.swift and BoardView.swift untouched (original fence
  preserved; lifted only for the new wrapper file)

AppRoute.completion limitation: case doesn't carry difficulty/mode, so
the Completion → Leaderboard route uses LeaderboardIDs.id(for: .dailyEasy)
placeholder. Backlog entry filed in design.md §不在 v1 範圍 §導航 for
expanding AppRoute.completion case in a future PR.

design.md §How.1: DI Composition Root section amended to drop
*ViewModelFactory references and document the actual inline-construction
pattern. Cross-links issues #15 / #34 / #45 + PRs #33 / #44 as the trail.

Verified:
- swift build: 0 warnings
- swift test: 364/364 in 69 suites
- xcodebuild iOS scheme: ** BUILD SUCCEEDED ** (Leader-run; subagent
  was sandbox-blocked)
- TODO sweep on Root/ + Board/BoardLoaderView.swift + AppComposition/
  → 0 hits

impl-notes: meetings/2026-05-20_route-destination-wireup.impl-notes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AppComposition: all 6 remaining ViewModelFactory entries also appear unused

1 participant