Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

The admin page shows the table height and a 'the arm rests on the table now - set the table here' button #184

Parked opened this
Closed without merging

/admin now has a Table section that shows the arm server's tableOffsetMm. I ran the admin, relay and lobby tests (60 pass) and pushed. I did not run the whole bun test suite; the forge runs that on push.

Notes

stopped parked by the crew deploy 0012547

opened this

/admin now has a Table section that shows the arm server's tableOffsetMm. I ran the admin, relay and lobby tests (60 pass) and pushed. I did not run the whole bun test suite; the forge runs that on push.

  • Owner: gets an editable number field (-100 to 100 mm) and a button, "The arm rests on the table now - set the table here". Both post back to /admin and redirect with "The table is set."
  • Moderator: sees the value as plain text, with no field or button. Posting either table action as a moderator returns 403.
  • How it reaches the arm server: the relay reads GET /settings and writes through PUT /settings and POST /settings/table-here. It uses the live arm server when there is one, otherwise the simulation. The page's CSP is unchanged and still has no script.
  • When it fails: if the arm server doesn't answer, the page says it didn't say where the table is. A refused or unreachable write shows the arm server's own message as the page error.
  • Where the code is: the new ArmTable interface in src/admin-routes.ts, the page section in src/admin-page.ts, and the relay wiring in src/relay.ts.
  • Test: the new case in src/admin-relay.test.ts runs against a stub arm server. It covers what the owner and a moderator see, the 403 for the moderator, rejecting an out-of-range value, setting a value, and "table here".
  • Type check: bun x tsc --noEmit already fails on main in src/ui/lobby-panel.js (107 lines of errors before my change). Nothing in the files I touched fails.

forge.json is untouched.

🤖 Generated with Claude Code

Closes #163

4 earlier comments · 3 events
Changes requested — before the latest push

The page work is sound: owner-only writes (403 for a moderator), the mm value is validated server-side, the redirect line is fixed text, the CSP is unchanged, and the test covers owner, moderator, bad value and both writes. The preview /admin answers 401 without the forge identity, as intended. Two things from the list are missing.

  1. README: Software/README.md documents /admin at about lines 471-513 (owner actions, moderators, the log) and says nothing about the Table section. Fix first: add a short paragraph there. It should say the owner sets the table height (-100 to 100 mm) or presses "The arm rests on the table now - set the table here", a moderator only reads it, and each action goes to the arm server (or the simulation).
  1. Both doors: src/tty.ts is untouched. Either give the terminal the same read and set (gated like the page: owner writes, moderator reads, guest sees nothing) with a test, or, if the terminal has no admin surface by design, say so in the README so that is a decision rather than a gap.

Smaller: the new test only checks 403 for table-here by a moderator; add table-set as well, since it is a separate case branch. On the page, label the number field so a screen-reader user hears the unit (the small text is inside the label, which is fine), and note the two table forms stack on 360px as a column. Check that, since the button text is long and must wrap rather than overflow.

commented

/admin now shows the table height and the "set the table here" button, and I've addressed the review points on this branch. I pushed it. The admin tests pass (12); I did not run the whole suite.

  • README: the /admin list in Software/README.md has a new Table bullet. The owner sets the height (-100 to 100 mm) or presses "The arm rests on the table now - set the table here". A moderator only reads it. Each action goes to the arm server, or the simulation when there is none, and is checked there.
  • Terminal: I did not add a read and set to src/tty.ts. The README already says admin settings are web-only, and the new bullet repeats that the terminal has no admin surface by design. If you want the terminal to have it, that's a separate change.
  • Test: a moderator posting table-set now gets a 403, and the stub's table value stays unchanged.
  • Label: the number field has an aria-label giving the unit ("Table height in millimetres above the model's table").
  • 360px layout: I did not open it in a browser. By the CSS, the button wraps rather than overflows: buttons have no nowrap, and the .actions row and .grid both wrap. I left the CSS alone.

🤖 Generated with Claude Code

Changes requested — before the latest push

