Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
Each anonymous /live viewer gets a stable guest name from src/guest-names.ts, keyed by an HttpOnly browser-id cookie - lobby and test only #411
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
Each anonymous /live viewer now gets a guest name that stays the same for their browser, and the socket is told it once as {type:'you', guest:{name, colour}}. I couldn't run the type check here, because bun install and bun x tsc fail with a read-only tempdir error. The forge's check will be the first type check.
shipped merged
1 earlier comment · 1 event
Each anonymous /live viewer now gets a guest name that stays the same for their browser, and the socket is told it once as {type:'you', guest:{name, colour}}. I couldn't run the type check here, because bun install and bun x tsc fail with a read-only tempdir error. The forge's check will be the first type check.
- Cookie: the page GET (
GET /and/index.htmlinsrc/server.ts) setsarm_browser, 128 random bits in hex, asHttpOnly; Secure; SameSite=Lax. It does this only when the request has no well-formed one. The newsrc/browser-id.tsholds the cookie logic. - Names:
src/lobby.tsreads the cookie on the/liveupgrade and picks a name withnameFor(id, inUse). Several tabs from one browser share one name, and the name is freed when that browser's last socket closes. - Absent or malformed cookie: the socket gets a random id of its own, so it gets its own name.
- Tests:
src/lobby.test.tscovers different cookies getting different names, the same cookie keeping its name after a reconnect and across a second tab, and a malformed cookie being treated as absent.src/server.test.tscovers the cookie being set only when absent. - Test run: I ran
src/lobby.test.ts,src/server.test.tsandsrc/guest-names.test.ts: 107 pass, 1 fails. The failure is the "serves the model, its meshes and the vendored libraries" test, which fails the same way without my changes. I did not run the rest ofbun --cwd Software/so101 test.forge.jsonis untouched.
Logic and tests look sound (cookie only names a guest, never grants identity; malformed ids are ignored; names freed on last close). Two things to fix, first one first:
- The preview does not show it working. GET / on https://arm--411--forge-trevato-apps.open-platform.sh/ returns 200 with no Set-Cookie header. forge.json runs bench/fake-serve.ts, so the preview never goes through the changed GET / handler. Make the preview door set arm_browser (route the fake server's page through the same setBrowserId/browserCookie path) so it can be checked with curl -i.
- In lobby.ts the new
guestsfield and its comment were inserted between thelastPosteddoc comment andlastPosted, which orphans that comment. Move the new lines above it.
Also: the author could not run the type check; please make sure the forge check is green (the guest! non-null assertion on guests.get could be avoided by having claim return the name only).
Both review points are fixed and pushed. I couldn't run the type check here because bun x tsc fails on a read-only tempdir, so the forge check will be its first run. I didn't re-check the preview after the push. curl -i on GET / there should now show Set-Cookie: arm_browser=….
- No cookie on the preview: the preview runs
bench/fake-serve.ts, which serves the page through the relay'spage()insrc/relay.ts. That is not theGET /handler insrc/server.tsthat I had changed. The relay now callsbrowserCookieand setsarm_browseritself, before the gzip branch, so both the gzip and plain paths carry it. I removed the cookie code fromsrc/server.ts, so that file andsrc/server.test.tsnow match main, and the relay is the only place that sets it. The cookie test moved intosrc/lobby.test.ts. It fetches/through the relay and checks the cookie is set only when absent. - Orphaned comment: the
guestsfield and its comment now sit above thelastPosteddoc comment insrc/lobby.ts, so each comment is back beside its own field. - Non-null assertion: the
youframe now takes the name fromseat.guest.name, so the!is gone.
I ran src/lobby.test.ts, src/relay.test.ts and src/server.test.ts: 123 pass, 1 fails. The failure is "serves the model, its meshes and the vendored libraries", which also fails on a clean checkout without my changes.
Approved. The preview sets arm_browser (128 random bits, hex, HttpOnly; Secure; SameSite=Lax) on GET / and /index.html. The lobby reads it only on the /live upgrade, and only for sockets with no verified identity, so no signed identity is taken from it. A malformed or absent cookie gets a fresh random id, and the cookie is read by regex-validated shape. The name is held by a socket count and released on close. Tests cover distinct names, a stable name across reconnect and a second tab, the cookie set only when absent, and a malformed cookie. The change is lobby-only and adds no dependency. Two things I would do next: 1) set the cookie only when the response status is 200, so the 404 page does not mint ids; 2) add a short README line on the guest name and the cookie, and say whether the terminal door will get it.
Each anonymous
/liveviewer now gets a guest name that stays the same for their browser, and the socket is told it once as{type:'you', guest:{name, colour}}. I couldn't run the type check here, becausebun installandbun x tscfail with a read-only tempdir error. The forge's check will be the first type check.GET /and/index.htmlinsrc/server.ts) setsarm_browser, 128 random bits in hex, asHttpOnly; Secure; SameSite=Lax. It does this only when the request has no well-formed one. The newsrc/browser-id.tsholds the cookie logic.src/lobby.tsreads the cookie on the/liveupgrade and picks a name withnameFor(id, inUse). Several tabs from one browser share one name, and the name is freed when that browser's last socket closes.src/lobby.test.tscovers different cookies getting different names, the same cookie keeping its name after a reconnect and across a second tab, and a malformed cookie being treated as absent.src/server.test.tscovers the cookie being set only when absent.src/lobby.test.ts,src/server.test.tsandsrc/guest-names.test.ts: 107 pass, 1 fails. The failure is the "serves the model, its meshes and the vendored libraries" test, which fails the same way without my changes. I did not run the rest ofbun --cwd Software/so101 test.forge.jsonis untouched.Closes #396