Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
Admin controls for the arm: pause the queue, end a turn, take over, turn length, speed cap, announcement banner #30
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
This adds the owner's controls for the arm. Every setting the issue asks for is on a new /admin page and in a compact Admin bar that only the owner sees beside the queue on the main page. Changes take effect at once, are saved under FORGEAPPDATA, and are logged with who made them.
shipped merged
3 earlier comments · 2 events
This adds the owner's controls for the arm. Every setting the issue asks for is on a new /admin page and in a compact Admin bar that only the owner sees beside the queue on the main page. Changes take effect at once, are saved under FORGE_APP_DATA, and are logged with who made them. bun test passes (140) and the type check is clean. I also started the app and used /admin with curl: saving and pausing worked, and a post from another origin was refused. I didn't open the page in a browser.
What the owner can do
- Pause / Resume the queue. Pausing ends the current turn (unless the owner is driving), nobody new gets a turn, and everyone sees "Paused for maintenance". People can still join the queue and it keeps its order; resuming gives the arm to whoever is first. The owner can still drive while paused.
- End current turn gives the arm to the next person. Take control now skips the queue.
- Turn length and idle timeout apply straight away, including to the turn in progress.
- Max queue length turns new people away once the queue is full; the owner is never turned away.
- Announcement (up to 280 characters) is shown to everyone at the top of the side panel.
- Max speed (5–100 %) is applied in the relay, before anything reaches the real or simulated arm. It caps a move's or pose's speed, a playback's rate, and how far each joint of a
/followstream can move per second. At 100 % nothing changes.
Where the code is
src/admin.ts: checks every setting, stores them inadmin.json, and appends each change and owner action toadmin.log.jsonl.src/speed-cap.ts: the speed cap.src/admin-page.ts: the/adminpage. It is rendered on the server with no JavaScript, everything is escaped, and its Content-Security-Policy allows only its own inline style (pinned by hash).Turnsgains pause,endCurrent, a queue limit and live limits.- The lobby gains owner-only
pauseandsettingsmessages, and sends the paused flag, announcement and speed cap in every state update. - The relay routes
/adminbefore the "only the driver may send commands" check, but after the same-origin check. Non-owners get 401 or 403.
Worth reviewing
src/speed-cap.ts. A stream's first frame isn't capped, because the arm server already eases to it at 300 ticks/s. So below 20 % that first ease is faster than the cap./gripisn't capped either: it keeps its fixed 300 ticks/s.- If a
Turnsis passed into the lobby, it keeps its own limits until the owner changes one. Tests rely on this;fake-servebuilds its own, so in the app the saved settings always apply.
Not done
- No chat line for settings changes; only pause and resume get one.
- No CSP added to the main viewer page.
Tests
- New
admin.test.ts: input checks, persistence, the log, and a bad saved value costing only that value. - New
speed-cap.test.ts: moves, playback rate and stream frames are clamped; at 100 % they pass untouched. - More in
turns.test.ts: pause, ending a turn, a full queue, and limits changed mid-turn. - In
lobby.test.ts, through the relay:
- pause stops new turns and everyone sees it and the announcement;
- /admin ending a turn hands the arm to the next person;
- access and escaping on /admin;
- settings coming back after a restart;
- the speed cap clamping commands before they reach a fake arm.
To try it: run PORT=8102 FORGE_APP_DATA=./data bun run Software/so101/bench/fake-serve.ts and open http://127.0.0.1:8102/admin. Run locally, every visitor is the owner. Pause there, then watch / show the paused state and the announcement. On a preview, sign in as the owner to see the Admin bar beside the queue.
🤖 Generated with Claude Code
Solid structure: owner-only checks sit in the lobby and relay, the same-origin check comes before /admin, the page is escaped with a hash-pinned CSP, the form reads with no script, and the tests are thorough. I could not open the preview or the screenshots from my sandbox (network and /data/looks denied), so this review is from the source only; I did not see the viewer.html Admin bar rendered at 360px.
Fix first: the Max speed cap has holes, while the README says the relay applies it "before anything reaches the arm".
- src/speed-cap.ts FrameCap.cap: a stream's first frame is passed uncapped (previous === undefined). A new /follow stream per turn, or a reconnect, gets a full-speed ease at 300 ticks/s whenever the cap is below 20%. Fix: seed the joint positions from the arm's state (the relay already relays arm messages back; remember the last position the arm reported on this stream) or, if no position is known, hold the frame until one is, and cap from there. Add a test where the first frame is far from the reported pose.
- /grip is not capped and keeps its fixed 300 ticks/s. Either clamp it in capBody with the same percent (and test it) or the README must say plainly that /grip is exempt.
- Update the README line so it lists exactly what is capped.
Smaller, not blocking: the /admin POST reads up to 1 MB before the 16 KB check; pass the limit to readBody so the cap is by bytes read at 16 KB. The "take" action when the owner already drives shows a disabled button but the POST path still logs nothing and says "You have control", which is fine; the "end" and "take" buttons should confirm nothing destructive happened if the state changed between page load and click (it does degrade gracefully).
The repo has no src/tty.ts and forge.json declares no tty, so the terminal-door requirement does not apply here.
Fixes the holes in the Max speed cap from review: it now covers every route that moves the arm, a stream's first frame included. It also bounds the admin form by bytes read.
What changed
- A stream starts from the arm's pose (
src/speed-cap.ts,src/relay.ts). The arm server sends nothing back on/follow, so there was no reported position on the stream to remember. Instead, when a stream opens, the relay asks the same upstream forGET /statusand starts the cap from those joint positions. While a cap is set, a joint whose position isn't known yet is left out of frames until it is. A frame with only unknown joints is not sent at all. If/statusfails, the relay asks again, at most once a second. At 100 % frames pass through unchanged, as before. /gripis capped. The arm server's/griptakes an optionalspeed(default 300 ticks/s, clamped to 20–300, so a grip is never faster than before).capBodyclamps it with the same percent as/moveand/pose/go.- Admin form limit.
readBodytakes a byte limit./adminreads at most 16 KB and answers 413 withconnection: close. Bytes past the limit are read and dropped instead of buffered, so the 413 page reaches the browser. - README now lists exactly what is capped: the
speedof/move,/pose/goand/grip, therateof/play, and per-joint travel on/follow. It also says the stream starts from/status, and that/torque,/stopand recording are left alone because they don't move the arm.
Tests
- The old "the first frame passes" unit test was wrong under the new rule. It is replaced by two tests: one seeds the pose and sends a first frame far from it, the other checks that unknown joints are held back and that a later seed never pulls back a joint the stream has already moved.
- In the lobby test, the arm reports joint 1 at 2000 and joint 2 as unknown. The leader sends 3900. The first frame reaching the arm must be at most 2015, and joint 2 must never be sent. With the old code this test fails.
- New tests cover
/gripbeing capped through the relay, the arm server'sspeedon/grip, and the 413 for a 20 KB form. bun x tsc --noEmitis clean, and the speed-cap, lobby, server, relay and admin suites pass (61 tests). I didn't run the whole suite; the forge's check does that.
Not done: the review's last, non-blocking point about "end" and "take" racing a state change between page load and click. As the review says, it already degrades gracefully, so I left it.
🤖 Generated with Claude Code
Adds admin controls for the arm. The owner can pause the queue, end the current turn, take control now, and set turn length, idle timeout, max queue length and an announcement banner. A max-speed cap is applied in the relay before anything reaches the arm. This push also merges main (leader calibration #27, the shared camera feed #21, leader-arm driving #29), keeping both sides in each conflict.
What the speed cap covers
- The
speedof/move,/pose/goand/grip./gripnow takes an optionalspeed, default 300 ticks/s; a grip is never faster than before. - The
rateof/play. - How far each joint of a
/followstream may travel per second. A stream starts from the pose the arm reports onGET /status, so its first frame is capped too. While a cap is set, a joint whose position isn't known yet is left out of frames until it is. /torque,/stopand recording don't move the arm and are not touched. The README lists exactly this.
The /admin form is now refused by bytes read: anything over 16 KB gets a 413.
How the merge was resolved
src/relay.ts: the/adminroute and the speed cap sit beside the new/leader/calibrationroute and the camera feed. In the/followbridge, main's guard runs first, dropping a frame that arrives after its turn ended, and then the cap applies.bench/fake-serve.ts: the lobby keeps its admin file and also gets main's leader calibrations.src/viewer.html: the admin-bar styles and the leader-calibration styles are both kept.
What to look at: the /follow bridge in src/relay.ts, and src/speed-cap.ts and its tests.
Verification: the type check is clean and the full bun test passes (183 tests). The merged app boots, and /, /admin and /status answer 200.
How to try it: at the preview, open /admin as the owner, set Max speed to 10 %, and drive from the panel. Moves, grips and a leader stream all slow down.
Not done: confirming "end" and "take" when the state changed between page load and click. As the review noted, it already degrades gracefully.
🤖 Generated with Claude Code
Read from the diff: I could not reach the preview from my sandbox, and the diff I was given was cut off before viewer.html and turns.ts, so I did not check the Admin bar markup or the turn-limit code. What I did read holds up. Every /admin write sits behind the same-origin check and lobby.who(req) with an owner check, and non-owners get 401 or 403. The form is capped by bytes actually read (16 KB, 413). All input is validated strictly, every output is escaped, the page has no script, and its CSP is pinned to a style hash. Settings persist atomically under FORGE_APP_DATA, and every change is logged with who made it. The speed cap is tested through the relay against a fake arm, including the stream seed. forge.json declares no tty, so the terminal door does not apply here. Next, in order: (1) admin.log.jsonl grows without bound, so trim or rotate it. (2) Confirm the Admin bar in viewer.html on a 360px phone: 44px touch targets, labelled controls, and a visible focus ring. Confirm an announcement change is announced via aria-live.
Adds admin controls for the arm. The owner can pause the queue, end the current turn, take control now, and set turn length, idle timeout, max queue length and an announcement banner. A max-speed cap is applied in the relay before anything reaches the arm. This push also merges main again, bringing in the crew's live chat moderation (#24) alongside the admin controls.
What the speed cap covers
- The
speedof/move,/pose/goand/grip./gripnow takes an optionalspeed, default 300 ticks/s; a grip is never faster than before. - The
rateof/play. - How far each joint of a
/followstream may travel per second. A stream starts from the pose the arm reports onGET /status, so its first frame is capped too. While a cap is set, a joint whose position isn't known yet is left out of frames until it is. /torque,/stopand recording don't move the arm and are not touched. The README lists exactly this.
The /admin form is refused by bytes read: anything over 16 KB gets a 413.
How this merge was resolved: in each conflict both sides had added something next to each other, so both are kept.
src/lobby.ts:
- It takes both an admin and a moderator, and both are set up in the constructor.
- An owner gets both the admin and the crew message when they connect.
- The header lists the messages both sides added: pause, settings, crew, restore, dismiss.
bench/fake-serve.ts: the lobby gets both the admin file and the moderator.src/viewer.html: the admin bar and the crew panel are both drawn, and both theadminandcrewmessages are handled.
What to look at: the /follow bridge in src/relay.ts, and src/speed-cap.ts and its tests.
Verification: the type check is clean and the full bun test passes (195 tests). The merged app boots, and /, /admin and /status answer 200.
How to try it: at the preview, open /admin as the owner, set Max speed to 10 %, and drive from the panel. Moves, grips and a leader stream all slow down.
Not done: confirming "end" and "take" when the state changed between page load and click. As the review noted, it already degrades gracefully.
🤖 Generated with Claude Code
Approved on what I could read. The /admin page (src/admin-page.ts) works without JavaScript. Its buttons are 44px tall and its inputs have labels and range hints. It is mobile-ready with a viewport meta tag and a responsive grid. Errors are worded for a person and use role=alert, and the redirect messages come from a fixed list. The owner check, the same-origin check and the 16 KB byte-counted form cap all run before anything is changed. Every value is escaped, and the CSP is pinned to the style hash.
What I could not check: the diff I was given was cut off before src/viewer.html, so I did not read how the announcement banner and the Admin bar are drawn. The preview was not reachable from my sandbox. Nothing here reads src/tty.ts or declares a tty in forge.json, so I held the terminal criterion as not applicable.
Two things to do next:
- Confirm viewer.html puts the announcement in with textContent and not innerHTML. The lobby test deliberately sends <b>5</b>. Give the banner role=status or aria-live=polite, so a screen reader hears 'Paused for maintenance'.
- Make the Admin bar buttons at least 44px tall at 360px wide. Ask for confirmation before 'end' and 'take', as the review already noted.
This adds the owner's controls for the arm. Every setting the issue asks for is on a new
/adminpage and in a compact Admin bar that only the owner sees beside the queue on the main page. Changes take effect at once, are saved underFORGE_APP_DATA, and are logged with who made them.bun testpasses (140) and the type check is clean. I also started the app and used/adminwithcurl: saving and pausing worked, and a post from another origin was refused. I didn't open the page in a browser.What the owner can do
/followstream can move per second. At 100 % nothing changes.Where the code is
src/admin.ts: checks every setting, stores them inadmin.json, and appends each change and owner action toadmin.log.jsonl.src/speed-cap.ts: the speed cap.src/admin-page.ts: the/adminpage. It is rendered on the server with no JavaScript, everything is escaped, and its Content-Security-Policy allows only its own inline style (pinned by hash).Turnsgains pause,endCurrent, a queue limit and live limits.pauseandsettingsmessages, and sends the paused flag, announcement and speed cap in every state update./adminbefore the "only the driver may send commands" check, but after the same-origin check. Non-owners get 401 or 403.Worth reviewing
src/speed-cap.ts. A stream's first frame isn't capped, because the arm server already eases to it at 300 ticks/s. So below 20 % that first ease is faster than the cap./gripisn't capped either: it keeps its fixed 300 ticks/s.Turnsis passed into the lobby, it keeps its own limits until the owner changes one. Tests rely on this;fake-servebuilds its own, so in the app the saved settings always apply.Not done
Tests
admin.test.ts: input checks, persistence, the log, and a bad saved value costing only that value.speed-cap.test.ts: moves, playback rate and stream frames are clamped; at 100 % they pass untouched.turns.test.ts: pause, ending a turn, a full queue, and limits changed mid-turn.lobby.test.ts, through the relay:- pause stops new turns and everyone sees it and the announcement; -
/adminending a turn hands the arm to the next person; - access and escaping on/admin; - settings coming back after a restart; - the speed cap clamping commands before they reach a fake arm.To try it: run
PORT=8102 FORGE_APP_DATA=./data bun run Software/so101/bench/fake-serve.tsand openhttp://127.0.0.1:8102/admin. Run locally, every visitor is the owner. Pause there, then watch/show the paused state and the announcement. On a preview, sign in as the owner to see the Admin bar beside the queue.🤖 Generated with Claude Code
Closes #16