feat(ui): script to build bundled (#11801)

We share the bundled UI built from p2 for Radius. This PR adds a script
to bundle it, and this gets uploaded to R2 on every green commit to
main.
This commit is contained in:
Cristina Poncela Cubeiro 2026-11-05 09:42:35 +01:00 • committed by GitHub
parent 5f6198c397
commit c5d98a78ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 139 additions and 6 deletions

View file

@ -47,12 +47,11 @@ P2_FAKE=1 npm start # http://127.0.0.1:8788, data in ~/.pi/p2
immediately. At most two previous generations remain available for up to 60 seconds. This polling is temporary
until loader model D provides scoped, per-facet `ClientBundle` pushes (`docs/plugin-loading.md` 5.3 and 12.2 step
4). The TUI launcher separately polls `/__p2_tui`. There is no Vite, source-module server or `index.html`.
- **Bundles for Radius Cloud Brain:** the public repo `earendil-works/bundled-ui` holds prebuilt copies of this web
bundle, built from a pi-private checkout by its `scripts/build.mts` (imports `buildWebBundle`). The script patches
three places in the built script: the Chord socket URL (`` new WebSocket(`${...}://${location.host}/chord`) ``),
the version poll (`fetch("/__p2_web",{cache:"no-store",credentials:"same-origin"})`) and the `/__p2_web/` asset
prefix. It fails when a target is missing, so changing those in `src/hosts/web/main.tsx` or `WEB_BUNDLE_PATH` means
updating that script.
- **Bundles for Radius Cloud Brain:** after CI passes on main, `.github/workflows/p2-cloud-bundle.yml` builds this
web bundle with `scripts/cloud-bundle.ts` and uploads it to the R2 bucket `pi-ui` under the commit's full SHA, which
Radius serves under `/pi/ui/`. The script patches the built script's Chord socket URL, version poll and `/__p2_web/`
asset prefix, and fails when one is missing: changing those in `src/hosts/web/main.tsx` or `WEB_BUNDLE_PATH` means
updating it.
- `npm run dev` also watches plugins and supervises runtime restarts; see **Dev mode** below. Under `npm start`,
code changes (web included) take effect only after a restart.
- **Data report** (`scripts/data-report.ts`, read-only, beside a live server): per session its title, location,