Skip to content

Refresh UI after deployments via service worker update flow#198

Open
MaciejTe wants to merge 2 commits into
developfrom
feat/app-auto-update
Open

Refresh UI after deployments via service worker update flow#198
MaciejTe wants to merge 2 commits into
developfrom
feat/app-auto-update

Conversation

@MaciejTe

Copy link
Copy Markdown
Collaborator

PR type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other... Please describe:

Signed-off-by: Maciek <tomczukmaciej@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-pwa registration to registerType: '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

  • include and setupFiles are 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.

Comment thread app/vite.config.ts Outdated
Comment thread app/src/lib/swUpdate.ts
…n modDNS teal

Signed-off-by: Maciek <tomczukmaciej@gmail.com>
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.

2 participants