Repository navigation
Stop an outdated tab from saving over newer progress (v0.11.2) - #54
Merged
Merged
Conversation
Each open copy of the game kept the save in memory and wrote all of it back on every change and whenever it was hidden. With two tabs open, a win in one was lost when the other was next hidden. Now a copy stops saving as soon as another tab or window saves, shows a notice, and reloads the newer save when it comes back into view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SGfak3CRUUVwG8x6w8D3gr
|
Visit the preview URL for this PR (updated for commit ff7f13f): https://stumped-game--pr54-claude-project-threa-0riqdxb9.web.app (expires Sat, 07 Nov 2026 02:38:52 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: dfc2bf844eeac82ebd1846d84aacfdcd42e42a2f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Barry · project thread
Fixes item 4 from the Ponytail repo audit.
Each open copy of the game loads the save once and writes all of it back on every change and whenever it is hidden. Two copies (two tabs, or the installed app and a browser tab) overwrite each other: solve a puzzle in one, switch to the other and away, and the best time, stats and solve log entry are gone.
src/controller.ts:savedElsewhere()stops all saving, both the save and the solve log, and shows a notice in the existing storage banner.src/index.ts: astorageevent for the save key calls it. When an outdated copy comes back into view, it reloads and picks up the newer save. A copy left visible beside the other one keeps the notice instead of reloading, because reloading would save again and make the other copy reload in turn, in a loop.src/controller.test.ts: two controllers share one store. One wins, and the outdated one retries and hides without overwriting the win.Checks:
pnpm run checkpasses (324 tests). In Chromium with two tabs on the dev server, starting a puzzle in tab A showed the notice in tab B, and a visibility change made B reload into A's puzzle.Generated by Claude Code