The page half works: the logic is sound, a moderator gets 403 on both table actions (tested), the number is validated 3 digits and -100..100, and the arm server also checks it. The preview answers 401 on /admin to a guest, as it should. One miss against the list: both doors. A person can set the table on the page but not in src/tty.ts (it has no table read or set), and the README answers that by calling the terminal having no admin surface by design. The owner's rule is that what a person can do on the page they can do in the terminal, and the terminal gates exactly as the page does (owner only to set, a moderator reads). Fix first: add a table read and set/here to src/tty.ts for the owner, read-only for a moderator, through the same ArmTable, with a test that a guest and a moderator are refused and the owner's write reaches the arm server; then update the README bullet. If the terminal truly has no admin surface for any setting today, say so with a pointer to that decision and open an issue for the terminal admin door instead of asserting it in the README. Smaller: the 360px layout was not looked at; ArmTable.read swallows every error into null, which shows "did not say" even when the server is down. Say so (e.g. unreachable) so the owner is not misled.

commented

The terminal can now read and set the table as well, and /admin tells an unreachable arm server apart from one that didn't report a height. I ran the terminal, admin and lobby tests (58 pass) and pushed. I did not run the whole suite.

  • Terminal commands: /table reads the height, /table 12 sets it (a whole number, -100 to 100), and /table here does what the page button does. They go through a new /admin/table route in src/admin-routes.ts, wired in relay.ts to the same ArmTable and the same owner/moderator check as the page. Here is how each person is treated:

- A guest gets 401. - Anyone who isn't the owner or a moderator gets 403. - A moderator can read, but a write gets 403. - The owner's write goes to the arm server.

  • Test: src/terminal.test.ts has a new case against the real simulation server. The owner reads and sets 12, and the simulation's /settings then shows 12. A moderator reads 12 and is refused /table 3 and /table here, and the value stays 12. A user who isn't the owner or a moderator, and a guest, are both refused.
  • README: the Table bullet documents the /table commands. I also removed an older sentence in the Moderators bullet that said the app has no terminal, because forge.json does declare tty. The other settings are still web-only.
  • Unreachable vs. no height: ArmTable.read no longer swallows errors. The page now shows "the arm server did not answer (…): the table height is not known" when it can't reach the arm server, and "did not say" only when it answered without a height.
  • 360px layout: I still haven't looked at it in a browser; I can't from here. The CSS wraps long button text rather than overflowing it.

🤖 Generated with Claude Code

commented

main is merged into the branch and pushed. The one conflict, in src/admin-routes.ts, is resolved. The terminal, admin, lobby and relay tests pass (80), and the type check shows no errors outside src/ui.

  • What conflicted: main changed /admin to answer anyone who isn't the owner or a moderator with a plain 404 (no such route). My branch had moved that check into a shared helper that answered 401 or 403.
  • How I kept both: the shared helper stays, and /admin now uses main's 404.
  • /admin/table: it follows the same rule and answers outsiders with 404. A moderator still reads the value and gets 403 on a write.
  • Terminal test and README: I updated the terminal test and the README Table bullet to say 404.

🤖 Generated with Claude Code

Changes requested

The page and terminal both work and are tested, but the new write door /admin/table has no same-origin check. Fix that first.

The owner's browser authenticates with the forge's signed headers on any request. handleTable parses the body as JSON whatever its content-type. A third-party page can therefore make the owner's browser POST a text/plain form body like {"here":true,"x":"="} and move the table. The rule is a same-origin check on every mutation, and handleAdmin follows it for the page.

Fix: apply the same Origin/Host check that handleAdmin uses to POST in handleTable, before readBody. Require content-type: application/json, which also forces a CORS preflight. Add a test that a POST with a foreign Origin gets 403 and leaves the table unchanged. The terminal's own poster must still pass, so check what it sends.

Smaller: in handleAdmin, else { await arm.set(...) } has needless braces and the case block braces are redundant. Please tidy them.

commented

Handed to a person by the crew: the reviewer asked for changes three times with no approval between, so the planner re-scopes it: split, replaced, or one more round with the reviewer's ask restated.

  1. juniper: The page work is sound: owner-only writes (403 for a moderator), the mm value is validated server-side, the redirect line is fixed text, the
  2. juniper: The page half works: the logic is sound, a moderator gets 403 on both table actions (tested), the number is validated 3 digits and -100..100
  3. juniper: The page and terminal both work and are tested, but the new write door /admin/table has no same-origin check. Fix that first.
commented

Parked by the crew: the preview's deploy failed and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs