agent pane: a peer's running subagent counts its time on the session's clock

Merged
TE
16d ago
+126-64

Summary

In a peer's chat, a running subagent's time was wrong. Its start and end are the session's event times, but four places counted it against this computer's Date.now(): the subagent group line, its rows, the agents pill and the summary card's list.

  • If the peer's clock ran ahead, the time read 0s the whole run.
  • If it ran behind, the time came out too long by the clock difference.

The turn's own "Working for" clock already corrects for this with the snapshot's clockOffsetMs (conversation/turns.ts), and so does auto-opening a new subagent's pane (subagentPanes.ts).

Now useNow (subagents/SubagentGroup.tsx), the clock every subagent time ticks on, returns the session's time. It reads a new SubagentClockContext, which App.tsx sets from snapshot.clockOffsetMs around the transcript, the agents pill and the summary card. A local session has no offset, so its times don't change.

Testing

  • New webviews/test/subagent-peer-clock.test.ts renders the group header for a running subagent started 5 seconds ago on the session's clock. The session is a minute ahead in one case and a minute behind in the other.
  • Red/green with bun test test/subagent-peer-clock.test.ts:
    • red at the test commit 3ffadc3: 0 pass / 2 fail ("0s" and "1m 5s"; the test falls back to a dummy context, so the base fails on the times, not on the import);
    • green at 0b303aa: 2 pass.
  • Also passed alone on the head:
    • subagent-group-label and subagent-progress;
    • agent-pane-agents-pill and agent-pane-subagents-tab (Chromium, CMUX_BROWSER_TESTS=1).
  • bun run typecheck reports no errors in the changed files. Its other errors are in files this PR doesn't touch. vp fmt and vp lint pass.

Observed / Not run

  • Not checked live against a peer daemon.
  • No new strings.

Changelog

Fixed: A running subagent in a chat on another computer shows its real elapsed time instead of 0s or a skewed one

๐Ÿค– Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes a running subagent's elapsed time in a peer's chat so it counts on the session's clock instead of this computer's.

A subagent's start and end are the session's event times, but four places โ€” the subagent group line, its rows, the agents pill, and the summary card's list โ€” counted them against Date.now(). If the peer's clock ran ahead, the time read 0s the whole run; if it ran behind, it read too long by the clock difference. The turn's own "Working for" clock already corrected for this.

useNow now returns the session's time through a new SubagentClockContext, which App.tsx sets from snapshot.clockOffsetMs around the transcript, the agents pill, and the summary card. A local session has no offset, so its times don't change. New tests cover a session a minute ahead and a minute behind.