clone

fifteen puzzle games for the terminal, with daily puzzles, weekly ladders and xp, built on bubble tea

chore/app-model-decomp
puzzletea / openspec / changes / refactor-root-tui-model / proposal.md
proposal.md 1.9K rendered
1## Why23The root Bubble Tea model has accumulated several responsibilities: route dispatch, screen caching, global key handling, active game lifecycle, spawn/export cancellation, persistence, and workflow-specific setup for create/daily/seeded/weekly play. This makes changes to TUI flow harder to reason about and raises the risk of regressions when adding new screens or session behavior.45## What Changes67- Reorganize the root TUI model so `Update` remains a thin dispatcher rather than the owner of every workflow.8- Clarify ownership boundaries for route/screen management, global shell state, active game/session lifecycle, and workflow-specific orchestration.9- Consolidate active game opening, spawning, resuming, saving, and completion persistence behind session-oriented APIs.10- Preserve existing user-facing behavior for menus, create flow, seeded play, daily/weekly play, export, help, debug, theme selection, persistence, and active puzzle controls.11- Add focused tests around the refactored routing/session behavior where current coverage depends on root model internals.1213## Capabilities1415### New Capabilities16- `root-tui-architecture`: Internal architecture requirements for the root Bubble Tea model, screen routing, workflow ownership, and behavior-preserving refactors.1718### Modified Capabilities1920None. This change is intended to preserve existing spec-level behavior.2122## Impact2324- Affected code: `app/model.go`, `app/update.go`, `app/view.go`, `app/screen_core.go`, `app/session_controller.go`, and workflow files such as `app/handle_create.go`, `app/handle_seed.go`, `app/handle_daily.go`, `app/weekly.go`, and `app/export.go`.25- Affected tests: focused `app` package tests for update routing, screen actions, session lifecycle, spawn cancellation/completion, save-on-exit, and weekly advancement.26- APIs: no public CLI, game registry, persistence schema, or game package API changes are planned.27- Dependencies: no new runtime dependencies are planned.