fix: resolve stale cache on GitHub Pages deploys#25
Merged
Conversation
Wire up the existing service worker registration so the app detects new versions deployed to GitHub Pages. When a new service worker is found, it automatically activates and reloads the page. After reload, a toast notification shows "App updated to vX.Y.Z". Key changes: - Remove auto-skipWaiting from SW install (client controls activation) - Register SW in main.tsx with the correct base URL - Add controllerchange listener to auto-reload on SW activation - Create UpdateToast component with auto-dismiss after 6s - Build service-worker.ts as a separate Rollup entry at a fixed path - Add tests for consumeUpdateFlag, UpdateToast, and SW exports https://claude.ai/code/session_012PcsftUoC8NyeLLV9LD3rE
Contributor
Release Version Check
This version will be released automatically when this PR is merged to |
Contributor
Preview DeploymentThe web app for this PR has been deployed: Use this to verify the app works correctly, especially for dependency updates. |
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.
Summary
How it works
service-worker.jsand listens for new versionsSKIP_WAITINGcontrollerchange, asessionStorageflag is set and the page reloadsUpdateToastcomponent displays the versionChanges
service-worker.ts: Removed autoskipWaiting()from install handler (client now controls activation timing)sw-register.ts: Addedcontrollerchangelistener, auto-update flow, andconsumeUpdateFlag()helpermain.tsx: Registers the service worker on mount, rendersUpdateToastafter updatesvite.config.ts: Buildsservice-worker.tsas a separate Rollup entry at a fixed path (service-worker.js)UpdateToast.tsx: New toast component with enter/exit animations and auto-dismissTest plan
service-worker.test.ts— 6 tests passsw-register.test.ts— 5 tests passUpdateToast.test.tsx— 5 tests passhttps://claude.ai/code/session_012PcsftUoC8NyeLLV9LD3rE