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

Migrated from github.com/Trevato/SO-ARM100

/admin shows each joint's servo control registers in one read-only table #472

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

/admin now has a Servos section. It shows one row per joint and one column per register, with the arm's GET /servo-params read on the server each time the page loads. I ran the whole Software/so101 test suite (755 pass).

Notes

shipped merged

opened this

/admin now has a Servos section. It shows one row per joint and one column per register, with the arm's GET /servo-params read on the server each time the page loads. I ran the whole Software/so101 test suite (755 pass). I added servo-panel.test.ts for this, and it passes. bun x tsc --noEmit reports errors in other files, but none in the files I touched. src/web is untouched, so I did not run design-lint.

  • Columns: they are whichever registers the arm returns, taken from its answer.
  • Silent servo: its row shows its error text, and any missing register shows "—".
  • Someone driving: a 409 shows the sentence "Someone is driving the arm, so the servos are not read now…".
  • Other failures: an arm that is unreachable or answers with something unexpected gets a sentence too, never a blank table.
  • Escaping: every value from the arm is cut to a safe length, stripped of control characters and HTML-escaped.
  • Owner only: the section appears only for the owner. A moderator sees /admin without it, and anyone else gets 404.

The page logic is in the new src/servo-panel.ts. src/relay.ts fetches /servo-params with a timeout of at most 3 seconds and passes it through src/admin-routes.ts to src/admin-page.ts.

The new tests cover the table from a fixture, including escaping and the per-row errors, and the 409 sentence. They also cover the owner-versus-moderator-versus-404 behaviour against a fake arm.

Closes #443

3 earlier comments · 1 event
commented

/admin now has a Servos section. It shows one row per joint and one column per register, with the arm's GET /servo-params read on the server each time the page loads. I ran the whole Software/so101 test suite (755 pass). I added servo-panel.test.ts for this, and it passes. bun x tsc --noEmit reports errors in other files, but none in the files I touched. src/web is untouched, so I did not run design-lint.

  • Columns: they are whichever registers the arm returns, taken from its answer.
  • Silent servo: its row shows its error text, and any missing register shows "—".
  • Someone driving: a 409 shows the sentence "Someone is driving the arm, so the servos are not read now…".
  • Other failures: an arm that is unreachable or answers with something unexpected gets a sentence too, never a blank table.
  • Escaping: every value from the arm is cut to a safe length, stripped of control characters and HTML-escaped.
  • Owner only: the section appears only for the owner. A moderator sees /admin without it, and anyone else gets 404.

The page logic is in the new src/servo-panel.ts. src/relay.ts fetches /servo-params with a timeout of at most 3 seconds and passes it through src/admin-routes.ts to src/admin-page.ts.

The new tests cover the table from a fixture, including escaping and the per-row errors, and the 409 sentence. They also cover the owner-versus-moderator-versus-404 behaviour against a fake arm.

Changes requested — before the latest push

The table, escaping, owner-only gating and tests are sound. Two items on the list are missed.

  1. README: nothing says the owner's /admin now has a read-only Servos section. The existing "Tuning the servos" section in Software/README.md (around line 937) lists GET /servo-params; add a sentence there saying where the owner sees it on /admin and when it shows a sentence instead (409 while someone drives, arm unreachable). Fix this first.
  1. Both doors: src/tty.ts is untouched, so the owner can read the registers on the page but not in the terminal. Either add the same owner-gated read to the terminal (using readServos for the same parsing, and a test that a guest sees nothing), or state in the pull why the terminal has no admin view. If the second, say so in the README.

Smaller: the preview /admin returned 404 to me without identity, which is expected, so I could not see the table as the owner; the unit and relay tests cover it.

commented

/admin has a read-only Servos section for the owner, and the terminal has a matching /servos command. I ran terminal.test.ts and servo-panel.test.ts, and both pass. The earlier full run had passed before the terminal change, and I did not rerun it.

  • README: the "Tuning the servos" section in Software/README.md now says the owner sees the registers in /admin's Servos section and as /servos in the terminal. It also says that while someone drives (the 409) or when the arm doesn't answer, both show one sentence instead of a table, and that moderators and everyone else see neither.
  • Terminal: /servos prints one line per joint, with its registers and any error. It uses readServos for the same parsing as the page, and src/tty.ts now wires it up. The owner sees the same sentences as on the page for a 409 or an unreachable arm. A guest gets "servos are for the owner", and a door without a reader says "not available here". A new test in terminal.test.ts covers all of these, including control characters being stripped.

I only filter for the owner. /servos goes through the relay's owner-only GET /servo-params, so the 404 for non-owners comes from the server, not the terminal.

commented

I merged main into the branch and pushed it. The only conflict was in src/terminal.ts.

I kept both sides in both places:

  • Help text: it now lists /zero <joint> [deg] (owner) from main and /servos (owner) from this branch.
  • Typed union: it has the zero variant and the servos variant.

terminal.test.ts and servo-panel.test.ts pass (38 tests), and tsc reports nothing in the files I touched. I did not rerun the full suite after the merge, so the rest rides on the forge's check.

commented

I merged main into the branch again and pushed. The conflict was in src/terminal.ts, in the same two places as last time.

  • Help text: I took main's version, which now has /table here|touch 1|2|3|<mm>, and kept /servos (owner) in it.
  • Typed union: I took main's table variant, which now allows { touch: 1 | 2 | 3 }, and kept the servos variant.

terminal.test.ts and servo-panel.test.ts pass (39 tests), and tsc shows no errors in the files I touched. I did not rerun the full suite after the merge, so the rest rides on the forge's check.

Approved

Owner-only read-only Servos table on /admin plus /servos in the terminal. Every arm-supplied value is type-checked, length-capped, stripped of control characters and escaped. The relay gates the owner, and the tests cover a 404 for non-owners. The 409 sentence, the per-row errors and the terminal door are covered too. The README is updated. The preview answers 404 to an anonymous /admin, as expected, but I could not sign in as the owner to see the table itself. Two things I would do next: (1) the /admin GET now waits up to 3 s on the arm for the owner, so load it after the page paints or cache the read for a few seconds; (2) add a short caption or wrapper note for narrow phones so the wide register table scrolls with a visible hint.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs