agent pane: a peer's running subagent counts its time on the session's clock
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.tsrenders 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: - Also passed alone on the head:
subagent-group-labelandsubagent-progress;agent-pane-agents-pillandagent-pane-subagents-tab(Chromium,CMUX_BROWSER_TESTS=1).
bun run typecheckreports no errors in the changed files. Its other errors are in files this PR doesn't touch.vp fmtandvp lintpass.
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
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.