You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let a finished chat subagent go back to done when Claude doesn't resume it - #51765
In a Claude chat, when a background helper agent has finished but a job it started finishes later, Orca guesses that Claude will wake the helper back up, and shows it as working. Sometimes Claude never does, and the chat then said "working" forever with nothing running. Now that guess expires after a minute: if Claude doesn't actually run the helper again, the helper goes back to "done" on its own.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$177
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$177
Prod
8
$\color{#1a7f37}{\Huge{\mathbf{+}}}$355
$\color{#cf222e}{\Huge{\mathbf{−}}}$61
$\color{#1a7f37}{\Huge{\mathbf{+}}}$294
What Changed
Before: in a Claude chat, a background subagent that Claude Code had already reported as finished was put back to working when a task it had launched ended (the "wake"). If Claude Code never resumed it, for example because the subagent had already been told it was finished, or because its worktree was gone, no frame for it ever arrived again. The row, the tab, the sidebar and the worker pill stayed working until the chat was closed. The ticket saw 50 and 75 minutes.
After: the wake holds the owner for a 60 second lease.
If any frame from Claude Code shows the owner's current run running inside the lease (task_progress, a running task_updated patch, or a running roster entry), the lease is cancelled and the owner keeps showing working for as long as it really runs. Frames and roster entries from an older run of the owner pass the same currency check as other task frames, so they can't cancel it.
If the owner really ends inside the lease, the lease is dropped and its real ending stands.
If nothing comes, the owner is restored to the ending it had (outcome, run id and its last summary and token count), emitted as an ordinary ended edge. A timer restates the row at the deadline, because in the stuck case no further frame arrives.
If Claude Code really does run the owner again later, a running report revives it with its saved kind and name.
Mechanism: ClaudeChildWorkDecoder now keeps the wake in ClaudeChildWake (claude-child-wake-lease.ts). drain() settles expired wakes before it hands out evidence. The lease is stamped at the first drain after the wake, so it runs on the same clock that settles it. ClaudeChildWorkPublisher reuses the scheduler the owed-notification lease already uses to restate a session's row at its next expiry. It only reschedules when a chat's deadline changes, and close/closeAll clear it. The decoder was at its line limit, so the owner index moved to claude-child-owner-index.ts. The task_notification report and the rest of the decoder's behaviour are unchanged.
This carries #47724 by @2SinceJuly (credited as co-author), with small follow-ups: unused helpers removed, the lease clock aligned with drain, the restored ending keeping the owner's summary, and the decoder tests trimmed to the lease invariants.
Why
The wake exists so a resumed subagent shows working from the frame that resumes it, not a moment later. Claude Code doesn't always resume, so an unbounded guess can pin a chat as working. Showing the owner working only once Claude Code reports it running would bring back that lag for every real resume. A bounded lease keeps the immediate feedback, and any real frame from Claude Code overrides it, so a genuine resume is never cut short.
Same repro in both builds: an owner subagent starts two background readers (40 s each), is woken by a one-second command and ends its turn. Claude Code then reports it finished while its readers still run. When the readers end, Orca wakes the owner and Claude Code never resumes it.
Before (main): about 6 minutes after the readers ended, still working (spinner on the tab and sidebar, "owner" pill)
After: back to done 60 s after the wake (Done on the tab and sidebar, no pill)
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Real-app QA on Linux (Electron dev copy, isolated profile, real Claude Code 2.1.332 in a Claude chat), with the UI and orca worktree ps --json sampled every 1-5 s:
Stuck case, before (main): the owner stayed working for more than 340 s after its readers ended, and never settled.
Stuck case, after (twice): the owner flipped to working when the readers ended, then returned to done/succeeded 60 s later (+0.7 s in the UI). The chat, tab and sidebar read Done, and the owner kept its replies and summary.
Real resume longer than the lease: an owner woken by its own background command ran a 90 s foreground command. It showed working for the whole run (about 92 s, past the 60 s lease) and went done when it really finished.
A settled owner messaged again ran for 33 s, showed working, then done.
All five decoder tests fail without this change except the real-ending one, which guards behaviour main already has (a real ending inside the window must stand) against the new restore.
claude-child-work-decoder.test.ts drives the decoder's public observe/drain with the ticket's frame sequence. It covers the restore after the lease (including the summary), a real resume cancelling the lease, stale running frames and roster entries not cancelling it, a real ending inside the lease standing (with no later revival from its late frames), and revival only from a running report.
Performance
None, because the lease adds one map entry per subagent wake and one shared timer entry per chat only while a wake is held. A frame in a chat with a held wake checks that chat's own wakes and does one map lookup for its deadline. It reschedules the shared timer only when the deadline changes, so there's no per-frame work across chats. Chats without a wake do nothing new.
Risk
The riskiest part is restoring an owner that Claude Code really did resume but reported no frame for within 60 s. It would show done until its next running frame revives it. In QA a resumed owner's frames arrived within about a second. Only Claude chat child-work rows are affected; terminal panes and other providers are not. A plain revert backs it out, and the lease is in memory only.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Security: no input, path or shell handling touched. Cross-platform: no platform-specific code; QA on Linux, and the decoder is shared. Remote SSH: the same decoder serves remote chats. Mobile: same child-work evidence on the wire. Backwards compatibility: nothing persisted changes.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
No actionable comments were generated in the recent review.
Walkthrough
The decoder now tracks child ownership and manages wake leases for successfully ended agent owners. Running confirmations can revive an expired owner, while lease expiry restores the saved ending and queues evidence. New roster helpers identify running tasks, and a publisher schedules republishing at wake expiry. The session adapter delegates child-work publication and clears publisher state when sessions close.
Merge Risk: Low · up to a987e
A finished chat subagent now returns to done after 60 seconds if Claude doesn't resume it. In the rare case where Claude resumes it without sending any update for over a minute, the row may briefly show done until the next update arrives. This is a known, deferred trade-off with a low merge risk.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title states the main behavior change: a finished chat subagent returns to done when Claude does not resume it. The changeset adds a 60-second lease to the child-wake state. On expiry, the owner r…
Description check
The description follows the repository template and fills in the main sections. It has an ELI5, a before/after account of the change, the mechanism, the reasoning for the approach, a linked issue refe…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title states the main behavior change: a finished chat subagent returns to done when Claude does not resume it. The changeset adds a 60-second lease to the child-wake state. On expiry, the owner restores its recorded ending. The title matches this change.
Full details: Description check
Explanation
The description follows the repository template and fills in the main sections. It has an ELI5, a before/after account of the change, the mechanism, the reasoning for the approach, a linked issue reference, visual proof, testing notes, a performance line, a risk level with a revert path, and a checked checklist. The AI Disclosure section is blank, but the template marks it as optional for internal contributors. The Linked Issue line says 'Tracked in #47715' and not 'Fixes #', so it does not follow the template's exact form. The section is still substantively complete.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving 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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
…he ending's summary
Leaves the task_notification report inline, drops unused helpers, and keeps the decoder tests to the lease invariants.
Co-authored-by: 2SinceJuly <[email protected]>
… ending, and skip unchanged re-arms
A stale running roster entry no longer cancels a held wake, a real ending inside the lease drops it and leaves nothing to revive, and frames that leave a chat's deadline unchanged no longer reschedule the shared timer.
Co-authored-by: 2SinceJuly <[email protected]>
…real endings stand
The lease deadline now uses the same monotonic clock as its timer, so a wall-clock correction cannot stretch it or make the timer spin. A real ending clears any revival of that run, and roster entries, which carry no run state, no longer cancel or revive a wake.
Co-authored-by: 2SinceJuly <[email protected]>
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Problem. In a Claude chat, a background subagent that Claude Code had already reported as finished was shown as working again when a task it launched ended, on the guess that Claude would resume it. When Claude didn't, nothing ever settled the row, and the chat said working until it was closed (tracked in #47715).
User-facing change. That guess now expires after 60 seconds. If Claude really runs the subagent again, it keeps showing working for as long as it runs. If not, the row goes back to its recorded ending (done, with its summary), and the chat reads done, with nothing typed.
Fixed during review (two fresh reviewers, then blinded regression audits):
Stale running frames from an older run of the subagent can't cancel the 60 s window. Roster entries, which carry no run state, neither cancel nor revive it (as on main).
A real ending, inside the window or after it, stands. Late frames from that run can't reopen the row.
The window and its timer both use the monotonic clock, so a wall-clock correction can't stretch it or make the timer spin.
Per-frame cost is constant. Pending wakes stay in deadline order, so a frame checks only the next one. The shared timer is rescheduled only when a chat's deadline changes.
Unused helpers were removed. The restored ending keeps the subagent's summary and token count. Tests were cut to five lease invariants.
Deferred (not blockers):
If Claude resumes a subagent but sends no frame for more than 60 s, the row shows done until its next frame, then working again. This is stated in Risk; in QA, resume frames arrived within about a second.
Reviving from a start frame emits two identical live edges. That's redundant but harmless.
Update for head a987e62: only a running report or a progress frame now counts as proof that Claude resumed a woken subagent, so a pending or paused update can't keep it working (covered by the stale-frame test). CI is green and a fresh blinded regression audit on this head is SAFE. Everything else in the status above is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
In a Claude chat, when a background helper agent has finished but a job it started finishes later, Orca guesses that Claude will wake the helper back up, and shows it as working. Sometimes Claude never does, and the chat then said "working" forever with nothing running. Now that guess expires after a minute: if Claude doesn't actually run the helper again, the helper goes back to "done" on its own.
What Changed
Before: in a Claude chat, a background subagent that Claude Code had already reported as finished was put back to working when a task it had launched ended (the "wake"). If Claude Code never resumed it, for example because the subagent had already been told it was finished, or because its worktree was gone, no frame for it ever arrived again. The row, the tab, the sidebar and the worker pill stayed working until the chat was closed. The ticket saw 50 and 75 minutes.
After: the wake holds the owner for a 60 second lease.
task_progress, a runningtask_updatedpatch, or a running roster entry), the lease is cancelled and the owner keeps showing working for as long as it really runs. Frames and roster entries from an older run of the owner pass the same currency check as other task frames, so they can't cancel it.endededge. A timer restates the row at the deadline, because in the stuck case no further frame arrives.Mechanism:
ClaudeChildWorkDecodernow keeps the wake inClaudeChildWake(claude-child-wake-lease.ts).drain()settles expired wakes before it hands out evidence. The lease is stamped at the first drain after the wake, so it runs on the same clock that settles it.ClaudeChildWorkPublisherreuses the scheduler the owed-notification lease already uses to restate a session's row at its next expiry. It only reschedules when a chat's deadline changes, and close/closeAll clear it. The decoder was at its line limit, so the owner index moved toclaude-child-owner-index.ts. Thetask_notificationreport and the rest of the decoder's behaviour are unchanged.This carries #47724 by @2SinceJuly (credited as co-author), with small follow-ups: unused helpers removed, the lease clock aligned with drain, the restored ending keeping the owner's summary, and the decoder tests trimmed to the lease invariants.
Why
The wake exists so a resumed subagent shows working from the frame that resumes it, not a moment later. Claude Code doesn't always resume, so an unbounded guess can pin a chat as working. Showing the owner working only once Claude Code reports it running would bring back that lag for every real resume. A bounded lease keeps the immediate feedback, and any real frame from Claude Code overrides it, so a genuine resume is never cut short.
Linked Issue
Tracked in #47715
Visual Proof
Same repro in both builds: an owner subagent starts two background readers (40 s each), is woken by a one-second command and ends its turn. Claude Code then reports it finished while its readers still run. When the readers end, Orca wakes the owner and Claude Code never resumes it.
Testing
Real-app QA on Linux (Electron dev copy, isolated profile, real Claude Code 2.1.332 in a Claude chat), with the UI and
orca worktree ps --jsonsampled every 1-5 s:All five decoder tests fail without this change except the real-ending one, which guards behaviour main already has (a real ending inside the window must stand) against the new restore.
claude-child-work-decoder.test.tsdrives the decoder's publicobserve/drainwith the ticket's frame sequence. It covers the restore after the lease (including the summary), a real resume cancelling the lease, stale running frames and roster entries not cancelling it, a real ending inside the lease standing (with no later revival from its late frames), and revival only from a running report.Performance
None, because the lease adds one map entry per subagent wake and one shared timer entry per chat only while a wake is held. A frame in a chat with a held wake checks that chat's own wakes and does one map lookup for its deadline. It reschedules the shared timer only when the deadline changes, so there's no per-frame work across chats. Chats without a wake do nothing new.
Risk
The riskiest part is restoring an owner that Claude Code really did resume but reported no frame for within 60 s. It would show done until its next running frame revives it. In QA a resumed owner's frames arrived within about a second. Only Claude chat child-work rows are affected; terminal panes and other providers are not. A plain revert backs it out, and the lease is in memory only.
Level: Low
AI Disclosure
Review
Agent skill upstream boundary
Notes
Security: no input, path or shell handling touched. Cross-platform: no platform-specific code; QA on Linux, and the decoder is shared. Remote SSH: the same decoder serves remote chats. Mobile: same child-work evidence on the wire. Backwards compatibility: nothing persisted changes.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)