Skip to content

TL-07: live SpacetimeDB board, resident and driver phones - #33

Merged
gholapksh merged 7 commits into
mainfrom
TL-07-live
Nov 8, 2026
Merged

gholapksh merged 7 commits into
mainfrom
TL-07-live

Conversation

@SJAryan

@SJAryan SJAryan commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

What changed

  • Fixture/Live switch in the top bar. Fixture stays the scripted walkthrough and the offline fallback.
  • Role gate (src/live/RoleGate.tsx): every live screen checks myRole. A window with no role shows a claim form (claimInvite). A window with the wrong role is told to open a separate private window. Each window holds one role.
  • Live board (src/live/LiveBoard.tsx): lanes, KPI tiles and route options come from the coordinator views. The coordinator can record a reply taken by phone (ingestCheckin), confirm a +20 min route delay (confirmRouteReport) and reserve (reserve with expectedVersion). The drawer shows the committed job, its 3-step status and a read-only thread.
  • Live phones (src/live/LivePhone.tsx): the driver and resident read driverJobs / residentJobs and jobMessages. Messages show Sending…, then sent; a failed send can be retried and reuses its clientMessageId. The driver taps I have arrived and the resident taps I received the battery (updateJob with expectedVersion). Server conflict: / forbidden: / rejected: errors are shown.
  • Registration stays fixture and carries a callout saying so.

How it was tested (Maincloud, 3 separate authenticated browser contexts)

  1. The coordinator records "30 to 60" for H17, and H17 moves to Act now. The coordinator reserves R4, and job 1 appears on both phones with no refresh.
  2. The resident sends "Can you use the side entrance?". It appears on the driver phone and in the coordinator thread.
  3. The driver replies "Yes, I'll meet you there." It appears on the resident phone and in the coordinator thread.
  4. The driver taps I have arrived and the resident taps I received the battery. All three windows show delivered live.

npx tsc -b and npm run build pass after merging current main.

Not done or not verified

  • The conflict message was not seen end to end. The UI already prevents the double booking this test could reach: busy options show No free option.
  • There is no en route status. The delay amount is fixed at +20 in the UI.
  • Registration and TL-09 consent are still fixture in this screen.

Clock: why this PR doesn't change it

The client uses real time on purpose, because the server does too. reserve computes the committed etaAt from ctx.timestamp. If the board used the incident clock instead, it would disagree with the ETA the server commits and texts to the resident. The wrong numbers come from the seed: it sets drivers' and batteries' freeAt to the incident clock (02:00 Nov 8). The fix is to seed freeAt relative to the publish time, or add an owner reducer that re-anchors the incident to now. That's A's module, tracked in #34, and it needs no change to this PR. Until then, record the margin story after 2 AM or in fixture mode.

Review follow-ups since opening

  • Missing or wrong-kind resources are never offered as free. A known runtime with no free option stays Act now and is labeled "No free option".
  • One identity per screen (coordinator, resident, driver) instead of one per browser.
  • A recorded reply reuses its event ID until it lands, and so does each delay report (each new report gets its own ID).
  • After delivery, the coordinator can release the battery and driver (A's releaseJob, TL-11 support: silent follow-ups with owners, audit and job release #39). On Maincloud this waits for A's TL-11 republish (TL-18 | Demo seed on real time, one lead incident, and a repeatable Maincloud reset #34), and until then the drawer shows "no such reducer".
  • After delivery, the driver phone says the job is done and the next one will appear there.
  • The delay link stays a single demo action: the server replaces the delay rather than adding to it, so a second +20 would change nothing. A real second report needs an amount field, which is out of scope here.

Needs from A

  • Reset the Maincloud data: the test left a check-in for H17, job 1 and its messages.
  • Replacement codes: D's coordinator, driver ana and resident H17 codes are now used. D needs new ones for the demo laptop. Send them privately.
  • Clock mismatch: the seeded freeAt is the incident clock (02:00 Nov 8), but readiness uses real time. Arrivals show about 02:13 and margins are about −200 min until then. Seed freeAt relative to now, or line the clocks up.
  • Battery after delivery: BAT-01 still counts as busy after delivery. Confirm whether that's intended.

Setup

Live mode needs VITE_SPACETIMEDB_HOST and VITE_SPACETIMEDB_DB_NAME in .env.local (gitignored). No invite codes are in the repo.

🤖 Generated with Claude Code

SJAryan and others added 2 commits November 7, 2026 22:31
Adds a Fixture/Live switch. Live mode gates each screen on the window's
claimed role, reads A's views through generated subscriptions, and writes
through reserve, ingestCheckin, confirmRouteReport, postJobMessage and
updateJob. Messages show sending, sent and a retry that reuses the same
clientMessageId; reducer conflict/forbidden/rejected errors are shown.

Co-Authored-By: Claude <[email protected]>
SJAryan and others added 2 commits November 7, 2026 22:46
…ncovered Act now

An option is blocked when its driver or asset is missing from the views, the
asset kind does not match the household's need, or either is busy. A known
runtime with no free option stays Act now (team lane rules: uncovered work
surfaces) and the board row now says 'No free option' instead of a dash.

Co-Authored-By: Claude <[email protected]>
Tabs and private windows of one browser share localStorage, so a single
token gave every tab the same role. main.tsx now keeps a token per screen
(board = coordinator, register/resident = resident, driver = driver). The
SDK pools connections by host and database, so in live mode moving to a
screen with another role reloads into that identity; fixture navigation
never reloads. Role-gate copy no longer says to use private windows.

Recording a phone reply now reuses one eventId and observedAt per answer
until it succeeds, so a retry after a lost response is a server-side no-op.

Co-Authored-By: Claude <[email protected]>
SJAryan and others added 3 commits November 7, 2026 23:04
After delivery the drawer offers 'Release BAT-01 and Ana for the next
household', calling A's releaseJob (#39) with the job's version. Once the
battery and driver no longer hold the job it says they are free. Merged
main for the TL-11 bindings.

A confirmed delay report now gets its own report ID, reused only when
retrying that same report, so a later report on the route is not treated
as a duplicate.

Co-Authored-By: Claude <[email protected]>
… appear

driver_jobs keeps every job for the driver and carries no release state, so
after delivery the driver screen now reads 'Job 1 done' and says the next job
appears as soon as a coordinator assigns it. A newer job replaces it
automatically, since the phone shows the latest job.

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants