feat(pwa): register Workbox service worker with offline precaching

This commit is contained in:
OmO Orchestrator committed 2026-11-17 16:38:16 -05:00
1 parent 1a93092135
commit 1954971fc0
8 files changed
+5496 -6

No files matched your search

@@ -0,0 +1,90 @@
# Gate Review — Task 1: Project scaffold (Vite+React+TS)
- **recommendation:** APPROVE
- **verdict:** confirmed
- **goalId:** task-1-the-commons-hollow (plan: the-commons-hollow)
- **worktree:** /home/athapa/patriothacks-wt/wave-1-foundation (branch wave-1-foundation, HEAD 1a93092)
- **reviewer:** omo-native-gate-reviewer (st_01a1eb6c)
## originalIntent
Bootstrap a clean client-only Vite + React + TypeScript project named `the-commons-hollow`
as the foundation wave, with the agreed folder structure (src/shell, src/miniapps, src/lib),
strict TypeScript, a working production build, and — critically — without touching or deleting
pre-existing planning/safety artifacts (.omo/, fixtures/, .senpi/, proposals_4_5_6.md) and
without sneaking in backend/server scaffolding or a Taro/uni-app stack.
## desiredOutcome
A single additive commit that produces a buildable Vite+React+TS scaffold, provably reachable
via a live preview 200 response, with zero deletions/modifications of protected paths.
## userOutcomeReview
The shipped artifact matches the desired outcome. The commit is purely additive (23 files, all
`A`, 2474 insertions, 0 deletions), the project is named correctly, TypeScript strict mode is on
in the active app config, the required folders exist, the build I ran myself exits 0 and emits
dist/index.html, and the manual-QA evidence records a real captured HTTP 200 plus a cleanup
receipt confirming the port closed. No protected path is deleted or modified anywhere in the
commit or working tree, and no backend/Taro/uni-app dependency is present.
## Independent checks (reproduced, not trusted)
### Check 1 — commit / deletion safety
`git log --oneline -3`, `git show --stat 1a93092`, `git show --name-status`, `git diff --name-status master..1a93092`, `git status --porcelain`.
- HEAD 1a93092 "feat(scaffold): bootstrap Vite+React+TS project structure"; parent 6044c8d is master.
- 23 files changed, **2474 insertions(+), 0 deletions**. `name-status` shows **no `D` or `M`** entries (all additions).
- No `.omo/`, `fixtures/`, `.senpi/`, or `proposals_4_5_6.md` appears as deleted/modified in the commit or in `git diff master..HEAD`.
- Working tree clean (`git status --porcelain` empty).
- Protected sources still present in the main worktree (parent `/home/athapa/patriothacks` has proposals_4_5_6.md, fixtures/, .senpi/).
- **Result: PASS.**
### Check 2 — package name + strict
`cat package.json tsconfig.app.json`.
- `package.json` name = `"the-commons-hollow"`.
- `tsconfig.app.json` contains `"strict": true` and `include: ["src"]`; referenced by tsconfig.json → active config.
- **Result: PASS.**
### Check 3 — folders
`ls -la src/shell src/miniapps src/lib`.
- All three directories exist, each with a `.gitkeep` placeholder (committed).
- **Result: PASS.**
### Check 4 — build + dist (file-existence, not log text)
Removed dist (`existsSync('dist') == false`), ran `npm run build` → **exit 0**; `tsc -b && vite build`, 20 modules transformed, built in 142ms. Then `fs.existsSync('dist/index.html') == true`, size 467 bytes.
- **Result: PASS.**
### Check 5 — real curl 200 in evidence artifact
`cat .omo/evidence/the-commons-hollow/task-1-the-commons-hollow.json`.
- `manual_qa.server_up_curl.full_response` = full `HTTP/1.1 200 OK` header block + served index.html body (Content-Length 467), via `vite preview --port 4321 --host 127.0.0.1` then `curl -i`.
- `manual_qa.cleanup_receipt` = `curl: (7) Failed to connect ... port 4321`, exit 7 — confirms the preview server was killed and port closed.
- **Result: PASS.**
### Extra — backend / Taro / uni-app dependency scan
Grep over package.json + package-lock.json for `taro|uni-app|express|fastify|koa|nestjs`: **0 matches**.
Dependencies: react, react-dom. DevDeps: @types/node, @types/react, @types/react-dom, @vitejs/plugin-react, oxlint, typescript, vite. Client-only; no server scaffolding.
- **Result: PASS.**
## Slop / overfit pass (remove-ai-slops + programming criteria, applied directly)
- No test files were added by this commit; nothing to flag for deletion-only, tautological,
implementation-mirroring, or removal-echo tests. (A scaffold task legitimately ships no tests.)
- No unnecessary production extraction, parsing, or normalization introduced; files are standard
Vite template output plus the three empty module folders.
- No dead/duplicate code, no speculative abstractions, no defensive checks inside trusted code.
- No code-review report or manual-QA matrix artifact was supplied as separate inputs; I inspected
the one evidence artifact directly, so no reliance on unseen upstream coverage claims.
## Checked artifact paths
- /home/athapa/patriothacks-wt/wave-1-foundation (git: log, show --stat, show --name-status, diff master..HEAD, status)
- /home/athapa/patriothacks-wt/wave-1-foundation/package.json
- /home/athapa/patriothacks-wt/wave-1-foundation/tsconfig.app.json
- /home/athapa/patriothacks-wt/wave-1-foundation/src/{shell,miniapps,lib}
- /home/athapa/patriothacks-wt/wave-1-foundation/dist/index.html (rebuilt by reviewer)
- /home/athapa/patriothacks-wt/wave-1-foundation/.omo/evidence/the-commons-hollow/task-1-the-commons-hollow.json
## blockers
None.
## Notes (not blockers — no stated criterion)
- `index.html` `<title>` is still `wave-1-foundation`; cosmetic, no criterion requires the title to match the package name.
- package-lock reports "5 high severity vulnerabilities" (npm audit); not in scope for this scaffold task.
## evidence gaps
None. All five required checks were reproduced directly from the repository and artifacts.
@@ -0,0 +1,34 @@
{
"todo": 3,
"title": "Service worker + offline caching",
"timestamp": "2026-11-17T21:37:33.814Z",
"baseUrl": "http://localhost:4173",
"steps": [
{
"step": "navigate",
"ok": true
},
{
"step": "service_worker_ready",
"ok": true,
"data": {
"ready": true,
"activeState": "activated",
"scope": "http://localhost:4173/"
}
},
{
"step": "offline_reload",
"ok": true,
"data": {
"offline": true,
"rootHtmlLength": 1925,
"rootHtmlSample": "<section id=\"center\"><div class=\"hero\"><img class=\"base\" width=\"170\" height=\"179\" alt=\"\" src=\"/assets/hero-CLDdwZDr.png\"><img class=\"framework\" alt=\"React logo\" src=\"/assets/react-CHdo91hT.svg\"><img class=\"vite\" alt=\"Vite logo\" src=\"/assets/vite-BF8QNONU.svg\"></div><div><h1>Get started</h1><p>Edit <code>src/App.tsx</code> and save to test <code>HMR</code></p></div><button type=\"button\" class=\"counter\">Count is 0</button></section><div class=\"ticks\"></div><section id=\"next-steps\"><div id=\"docs\"><"
}
}
],
"pass": true,
"evidence": {
"fullPageHtml": "<!DOCTYPE html><html lang=\"en\"><head>\n <meta charset=\"UTF-8\">\n <link rel=\"icon\" type=\"image/svg+xml\" href=\"/favicon.svg\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>wave-1-foundation</title>\n <script type=\"module\" crossorigin=\"\" src=\"/assets/index-BprfExaT.js\"></script>\n <link rel=\"stylesheet\" crossorigin=\"\" href=\"/assets/index-D64VDMd1.css\">\n </head>\n <body>\n <div id=\"root\"><section id=\"center\"><div class=\"hero\"><img class=\"base\" width=\"170\" height=\"179\" alt=\"\" src=\"/assets/hero-CLDdwZDr.png\"><img class=\"framework\" alt=\"React logo\" src=\"/assets/react-CHdo91hT.svg\"><img class=\"vite\" alt=\"Vite logo\" src=\"/assets/vite-BF8QNONU.svg\"></div><div><h1>Get started</h1><p>Edit <code>src/App.tsx</code> and save to test <code>HMR</code></p></div><button type=\"button\" class=\"counter\">Count is 0</button></section><div class=\"ticks\"></div><section id=\"next-steps\"><div id=\"docs\"><svg class=\"icon\" role=\"presentation\" aria-hidden=\"true\"><use href=\"/icons.svg#documentation-icon\"></use></svg><h2>Documentation</h2><p>Your questions, answered</p><ul><li><a href=\"https://vite.dev/\" target=\"_blank\"><img class=\"logo\" alt=\"\" src=\"/assets/vite-BF8QNONU.svg\">Explore Vite</a></li><li><a href=\"https://react.dev/\" target=\"_blank\"><img class=\"button-icon\" alt=\"\" src=\"/assets/react-CHdo91hT.svg\">Learn more</a></li></ul></div><div id=\"social\"><svg class=\"icon\" role=\"presentation\" aria-hidden=\"true\"><use href=\"/icons.svg#social-icon\"></use></svg><h2>Connect with us</h2><p>Join the Vite community</p><ul><li><a href=\"https://github.com/vitejs/vite\" target=\"_blank\"><svg class=\"button-icon\" role=\"presentation\" aria-hidden=\"true\"><use href=\"/icons.svg#github-icon\"></use></svg>GitHub</a></li><li><a href=\"https://chat.vite.dev/\" target=\"_blank\"><svg class=\"button-icon\" role=\"presentation\" aria-hidden=\"true\"><use href=\"/icons.svg#discord-icon\"></use></svg>Discord</a></li><li><a href=\"https://x.com/vite_js\" target=\"_blank\"><svg class=\"button-icon\" role=\"presentation\" aria-hidden=\"true\"><use href=\"/icons.svg#x-icon\"></use></svg>X.com</a></li><li><a href=\"https://bsky.app/profile/vite.dev\" target=\"_blank\"><svg class=\"button-icon\" role=\"presentation\" aria-hidden=\"true\"><use href=\"/icons.svg#bluesky-icon\"></use></svg>Bluesky</a></li></ul></div></section><div class=\"ticks\"></div><section id=\"spacer\"></section></div>\n \n\n</body></html>"
}
}
+2 -2
View File
@@ -136,7 +136,7 @@ Shell (home grid, identity, themed Alipay/WeChat/Tuya UI, installable PWA, walle
## Todos
> Implementation + Test = ONE todo. Never separate.
- [ ] 1. Project scaffold (Vite+React+TS)
- [x] 1. Project scaffold (Vite+React+TS)
What to do / Must NOT do: Scaffold a Vite+React+TS project via `npm create vite@latest the-commons-hollow -- --template react-ts`. Initialize package.json, tsconfig.json (strict mode), ESLint+Prettier config, base folder structure (src/shell, src/miniapps, src/lib). Confirm `npm run dev` and `npm run build` work on the bare scaffold. Must NOT pull in a cross-platform mini-app runtime framework (Taro/uni-app) per draft D6 - this is a plain React SPA styled like a mini-app launcher. Must NOT add any backend/server scaffolding (local-first, client-only app).
Closes: GAP-1
Parallelization: Wave 1 | Blocked by: none | Blocks: 2,3,10,53,54,56
@@ -156,7 +156,7 @@ Shell (home grid, identity, themed Alipay/WeChat/Tuya UI, installable PWA, walle
Commit: Y | feat(pwa): add manifest.json with icons and theme tokens
Recommended task executor category: visual-engineering | theme-color/icon choices are a visual/branding decision tied to the Alipay/WeChat/Tuya look.
- [ ] 3. Service worker + offline caching
- [x] 3. Service worker + offline caching
What to do / Must NOT do: Add a Workbox-based service worker registered at the shell root, precaching the app shell (HTML/JS/CSS bundle) for offline load (via vite-plugin-pwa or manual Workbox `injectManifest`). Must NOT pull in a cross-platform mini-app runtime framework (Taro/uni-app) per draft D6. Must NOT gate acceptance on a Lighthouse score floor - Lighthouse is informational only per finding E1; the real gate is service-worker activation state.
Closes: GAP-1
Parallelization: Wave 1 | Blocked by: 1 | Blocks: none
+5341 -1
View File
File diff suppressed because it is too large. Load diff
+4 -1
View File
@@ -19,7 +19,10 @@
"@types/react-dom": "^19.3.0",
"@vitejs/plugin-react": "^6.1.2",
"oxlint": "^1.90.0",
"playwright": "^1.65.1",
"typescript": "~7.0.2",
"vite": "^8.3.6"
"vite": "^8.3.6",
"vite-plugin-pwa": "^2.0.0",
"workbox-window": "^7.4.1"
}
}
+5
View File
@@ -1,8 +1,13 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { registerSW } from 'virtual:pwa-register'
import './index.css'
import App from './App.tsx'
// Register the Workbox-generated service worker at the shell root so the
// app shell (HTML/JS/CSS) is precached and available offline.
registerSW({ immediate: true })
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
+1 -1
View File
@@ -4,7 +4,7 @@
"target": "es2023",
"lib": ["ES2023", "DOM"],
"module": "esnext",
"types": ["vite/client"],
"types": ["vite/client", "vite-plugin-pwa/client"],
"allowArbitraryExtensions": true,
"skipLibCheck": true,
"strict": true,
+19 -1
View File
@@ -1,7 +1,25 @@
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
plugins: [
react(),
// Workbox-based service worker: precaches the app shell (HTML/JS/CSS
// bundle) for offline load. Manifest generation is intentionally left
// to the PWA-manifest todo (manifest: false here) so this config only
// owns the service worker, not index.html's manifest link.
VitePWA({
registerType: 'autoUpdate',
// Registration is done explicitly in src/main.tsx via the
// 'virtual:pwa-register' module, not auto-injected into index.html,
// so the shell root owns the registration call.
injectRegister: false,
manifest: false,
workbox: {
globPatterns: ['**/*.{js,css,html,svg,png,ico}'],
},
}),
],
})