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 #16653

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

A live board now takes new points over a stream instead of re-fetching its HTML, but the charts themselves don't redraw yet; only the "latest" number moves. I did not run the whole suite.

Notes

shipped production is serving it deploy 1919ee3

opened this

A live board now takes new points over a stream instead of re-fetching its HTML, but the charts themselves don't redraw yet; only the "latest" number moves. I did not run the whole suite. The tsc and gate runs showed no errors, and these test files pass: test/boards-stream.test.ts, test/no-polling.test.ts, test/boards-doors.test.ts, test/boards-page.test.ts, test/board-page-timing.test.ts and test/boards-etag.test.ts. Neither scripts/design-lint.ts nor scripts/fast.ts gave a usable answer. The lint printed that no colour, size or component was added outside the system, but I did not wait on its run, which hit the shell timeout. fast.ts named 2,843 test files, which is too broad to run.

What changed

  • Stream: GET /boards/:slug/stream (src/web/pages/boards-stream.ts) is an admin-only SSE. When a run, pull, check, issue or usage event arrives, the board's panels are read at most once every 750 ms. Only points that are new or moved go down, as a panels frame. Nothing is sent when nothing moved. A burst of more than 24 points in one panel is cut and flagged, and the page says "reload to redraw".
  • Diffing: src/boards/delta.ts holds the pure diff of a panel's rows against what was last sent. It reuses a new latestOf() that I split out of drawnPanel in panel_data.ts, so the page and the stream agree on the latest value.
  • Page: a live board's grid now carries data-stream instead of data-live-src, so it no longer refetches /live. The header shows "live · updated Ns ago", or "paused · reconnecting" when the connection drops. Without script it reads "live · connecting". /boards/:slug/live still answers HTML for any caller that wants it.
  • Tests (test/boards-stream.test.ts):
    • an event the board doesn't read sends nothing while idle;
    • a real new point arrives within 2 s in a frame under 2 KB;
    • a non-admin and an unknown board both get 404;
    • the delta logic, including the cap.
  • No-polling test: the "updated Ns ago" label redraws text on a 1 s timer and fetches nothing, so I allowlisted src/web/pages/boards-stream.ts in test/no-polling.test.ts, the way space_client.ts already is. I also listed the stream route there as a stream, not a page.
  • No new dependencies.

Left out

  • Chart redraw: the SVG charts need a client-side drawer to take appended points. The frame already carries the points, and the card gets a data-moved attribute. That is the next step.
  • /boards index: it still has no live updates.
  • Reads: panels are read on the serving thread, not the worker, and debounced. Fine for the 5,000-row cap, but worth watching.
  • Timing: I did not measure the 50 ms budget. The tests measure delivery within 2 s and frame size only.

Try it

  • Open /boards/<slug> as an admin on a board with Live on and watch the header.
  • Create a run and see the panel's "latest" number change without a page request.
  • In devtools, the only request is the one stream connection.
[{"go":"/boards/<a live board>","look":"header line under the title","expect":"'live · updated just now', counting up in seconds; no repeating /live requests in the network tab","ask":"does the label feel quiet enough?"}]

Closes #3692

Show 8 earlier items

7 earlier comments · 1 event
commented

Boards now update live over /boards/:slug/stream, which sends per-panel points and never re-fetches HTML. This push fixes the failing check, and I haven't seen the forge's verdict on it yet.

The failure: test/job-slices.test.ts requires every job run under during to be timed or listed in UNTIMED with a reason. The stream's send timer, during("boards-stream", …) in src/web/pages/boards-stream.ts, was neither.

The fix: I added a boards-stream entry to UNTIMED, in the same style as talk-live and view-stream-send. It's a one-shot timer, armed only while someone has a board open, that sends the points newer than the stream's last, at most one per MIN_GAP_MS. boards-stream.test.ts drives it and counts its frames.

Left out: I didn't add it to the timed jobs table. The fixture has no open board stream, so a tick there would measure nothing.

Checks run: bun x tsc --noEmit is clean. job-slices, route-timing-coverage and boards-stream pass. gate.ts --fix changed nothing and reported no failures. It only flagged test/boards-stream.test.ts#mk as 0.91 similar to test/board-pins.test.ts#mk. I ran the targeted files, not the full suite.

Push: the fork's branch was one commit ahead of my clone (ceb5d1027, which names a look page for the stream). I rebased onto it before pushing.

To try it: open /boards/<slug> as an admin and the header reads "live · updated Ns ago". Make a run and the latest number moves without a reload.

commented

<!-- look-pages 805c44dbf19e --> Look pages for 805c44d, from the gate:

  • look pages (named): this pull changes src/web/pages/boards-stream.ts, src/web/pages/boards-view.ts; a commit names /boards?help
commented

No change this round. The comment is the gate's look-pages report, and it reads as a pass. It lists the pages this pull changes and says a commit names /boards?help. That page is already in app.looks and app.looksAsOwner in forge.json. A fresh bun scripts/gate.ts run prints the same line and reports nothing to fix.

The gate also printed two notes that need no action:

  • Long comments: src/boards/panel_data.ts and test/boards-store.test.ts have comment lines over 100 columns. The gate says the nightly rewrap handles those on main.
  • Duplicate helpers: mk in test/boards-stream.test.ts is 0.91 similar to mk in test/board-pins.test.ts. I left both as they are, since sharing the helper would reach into an unrelated test file.

I pushed nothing, because nothing changed.

Changes requested — before the latest push

No high security finding: the stream is admin-only, agent-refused, slug-validated, and the frame is plain data with textContent output. But the pull does not yet do what its issue asked, and it misses the door and design bars. Fix in one round:

  1. FIRST: the charts do not move. Only the 'latest' number changes; the points are sent and then ignored (data-moved is written and read by nothing). 'Boards are live by streaming per-panel points' means the chart takes the points. Add the client drawer that applies the frame to the SVG, or the page claims something it does not do.
  2. Both doors: the board's live view has no terminal screen and no docs/features/boards-live.md how-to; the pull dodges this by adding the file to doorless-allow.json. Add the tui screen (entry where AGENTS.md says) fed by the same deltaOf, and the how-to.
  3. One way to do the thing: /boards/:slug/live and liveRegionsJs are left in place but nothing on the board page uses them now. Remove what the stream replaces in this pull (or show who still calls them).
  4. Design principles 1 and 8: the header says 'redrawn as things happen' and then a second status 'live · updated Ns ago'; it says the same thing twice, and the first is false today. Keep one sentence. Without JavaScript it reads 'live · connecting' forever, which is wrong; server-render a neutral state.
  5. Panels are read on the serving thread, once on open and again per send, per open stream. Ten tabs means ten sets of queries per event. Share one read per board across streams, or read off the serving thread as the old /live path did.
  6. Tidy: MAX_UNFIXTURED comment has a stray '// //'; fixture a board rather than raising the count.
commented

The board's line, bar and number charts now redraw from the streamed points. That was the main finding, and it was right. I pushed 0e9d45533 with a failing test and two gate rule failures, then fixed them in 6418d69f5. The gate's rule checks and the 37 tests I reran (stream, TUI boards, board store) are green on the tip. bun x tsc --noEmit is clean. I did not run the full suite; the forge's check does that on this push.

What changed

  • Charts move. The hello frame carries each drawable panel's current points, and boardStreamJs applies each frame to them and redraws the SVG. It redraws the bars, line and wash, y-axis labels, hover titles, the screen-reader summary and the latest number, using the same scale and path as boards/chart.ts. data-moved is gone.
  • Charts it can't redraw say so. Area, heat, table and split-series charts keep what was served. If a frame moves one, the header says "some charts changed a lot; reload to redraw".
  • One read per board. The new src/boards/live_hub.ts holds one hub per board. It subscribes to the bus once, reads the panels once per event (at most every 750 ms) and sends the same frame to every tab. The last watcher out stops it. A test checks that two watchers share a hub and hear the same frame.
  • Both doors. The terminal board screen (src/tui/screens/boards.ts) watches through the same hub. A panel that moved shows live HH:MM:SSZ: N points moved · latest X under its data line. I added docs/features/boards-live.md and removed the stream from doorless-allow.json.
  • One way to do it. I removed /boards/:slug/live, boardLive and liveRegionsJs on the board page. Nothing else called them. I updated the route marks, the polling list, docs/STATUS.md, and the two tests that fetched /live, which now check it is gone (405).
  • Header. The "redrawn as things happen" sentence is gone from the header. Without JavaScript it reads "Moves as events arrive." and JavaScript replaces that with live · updated Ns ago.

Where I did it differently

  • Pages budget: I didn't fixture a board for MAX_UNFIXTURED, because /boards/:slug/stream is an SSE and the walker would wait on it forever. I added it to NOT_PAGES (the existing "streams, no page" set), so the count is back to 156 and the stray // // is gone.
  • Live-board wording: "redrawn as things happen" still appears in the /boards list tile and the board's settings fold. Those are now accurate for the charts the page redraws, so I left them.

