Skip to content

Persist ramp progress across sessions and add a Reset Progress option - #17

Merged
yottanami merged 1 commit into
mainfrom
agent/211-automode-persistence
Aug 27, 2026
Merged

yottanami merged 1 commit into
mainfrom
agent/211-automode-persistence

Conversation

@yottanami

@yottanami yottanami commented Aug 27, 2026 •

Copy link
Copy Markdown
Owner

Closes Men-in-Black-5/ideas#211

What

The difficulty ramp is driven entirely by score (currentStage()), so persisting progress just means seeding the next run's score from the highest score reached before, stored monotonically in localStorage (cn_autoProgress). No new stage/progress variable to keep in sync with the ramp logic.

Also adds a confirm-gated "Reset Progress" item to the main menu, since a destructive action deserves a guard, and the acceptance criteria call for a way back to stage one.

Scope note

ideas#211 was written in terms of the old Auto/Custom mode split (#44) and says "Custom mode is unaffected". 083034c ("Replace the Auto/Custom split with one mode and a score ramp", merged 2026-08-17) removed that split before this issue was filed, so there's no separate Custom mode left to be unaffected. Implemented against the current single-mode design, where the ramp always applies.

Testing

  • npx vitest run: 182/182 passing (174 pre-existing + 8 new in test/auto-progress.test.ts, covering load/save/reset, monotonic-best behavior, storage-unavailable handling, and that updateScore() persists automatically).
  • npx tsc --noEmit and npm run build: clean, dist/app.js rebuilt and committed.
  • Manual verification in a real headless Chromium (Playwright): loaded the page, confirmed the new button renders in the existing retro-menu style with no layout regression, and exercised the actual DOM click handler end to end. Seeded cn_autoProgress, confirmed loadSavedProgress() reads it, confirmed a lower saveProgress() call doesn't regress the stored best, clicked Reset Progress with confirm() mocked true (clears storage) and then false (leaves it untouched).

The difficulty ramp is driven entirely by `score` (see currentStage()), so
"resuming where you left off" just means seeding the next run's score from
the highest score reached before, monotonically, in localStorage
(cn_autoProgress). No new stage/progress variable to keep in sync.

Also adds a "Reset Progress" item to the main menu, confirm-gated since it's
a destructive action, so a player who wants to restart the ramp from stage
one has a way back.

Note on scope: ideas#211's acceptance criteria describe this in terms of the
old Auto/Custom mode split (#44), which 083034c already replaced with a
single always-ramping mode before this issue was filed -- the "Custom mode
unaffected" criterion is moot now, there's no separate mode to affect.
Implemented against the current single-mode design instead.

Closes Men-in-Black-5/ideas#211
@yottanami

Copy link
Copy Markdown
Owner Author

reviewer: scope read confirmed — issue#211 was filed 2026-08-27, ten days after 083034c (merged 2026-08-17) already replaced the Auto/Custom split with the single always-ramping mode, so the 'Custom mode is unaffected' criterion is just stale from whatever the issue was drafted against. Implementing against current single-mode design is correct.

Code review passed: seeding score from the stored best rather than a separate progress variable is the right call since currentStage() already derives entirely from score, so there's nothing else that could drift out of sync. Monotonic save, garbage/negative-value handling, storage-unavailable try/catch on all three operations, and the confirm-gated reset all match the acceptance criteria. 8 new tests cover it well, CI green. Merging.

@yottanami
yottanami merged commit e9c1163 into main Aug 27, 2026
3 checks passed
@yottanami
yottanami deleted the agent/211-automode-persistence branch August 27, 2026 10:02
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.

1 participant