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

Parked opened this
Closed without merging

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.

Notes

stopped parked by the crew deploy c14376c

opened this

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() in src/web/client.ts keeps its new EventSource('/events') line. It now also listens for the run.log SSE frames and re-dispatches them on document as forge:runlog.
  • Run page script: studioRunJs listens for forge:runlog frames 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 when forge:event carries run.finished for its run. That event's payload already holds the state, summary, cost and turns. The run page now ships liveRegionsJs so that connection exists.
  • First paint: the log is still rendered from the file. src/web/studio/log.ts and src/web/studio/run.ts stamp the log box with data-run, data-log and data-seen, the count of lines drawn. The count is left off when the file was cut to its tail.
  • Catch-up: when /events opens 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.ts checks that a running run's page opens only /events, has no follow=1 or data-stream, and wires run.log, forge:runlog, data-run and data-seen.

Left out

  • The issue says the frames arrive as the forge event. They are a separate run.log SSE 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.

Closes #2843

2 earlier comments
commented

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() in src/web/client.ts keeps its new EventSource('/events') line. It now also listens for the run.log SSE frames and re-dispatches them on document as forge:runlog.
  • Run page script: studioRunJs listens for forge:runlog frames 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 when forge:event carries run.finished for its run. That event's payload already holds the state, summary, cost and turns. The run page now ships liveRegionsJs so that connection exists.
  • First paint: the log is still rendered from the file. src/web/studio/log.ts and src/web/studio/run.ts stamp the log box with data-run, data-log and data-seen, the count of lines drawn. The count is left off when the file was cut to its tail.
  • Catch-up: when /events opens 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.ts checks that a running run's page opens only /events, has no follow=1 or data-stream, and wires run.log, forge:runlog, data-run and data-seen.

Left out

  • The issue says the frames arrive as the forge event. They are a separate run.log SSE 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.
commented

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.log frames for its run, received over /events. It no longer opens the per-run ?follow=1 stream.
  • 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 /events opens 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 /events reports run.finished for it.
  • Test: A running run's page opens only /events, and test/map.test.ts passes unchanged.
  • Left out:
    • The issue says the frames arrive as the forge event. They are a separate run.log event, 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.
commented

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

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs