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

Migrated from github.com/Trevato/SO-ARM100

A restart costs a blink, not a session: turn, queue and chat survive it and the page reconnects in under a second #453

Merged opened this in answer to

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

Merged

Most of #440 was already on main. The missing piece was how fast the page retries, so I changed that and added the restart test. Already on main: Turns writes the driver, the queue order, names and turn times to turns.json and restores them on start.

Notes

shipped merged

opened this

Most of #440 was already on main. The missing piece was how fast the page retries, so I changed that and added the restart test.

Already on main:

  • Turns writes the driver, the queue order, names and turn times to turns.json and restores them on start. The driver keeps the same endsAt, so the remaining time is intact.
  • Chat, mutes and moderation, the admin settings and a held arm are also restored from the data directory.
  • A lost relay link still parks the arm. The turn is restored with readyBy: null, so the driver's next command needs no extra click.
  • Nothing in the 3D model path depends on the socket, so it needs no reload. Cameras reopen their own sockets.

Changed:

  • /live retry: backoff in src/ui/lobby-panel.js now runs 100, 200, 400, 800, 1600, then 2000 ms. It was 250 ms to 2 s. The "reconnecting…" chip was already a small tag in the header that never covers the camera.
  • Camera feed retry: RETRY_MS in src/ui/video.js drops from 500 to 100 ms.
  • Seat: the seat is the browser id cookie or the signed identity, and it was already kept across reconnects. I did not change it.
  • Updated test: src/ui/lobby-panel.test.ts now expects the new delays.

New test, src/restart-session.test.ts:

  1. A signed-in driver takes a turn through the real relay and a fake arm server.
  2. The relay and lobby are closed and started again on the same port and data directory.
  3. The driver reconnects to /live and is still the driver with the same endsAt.
  4. A stamped /follow frame then reaches the fake bus as a goal write with no extra step.
  5. The reconnect, turn check and goal write finish in under 1 s. The test caps the old relay's shutdown at 500 ms, which Bun's node:http needs to avoid hanging.

I ran the src/ui tests, lobby.test.ts, relay-restart.test.ts and the new test: all 208 pass. tsc --noEmit reports the same 32 errors as before my change, and none are in files I touched. I did not run the full suite or design-lint.

Closes #440

commented

Most of #440 was already on main. The missing piece was how fast the page retries, so I changed that and added the restart test.

Already on main:

  • Turns writes the driver, the queue order, names and turn times to turns.json and restores them on start. The driver keeps the same endsAt, so the remaining time is intact.
  • Chat, mutes and moderation, the admin settings and a held arm are also restored from the data directory.
  • A lost relay link still parks the arm. The turn is restored with readyBy: null, so the driver's next command needs no extra click.
  • Nothing in the 3D model path depends on the socket, so it needs no reload. Cameras reopen their own sockets.

Changed:

  • /live retry: backoff in src/ui/lobby-panel.js now runs 100, 200, 400, 800, 1600, then 2000 ms. It was 250 ms to 2 s. The "reconnecting…" chip was already a small tag in the header that never covers the camera.
  • Camera feed retry: RETRY_MS in src/ui/video.js drops from 500 to 100 ms.
  • Seat: the seat is the browser id cookie or the signed identity, and it was already kept across reconnects. I did not change it.
  • Updated test: src/ui/lobby-panel.test.ts now expects the new delays.

New test, src/restart-session.test.ts:

  1. A signed-in driver takes a turn through the real relay and a fake arm server.
  2. The relay and lobby are closed and started again on the same port and data directory.
  3. The driver reconnects to /live and is still the driver with the same endsAt.
  4. A stamped /follow frame then reaches the fake bus as a goal write with no extra step.
  5. The reconnect, turn check and goal write finish in under 1 s. The test caps the old relay's shutdown at 500 ms, which Bun's node:http needs to avoid hanging.

I ran the src/ui tests, lobby.test.ts, relay-restart.test.ts and the new test: all 208 pass. tsc --noEmit reports the same 32 errors as before my change, and none are in files I touched. I did not run the full suite or design-lint.

Approved

Approved. The change is small and does what the issue asks. The /live backoff now runs 100/200/400/800/1600/2000 ms, and the camera RETRY_MS drops to 100 ms. The restart test boots the real relay twice on the same port and data directory and checks that the driver keeps the same turn (same endsAt). It then checks that a stamped /follow frame reaches the arm, all inside 1 s. The existing lobby-panel tests are updated to the new delays. The preview answers 200 on /. I did not run the tests or see a restart on the preview. No new dependencies, no security surface touched.

Two things I would do next:

  1. The < 1000 ms assertion in restart-session.test.ts depends on wall-clock time and can flake on a loaded CI machine. Assert on the order of events, or give it more headroom, and keep the 1 s target as a measured number rather than a pass/fail line.
  2. Retrying every 100 ms for the first attempts on both /live and the cameras could pile up if the relay stays down for a long time. Add a little jitter, or a longer cap for the camera retry, so a restart with many viewers does not produce a reconnect burst.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs