Skip to content

Fix PWA install banner not rendering and service worker cache failures#5499

Open
udithishanka wants to merge 5 commits intojaseci-labs:mainfrom
udithishanka:fix/pwa-banner-and-sw-bugs
Open

Fix PWA install banner not rendering and service worker cache failures#5499
udithishanka wants to merge 5 commits intojaseci-labs:mainfrom
udithishanka:fix/pwa-banner-and-sw-bugs

Conversation

@udithishanka
Copy link
Copy Markdown
Collaborator

Summary

  • Fix JS // comments in Jac string literals being corrupted by compiler (stripped to single /), causing SyntaxError in generated PWA scripts
  • Replace cache.addAll() with resilient individual cache.add() + .catch() so auth-redirected URLs don't crash service worker installation
  • Add missing beforeinstallprompt capture and install banner script injection to render_page() runtime path

Changes

  • jac-client/jac_client/plugin/src/targets/impl/pwa_target.impl.jac — Changed // to /* */ in all generated JS strings; replaced addAll with individual caching; removed './' from precache list
  • jac-client/jac_client/plugin/impl/client.impl.jac — Import and call _build_install_prompt_capture_script and _build_pwa_install_banner_script in PWA render path

Test plan

  • Run jac build --client pwa main.jac and verify sw.js and index.html have valid JS (no single-slash comments)
  • Run jac start --client pwa main.jac and verify install banner appears after 3 seconds
  • Verify service worker registers without addAll cache errors in console
  • Test on app with auth (401 responses should not break SW installation)

Three bugs in jac-client PWA target:

1. JS comments using // inside Jac string literals get first slash stripped
   by Jac compiler, producing invalid JS (SyntaxError: Unexpected token ':').
   Changed all // to /* */ block comments in generated JS strings.

2. cache.addAll() in service worker fails entirely if any URL returns non-2xx
   (e.g. auth redirects). Replaced with individual cache.add() + .catch()
   so partial failures don't break SW installation.

3. render_page() only injected manifest link and SW registration for PWA but
   missed the beforeinstallprompt capture and install banner scripts. Added
   imports of _build_install_prompt_capture_script and
   _build_pwa_install_banner_script to the runtime render path.
@udithishanka udithishanka force-pushed the fix/pwa-banner-and-sw-bugs branch from 478b14a to 4aeb0f5 Compare April 9, 2026 13:59
udithishanka and others added 3 commits April 9, 2026 19:35
The API base URL guard in _format_define_entries is needed for desktop
builds where Tauri injects the URL at runtime. Reverted comment style
changes (/* */ back to //) as they were unnecessary.
…uard

Ensures the three PWA runtime scripts (prompt capture, SW registration,
install banner) stay wired into client.impl.jac, and that the API base
URL define is skipped for desktop/Tauri builds.
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