fix(web): freeze idle agent elapsed timers - #6238
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| const startedAt = agent.startedAt; | ||
| // Idle is resumable, so it has no completedAt. Its latest update is the | ||
| // transition that ended the current activation and must freeze the timer. | ||
| const endedAt = live ? null : (agent.completedAt ?? agent.updatedAt); |
There was a problem hiding this comment.
🟡 Medium components/AgentsPanel.tsx:92
The endedAt fallback to updatedAt applies to every non-running/waiting status, including pending. When a resumable idle agent is requeued to pending and applyStatus preserves its previous startedAt, the elapsed timer freezes at the old updatedAt timestamp while the row shows "Working." Consider restricting the updatedAt fallback to idle only — pending should be treated as active so its timer runs against startedAt.
- const endedAt = live ? null : (agent.completedAt ?? agent.updatedAt);
+ const endedAt = live
+ ? null
+ : agent.status === "idle"
+ ? agent.updatedAt
+ : agent.completedAt;🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/AgentsPanel.tsx around line 92:
The `endedAt` fallback to `updatedAt` applies to every non-`running`/`waiting` status, including `pending`. When a resumable `idle` agent is requeued to `pending` and `applyStatus` preserves its previous `startedAt`, the elapsed timer freezes at the old `updatedAt` timestamp while the row shows "Working." Consider restricting the `updatedAt` fallback to `idle` only — `pending` should be treated as active so its timer runs against `startedAt`.
Problem
Codex child agents remain idle and resumable after a turn, so they intentionally have no terminal
completedAt. The Agents panel treats those rows as non-live but passed that missing timestamp toelapsedBetween, which falls back toDate.now(). Their displayed run duration therefore kept accumulating idle time whenever the panel rendered.For example, a child that ran from 21:49:13 to 22:07:16 displayed
44m 47sat 22:34 instead of freezing at its actual18m 03sduration.Fix
completedAtwhen available.updatedAtfor resumable idle agents, matching the settled-idle behavior from the earlier snapshot implementation.Review history
This exact failure mode was reported by Macroscope during review of #5219, including the same
updatedAtrecommendation. The finding was automatically marked "No longer relevant as of 4622c3a", but that commit changed timeline folding and its tests rather thanAgentsPanel; the elapsed-time calculation remained unchanged and the bug shipped.Verification
pnpm exec vp test run apps/web/src/components/AgentsPanel.test.tsxpnpm exec vp lint apps/web/src/components/AgentsPanel.tsx apps/web/src/components/AgentsPanel.test.tsxpnpm exec vp fmt --check apps/web/src/components/AgentsPanel.tsx apps/web/src/components/AgentsPanel.test.tsxpnpm --filter @t3tools/web typecheckMade by gpt-5.6-sol using the Codex harness in T3 Code.
Note
Freeze elapsed timers for idle agents at their last update time
In AgentsPanel.tsx, the
AgentElapsedcomponent previously had noendedAtfor non-live agents without acompletedAt(e.g. idle agents), causing the timer to keep counting against the current time. It now usescompletedAt ?? updatedAtas the freeze point for all non-live agents. A test suite in AgentsPanel.test.tsx verifies the frozen elapsed time is rendered correctly.📊 Macroscope summarized 4684703. 1 file reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.