Skip to content

RootView destination closure returns EmptyView — app navigation beyond Home is broken #45

Closed

Description

@wei18

Severity

Critical for v1 ship — App is unusable past the Home screen on real device. Every View renders standalone in snapshot tests, but production navigation never reaches them because RootView's destination closure ignores the route.

Root cause

Packages/SudokuKit/Sources/SudokuUI/Root/RootView.swift:22:

NavigationStackHost(
    path: ...,
    sidebar: { sidebarPlaceholder },
    content: { rootContent },
    destination: { _ in EmptyView() }   // ← THIS
)

When user taps a HomeView mode card → viewModel.path.append(.daily) → NavigationStack tries to render destination(.daily) → returns EmptyView() → user sees blank screen.

Discovery

Issue #34 cleanup confirmed all 7 ViewModelFactory entries were dead. Tracing why: the destination closure never calls them either. The DI/composition pattern envisioned by design.md §How.1 was never wired end-to-end.

Fix

Two coupled changes:

  1. Code: RootView.destination becomes a real switch:

    destination: { route in
        switch route {
        case .home:                       EmptyView()  // root content, not pushed
        case .daily:                      DailyHubView(viewModel: ...)
        case .practice:                   PracticeHubView(viewModel: ...)
        case .board(let puzzleId):        BoardView(viewModel: ...)
        case .completion(let pid, let secs): CompletionView(viewModel: ...)
        case .leaderboard(let id):        LeaderboardView(viewModel: ...)
        case .settings:                   SettingsView(viewModel: ...)
        }
    }

    Each downstream VM is constructed inline with the same Binding-or-let pattern as HomeViewModel (post HomeView mode cards have shrunken tap targets; Mac sidebar items don't respond #15). Some VMs need protocol-injected deps (PuzzleStore, Persistence, GameCenter, Telemetry) — those need plumbing through RootView.init or via composition root.

  2. Spec: docs/design.md §How.1 amends:

Acceptance

  • After fix, tapping any HomeView card on real device (or Xcode preview) renders the corresponding View, not blank
  • All 364 tests still green (snapshot tests already instantiate each View standalone — they'll keep passing regardless)
  • Mac sidebar (already wired via NavigationLink in PR fix(homeview, sidebar): tap targets + Mac sidebar wiring + throwaway VM #16) still navigates correctly
  • design.md §How.1 reflects actual code

Risk

  • BoardView / CompletionView need significant deps (PuzzleStore, Persistence, GameCenter, telemetry). RootView currently doesn't own these — they're plumbed via the (almost-empty) AppComposition struct.
  • Either bubble deps into RootView's init, OR move them to @Environment-injected, OR rebuild the composition root to support inline construction.
  • Likely the cleanest is: RootView.init takes all the protocols it needs and passes them down per-route inside destination switch.

Workflow

Subagent should follow agent-impl-notes-log + PROPOSAL → IMPL given the architecture scope. Submit proposal first; Leader approves; then implement.

Discovery

Surfaced 2026-05-20 during #34 cleanup audit; user picked Option A (amend §How.1) which forced realization that wiring destination closure is part of the same fix.
EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions