Skip to content

fix(minesweeper): practice "Play Again" leaves the exploded board frozen, no new game #910

Closed

Description

@wei18

Symptom

Minesweeper → Practice → any difficulty → hit a mine (boom/loss) → tap Play Again. The board does NOT restart: it stays frozen on the exploded state, still showing the revealed mine positions from the lost game.

Root cause (mirror drift, MS-only, Practice-only)

The onPlayAgain closure DOES fire a real new-board path (MinesweeperBoardView.swift:1163-1169 → LiveRouteFactory+DailyBoardOpen.swift:100-107 mints a new seed → presentGame), so it's not a closure-level no-op. The break is SwiftUI identity:

MinesweeperBoardView builds its game state inline: @State private var viewModel = State(initialValue: MinesweeperGameViewModel(...)) (MinesweeperBoardView.swift:72,225-235). On Play Again the route changes but the view's structural identity does not (same type, same tree position in GameRoot's GameModalContent, GameRoot.swift:216-229, no .id(route)), so SwiftUI treats the new MinesweeperBoardView(seed:…) as an update — @State's initialValue is only honored on first creation per identity, so the new seed is discarded and the old exploded-board @State survives.

Why Sudoku works: Sudoku wraps BoardView in BoardLoaderView with .task(id: puzzleId) (BoardLoaderView.swift:152-159); puzzleId updates on every re-render and .task(id:) re-fires on change → forces a fresh GameViewModel. MS Practice has no such loader wrapper (only Daily has an indirection layer, and Daily's onPlayAgain is hard-nil by design — one-per-day). MS never got the #652 Play-Again snapshot/debug-hook regression test that Sudoku has, so this went undetected.

Fix direction

Give MS Practice boards the same identity-reset Sudoku has — either a .task(id: seed/difficulty)-gated rebuild (mirror BoardLoaderView) or .id(seed) on the mounted content — NOT a dismiss/present reordering (Sudoku proves ordering isn't the problem). Add the missing MS Play-Again regression test.

Verification required

Sim repro (Practice → lose → Play Again → confirm fresh board). Mute BGM first. Add regression test mirroring Sudoku #652.

Origin: owner bug report 2026-07-20.

Activity

  1. added
    bug
    on Jul 20, 2026
  2. wei18 commented on Jul 20, 2026

    @wei18
    OwnerAuthor

    🔒 Claiming — dispatching to an implementation agent (Leader session 064a54f6). Fix mirrors Sudoku's BoardLoaderView identity-reset; MS Practice-only.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions