Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
Page control for tableOffsetMm and a table-here button in the settings panel #181
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
The Admin tab's Safe zone card now has a "table offset" number field and a "Table is here" button. I haven't tried either against a running server. This pull depends on #173, which adds tableOffsetMm and POST /settings/table-here.
shipped merged
2 earlier comments · 2 events
The Admin tab's Safe zone card now has a "table offset" number field and a "Table is here" button. I haven't tried either against a running server.
This pull depends on #173, which adds tableOffsetMm and POST /settings/table-here. Neither is on main yet, so the controls won't work until #173 merges. I also couldn't read #173's code, so I assumed the table-here call takes an empty JSON body and returns {error} on failure.
- Offset field: it takes -100 to 100 mm and saves through
PUT /settingslike the table margin next to it. A line under the row shows the current offset, and it falls back to 0 if the server doesn't sendtableOffsetMm. - Table-here button: it posts to
/settings/table-here, then reloads the settings so the field and the line show the new offset. A failure is shown as the server's error message. - Admin only: I added no check of my own. The whole Admin tab is already admin-only, and the server takes settings changes from admins only.
- Test:
src/viewer-table.test.tsonly checks that the page contains the new controls and the two routes. It passes. I haven't runtscor the rest of the suite.
The changes are in Software/so101/src/viewer.html and the new test file.
🤖 Generated with Claude Code
The page controls are wired correctly: api() exposes ok, the routes exist on main from #173 and are admin-only in the relay, and the preview serves the controls. Two things from the list are missed.
- Fix first: the test would not catch a broken control. It only greps viewer.html for strings, so the handler could be dead and it would still pass. Test the behaviour that is new: either the server side that the button depends on (POST /settings/table-here with a non-admin refused, and with an admin setting tableOffsetMm), or extract the button's handler and field wiring so a test can drive it. Also run
bun x tsc --noEmitandbun test; the pull says neither was run.
- Both doors: src/tty.ts has no way to set the table offset or run table-here. A person on the page can do it, but a person in the terminal cannot. Add a terminal command for each, gated like the page (admin only), and document both in the README. If settings are deliberately page-only today, say so in the pull and open an issue for it.
Smaller points:
<p id="tableNote">is empty until loadSettings resolves, then fills. On a 360px phone that is a layout shift. Reserve its height with CSS or render the text server-side.- A failed table-here (409 from the server) is shown only in the transient #msg. That is acceptable, but the 409 text is long, so check that #msg wraps on 360px.
The Admin tab on the page now has a "table offset" field (-100 to 100 mm) and a "Table is here" button, and the terminal has /table here and /table <mm>. bun test passes (428 tests, 0 failures). bun x tsc --noEmit reports 107 errors, all in .js files and the same count with and without this change. I haven't tried the page or terminal controls against a running server.
- Terminal:
/table hereposts to/settings/table-here./table <mm>sendsPUT /settingswithtableOffsetMm. The terminal doesn't check who is an admin; it relies on the server'sADMIN_ONLYgate, as/stopand/mutedo. A refusal is printed aserror: …, and success printstable offset is N mm./table 101or/table abcgets a usage line without calling the server. Both commands are in the/helpline and in the README's terminal section. The code is insrc/terminal.ts. - Tests:
- Replaced test: I deleted the test that only searched viewer.html for strings, because it would pass with a dead handler.
- New tests: src/terminal.test.ts now covers parsing, the POST/PUT requests with their signed headers, a 403 coming back as the error, and what the terminal prints.
- Server gate: it was already covered. lobby.test.ts checks that /settings/table-here gives 401 with no identity, 403 for a non-admin and 200 for an admin, and server.test.ts checks that table-here sets the offset.
- Not tested: the page's button handler itself is still not driven by any test. I didn't extract it.
- Layout shift:
#tableNotenow hasmin-height:3em, so the content below it no longer jumps when the text fills in. #msgon 360px: not checked on a phone.#msgiswidth:max-contentwith amax-widthjust under the screen width, so a long 409 text should wrap.- tsc setup:
bun installandtscfailed on the read-only temp directory until I pointedBUN_TMPDIRand the install cache at$TMPDIR.
🤖 Generated with Claude Code
The terminal half is solid (parsing, signed POST/PUT, refusal printed, server gate already tested, help and README updated), and the preview serves the new controls. One miss against the list: the page half of this change has no test. The Table-is-here click handler, the offset onchange and the tableNote text are the main thing issue #181 asks for, and the only test that touched them was deleted. Delete the handler and bun test stays green. Fix first: put the handler logic in a small module (for example src/ui/table-control.js, plain data in and out, taking the api and msg functions) and add a test that fails without it. It should cover: a successful click calls POST /settings/table-here with {} and reloads the settings; an error response shows the server error through msg; an out-of-range offset is not saved. Also fix the README sentence (inline comment). Smaller: the page shows no sign of the 409 wording being wrapped on 360px; please check #msg there. A static style="min-height:3em" is fine, but a class in the stylesheet matches the file better.
The page's table controls now live in src/ui/table-control.js, and a new test file covers them. bun test passes (436 tests); bun x tsc --noEmit shows 107 errors in .js files, the same count as before this change. I haven't opened the page in a browser.
- Module:
bindTableControl({ input, button, api, msg, reload })holds the "Table is here" click and the offset field'sonchange.tableNote(settings)builds the note under the row.src/viewer.htmlloads the module with a dynamic import the first time the Admin tab loads. A static import pushed the first-visit page over the 51.2 KB gzip limit thatserver.test.tschecks. - Click: it posts
{}to/settings/table-hereand reloads the settings. An error response, including a long 409, goes throughmsgas the server worded it. The button is disabled while the request is in flight, and a second click does nothing, since each click rewrites the table plane from the arm's pose. - Offset field: a whole number from -100 to 100 is saved with
PUT /settingsand the settings reload. Out-of-range, fractional, empty or non-numeric values aren't saved, andmsgsays why. If the server refuses a value, its error is shown. - Tests:
src/ui/table-control.test.tscovers success, the server error, an error with no text, the double click, the field's save and rejects, a server refusal on the field, and the note. These fail if the handlers are removed. - Styling:
#tableNotegetsmin-height: 3emfrom the stylesheet instead of an inline style.#msggetsoverflow-wrap: anywhere, so a long 409 wraps on a narrow screen. I haven't checked that on a 360px display. - README: the terminal sentence is split. "Only an owner may set the table (
/table)" now reads as its own clause, in shorter lines.
🤖 Generated with Claude Code
Does what #181 asked: Admin-tab offset field and "Table is here" button (server-gated by ADMIN_ONLY, double-click guarded, 409 text shown and wrapped), and the same two actions as /table here and /table <mm> in the terminal, signed and server-gated, in /help and the README. Tests would fail without the handlers; no new dependency. Next: (1) check #msg wrapping and the #tableNote min-height on a real 360px phone, since both were only reasoned about; (2) the terminal says "owner" while the code and server say admin, so use one word in README and HELP.
The Admin tab's Safe zone card now has a "table offset" number field and a "Table is here" button. I haven't tried either against a running server.
This pull depends on #173, which adds
tableOffsetMmandPOST /settings/table-here. Neither is onmainyet, so the controls won't work until #173 merges. I also couldn't read #173's code, so I assumed the table-here call takes an empty JSON body and returns{error}on failure.PUT /settingslike the table margin next to it. A line under the row shows the current offset, and it falls back to 0 if the server doesn't sendtableOffsetMm./settings/table-here, then reloads the settings so the field and the line show the new offset. A failure is shown as the server's error message.src/viewer-table.test.tsonly checks that the page contains the new controls and the two routes. It passes. I haven't runtscor the rest of the suite.The changes are in
Software/so101/src/viewer.htmland the new test file.🤖 Generated with Claude Code
Closes #178