garage44.eu/jeroen/cartopolis

logclone: git clone https://garage44.eu/jeroen/cartopolis.git

.. /docs/notes/web-client-is-the-world.md

raw


topic: web-client-is-the-world triggers: [framed_session.rs, world-frame.ts, world-browser.ts, discs.rs, comms, "feature = "comms"", "cartopolis.session", "cartopolis.ready", crates/cartopolis/index.html, chat.tsx] updated: 2026-11-26

On the web the client is only the world; the page does the talking

Decided 2026-11-22 with the owner. The app runs as three things: the native app (desktop, APK, and later Pinnacle), the HTML site at cartopolis.org, and the app's own wasm build framed by that site as its World tab. Before this, the wasm build was the whole app, so in one browser a person had two sign-ins, two connections and two chat devices with their own keys (web-chat.md), and every talking feature existed twice in the browser — once in HTML, once in the app's UI inside the frame — and calls three times (str0m in the app, web_call in the frame, lib/call.ts on the page).

The split

The page signs the frame in

framed_session.rs (wasm only) and crates/atlas/web/src/lib/world-frame.ts: the frame posts {type: "cartopolis.ready"} to its parent once it listens; the page answers {type: "cartopolis.session", token} and posts it again on every sign-in and sign-out. The token is the page's own ($s.signup.token), the one the chat worker says hello with, so the world is the same account with no keys of its own. Both directions stay on the page's origin. The frame never stores the token (persist_token: false) and never enters a remembered session (lib.rs), which could be another account than the page's.

WebGPU is checked before the frame loads

The web build needs WebGPU (crates/cartopolis/Cargo.toml has why WebGL2 is no fallback), so World asks navigator.gpu.requestAdapter() first, and without an adapter shows what it needs and a link to the app instead of the frame. Community works in any browser.

crates/atlas/web/world-browser.ts drives both against a real simulator, on a build node with --chromium /usr/bin/chromium: a browser without WebGPU gets the message and no frame; one with SwiftShader's adapter gets the frame, which logs that it took the page's session, and the simulator authenticates the account twice (the chat worker and the world). First run 2026-11-22: signed in 5 s after the frame was made. The world then loses its device on SwiftShader, as every canvas does there (web-device-loss.md): a node proves the sign-in, not the picture.

Size, 2026-11-22, deploy/build/wasm.sh on vps-1: the module is 100.3 MB (15.3 MB as trunk's .br), against 108.8 MB (16.5 MB brotli as served) for the build published that morning, which was cut from an older main — so about 8 MB of the module, not a measurement of comms alone.

Not done yet