feat(host): a board save is answered once its follow sees the transaction

Merged
CH
11d ago
+86-7

This is the host half of the board-save area in the txid rollout. When the window saves the whiteboard, the host waits until the board follow has seen the save's transaction, then answers the window. It builds on the shared wait from #4423 and on the service half, #4432, which made the save answer txid.

Ported from the txid half of #3757 (11af552b / cc26ed92 from that PR's earlier history).

What changes

  • board-follow.ts: BoardFollowDependencies takes an optional onTxWait and passes it to liveRows.
  • compose-tasks.ts:
    • followLive passes an optional onTxWait through to the follow it runs.
    • followBoard keeps the TxWait the follow hands out, tagged with its task. When a follow is let go, it clears only the wait it handed out itself.
    • tasks.boardSave calls confirmWrite(wait, saved.txid) before it answers { saved: true }.
    • The wait runs outside serial, so a slow or missing transaction never holds up other task work. The board view is still written as soon as the save answers.
  • The answer goes out at once when the save carries no txid (an elements-only or unchanged save, see #4432), when the board is polled, or when no follow stands. That is confirmWrite's fallback.

Tests

compose-tasks.test.ts, using fakeRealtime:

  • A save that answers txid 42 doesn't answer while 42 is still awaited, and answers { saved: true } once arrive("42").
  • A save with no txid answers at once.
  • After the follow stops and isn't sealed again (no wait), a save with a txid answers at once and leaves nothing awaited.

Checks run: host typecheck; vitest on compose-tasks.test.ts, board-follow.test.ts and live-follow.test.ts; biome; ./scripts/oxlint.sh.

Made with Luke


Devin Review