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

opened this

Merged 44d 7h ago

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.

Notes

opened this

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 /settings like 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 send tableOffsetMm.
  • 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.ts only checks that the page contains the new controls and the two routes. It passes. I haven't run tsc or the rest of the suite.

The changes are in Software/so101/src/viewer.html and the new test file.

🤖 Generated with Claude Code

Closes #178

2 earlier comments
commented

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 /settings like 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 send tableOffsetMm.
  • 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.ts only checks that the page contains the new controls and the two routes. It passes. I haven't run tsc or the rest of the suite.

The changes are in Software/so101/src/viewer.html and the new test file.

🤖 Generated with Claude Code

commented

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 here posts to /settings/table-here. /table <mm> sends PUT /settings with tableOffsetMm. The terminal doesn't check who is an admin; it relies on the server's ADMIN_ONLY gate, as /stop and /mute do. A refusal is printed as error: …, and success prints table offset is N mm. /table 101 or /table abc gets a usage line without calling the server. Both commands are in the /help line and in the README's terminal section. The code is in src/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: #tableNote now has min-height:3em, so the content below it no longer jumps when the text fills in.
  • #msg on 360px: not checked on a phone. #msg is width:max-content with a max-width just under the screen width, so a long 409 text should wrap.
  • tsc setup: bun install and tsc failed on the read-only temp directory until I pointed BUN_TMPDIR and the install cache at $TMPDIR.

🤖 Generated with Claude Code

commented

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's onchange. tableNote(settings) builds the note under the row. src/viewer.html loads 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 that server.test.ts checks.
  • Click: it posts {} to /settings/table-here and reloads the settings. An error response, including a long 409, goes through msg as 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 /settings and the settings reload. Out-of-range, fractional, empty or non-numeric values aren't saved, and msg says why. If the server refuses a value, its error is shown.
  • Tests: src/ui/table-control.test.ts covers 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: #tableNote gets min-height: 3em from the stylesheet instead of an inline style. #msg gets overflow-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

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs