Refresh UI after deployments via service worker update flow#198
Open
MaciejTe wants to merge 2 commits into
Open
Refresh UI after deployments via service worker update flow#198MaciejTe wants to merge 2 commits into
MaciejTe wants to merge 2 commits into
Conversation
Signed-off-by: Maciek <tomczukmaciej@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the app’s service worker (SW) update strategy so long-lived SPA tabs reliably discover new deployments and refresh in a controlled way (avoiding “new SW + old JS chunks” mismatches).
Changes:
- Switches
vite-plugin-pwaregistration toregisterType: 'prompt'and enables Workbox cache cleanup. - Adds a SW update orchestration module (
setupSWUpdate) that periodically checks for SW updates and prompts/apply-updates via a toast + visibility logic. - Adds unit tests and vitest stubbing for the PWA virtual module; updates nginx caching rules for SW-related un-hashed assets.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| app/vite.config.ts | Changes PWA register type to prompt and enables outdated cache cleanup. |
| app/src/vite-env.d.ts | Adds vite-plugin-pwa/client type references for TS support. |
| app/src/main.tsx | Initializes the SW update flow at app startup. |
| app/src/lib/swUpdate.ts | Implements the SW polling + “refresh” toast update flow. |
| app/src/tests/vitest.config.ts | Aliases the PWA virtual module to a local stub for unit tests. |
| app/src/tests/unit/mocks/virtual-pwa-register.ts | Provides the stubbed virtual:pwa-register module for tests. |
| app/src/tests/unit/lib/swUpdate.test.ts | Adds unit tests covering polling, visibility checks, and refresh prompting behavior. |
| app/nginx.conf | Ensures SW/manifest-related assets revalidate instead of being long-cached. |
Comments suppressed due to low confidence (1)
app/src/tests/vitest.config.ts:15
includeandsetupFilesare mis-indented (and the alias map is missing trailing commas), which makes the config harder to read and can trip format/lint checks. Consider normalizing indentation and adding trailing commas consistently within this object.
test: {
include: ['src/__tests__/unit/**/*.{test,spec}.{ts,tsx}'],
exclude: [
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…n modDNS teal Signed-off-by: Maciek <tomczukmaciej@gmail.com>
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.
PR type
What kind of change does this PR introduce?