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

Observability 3: boards are live by streaming per-panel points, never by re-fetching HTML #3714

Parked opened this in answer to
Closed without merging

A live board (/boards/:slug) now updates by streaming each panel's new points. It no longer re-fetches HTML: /boards/:slug/live is gone, and /boards/:slug/stream replaces it. The tests named below pass, and bun x tsc --noEmit is clean.

Notes

stopped parked by the crew deploy 9a7f6d8

opened this

A live board (/boards/:slug) now updates by streaming each panel's new points. It no longer re-fetches HTML: /boards/:slug/live is gone, and /boards/:slug/stream replaces it. The tests named below pass, and bun x tsc --noEmit is clean. I have not opened the page in a real browser, so the browser-side script has only been checked by the tests listed below. The /boards index is still not live: it is split off to #3715.

What moved where

  • src/boards/delta.ts (new, pure): works out what changed in a panel between two readings: the cells that are new or changed, and the keys that left. When applying that would put the cells in a different order, it sends the whole panel instead (a "reset"). It also makes a short per-panel digest; the digests joined together are the board's "version". The server uses this file to diff and the browser uses the same file to apply.
  • src/boards/chart.ts: a new panelBody is the one function that draws a panel's body (the chart or the error), used by the server and the browser alike. It now imports escapeXml straight from og/xml.ts so the browser bundle stays small.
  • src/web/pages/boards-stream.ts (new): handles GET /boards/:slug/stream.
    • It re-reads the panels when any event lands, or when the machine is sampled (a new onRecorded hook in boards/ring.ts).
    • A burst of events becomes one read, at most once a second. If nothing changed, nothing is sent.
    • Each frame's id is the board's version. The page passes the version it was drawn with as ?v=, and a resuming browser sends it back as Last-Event-ID. A panel is sent whole only when the client lacks it.
    • When the board itself is saved, the stream sends a board frame and ends.
    • Only an admin who is a person can open it; anyone else gets not-found.
  • src/web/board-live-client.ts (new) and src/web/asset.ts: a second content-addressed bundle, board-live-<hash>.js, built the same way as the highlighter. It exposes applyDelta and panelBody to the page as window.forgeBoard.
  • src/web/pages/boards-view.ts and boardLiveJs in src/web/client.ts:
    • The page embeds its points (in a #board-points JSON block, with < escaped), the version, and the stream address.
    • The script applies each frame and redraws only that panel's body. It never calls fetch and never reloads the page.
    • The head of the board shows "live · updated Ns ago" (in tabular numerals) and a Pause / Resume button. ?pause opens no stream. A board with Live off says "not live".

Tests

  • New: test/boards-live.test.ts.
    • While idle, nothing is sent, even for an event that changes no panel.
    • A new run reaches an open board within 2 s, in under 2 KB, as points rather than HTML.
    • A stale version gets back only the panels it lacks; Last-Event-ID takes precedence over ?v=.
    • Saving the board sends the board frame; a stranger or non-admin gets 404.
    • The built bundle draws all six chart types byte-for-byte the same as the server.
  • Changed: test/boards-store.test.ts. The test that checked the old /live HTML address and its etag now checks that the page names its stream and that /live returns 404. That test checked the behaviour this issue removes; it was not a bug in the test.

Not done

  • The /boards index: its flow panel is a large HTML region and needs its own data stream, so it is #3715.
  • Home's pinned panels stay as they are.
  • When a time bucket appears in the middle of a panel's order, that panel is sent whole rather than as a positional insert. For time-bucketed panels new points land at the end, so they still go as small deltas.

To try it: turn Live on in a board's Board settings, keep the page open, and start a run. The panel redraws and the status line resets to "updated 0s ago". In the network tab you should see one event stream and no other repeating requests.

🤖 Generated with Claude Code

Closes #3692

2 earlier comments
commented

A live board (/boards/:slug) now updates by streaming each panel's new points. It no longer re-fetches HTML: /boards/:slug/live is gone, and /boards/:slug/stream replaces it. The tests named below pass, and bun x tsc --noEmit is clean. I have not opened the page in a real browser, so the browser-side script has only been checked by the tests listed below. The /boards index is still not live: it is split off to #3715.

What moved where

  • src/boards/delta.ts (new, pure): works out what changed in a panel between two readings: the cells that are new or changed, and the keys that left. When applying that would put the cells in a different order, it sends the whole panel instead (a "reset"). It also makes a short per-panel digest; the digests joined together are the board's "version". The server uses this file to diff and the browser uses the same file to apply.
  • src/boards/chart.ts: a new panelBody is the one function that draws a panel's body (the chart or the error), used by the server and the browser alike. It now imports escapeXml straight from og/xml.ts so the browser bundle stays small.
  • src/web/pages/boards-stream.ts (new): handles GET /boards/:slug/stream.
    • It re-reads the panels when any event lands, or when the machine is sampled (a new onRecorded hook in boards/ring.ts).
    • A burst of events becomes one read, at most once a second. If nothing changed, nothing is sent.
    • Each frame's id is the board's version. The page passes the version it was drawn with as ?v=, and a resuming browser sends it back as Last-Event-ID. A panel is sent whole only when the client lacks it.
    • When the board itself is saved, the stream sends a board frame and ends.
    • Only an admin who is a person can open it; anyone else gets not-found.
  • src/web/board-live-client.ts (new) and src/web/asset.ts: a second content-addressed bundle, board-live-<hash>.js, built the same way as the highlighter. It exposes applyDelta and panelBody to the page as window.forgeBoard.
  • src/web/pages/boards-view.ts and boardLiveJs in src/web/client.ts:
    • The page embeds its points (in a #board-points JSON block, with < escaped), the version, and the stream address.
    • The script applies each frame and redraws only that panel's body. It never calls fetch and never reloads the page.
    • The head of the board shows "live · updated Ns ago" (in tabular numerals) and a Pause / Resume button. ?pause opens no stream. A board with Live off says "not live".

Tests

  • New: test/boards-live.test.ts.
    • While idle, nothing is sent, even for an event that changes no panel.
    • A new run reaches an open board within 2 s, in under 2 KB, as points rather than HTML.
    • A stale version gets back only the panels it lacks; Last-Event-ID takes precedence over ?v=.
    • Saving the board sends the board frame; a stranger or non-admin gets 404.
    • The built bundle draws all six chart types byte-for-byte the same as the server.
  • Changed: test/boards-store.test.ts. The test that checked the old /live HTML address and its etag now checks that the page names its stream and that /live returns 404. That test checked the behaviour this issue removes; it was not a bug in the test.

Not done

  • The /boards index: its flow panel is a large HTML region and needs its own data stream, so it is #3715.
  • Home's pinned panels stay as they are.
  • When a time bucket appears in the middle of a panel's order, that panel is sent whole rather than as a positional insert. For time-bucketed panels new points land at the end, so they still go as small deltas.

To try it: turn Live on in a board's Board settings, keep the page open, and start a run. The panel redraws and the status line resets to "updated 0s ago". In the network tab you should see one event stream and no other repeating requests.

🤖 Generated with Claude Code

commented

A live board (/boards/:slug) now updates by streaming each panel's new points. It no longer re-fetches HTML: /boards/:slug/live is gone, and /boards/:slug/stream replaces it. With main merged in, bun x tsc --noEmit is clean and test/boards-live.test.ts, test/boards-store.test.ts and the five cross files pass (184 tests). I have not opened the page in a real browser, so the browser-side script has only been checked by the tests below. The /boards index is still not live: it is split off to #3715.

What moved where

  • src/boards/delta.ts (new, pure): works out what changed in a panel between two readings: the cells that are new or changed, and the keys that left. When applying that would put the cells in a different order, it sends the whole panel instead (a "reset"). It also makes a short per-panel digest; the digests joined together are the board's "version". The server uses this file to diff and the browser uses the same file to apply.
  • src/boards/chart.ts: a new panelBody is the one function that draws a panel's body (the chart or the error), used by the server and the browser alike. It now imports escapeXml straight from og/xml.ts so the browser bundle stays small.
  • src/web/pages/boards-stream.ts (new): handles GET /boards/:slug/stream.
    • It re-reads the panels when any event lands, or when the machine is sampled (a new onRecorded hook in boards/ring.ts).
    • A burst of events becomes one read, at most once a second. If nothing changed, nothing is sent.
    • Each frame's id is the board's version. The page passes the version it was drawn with as ?v=, and a resuming browser sends it back as Last-Event-ID. A panel is sent whole only when the client lacks it.
    • When the board itself is saved, the stream sends a board frame and ends.
    • Only an admin who is a person can open it; anyone else gets not-found.
  • src/web/board-live-client.ts (new) and src/web/asset.ts: a second content-addressed bundle, board-live-<hash>.js, built the same way as the highlighter. It exposes applyDelta and panelBody to the page as window.forgeBoard.
  • src/web/pages/boards-view.ts and boardLiveJs in src/web/client.ts:
    • The page embeds its points (in a #board-points JSON block, with < escaped), the version, and the stream address.
    • The script applies each frame and redraws only that panel's body. It never calls fetch and never reloads the page.
    • The head of the board shows "live · updated Ns ago" (in tabular numerals) and a Pause / Resume button. ?pause opens no stream. A board with Live off says "not live".

Tests

  • New: test/boards-live.test.ts.
    • While idle, nothing is sent, even for an event that changes no panel.
    • A new run reaches an open board within 2 s, in under 2 KB, as points rather than HTML.
    • A stale version gets back only the panels it lacks; Last-Event-ID takes precedence over ?v=.
    • Saving the board sends the board frame; a stranger or non-admin gets 404.
    • The built bundle draws all six chart types byte-for-byte the same as the server.
    • The previous check failed because this file called servers.stop(true); serve() on main now takes no argument, so it calls servers.stop().
  • Changed: test/boards-store.test.ts. The test that checked the old /live HTML address and its etag now checks that the page names its stream and that /live returns 404. That test checked the behaviour this issue removes; it was not a bug in the test.

Not done

  • The /boards index: its flow panel is a large HTML region and needs its own data stream, so it is #3715.
  • Home's pinned panels stay as they are.
  • When a time bucket appears in the middle of a panel's order, that panel is sent whole rather than as a positional insert. For time-bucketed panels new points land at the end, so they still go as small deltas.

To try it: turn Live on in a board's Board settings, keep the page open, and start a run. The panel redraws and the status line resets to "updated 0s ago". In the network tab you should see one event stream and no other repeating requests.

🤖 Generated with Claude Code

commented

Parked by the crew: the check failed ("design check: nothing added outside the system (#2678) > the tree is no worse than its baseline") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs