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

Migrated from github.com/Trevato/SO-ARM100

TOP: a restart never costs you control - reconnect in a second, keep your turn and queue place, and the arm holds still meanwhile #217

Parked opened this in answer to
Closed without merging

A restart no longer takes the arm from its driver or anyone their place in the queue. The page reconnects within a second, and the arm holds still while the app is away. The suites I ran here pass, including the new restart test (src/restart.test.ts).

Notes

stopped parked by the crew deploy 19ca00c

opened this

A restart no longer takes the arm from its driver or anyone their place in the queue. The page reconnects within a second, and the arm holds still while the app is away. The suites I ran here pass, including the new restart test (src/restart.test.ts). It kills the app mid-turn and checks that the driver gets control back, the queue keeps its order and the arm does not move during the gap.

Saved across a restart

  • src/turn-store.ts writes the driver and their turn end time plus the queue to turns.json on every change, and loads them back on start. A file it can't make sense of restores nobody rather than half a queue. Chat was already saved.
  • Turns.restore (src/turns.ts) gives the driver their turn until its original end. The idle timer and any pending "Ready" start fresh, because nobody could act while the app was down. Everyone restored gets the usual 10 s to reconnect. If a turn ran out during the gap, the next person in line is called.
  • src/held-store.ts keeps STOP's hold through a restart, on both the relay (relay-held.json) and the Pi server (held.json). If the file exists but can't be read, the arm stays held.

The page (src/ui/lobby-panel.js, viewer.html)

  • /live reconnects by itself, retrying after 0.25 s, 0.5 s, 1 s, then every 2 s, and never reloads the page.
  • While reconnecting it keeps who you are and the last known turn and queue on screen, shows a "reconnecting…" chip, and turns driving off. It says "reconnecting" in this state, never "simulated". Driving comes back once the server has sent hello and state.

GET /deploy-ok: answers 200 {"ok":true,"driving":false} when nobody is driving and 409 while someone is.

The page-size budget: main was already over the 51.2 KB first-visit budget in server.test.ts (51,743 bytes before this change), so that test failed on main too. src/lean-page.ts now drops the comment-only lines from the page's script when serving it, which saves about 2.8 KB gzipped. The file on disk keeps its comments. Its test checks the script compiles to the same code either way.

Tests changed: one restart test I had written in turns.test.ts had a mistake. It advanced the clock with no activity, so the driver timed out on idle before the restart. I fixed the test, not the code. I also added a STOP-survives-restart test to server.test.ts.

Not done: the 10 s reconnect grace is unchanged, and a restart is not announced in chat.

To try it: on the preview, take control, redeploy, and watch the chip come and go with your turn intact. curl …/deploy-ok shows the 409 while you drive.

🤖 Generated with Claude Code

Closes #202

Closes #202

commented

A restart no longer takes the arm from its driver or anyone their place in the queue. The page reconnects within a second, and the arm holds still while the app is away. The suites I ran here pass, including the new restart test (src/restart.test.ts). It kills the app mid-turn and checks that the driver gets control back, the queue keeps its order and the arm does not move during the gap.

Saved across a restart

  • src/turn-store.ts writes the driver and their turn end time plus the queue to turns.json on every change, and loads them back on start. A file it can't make sense of restores nobody rather than half a queue. Chat was already saved.
  • Turns.restore (src/turns.ts) gives the driver their turn until its original end. The idle timer and any pending "Ready" start fresh, because nobody could act while the app was down. Everyone restored gets the usual 10 s to reconnect. If a turn ran out during the gap, the next person in line is called.
  • src/held-store.ts keeps STOP's hold through a restart, on both the relay (relay-held.json) and the Pi server (held.json). If the file exists but can't be read, the arm stays held.

The page (src/ui/lobby-panel.js, viewer.html)

  • /live reconnects by itself, retrying after 0.25 s, 0.5 s, 1 s, then every 2 s, and never reloads the page.
  • While reconnecting it keeps who you are and the last known turn and queue on screen, shows a "reconnecting…" chip, and turns driving off. It says "reconnecting" in this state, never "simulated". Driving comes back once the server has sent hello and state.

GET /deploy-ok: answers 200 {"ok":true,"driving":false} when nobody is driving and 409 while someone is.

The page-size budget: main was already over the 51.2 KB first-visit budget in server.test.ts (51,743 bytes before this change), so that test failed on main too. src/lean-page.ts now drops the comment-only lines from the page's script when serving it, which saves about 2.8 KB gzipped. The file on disk keeps its comments. Its test checks the script compiles to the same code either way.

Tests changed: one restart test I had written in turns.test.ts had a mistake. It advanced the clock with no activity, so the driver timed out on idle before the restart. I fixed the test, not the code. I also added a STOP-survives-restart test to server.test.ts.

Not done: the 10 s reconnect grace is unchanged, and a restart is not announced in chat.

To try it: on the preview, take control, redeploy, and watch the chip come and go with your turn intact. curl …/deploy-ok shows the 409 while you drive.

🤖 Generated with Claude Code

Closes #202

commented

Parked by the crew: the preview's deploy failed in the place it ran, not in the change, and it could not be run again

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs