feat(panel,host): a shown transcript tab hears its pages pushed, with no read loop

Merged
CH
5d ago
+489-682

The window half of making the agent transcript live on main. It's stacked on #4175 and replaces #3931, which was built on the old stack.

What changed

  • packages/panel/src/tasks/use-agent-transcript.ts: the hook takes a transcript key and a TranscriptFollower.
    • While the tab is shown it holds the transcript's stream open on the act port (codingAgents.transcript, from #4175), and closes it when hidden or unmounted.
    • Each pushed page joins the held messages by id. The read loop, the cursor and the read-through bookkeeping are gone.
    • A stream that won't open, or a failure page, sets failed. Try again opens the stream again, and the messages held stay meanwhile.
  • Tabs: the agent tab, the agent-worker tab and the task's planning-worker tab follow by key. The planning worker uses { kind: "taskWorker", taskId, callId }. CodingAgentsControl.transcripts is the window's follower.
  • Copy transcript: codingAgents.messages and tasks.messages with a callId stay, because Copy transcript reads them. The host's codingAgents.messages now answers at once through the service's wait=none read.
  • Host: the held read is retired: transcriptPast, readUntilSaid, TranscriptReads and the 20 s HOLD. So is followsAgent, which only the loop used.

Tests

  • New use-agent-transcript.test.ts:
    • A shown tab follows its transcript, joins its pages by id, and lets the stream go once hidden.
    • A failure offers Try again, which follows again while the held messages stay.
  • The tab tests that stubbed readTranscript now push pages through pushedTranscripts (#testing/tasks-control). The agent page test answers the stream with a generator.
  • Deleted, since they test the retired held read: four compose-coding-agents.test.ts tests, "a running agent's transcript is held open…", "a worker's transcript is followed under its own seal…", "a transcript the account does not reach is not found…" and "a read the service says only the clock may end…". #4175's follow tests cover the live behaviour.

Checks run locally

pnpm check:affected gets OOM-killed in the sandbox, so I ran its pieces one at a time:

  • repository-checks.sh, biome check ., oxlint, knip
  • tsc for host and panel
  • vitest for host and for panel's tasks and desktop (2115 tests)

What to check by hand (desktop and web)

  1. Running agent: show its tab. Lines land as it writes them, with no lag of about a second.
  2. Ended agent: show it. The whole transcript appears, and the spinner doesn't stay.
  3. Hide and show: switch tabs and come back. The transcript is complete, with no duplicated lines.
  4. Agent's worker: open a worker's tab. It fills in and keeps up.
  5. Planning worker: during a call, open one from the plan's work. It fills in.
  6. Web: the same agent tab in the web app updates live.
  7. Copy transcript: it still gives the full text.

Made with Luke