Skip to content

fix(pwa): emit legacy service-worker2.js and unregister old registrations#44

Open
hsingh23 wants to merge 1 commit intomasterfrom
codex/update-service-worker-for-latest-files
Open

fix(pwa): emit legacy service-worker2.js and unregister old registrations#44
hsingh23 wants to merge 1 commit intomasterfrom
codex/update-service-worker-for-latest-files

Conversation

@hsingh23
Copy link
Owner

Motivation

  • The PWA was not reliably updating because the running service worker registrations pointed at a different filename than the new Vite PWA output.
  • Legacy registrations (older script names) can block activation of new builds and must be cleaned up before registering the current worker.
  • Keep a manual hook to trigger updates programmatically and trigger checks on visibility/online events.

Description

  • Configure VitePWA to emit the legacy filename by setting filename: "service-worker2.js" in vite.config.js.
  • Add unregisterLegacyServiceWorkers in src/index.jsx to find and unregister registrations whose scriptURL does not end with service-worker2.js.
  • Add registerServiceWorker which calls the cleanup and then captures the updateSW helper from registerSW, and call it from bootstrap before app render.
  • Expose a manual update hook as window.requestServiceWorkerUpdate and trigger it on visibilitychange (when visible) and online events, with informative console logs in lifecycle callbacks.

Testing

  • Ran bun run validate (which runs tsc --noEmit && bun run lint && bun run test) and it failed due to missing dependencies and type declarations in the environment.
  • No other automated tests were executed in this environment because the type/module resolution errors prevented the full validation pipeline from completing.

Codex Task

@hsingh23
Copy link
Owner Author

@codex fix merge conflict

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@hsingh23
Copy link
Owner Author

@codex resolve conflict

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

@hsingh23
Copy link
Owner Author

hsingh23 commented Dec 31, 2025 via email

@chatgpt-codex-connector
Copy link

Summary

  • No merge conflicts found in the working tree; repository is clean after restoring unintended local lockfile changes.
  • Attempted the required superpowers bootstrap command, but the executable was not present in this environment.

Testing

  • bun run validate (failed: missing dependencies/type declarations in the environment)

Notes

  • Superpowers bootstrap failed: /root/.codex/superpowers/.codex/superpowers-codex not found.

View task →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant