Repository navigation
fix(sidebar): give a subagent row its own activity clock instead of its parent's - #21400
brennanb2025 wants to merge 10 commits into
Conversation
…ts parent's A subagent child row borrowed its parent's `updatedAt` as its staleness clock and set no `evidenceObservedAt`, so the sidebar's "No update in N" label reported the PARENT's silence as the child's. With one child that reads correctly by coincidence — the child's activity is what advanced the parent's clock. With siblings it is wrong: a child quiet for ten minutes reads "No update in 0m" because a sibling just pinged. Reuse `evidenceObservedAt`, the field that already carries this meaning on `AgentStatusEntry` and whose reader already prefers it and already falls back to `updatedAt`. Add it as an optional field on the two child-bearing wire types and stamp it at the producer boundaries that already classify an event as the child's: - Claude hook roster: every child-attributed tool event and the lead's background-task fold. - Codex hook roster: every child-attributed lifecycle and tool event. The stamp takes an explicit observation argument, because two callers (the transcript scan and the restore seed) pass a SPAWN stamp as their creation clock and reusing it would backdate the child's recency to its own birth. - Structured background tasks: `task_started`, `task_updated`, the aggregate roster frame, and — the load-bearing one — `task_progress`. That branch previously dropped a frame entirely unless the task was backgrounded AND the frame carried token usage, discarding the only per-child liveness signal a backgrounded child emits. A usage-free progress frame now refreshes the clock, which changes publish FREQUENCY on that shared path. `startedAt` is untouched everywhere. It is the spawn stamp two roster sorts, `compareWorktreeAgentRows`, cap eviction, and the equality/shed digest all depend on, so this adds a second field rather than moving that one. The time column is untouched too: it is documented bimodal (finish-time for a done row, start-time for an active one), so "14m" on a working child is a correct elapsed duration. Absent means the host never reported it, never "never active" — deliberately NOT normalized to 0 the way `startedAt` is, which would render as decades of silence. The reader keeps the parent `updatedAt` borrow as the documented old-host fallback. The shed-roster digest deliberately excludes the new field: it moves on every child tool event, so folding it into an IDENTITY digest would make a shed roster almost never match its cached twin, and an unrestored roster blanks live child rows and unblocks hibernation. Moves the tracked-row merge and the progress-frame fold next to the row type they belong to, which also keeps the tracker inside its line budget.
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe change adds optional Priority: ⬇️ Low 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
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 |
There was a problem hiding this comment.
Important
The per-child clock is wired correctly, but the two aggregate-frame paths stamp a membership frame's arrival time as the child's own activity. On the structured path a quiet child's "No update in N" still resets when a sibling starts/finishes or the lead's turn ends — the same borrowed-clock symptom this PR removes elsewhere. The repo's own comments describe that frame as a level signal that "carries no evidence of a new run."
Reviewed changes
- Per-child observation clock — adds optional
evidenceObservedAttoAgentSubagentSnapshotandAgentSessionBackgroundTask, stamped at child-attributed ingestion in both hook rosters, the structured background-task tracker, and the renderer bridge. - Sidebar child row —
buildSubagentChildRowscopies the child clock onto the synthetic entry while keeping the parent'supdatedAtas the old-host fallback andstartedAtas the sort/elapsed stamp. - Task-progress liveness — a usage-free
task_progressframe now refreshes the clock instead of being dropped. - Relay shed digest — deliberately excludes the new field, pinned by a new test.
- Refactor — background-task merge and progress folds moved into
claude-settled-background-tasks.ts. - Tests — regression coverage for sibling divergence, spawn-stamp stability, the old-host fallback, and the usage-free progress frame.
- Planning doc — 615-line
ATTRIBUTION-child-clock.mdadded at repo root.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| @@ -242,7 +249,8 @@ export class ClaudeBackgroundTaskTracker { | |||
| description: taskDescription(task.description) ?? existing?.description, | |||
| name: taskName(task) ?? existing?.name, | |||
| state: liveClaudeTaskRunState(task.status) ?? existing?.state, | |||
| startedAt: existing?.startedAt ?? this.now(), | |||
| startedAt: existing?.startedAt ?? observedAt, | |||
| evidenceObservedAt: observedAt, | |||
There was a problem hiding this comment.
This stamps the background_tasks_changed frame's arrival time as each listed task's own activity. That frame is a set-membership snapshot — it fires when a task starts or finishes, not when each listed child acts — so a quiet sibling's clock advances because another task changed. The repo documents this frame as membership only (claude-background-task-roster.ts:33-34: "Presence must not revive a settled row; the task's own frames alone settle or restart it"; claude-background-task-rows.test.ts:235-237: "presence is a level signal ... which carries no evidence of a new run"), and the field's own docstring says "Last epoch ms this task's OWN activity was observed." This is the same borrowed-clock symptom the PR removes on the per-child paths.
Technical details
# Aggregate roster frames stamp the child's clock from set membership
## Affected sites
- `src/main/claude/claude-background-task-tracker.ts:253` — `replaceAggregateRoster` writes the single `observedAt` from the `background_tasks_changed` frame onto every listed task. `task_started`/`task_updated`/`task_progress` already give each task a genuine per-task clock, so this stamp only adds the sibling-borrowed one.
- `src/shared/claude-subagent-roster.ts:195` — `foldClaudeBackgroundTasksIntoRoster` writes the lead `Stop`/`StopFailure` time (`claude-events.ts:211-216`) onto every running id in the lead's inventory. The PR doc flags this one for review (§5/§9 Step 2); the same argument applies to the tracker path, which the doc does not flag.
- Pinned as current behavior by `claude-background-task-tracker.test.ts:421-426` and `claude-subagent-roster.test.ts:551-561`.
## Required outcome
- A quiet child's `evidenceObservedAt` must not advance because a sibling started/finished or the lead's turn ended.
## Suggested approach
- Stamp only from per-task frames (`task_started`, `task_updated`, `task_progress`) and the hook roster's per-child upsert; or stamp an aggregate frame only on a task's first sighting. If an aggregate frame is intended to count as liveness, reconcile the field docstring (`agent-status-types.ts:82-86`, `claude-settled-background-tasks.ts:34-35`) and the roster comments above, and state which reading "No update in N" is meant to express.
## Open questions for the human
- Does the Claude SDK re-probe each listed task when it emits `background_tasks_changed`, or echo cached membership? The repo has no captured Claude stream transcript to settle it (`src/main/runtime/__fixtures__/` holds no Claude frames).There was a problem hiding this comment.
ℹ️ No new changes to review — the only commit since the prior review is a merge of
main(9907117), and the PR'sbase...headdiff is byte-identical to the version already reviewed. The prior review's findings remain open.
Reviewed changes
c23f7d8755— mergeorigin/maininto the branch. No file changes on the PR side; the diff TOC and content are identical to55a69eb.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in the new commit — the transcript producer mirrors the existing child-clock wiring, and the normalization guard now matches the repo's
isTimestampconvention. One description nit below.
Reviewed changes
- Transcript-scan child clock —
reconcileCodexSubagentTranscriptnow computesobservedAt = Date.now()once per reconcile and passes it toupsertCodexSubagentfor each parent-rolloutsub_agent_activityrecord it reads, so a Codex child known only from the parent's transcript gets its own clock instead of none. The rollout cursor is incremental, so only newly appended records stamp;startedAtis still the provider spawn time. - Negative observation rejected into absence —
normalizeSubagentSnapshotnow dropsevidenceObservedAt < 0, aligning the subagent snapshot with theisTimestampvalidator used elsewhere on the wire. - Tests — the transcript clock is shown advancing across two reconciles under fake timers, and a negative
evidenceObservedAtis shown normalizing to absent.
ℹ️ Nitpicks
- The PR description's mechanism section still says the Codex transcript scan "simply does not pass" the observation moment, but after
933407dit passesDate.now(). Worth updating so the description matches the code.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Resolved the merge conflict against current main and pushed merge commit . Preserved the child-clock changes together with main's Codex reviewer/transcript updates; focused Codex transcript/roster/status tests pass (91 tests). |
|
Correction: conflict resolution was pushed in merge commit c0ffb21. Main’s Codex reviewer/transcript updates and the child activity-clock changes are both preserved; focused Codex transcript/roster/status tests pass (91 tests). |
There was a problem hiding this comment.
ℹ️ No new issues — the only change since the prior review is the merge of
main, and both of its conflict resolutions were verified faithful.
Reviewed changes
- Merged
origin/maininto the branch (c0ffb21). Re-integrated main's Codex approval-reviewer refactor, resolving conflicts incodex-events.tsandcodex-subagent-transcript.ts. The merge result equals main's current code plus only this PR'sevidenceObservedAtadditions:normalizeCodexEventadopts main'schildState/reconcileCodexSubagentReviewerpath, andreconcileCodexSubagentTranscriptkeeps its singleparentRecordscursor read while still stampingobservedAtper transcript-only child record. Targeted suites (codex-subagent-transcript,codex-subagent-roster,agent-hook-relay,agent-status-types) pass — 90 tests.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
The PR-specific red check is fixed.
The remaining CI jobs are running on the corrected head. |
Validation gap resolvedThe previously documented Electron validation gap is closed.
Readiness checks before and after the review are clean. The same-model review/fix loop is clean, CI is green, and no scope-expanding changes were made. |
Full provider E2E validation completeBoth real providers were exercised through the exact PR branch in Electron (
No files were edited or committed by either provider task. This closes the previous Codex validation gap; focused tests and CI remain green. |
|
Closing as superseded: #22565 (merged) gives each subagent row its own activity clock through the child's own observation time, on main's single subagent-row source, which is what this PR set out to do. |





ELI5
When an agent in the sidebar starts helper agents of its own, each helper gets its own
indented row. If Orca stops hearing from a row, it writes a small note under it saying how
long it has been since it last heard anything — "No update in 12m".
Those helper rows were not keeping their own clock. They all read the clock belonging to the
agent that started them. So if one helper had been silent for ten minutes while a second
helper was chattering away, the silent one still claimed it had just been heard from — it was
quietly reporting its sibling's activity as its own.
Now each helper keeps its own clock, so that line finally says something true about the row
it sits under.
What Changed
Before. Every helper row on a parent copied the parent's "last heard from" timestamp.
With exactly one helper this looked right by accident: the helper's own activity was the thing
keeping the parent's clock moving, so the two numbers agreed. Add a second helper and it
breaks — a helper that has done nothing for ten minutes shows "No update in 0m" because a
sibling just reported in. A parent that talks for its own reasons does the same thing. The
number was never wrong in an obvious way, which is why it survived: it was wrong in a way that
only shows up when you have more than one helper.
After. Each helper row carries the moment Orca last saw that helper do something, and
the "No update in N" line reads it. Two siblings under one parent now show different numbers.
The mechanism. Orca already has a field that means exactly this on an agent row —
evidenceObservedAt, "when the evidence was observed", kept separate fromupdatedAt, whichis the delivery clock. The reader that writes the "No update in N" line already prefers it and
already falls back to
updatedAtwhen it is missing. What was missing was anyone setting iton a helper row.
So this adds that same field, optional, to the two types that describe a helper, and sets it at
the points that already decide "this event belongs to the child, not the parent":
time into the roster update and the roster threw it away. It is now recorded. The parent's
own end-of-turn inventory, which lists the children still running, counts as an observation
of each child it lists.
pass a spawn time as the creation clock — the transcript scan and the restore-from-disk
seed. Reusing it would have backdated a child's "last heard from" to its own birth, so the
observation moment is now a separate, explicit argument that those two callers simply do not
pass.
task_progressframe entirely unless the task was backgrounded and the frame carried tokenusage. That frame's
descriptionis the child's current activity ("Running Bash"), and for abackgrounded child it is the only proof-of-life Orca ever receives. A usage-free progress
frame now refreshes the clock instead of being dropped.
What deliberately did not change.
active row reads time-since-start. "14m" on a helper that has been working fourteen minutes
is a correct elapsed duration, and the pop-out dashboard shows no timestamp for helpers at
all. Giving the column a third meaning for helpers only, on one of three surfaces, would make
Orca disagree with itself.
eviction rule, and the row-equality check all depend on it holding still. Moving it would
reshuffle sibling rows under the user's cursor on every ping. This adds a second field rather
than repurposing that one.
host that predates this field. Deleting it would leave an older host reading "No update in
<the row's entire lifetime>"; replacing it with "now" would invent freshness, which is
the same class of bug on the other side.
Why
The bug is a row reading a clock that belongs to a different producer. The fix is to attribute
the observation where the event is already classified as the child's, which is at ingestion —
not to add a rule at the reader deciding whose clock to trust. Attribution at the reader is the
thing that produced this bug, and the store's own guidance is that readers keep presentation
policy only.
Alternatives considered.
— no per-child activity timestamp was on the wire at all.
evidenceObservedAtalready carriesthis exact meaning on the parent row type, its reader already prefers it and already falls
back correctly, so reusing the name made the reader change a single line and left a search for
a second "last activity" concept empty.
not moving, and its own source comment says it is preserved so clients can render elapsed and
keep a stable first-seen sort.
a tool event every few seconds, so a recency reading is a constant pulse; the elapsed duration
is the number a user acts on ("this has been running forty minutes"). And Orca already has a
dedicated channel for recency, in words, on the secondary line — which is the line this change
actually fixes.
Two things this does not fix, stated rather than implied. A parked, idle helper still times
from its spawn moment, because there is no "settled at" stamp for helpers; that needs a
different field. And the fallback clock is the parent's, so on an older host a helper still
inherits whatever the parent's clock says — this change is what lets a current host stop
depending on it.
Linked Issue
Fixes #
Visual Proof
Live Electron validation used both real providers to create parallel child agents from one
parent. The rendered Agents/session surfaces and provider terminals showed the completed runs:
These are after-state captures from provider-backed flows; no synthetic state was injected.
Testing
pnpm tc,oxlint, andpnpm run check:code-quality:changedall pass. Targeted suites aregreen; the whole of
src/shared,src/main/claude,src/main/agent-hooks,src/renderer/src/components/sidebarand.../native-chatwas run — 14,590 passed, with onepre-existing failure in
claude-structured-real-cli.test.tsthat reproduces identically on theunmodified source (it asserts a custom slash command is present in the locally installed CLI's
catalog and touches nothing here).
Every new regression test was shown failing before the change and passing after:
observably wrong, and which could not be written before because the field did not exist.
old-host path. Ablated by deleting the parent borrow, which turns it red.
leaving both spawn stamps and the snapshot sort untouched.
task_progressframe carrying no usage now advances the clock, preserves the spawn stampand the task's name, and reports the state as changed — the branch that previously returned
early and wrote nothing.
into the digest, which turns it red.
Electron validation used the exact PR branch, an isolated profile,
ORCA_BACKGROUND_LAUNCH=1,and Playwright CDP. A real Claude Code session created two provider-backed children; the backing
status store recorded distinct child
evidenceObservedAtvalues, and the visible Agents surfacerendered the completed parent session. A real Codex session also completed with exactly two
parallel subagents; its provider output and session surface reported both read-only inspections,
and its transcript path is covered by the focused tests listed above.
The change is only observable on a parent with two or more helpers, once a row has decayed to
unverifiable, and on a provider whose children actually emit child-attributed events. For a
provider whose children emit nothing the field stays absent and the row keeps today's behaviour,
which is the correct degrade.
Review
Wire compatibility
Two additive optional numeric fields, one on the hook status payload's child rows and one on
the
agentSession.*background-task row. Both are new keys on frames that already exist, decodedby parsers that ignore unknown keys. No new opcode, no new frame, no new journal item kind, so no
capability negotiation is required.
which is exactly today's behaviour — the skew degrades to the status quo, never to something
worse.
never this child has never been active. It is specifically not normalized to
0the waythe spawn stamp is, because
0would render as decades of silence. The reader falls through tothe existing clock with no extra branch. Nothing anywhere gates on the field being present.
stops being synthesized.
task_progressframecarrying no token usage used to produce no publish and now produces one. That is a change in
publish frequency, not in frame content — old clients decode an identical frame shape whose
only new key they ignore. The knock-on is a new child-row array per child event and the React
re-renders behind it; the structured bridge's write gate already turns over on every publish,
so nothing changes there. Not measured. If it bites, the mitigation is to round the timestamp
to a coarse bucket at the producer, and that tradeoff should be written down rather than
applied quietly.
mobile/srchas zero non-testreferences to subagents or background tasks.
not.toHavePropertyassertions were added anywhere; the cross-version wire test stays greenfor an added optional field by design, and was run.
One deliberate deviation from the plan, with its reason
The plan called for adding the new field to the relay's shed-roster digest so a roster differing
only in the clock could not collide. I did not, and pinned the opposite with a test.
That digest carries roster identity, so a relay that had to drop an oversized roster can
re-attach the cached one. The new field moves on every child tool event. Folding it in would mean
a shed roster essentially never matches its cached twin — and an unrestored roster blanks live
child rows and unblocks hibernation for a pane whose helpers are still running, which is the
precise failure the restore exists to prevent. Restoring the cached clock instead is conservative:
an older observation is still a true statement about when the child was last seen, and can never
fabricate freshness. Both the reasoning and the ablation are recorded in the code and the test.
Structural note
This adds no new writer of a status row and removes none. Orca keeps two real writers of one
status row apart with publication filters; that structure is untouched here and is not narrowed
by this change.
Refactor carried along
The tracked background-task row's merge rule and its progress-frame fold moved next to the row
type they belong to, beside the comment that already documents why the spawn stamp is preserved.
That is where the "which clock moves and which does not" rule now lives in one place, and it also
keeps the tracker inside its line budget without suppressing the rule.
Agent skill upstream boundary
Notes
Cross-platform: no platform-dependent code; all timestamps come from existing clocks. SSH/remote:
covered under Wire compatibility above — the execution host remains the authority for every stamp,
and a client never synthesizes one. Folder workspaces and git worktrees are equally unaffected;
nothing here reads workspace shape. Security: no new input crosses a trust boundary beyond one
optional number, validated as a finite number at the same boundary that already validates the
rest of the row, and rejected into absence rather than into a value.
Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)