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 #2851
A running run's page now appends its log lines from the shared /events connection and no longer opens …/runs/:id/log?follow=1. bun test passes on test/studio-runs.test.ts, test/map.test.ts (unchanged) and test/live-pages.test.ts. I couldn't run tsc here: bun x and bun install fail with a read-only tempdir.
stopped parked by the crew deploy c14376c
2 earlier comments
A running run's page now appends its log lines from the shared /events connection and no longer opens …/runs/:id/log?follow=1. bun test passes on test/studio-runs.test.ts, test/map.test.ts (unchanged) and test/live-pages.test.ts. I couldn't run tsc here: bun x and bun install fail with a read-only tempdir. The forge's check will be the first type check of this change.
What changed
- Shared stream:
connect()insrc/web/client.tskeeps itsnew EventSource('/events')line. It now also listens for therun.logSSE frames and re-dispatches them ondocumentasforge:runlog. - Run page script:
studioRunJslistens forforge:runlogframes for its own run and appends the lines. The rest of the page (cap, follow/jump, check steps) is unchanged. It repaints the word, cost and steer box whenforge:eventcarriesrun.finishedfor its run. That event's payload already holds the state, summary, cost and turns. The run page now shipsliveRegionsJsso that connection exists. - First paint: the log is still rendered from the file.
src/web/studio/log.tsandsrc/web/studio/run.tsstamp the log box withdata-run,data-loganddata-seen, the count of lines drawn. The count is left off when the file was cut to its tail. - Catch-up: when
/eventsopens or reopens, the page reads the plain log and appends only lines past that count. Frames wait until that read finishes. Nothing is drawn twice, and lines written between the render and the connection are not lost. - Test:
test/studio-runs.test.tschecks that a running run's page opens only/events, has nofollow=1ordata-stream, and wiresrun.log,forge:runlog,data-runanddata-seen.
Left out
- The issue says the frames arrive as the
forgeevent. They are a separaterun.logSSE event (no id, never replayed), so I listened for that name instead. - A frame the server cut for size (64 lines or 16 KB) leaves its omitted lines out until the next reconnect catch-up. Frames are lossy by design.
- A run whose log was already tail-truncated at render has no
data-seen. It gets live frames but no catch-up read. - I did not exercise the script in a browser. The tests only check the HTML and script text.
The run page now reads its log from the one /events connection and opens no stream of its own. The branch merges cleanly with main again.
The check failed because main had added its own run.log dispatch in connect() while I added another. I kept main's, which dispatches the forge:run-log event, and pointed the run page's script and my test at that name. connect() still has new EventSource('/events').
On test/studio-runs.test.ts, test/map.test.ts, test/live-pages.test.ts and test/events-run-log.test.ts, all 65 tests pass. I still couldn't run tsc here, so the forge's check is the first type check of this change. I didn't open the page in a browser either.
- What changed: The run page appends lines from the
run.logframes for its run, received over/events. It no longer opens the per-run?follow=1stream. - First paint: The log is still server-rendered from the file. The server stamps the page with how many lines it drew (
data-seen), and a catch-up read when/eventsopens adds only lines past that count. Live frames wait for that read, so nothing is shown twice. - Finish: The run's word, cost and steer box update when
/eventsreportsrun.finishedfor it. - Test: A running run's page opens only
/events, andtest/map.test.tspasses unchanged. - Left out:
- The issue says the frames arrive as the
forgeevent. They are a separaterun.logevent, so I listened for that. - 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 at render gets live lines but no catch-up read.
- The issue says the frames arrive as the
Parked by the crew: the check failed ("apps, runs and the crew on the web > the runs list, one run's log page, and the short door to it") and the decider saw no point in another try
A running run's page now appends its log lines from the shared
/eventsconnection and no longer opens…/runs/:id/log?follow=1.bun testpasses ontest/studio-runs.test.ts,test/map.test.ts(unchanged) andtest/live-pages.test.ts. I couldn't runtschere:bun xandbun installfail with a read-only tempdir. The forge's check will be the first type check of this change.What changed
connect()insrc/web/client.tskeeps itsnew EventSource('/events')line. It now also listens for therun.logSSE frames and re-dispatches them ondocumentasforge:runlog.studioRunJslistens forforge:runlogframes for its own run and appends the lines. The rest of the page (cap, follow/jump, check steps) is unchanged. It repaints the word, cost and steer box whenforge:eventcarriesrun.finishedfor its run. That event's payload already holds the state, summary, cost and turns. The run page now shipsliveRegionsJsso that connection exists.src/web/studio/log.tsandsrc/web/studio/run.tsstamp the log box withdata-run,data-loganddata-seen, the count of lines drawn. The count is left off when the file was cut to its tail./eventsopens or reopens, the page reads the plain log and appends only lines past that count. Frames wait until that read finishes. Nothing is drawn twice, and lines written between the render and the connection are not lost.test/studio-runs.test.tschecks that a running run's page opens only/events, has nofollow=1ordata-stream, and wiresrun.log,forge:runlog,data-runanddata-seen.Left out
forgeevent. They are a separaterun.logSSE event (no id, never replayed), so I listened for that name instead.data-seen. It gets live frames but no catch-up read.Closes #2843