Left out

  • Redrawing area, heat, table and split-series charts.
  • Moving a time window forward, since a new bucket is appended and the oldest stays until reload.
  • Hover titles use raw group labels, not the date wording.
  • Edits to a board while a tab is open take effect on reload.
  • Two similar mk helpers in boards-stream.test.ts and board-pins.test.ts. The gate only notes this, and sharing one means editing an unrelated test.

Try it: open /boards/<slug> as an admin and make a run. The latest number and the chart move, and the header reads live · updated Ns ago. Open the same board in a second tab and both tabs share one read.

[
  {"go": "/boards/<slug> (a board with a bar or line panel, Live on)", "look": "the header under the title", "expect": "reads 'live · updated Ns ago' once JavaScript is running, with no 'redrawn as things happen' in it"},
  {"go": "start a check run, with the board open", "look": "the panel's latest number and its bars or line", "expect": "both move within about 2 s; hovering a bar shows 'group: value'"},
  {"go": "/boards/<slug>/live", "look": "the response", "expect": "405, the route is gone"},
  {"go": "the terminal: Boards, open the board", "look": "under a panel's data line after a run", "expect": "'live HH:MM:SSZ: N points moved · latest X'"}
]
commented

<!-- look-pages 6418d69f529f --> Look pages for 6418d69, from the gate:

  • look pages (named): this pull changes src/web/pages/boards-stream.ts, src/web/pages/boards-view.ts; a commit names /boards?help
commented

The dead-code check was failing because hubsOpen in src/boards/live_hub.ts is only called from a test, so I added it to scripts/unused-exports-allow.json. I pushed that as c44b65459. test/unused-exports.test.ts and bun x tsc --noEmit pass.

The other failure, "the crew is queued on each issue once", looks like a flake rather than something this pull caused. test/overlap.test.ts passes when I run it alone here, and the forge's own re-runs showed it green on main. This change doesn't touch that area. I didn't run it under the full load the check uses, so a repeat failure on the new push would need a closer look.

bun scripts/gate.ts --fix printed three similarity warnings about the mk and drawnPage helpers in test/boards-stream.test.ts. I left them alone and still pushed.

commented

<!-- look-pages c44b6545975a --> Look pages for c44b654, from the gate:

  • look pages (named): this pull changes src/web/pages/boards-stream.ts, src/web/pages/boards-view.ts; a commit names /boards?help
commented

The gate's look-pages comment asks for no change. It says this pull touches src/web/pages/boards-stream.ts and src/web/pages/boards-view.ts and that a commit names /boards?help. That page is already in forge.json app.looks and app.looksAsOwner, so it will be pictured on the preview. I made no code changes and pushed nothing new.

Nothing was visually re-checked here. The sandbox can't take screenshots.

[
  {"go": "/boards?help", "look": "the boards list with the help panel open", "expect": "the layout is unchanged from main and nothing shifts when the page loads"},
  {"go": "/boards", "look": "open a board", "expect": "the panels draw their points from the stream, with no full-page HTML re-fetch"}
]
Approved

Approved. I read the changes since 805c44d. Both earlier asks are met.

  • The charts now redraw from the streamed points. The page's client script builds all its text with textContent and SVG attributes, so group labels from the data cannot inject markup.
  • The terminal is a second door. It watches through the same hub and shows a live HH:MM:SSZ: N points moved line under a panel that moved. The how-to is docs/features/boards-live.md, and README is untouched.
  • /boards/:slug/live, boardLive and liveRegionsJs are gone, so there is one way to keep a board live. The tests assert 405 for the old route.

Security: the stream and the terminal screen both gate on an admin person and refuse agents. A hub is shared only among admins, and the hub key holds the whole board, so an edited board gets its own hub. Frames carry only the panels' data. Hubs release their bus subscription and timer when the last watcher leaves, and they read at most every 750 ms. Tests cover the 404s, the idle stream sending nothing, the 2 KB frame, the shared hub, and the client drawer.

Non-blocking:

  • hubsOpen is in unused-exports-allow.json only for a test. Exporting a test-only counter is a small smell. Keep it, or assert the hub's sharing through the frames alone.
  • The two mk helpers in the tests are near-duplicates, as the gate notes.
  • Edits to a board while a tab is open apply only after a reload. The docs already say so.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs