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

A run page shows its log live from /events and opens no EventSource of its own #2866

opened this

Merged 44d 6h ago, live in production

A running run's page now reads its log from the one /events connection and opens no stream of its own. The previous check failed on a test that still expected the old per-run stream. I had left that test unchanged, which was my mistake.

Notes

opened this

A running run's page now reads its log from the one /events connection and opens no stream of its own. The previous check failed on a test that still expected the old per-run stream. I had left that test unchanged, which was my mistake. test/web-apps.test.ts, test/studio-runs.test.ts and test/map.test.ts pass (65 tests); I haven't run the full suite. I couldn't run tsc here (the sandbox's tempdir is read-only), so the forge's check is the first type check of this change.

  • Live log: the page appends lines from the run.log frames for its run. These arrive as forge:run-log, which connect() already dispatches on main, and connect() still has new EventSource('/events'). The per-run ?follow=1 stream is no longer opened.
  • First paint: the log is still server-rendered from the file. The page also records how many lines it drew (data-seen), and a catch-up read when /events opens or reopens appends only lines past that count. Live frames wait for that read, so nothing is shown twice.
  • Finish: the word, cost and steer box update when /events reports run.finished for the run.
  • Test fix: the failing test, "the runs list, one run's log page, and the short door to it", asserted data-stream= on a running run's page. The test was wrong for this design. It now expects data-run="<id>" while the run is going and no data-stream= at all.
  • New test: a running run's page opens only /events.

Left out:

  • A frame the server cut for size (64 lines or 16 KB) loses its omitted lines until the next reconnect catch-up.
  • A run whose log was already cut to its tail when the page rendered gets live lines but no catch-up read.
  • I haven't exercised the script in a browser.

Closes #2843

commented

A running run's page now reads its log from the one /events connection and opens no stream of its own. The previous check failed on a test that still expected the old per-run stream. I had left that test unchanged, which was my mistake. test/web-apps.test.ts, test/studio-runs.test.ts and test/map.test.ts pass (65 tests); I haven't run the full suite. I couldn't run tsc here (the sandbox's tempdir is read-only), so the forge's check is the first type check of this change.

  • Live log: the page appends lines from the run.log frames for its run. These arrive as forge:run-log, which connect() already dispatches on main, and connect() still has new EventSource('/events'). The per-run ?follow=1 stream is no longer opened.
  • First paint: the log is still server-rendered from the file. The page also records how many lines it drew (data-seen), and a catch-up read when /events opens or reopens appends only lines past that count. Live frames wait for that read, so nothing is shown twice.
  • Finish: the word, cost and steer box update when /events reports run.finished for the run.
  • Test fix: the failing test, "the runs list, one run's log page, and the short door to it", asserted data-stream= on a running run's page. The test was wrong for this design. It now expects data-run="<id>" while the run is going and no data-stream= at all.
  • New test: a running run's page opens only /events.

Left out:

  • A frame the server cut for size (64 lines or 16 KB) loses its omitted lines until the next reconnect catch-up.
  • A run whose log was already cut to its tail when the page rendered gets live lines but no catch-up read.
  • I haven't exercised the script in a browser.
commented

A running run's page now opens the one /events connection, so its log moves live and the finish repaints the page. @juniper was right that it never connected before. test/studio-runs.test.ts, test/web-apps.test.ts, test/map.test.ts and test/live-pages.test.ts pass (75 tests). I still couldn't run tsc, and I haven't exercised the script in a browser.

What changed

  • Connection: liveRegionsJs only calls connect() when the page has a [data-live] element, and the run page had none. I added <span data-live="run.finished" hidden> to src/web/studio/run.ts, rendered only while the run is unfinished and its log is readable. It has no id on purpose. With no id, the shared script never refetches the page for it, and its only effect is to open /events. The forge:run-log, forge:live and forge:event handlers on the run page now fire.
  • Reconnecting: a hidden #run-conn line shows "Reconnecting; lines written meanwhile appear when it is back." while forge:live says reconnecting. It hides again on open, which also triggers the catch-up read.
  • Test: the run-page test now requires the served HTML to contain the data-live element and #run-conn, in addition to the script checks. It is the check that fails if the element is removed.
  • Gaps in the README: the two silent gaps are named under "What works today". A frame the server cuts for size loses its omitted lines until the next reconnect's catch-up read. A run whose log was already cut to its tail at render gets no catch-up read.

I haven't opened an issue to close those two gaps; they are documented, not fixed.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs