Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
Watch anonymously, sign in to drive: one driver at a time, a visible queue, and a chat beside the arm #6
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
Anyone can now watch the arm without signing in. To drive, a person signs in and takes a turn: one driver at a time, decided on the server, with a live queue and a chat beside the arm. All 124 tests pass and the type check is clean.
shipped merged
Anyone can now watch the arm without signing in. To drive, a person signs in and takes a turn: one driver at a time, decided on the server, with a live queue and a chat beside the arm. All 124 tests pass and the type check is clean. I booted the app with an identity key set: / answered in 26 ms, an anonymous POST /torque got a 401, and /live greeted the visitor. I could not open the page in a browser here, so the side panel and the locked controls have not been checked by eye.
How it works
- Who someone is (
src/identity.ts): the app checks the forge's signedx-forge-identityheader againstFORGE_APP_IDENTITY_KEY. A missing, forged, expired or odd header counts as anonymous. The forge'sadminrole (anyone who may write this repository) counts as the owner. - Turns (
src/turns.ts): a turn lasts 3 min. It ends on hand-back, after 30 s with no command, or 10 s after the driver's connection drops. Someone in the queue who drops for 10 s leaves it. The owner skips the queue and can end anyone's turn. - Chat (
src/chat.ts): one message per 2 s per person, 500 characters, last 200 kept in$FORGE_APP_DATA/so101/chat.jsonalong with the mutes. Control and bidi characters are stripped, and the page only ever shows messages as text. - One WebSocket (
src/lobby.ts,/live): carries the turn, the queue with each place and its longest wait, and the chat. Driver changes appear as system lines. A ping every 5 s catches connections that die silently. - The gate (
src/relay.ts): every command (anyPOST/PUT) and the/followstream from anyone but the driver is refused before it reaches an arm. Anonymous visitors get 401, others 403. The owner may press Stop during anyone's turn. When a turn ends, that person's streams are closed and a stop is sent to the arm. - The page (
src/viewer.html): a side panel (below the arm on phones) with the driver, a countdown and idle warning, the queue with your place highlighted, the buttons (Sign in to take control / Take control / Hand back / Leave the queue) and the chat. The owner gets delete, mute and end buttons. Controls and 3D dragging are disabled unless it is your turn.
Worth reviewing
- Refused
/followstreams: Bun never delivers an HTTP status written to a socket that is being upgraded, and browsers can't read that status anyway. So a refused/followstream is accepted and closed at once with code 4401 or 4403 and a reason the page shows. - Local mode: run with no
FORGE_APP_ENVand no key, every visitor is the owner and drives without queueing, as before. On the forge a missing key means nobody can drive. - Tests: a new
src/lobby.test.tsruns through the real relay. It covers:- two signed-in clients, where only one drives and the other takes over on hand-back, idle and dropped connection;
- anonymous commands refused;
- a forged header refused;
- the chat rate limit;
- the owner overrides.
- Corrected test: one of my own new turns tests was wrong, not the code: it jumped 60 s with no command and expected the turn to survive. It now sends a command every 20 s.
- Changed existing test: the original
fake-servetest now pinsFORGE_APP_ENVand the key to empty, so it stays in local mode even when the forge's environment is set. A new test checks the forge setup refuses anonymous commands.
Not done
- The arm's own server (
so101 serve) has no login; the gate lives only in the hosted app, so keep that server off the open internet. - The pose display still polls
/statusas before; only the queue and chat are on the WebSocket. - The wait shown is an upper bound (a turn can end early, never late).
To try it
Run PORT=8102 FORGE_APP_ENV=preview FORGE_APP_IDENTITY_KEY=x bun run Software/so101/bench/fake-serve.ts and open http://127.0.0.1:8102. The page shows you as an anonymous watcher. On the preview, open it in two signed-in browsers and one private window. Anonymous viewing in production needs the app switched to public.
🤖 Generated with Claude Code
Anyone can now watch the arm without signing in. To drive, a person signs in and takes a turn: one driver at a time, decided on the server, with a live queue and a chat beside the arm. All 124 tests pass and the type check is clean. I booted the app with an identity key set:
/answered in 26 ms, an anonymousPOST /torquegot a 401, and/livegreeted the visitor. I could not open the page in a browser here, so the side panel and the locked controls have not been checked by eye.How it works
src/identity.ts): the app checks the forge's signedx-forge-identityheader againstFORGE_APP_IDENTITY_KEY. A missing, forged, expired or odd header counts as anonymous. The forge'sadminrole (anyone who may write this repository) counts as the owner.src/turns.ts): a turn lasts 3 min. It ends on hand-back, after 30 s with no command, or 10 s after the driver's connection drops. Someone in the queue who drops for 10 s leaves it. The owner skips the queue and can end anyone's turn.src/chat.ts): one message per 2 s per person, 500 characters, last 200 kept in$FORGE_APP_DATA/so101/chat.jsonalong with the mutes. Control and bidi characters are stripped, and the page only ever shows messages as text.src/lobby.ts,/live): carries the turn, the queue with each place and its longest wait, and the chat. Driver changes appear as system lines. A ping every 5 s catches connections that die silently.src/relay.ts): every command (anyPOST/PUT) and the/followstream from anyone but the driver is refused before it reaches an arm. Anonymous visitors get 401, others 403. The owner may press Stop during anyone's turn. When a turn ends, that person's streams are closed and a stop is sent to the arm.src/viewer.html): a side panel (below the arm on phones) with the driver, a countdown and idle warning, the queue with your place highlighted, the buttons (Sign in to take control / Take control / Hand back / Leave the queue) and the chat. The owner gets delete, mute and end buttons. Controls and 3D dragging are disabled unless it is your turn.Worth reviewing
/followstreams: Bun never delivers an HTTP status written to a socket that is being upgraded, and browsers can't read that status anyway. So a refused/followstream is accepted and closed at once with code 4401 or 4403 and a reason the page shows.FORGE_APP_ENVand no key, every visitor is the owner and drives without queueing, as before. On the forge a missing key means nobody can drive.src/lobby.test.tsruns through the real relay. It covers:fake-servetest now pinsFORGE_APP_ENVand the key to empty, so it stays in local mode even when the forge's environment is set. A new test checks the forge setup refuses anonymous commands.Not done
so101 serve) has no login; the gate lives only in the hosted app, so keep that server off the open internet./statusas before; only the queue and chat are on the WebSocket.To try it Run
PORT=8102 FORGE_APP_ENV=preview FORGE_APP_IDENTITY_KEY=x bun run Software/so101/bench/fake-serve.tsand open http://127.0.0.1:8102. The page shows you as an anonymous watcher. On the preview, open it in two signed-in browsers and one private window. Anonymous viewing in production needs the app switched to public.🤖 Generated with Claude Code
Closes #5