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
feat(agent-status): add a bounded agent process exit watch - #47839
Some agents say "session ended" while their process keeps running. This adds a small watcher that checks whether the process really exited before Orca marks the terminal as finished.
What Changed
Standalone. Rebased onto main at 845867a; it has no dependencies and can merge on its own. Commit ca8014bc9e.
Adds AgentProcessExitWatch, which probes a pane's agent process after it reports a session end.
Backs off from 250 ms to 8 s, for at most 90 s, and stops once the probe confirms the exit, has nothing to check, or the pane no longer holds what the watch started for.
Ignores a probe that settles after a stop or restart.
Nothing uses it yet; the Droid exit PR in this stack is the first caller.
Why
Droid sends SessionEnd both when it exits and when /new switches sessions (recorded on Droid 0.238.0 and 0.244.0), so SessionEnd alone cannot prove the process exited. A bounded, cancellable watch keeps that proof out of each provider.
Linked Issue
Part of #9690: groundwork for the Droid exit PR (see Stack).
Visual Proof
N/A: no caller in this PR.
Testing
Local macOS only.
ORCA_CODE_QUALITY_BASE=stablyai/main pnpm check:changed passed on this commit after the rebase (format, oxlint, typecheck, tests importing the change, selected ratchets).
Full unit suite (pnpm test --maxWorkers=6) on this branch: 1322 test files passed, 3 failed, 15 skipped. The failing files also fail on main at 845867a on this machine: agent-cli-update-timeout (timing), bot-upcoming-copy (locale), worktree-removal-real-git (temp-dir cleanup).
Golden E2E journeys ran on the previous stack tip (main at 59f3122): 8 passed, 4 skipped (Windows-only), and golden-fresh-profile-terminal failed the same way on main. Not rerun after the rebase.
Not run: Linux, Windows, or SSH remote hosts.
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
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Considered security, macOS/Linux/Windows paths, SSH remote hosts, mobile compatibility, folder workspaces, and performance. Execution coverage is limited to the checks listed under Testing.
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)
Merge message
feat(agent-status): add a bounded agent process exit watch
An agent can report a session end while its process keeps running.
Add a bounded watch that probes the pane's agent process with backoff
for up to 90 s and stops once the exit is confirmed or the pane no
longer holds the watched process.
The changes add provider-managed pane-state cleanup and claims, replace Claude-specific expiry timers with lease-provider scheduling, and add polling for agent process exits. The runtime write guard also protects additional agent-home directories and inherited configuration paths.
Merge Risk: Low · up to 08e42
The new process-exit watch is not used yet, so merging does not change behavior today. Before the first caller is added, the watch should enforce its 90-second limit even when a probe never returns. Without that, a stuck probe keeps the watch alive indefinitely.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "feat(agent-status): add a bounded agent process exit watch" matches the main change: the new AgentProcessExitWatch class in src/shared/agent-status/process/ polls an agent process after a s…
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.
Description check
The description covers most required template sections. It has a substantive ELI5, a What Changed section with the mechanism (backoff from 250 ms to 8 s, 90 s limit, stop conditions), a Why section th…
Full details: Title check
Explanation
The title "feat(agent-status): add a bounded agent process exit watch" matches the main change: the new AgentProcessExitWatch class in src/shared/agent-status/process/ polls an agent process after a session-end report, with backoff and a 90-second deadline. The title is specific and follows a conventional commit style. It does not describe the rest of the stack's changes (hook state slots, lease timers, test home guards), but the PR's own changeset is mainly the exit watch plus its test, so the title is accurate.
Full details: Description check
Explanation
The description covers most required template sections. It has a substantive ELI5, a What Changed section with the mechanism (backoff from 250 ms to 8 s, 90 s limit, stop conditions), a Why section that explains the Droid SessionEnd ambiguity, Testing with commands and results, a Performance line, a Risk level with a revert plan, and completed checklist and upstream boundary items. Gaps: the Linked Issue section says 'Part of #9690' rather than the 'Fixes #' form the template asks for, and the template asks for a Visual Proof N/A reason, which is given. The AI Disclosure section is left as the raw template comment with no content. The Merge message block is extra content outside the template. The Testing section also reports that the full test suite had 3 failing files, which the reviewer should weigh. The checklist leaves the lint/typecheck/test/build item unchecked, with no note that CI will cover it. The Testing section does not say whether the new test was shown to fail without the change, which the anti-pattern checkbox requires.
Resolution
Optional improvements: fill in or mark the AI Disclosure section, state whether the new test fails without the change, and clarify the linked issue reference (the template asks for a 'Fixes #' link, and the author notes this PR is part of #9690). The PR description is mostly complete, so these items are not blocking.
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; 7 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Stability & Availability · Quick win
Expire watches while a probe is pending.
If watch.probe() never settles, no code checks the deadline again. The map retains the watch and its host beyond the stated 90-second window.
Add deadline cleanup that runs independently of probe settlement. Cancel that cleanup on completion, stop, or replacement. Keep the identity checks so late settlement cannot affect a replacement watch.
This follows the PR's bounded-watch objective and the retrieved learning about lifecycle-bound asynchronous work.
…ng its end
AgentProcessExitWatch probes a pane's agent process after it reports a
session end, backing off from 250 ms to 8 s for at most 90 s, and stops as
soon as the probe confirms the exit, has nothing to check, or the pane no
longer holds what the watch started for. A probe that settles after a stop
or restart is ignored.
Hook providers whose SessionEnd can precede the process exit (a /clear also
ends a session) use it to end the row only once the process is gone.
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
Some agents say "session ended" while their process keeps running. This adds a small watcher that checks whether the process really exited before Orca marks the terminal as finished.
What Changed
Standalone. Rebased onto main at 845867a; it has no dependencies and can merge on its own. Commit
ca8014bc9e.AgentProcessExitWatch, which probes a pane's agent process after it reports a session end.Why
Droid sends SessionEnd both when it exits and when
/newswitches sessions (recorded on Droid 0.238.0 and 0.244.0), so SessionEnd alone cannot prove the process exited. A bounded, cancellable watch keeps that proof out of each provider.Linked Issue
Part of #9690: groundwork for the Droid exit PR (see Stack).
Visual Proof
N/A: no caller in this PR.
Testing
Local macOS only.
ORCA_CODE_QUALITY_BASE=stablyai/main pnpm check:changedpassed on this commit after the rebase (format, oxlint, typecheck, tests importing the change, selected ratchets).pnpm test --maxWorkers=6) on this branch: 1322 test files passed, 3 failed, 15 skipped. The failing files also fail on main at 845867a on this machine:agent-cli-update-timeout(timing),bot-upcoming-copy(locale),worktree-removal-real-git(temp-dir cleanup).golden-fresh-profile-terminalfailed the same way on main. Not rerun after the rebase.Not run: Linux, Windows, or SSH remote hosts.
Changed test files:
src/shared/agent-status/process/agent-process-exit-watch.test.tsPerformance
None, because nothing starts a watch in this PR. Once used, a watch is bounded to 90 s per pane with backoff from 250 ms to 8 s.
Risk
Level: Low
New module with no caller here. Back out with a plain revert.
AI Disclosure
Review
Self-reviewed this PR's single commit for correctness, security, and performance. Merge order:
Agent skill upstream boundary
Notes
Considered security, macOS/Linux/Windows paths, SSH remote hosts, mobile compatibility, folder workspaces, and performance. Execution coverage is limited to the checks listed under Testing.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Merge message