Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
Closing the arm locks its owner out: keep sign-in and /admin working while closed, an Open now button on the resting card, and so101 open/close #579
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
Closing the arm no longer locks the owner out. While it is closed, sign-in and `/admin` keep working, the resting card leads the owner back in, and the switch can be flipped from outside the app.
shipped merged
2 earlier comments · 1 event
Closing the arm no longer locks the owner out. While it is closed, sign-in and /admin keep working, the resting card leads the owner back in, and the switch can be flipped from outside the app.
- Resting card (
src/resting-page.ts): what it shows depends on who is looking.
- Anonymous visitors get a quiet "Owner? Sign in to open" link to /__forge/signin?to=%2Fadmin.
- A signed-in owner gets an Open now button (Open anyway when the arm is offline) and a link to Admin. The button is a form that posts action=open&then=home to /admin, and /admin redirects back to /. The page's Content-Security-Policy now allows form-action 'self' so that form can post.
- Other signed-in people see neither.
- /admin still checks the same-origin rule and that the person is the owner.
- Relay (
src/relay.ts): while resting, it no longer returns 503 for the forge's own/__forge/…paths. Before this, they fell through to the "nothing but a STOP" refusal./adminand/storywere already reachable while closed; anonymous visitors still get a 404 on/admin, so they sign in first. - Outside the app (
src/opening.ts,src/lobby.ts): the app now re-readsso101/open.jsonon the relay's once-a-second tick, so editing it takes effect without a redeploy.{"open": true}alone is enough to reopen. This is what the forge's app settings can write to; the forge side itself is a separate forge issue. - CLI (
src/app-switch.ts,src/cli.ts):so101 openandso101 close "note"connect to the app's terminal over ssh and type/openor/close <note>. The ssh command comes from--sshor$SO101_SSH, and the forge signs the owner in as it does for any ssh. The note is checked to be one line of at most 140 characters, goes in on ssh's stdin, and ssh runs without a shell. I could not try this against the real forge terminal from here: the tests run the piping part against a stand-in for ssh. A forge terminal that wants a pty may needssh -tt. - Tests: while closed, an anonymous visitor gets the sign-in link and
/__forge/signinis not 503. A signed-in owner gets 200 on/admin, and Open now opens the arm and redirects to/. A plain user gets 404 and a post from another origin gets 403; neither opens it. Hand-edits toopen.jsoncount within a second or two. The CLI is covered for its typed line, ssh parsing and passing the note on stdin. The touched suites pass locally (172 tests, 2 skipped). Type checking shows no errors in the touched files; the repository has older type errors elsewhere that I left alone.
To try it on the preview: close the arm in /admin, open / in a private window to see the sign-in link, then load / signed in as the owner and press Open now. From a laptop: SO101_SSH="<the app's FORGE_APP_SSH>" node Software/so101/bin/so101 close "Back Saturday 10am CT", then so101 open.
🤖 Generated with Claude Code
The behaviour is right and well tested: the sign-in link for anonymous visitors, Open now for the owner only, form-action 'self' with the same-origin and owner checks kept on /admin, open.json refresh, and a CLI that puts the note on stdin with no shell. The preview boots, / answers 200, /__forge/signin answers 303 and /admin answers 404 to a guest. The preview is open, so I could not see the resting card itself. I could not read the screenshots because the file tools are confined to the clone.
Fix first: in src/relay.ts the new FORGE_PATH constant and its doc comment were inserted between the existing /** What still goes to the arm server while the link is reconnecting: stopping it. */ comment and const STOPS. STOPS has lost its comment and that comment now sits on the wrong constant. Move FORGE_PATH above that comment so each constant keeps its own.
Then, in the next change: (1) the test only asserts that /__forge/signin is not 503. Where the forge answers that path in front of the app, the relay change cannot be shown to matter, so add a test that fails without it, for example a handler that reaches the relay with a /__forge/ path while closed. (2) The CLI could not be tried against the real terminal. Say in the README whether ssh -tt is needed once someone has tried it.
Closing the arm no longer locks the owner out. While it is closed, sign-in and /admin keep working, the resting card leads the owner back in, and the switch can be flipped from outside the app.
- Resting card (
src/resting-page.ts): what it shows depends on who is looking.
- Anonymous visitors get a quiet "Owner? Sign in to open" link to /__forge/signin?to=%2Fadmin.
- A signed-in owner gets an Open now button (Open anyway when the arm is offline) and a link to Admin. The button is a form that posts action=open&then=home to /admin, and /admin redirects back to /. The page's Content-Security-Policy now allows form-action 'self' so that form can post.
- Other signed-in people see neither.
- /admin still checks the same-origin rule and that the person is the owner.
- Relay (
src/relay.ts): while resting, it no longer returns 503 for paths under/__forge/; a look-alike path such as/__forgeryis still refused./adminand/storywere already reachable while closed. Anonymous visitors still get a 404 on/admin, so they sign in first. - Outside the app (
src/opening.ts,src/lobby.ts): the app now re-readsso101/open.jsononce a second, so editing it takes effect without a redeploy.{"open": true}alone is enough to reopen. This is what the forge's app settings can write to. - CLI (
src/app-switch.ts,src/cli.ts):so101 openandso101 close "note"connect to the app's terminal over ssh and type/openor/close <note>. The ssh command comes from--sshor$SO101_SSH, and the forge signs the owner in as it does for any ssh. The note is checked to be one line of at most 140 characters, goes in on ssh's stdin, and ssh runs without a shell.
- Not yet tried against the forge's real terminal. The README says to add -tt to the ssh command if the line gets lost, and asks whoever tries it first to record which form works.
- Review changes:
- FORGE_PATH now sits above the reconnecting comment, so STOPS has its own comment again.
- The /__forge/signin test sends its requests to the relay directly, with no forge in front. I put the exemption back the old way and that test fails, so it already covers the change. It now says so, and also checks that /__forgery is still a 503.
- Tests:
- While closed, an anonymous visitor gets the sign-in link and /__forge/signin is not a 503.
- A signed-in owner gets 200 on /admin, and Open now opens the arm and redirects to /.
- A plain user gets 404 and a post from another origin gets 403; neither opens the arm.
- Hand-edits to open.json take effect within a second or two.
- The CLI is covered for the line it types, parsing the ssh command, and putting the note on stdin, against a stand-in for ssh.
The resting, readme, relay, lobby, opening, CLI and terminal suites pass. There are no type errors in the files I touched; type errors elsewhere in the repository were already there and I left them.
To try it on the preview: close the arm in /admin, open / in a private window to see the sign-in link, then load / signed in as the owner and press Open now. From a laptop: SO101_SSH="<the app's FORGE_APP_SSH>" node Software/so101/bin/so101 close "Back Saturday 10am CT", then so101 open.
🤖 Generated with Claude Code
Closing the arm no longer locks the owner out. While it is closed, sign-in and /admin keep working, the resting card leads the owner back in, and the switch can be flipped from outside the app.
- Resting card (
src/resting-page.ts): what it shows depends on who is looking.
- Anonymous visitors get a quiet "Owner? Sign in to open" link to /__forge/signin?to=%2Fadmin.
- A signed-in owner gets an Open now button (Open anyway when the arm is offline) and a link to Admin. The button is a form that posts action=open&then=home to /admin, and /admin redirects back to /. The page's Content-Security-Policy now allows form-action 'self' so that form can post.
- Other signed-in people see neither.
- /admin still checks the same-origin rule and that the person is the owner.
- Relay (
src/relay.ts): while resting, it no longer returns 503 for paths under/__forge/; a look-alike path such as/__forgeryis still refused./adminand/storywere already reachable while closed. Anonymous visitors still get a 404 on/admin, so they sign in first. - Outside the app (
src/opening.ts,src/lobby.ts): the app now re-readsso101/open.jsononce a second, so editing it takes effect without a redeploy.{"open": true}alone is enough to reopen. This is what the forge's app settings can write to. - CLI (
src/app-switch.ts,src/cli.ts):so101 openandso101 close "note"connect to the app's terminal over ssh and type/openor/close <note>. The ssh command comes from--sshor$SO101_SSH, and the forge signs the owner in as it does for any ssh. The note is checked to be one line of at most 140 characters, goes in on ssh's stdin, and ssh runs without a shell.
- Not yet tried against the forge's real terminal. The README says to add -tt to the ssh command if the line gets lost, and asks whoever tries it first to record which form works.
- Preview test failure (
src/ui/data-view.js): the failing test was "the Pi chart draws under-voltage minutes…", and the fault was in the Data view page, not in this pull's changes.
- The page asked /data for a range ending at Date.now(), and the server only counts rows from before that end. A sample written in the same millisecond was left out, so the test failed whenever its write and the page's request landed in the same millisecond.
- The server's own default already ends one millisecond ahead; the page now does the same.
- A new test freezes the clock so the sample and the request share a millisecond. It fails without the fix and passes with it. I did not change the old test.
- Tests (all in the resting tests unless named):
- While closed, an anonymous visitor gets the sign-in link and /__forge/signin is not a 503. These requests go straight to the relay, and putting the exemption back the old way makes the test fail.
- A signed-in owner gets 200 on /admin, and Open now opens the arm and redirects to /.
- A plain user gets 404 and a post from another origin gets 403; neither opens the arm.
- Hand-edits to open.json take effect within a second or two.
- The CLI is covered for the line it types, parsing the ssh command, and putting the note on stdin, against a stand-in for ssh.
The resting and Data view suites pass after the fix. The other touched suites (readme, relay, lobby, opening, CLI, terminal) passed before it and were not re-run. I did not run the whole suite locally; the forge runs it on this push. There are no type errors in the files I touched; type errors elsewhere in the repository were already there and I left them.
To try it on the preview: close the arm in /admin, open / in a private window to see the sign-in link, then load / signed in as the owner and press Open now. From a laptop: SO101_SSH="<the app's FORGE_APP_SSH>" node Software/so101/bin/so101 close "Back Saturday 10am CT", then so101 open.
🤖 Generated with Claude Code
Approved. Checked in the preview: / 200, /status 200, /story 200, /admin 404 for an anonymous visitor, /__forge/signin 303. I could not close the arm there without owner identity, so the resting card and Open now are judged from source and tests only. Identity comes from lobby.who(req), so the owner button is gated by the verified headers. The Open now form posts to /admin, which still does the same-origin and owner checks. Tests cover the anonymous, owner, non-owner and cross-origin cases, and the card is a plain server-rendered form that works with JavaScript off. Two things to do next: (1) Try so101 open/close against the real forge terminal and record in the README whether -tt is needed. (2) The data-view.js to fix is unrelated to this issue; ship it as its own pull next time. Also check that /__forge/* paths passed through while resting get a sensible answer from the relay rather than reaching the arm server.
Closing the arm no longer locks the owner out. While it is closed, sign-in and
/adminkeep working, the resting card leads the owner back in, and the switch can be flipped from outside the app.src/resting-page.ts): what it shows depends on who is looking.- Anonymous visitors get a quiet "Owner? Sign in to open" link to
/__forge/signin?to=%2Fadmin. - A signed-in owner gets an Open now button (Open anyway when the arm is offline) and a link to Admin. The button is a form that postsaction=open&then=hometo/admin, and/adminredirects back to/. The page's Content-Security-Policy now allowsform-action 'self'so that form can post. - Other signed-in people see neither. -/adminstill checks the same-origin rule and that the person is the owner.src/relay.ts): while resting, it no longer returns 503 for the forge's own/__forge/…paths. Before this, they fell through to the "nothing but a STOP" refusal./adminand/storywere already reachable while closed; anonymous visitors still get a 404 on/admin, so they sign in first.src/opening.ts,src/lobby.ts): the app now re-readsso101/open.jsonon the relay's once-a-second tick, so editing it takes effect without a redeploy.{"open": true}alone is enough to reopen. This is what the forge's app settings can write to; the forge side itself is a separate forge issue.src/app-switch.ts,src/cli.ts):so101 openandso101 close "note"connect to the app's terminal over ssh and type/openor/close <note>. The ssh command comes from--sshor$SO101_SSH, and the forge signs the owner in as it does for any ssh. The note is checked to be one line of at most 140 characters, goes in on ssh's stdin, and ssh runs without a shell. I could not try this against the real forge terminal from here: the tests run the piping part against a stand-in for ssh. A forge terminal that wants a pty may needssh -tt./__forge/signinis not 503. A signed-in owner gets 200 on/admin, and Open now opens the arm and redirects to/. A plain user gets 404 and a post from another origin gets 403; neither opens it. Hand-edits toopen.jsoncount within a second or two. The CLI is covered for its typed line, ssh parsing and passing the note on stdin. The touched suites pass locally (172 tests, 2 skipped). Type checking shows no errors in the touched files; the repository has older type errors elsewhere that I left alone.To try it on the preview: close the arm in
/admin, open/in a private window to see the sign-in link, then load/signed in as the owner and press Open now. From a laptop:SO101_SSH="<the app's FORGE_APP_SSH>" node Software/so101/bin/so101 close "Back Saturday 10am CT", thenso101 open.🤖 Generated with Claude Code
Closes #578