Repository navigation
Conversation
|
|
Note Reviews pausedIt 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
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 8.70% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 12 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
-
Check name Status Explanation Title check ✅ Passed The title clearly identifies the main change: signaling an agent process group before force-killing a closed terminal. Description check ✅ Passed The description explains the problem, scope, behavior change, compatibility decisions, testing evidence, and linked issue. It does not use the required template headings and omits explicit entries for… Linked Issues check ✅ Passed The changes meet the coding requirements in [ #23865]. Agent-session teardown sendsSIGTERMto POSIX process groups, waits within the existing close budget for up to 2 seconds, and escalates to `SIGK…Out of Scope Changes check ✅ Passed The changes remain within [ #23865]. The subprocess API, POSIX process-group discovery, bounded termination controller, teardown integration, and tests directly support explicit agent-session closes an…
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Autopilot is currently an internal CodeRabbit preview.
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 @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
SessionTerminationController.signalGroupsThenForceKillWithinBudget— SIGTERMs the PTY's POSIX process groups, waits a 2s grace clipped totimeoutMs, then SIGKILLs and waits the remaining budget; cancels the 5s graceful fallback first. Windows / handles withoutsignalProcessGroupskeep the direct force-kill.SubprocessHandle.signalProcessGroups?— new optional handle method;createDaemonPtySubprocessHandleno-ops whendead/win32 and otherwise delegates tosignalPosixPtyProcessGroupswith a root-pid fallback.TerminalSessionTeardown— the three immediate agent paths (initial root kill, laterequestImmediateescalation, already-terminating escalation) route through the new method; plain shells keepforceKillAndWaitForExit.- Tests — new
session-termination-controller.test.tssuite, updated teardown assertions, and asignalProcessGroupsstub added to the shared adapter harness.
The reported trigger is the immediate path (closeTerminal → stopExplicitlyClosedTabPtys → stopAndWait → daemon kill { immediate: true }), so the fix lands where the hooks were being skipped. I confirmed the total close ceiling is unchanged — grace and the post-SIGKILL wait together stay within timeoutMs (default 8s), which keeps IMMEDIATE_KILL_REPLY_BUDGET_MS and the runtime stop deadline valid. I also ran the changed controller/teardown tests, terminal-host.test.ts, the session-adoption suite, and the existing slow-exit budget test: all pass.
ℹ️ Verification and residual scope
The unit tests pin signal ordering, but the fix was not exercised against a live Claude session (so the actual SessionEnd firing is unverified) nor on Windows — the author called both out in the PR body. Separately, only the immediate path is changed: the graceful fallback used when an immediate stop fails to confirm (killPtyFromRuntimeController with immediate: false, reached via stopExplicitlyClosedTabPtys line 52) still sends the root-only signal, so a hook would be skipped on that narrow path. Neither blocks this PR; noting them so the scope is explicit.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
790650b to
6f16c92
Compare
Sync update (
|
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: f0f4993e-4c7c-42ab-b780-8fd72a597d51
📥 Commits
Reviewing files that changed from the base of the PR and between 790650b486ca68dbc9776b87be0bc219f977e060 and 6f16c9268b83e1e4a223463c70e7ec0d11f321e1.
📒 Files selected for processing (2)
src/main/daemon/session-termination-controller.test.tssrc/main/daemon/session-termination-controller.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
There was a problem hiding this comment.
Important
The new commit's post-root-exit SIGKILL escalation never reaches the OS — it is dropped by the daemon handle's dead guard before any signal is sent.
Reviewed changes (delta since the prior pullfrog review at 790650b)
- Added
killRemainingProcessGroupstoSessionTerminationController, escalating to a groupSIGKILLon every branch where the root has already exited (right afterSIGTERM, after a successful grace wait, and after the grace catch). - Reworked the controller tests to assert the post-exit
SIGKILLordering, replacing the earlier "does not force-kill when the process exits during the grace" case.
The idea is sound — a shell that dies on SIGTERM while a child group ignores it should still get a group SIGKILL — but as written the escalation is inert on POSIX. Detailed below.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
6f16c92 to
95efbd0
Compare
Sync update (
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The delta since the prior pullfrog review at 6f16c92 is commit 95efbd0, which closes the one open finding from that review.
- Post-exit group
SIGKILLnow reaches the OS —createDaemonPtySubprocessHandle.signalProcessGroupscaptures the pgids it signals during the pre-exitSIGTERMand, once the root has exited (dead), replaysprocess.kill(-pgid, signal)against those captured ids instead of returning early or re-resolving the reaped root.session-termination-controller.test.tsis pinned to a POSIX platform so the group-signal cases run on Windows CI too. - Force-kill retry bounded by the caller's budget —
requestForceKillWithRetrynow takes an optional remaining-budget and clips (or skips) its retry wait to it, so a failingforceKill()cannot overruntimeoutMsafter the grace has already consumed it. The no-arg path used byforceKillAndWaitForExitis unchanged. - New coverage —
subprocess-handle-group-signal.test.tsasserts the captured groups receiveSIGKILLafter exit (and that no root lookup happens when nothing was captured); a retry-budget case was added to the controller suite.
I confirmed the new capture wiring against the real signalPosixPtyProcessGroups (its deps.signalProcessGroup seam is genuinely invoked), re-ran the changed suites (controller 9, teardown 14, group-signal 2 — 25 passed) plus the slow-exit/pty-subprocess regression suites (39 passed), and linted the changed files clean.
ℹ️ Notes on residual scope
Two carry-forward items that do not block this PR: no live-Claude or Windows verification (author-disclosed — the unit tests pin signal ordering only), and the graceful (non-immediate) agent teardown path still root-signals only, so a hook could be skipped there. Both were noted in the prior review and remain out of scope here.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
95efbd0 to
babdabc
Compare
Sync update (
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The delta since the prior pullfrog review at 95efbd0 is commit babdabc, which closes the one open concern Greptile raised.
- Post-root-exit group
SIGKILLnow checks tty ownership —signalRememberedProcessGroupsre-reads the groups still on the PTY through the newreadPosixProcessGroupsOnTerminaland onlykillpgs a remembered id that still appears, so a pgid recycled after the root exited can no longer be signaled. - New helper —
readPosixProcessGroupsOnTerminalrunsps -t <slave path> -o pgid=behind anisSafeTerminalNameguard; it returnsnullwhen the name is unsafe or the table is unreadable so the caller fails closed. - Coverage — new subprocess-handle cases assert that a group that left the PTY and an unreadable table both skip the
SIGKILL, plus threereadPosixProcessGroupsOnTerminalcases.
I verified that the full path form node-pty reports (/dev/ttysNNN) is accepted by macOS ps -t (addelem_tty in Apple adv_cmds/ps/ps.c; FreeBSD ps(1) man page), so the guard does not silently no-op on this PR's primary platform, and re-ran the changed suites (57 passed).
ℹ️ Residual scope
The guard replaces the previous unconditional replay with a tty-ownership check, so the post-exit group SIGKILL is now best-effort: if ps -t fails or the group has left the tty, the leftover group is not swept and killRemainingProcessGroups returns without another enforcement step. This is the correct direction — it removes the recycled-pgid hazard — and the case is rare, so it does not block. Flagging only so the behavior is explicit.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Sync update (
|
There was a problem hiding this comment.
Important
The full-process-table fallback added by cd34afe cannot match the PTY on any host that triggers it, so on those hosts it returns an empty list and sweeps nothing, while the new test asserts a scenario no real host produces. The primary macOS fix (the direct ps -t path) is unaffected.
Reviewed changes
The delta since the prior pullfrog review at babdabc is commit cd34afe.
- Extracted the terminal-group reader —
readPosixProcessGroupsOnTerminal(plusisSafeTerminalNameandparseProcessGroupIds) moved out ofposix-pty-process-groups.tsinto the newposix-process-groups-on-terminal.tsand re-exported for existing callers. - Added a full-process-table fallback — when
ps -t <tty> -o pgid=is rejected,readGroupsOnTerminallatchesterminalSelectionUnsupportedand readsps -e -o pid,pgid,tty,statinstead, matching rows by terminal name. - New coverage — a case asserting the fallback returns the group from a
ttys001-form table, plus tests for the unsafe-name and unreadable-tablenullpaths.
I re-ran the changed suites (posix-pty-process-groups 45, subprocess-handle-group-signal 4, session-termination-controller 9, terminal-session-teardown 14 — all pass) and confirmed the extraction preserves the non-fallback behavior.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
cd34afe to
bd879f6
Compare
Sync update (
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The delta since the prior pullfrog review at cd34afe (commits 79d0386 and bd879f6, replayed by the rebase) closes the one open finding — the -t-rejected full-table fallback could not match the tty form any real host emits.
- Made the full-table fallback match real
psoutput —terminalNamesnow also emits the/dev/-relative form (pts/100for Linux procps) and the BusyBoxmajor,minorform derived fromstatSync(ptsName).rdevthroughposixBusyboxTtyName, so the fallback matches both procps and BusyBox instead of returning an empty list. - Deduplicated the shared
pshelpers —POSIX_PS_ALL_PROCESS_ARGS,posixProcessTableSpec,readPosixProcessTableOutput, andrejectedPosixPsSelectornow live once inposix-process-groups-on-terminal.tsand are imported byposix-pty-process-groups.ts;rejectedPosixPsSelectorreturns the rejected flag ('p' | 't') rather than a boolean. - Added fallback coverage — cases for the
pts/Nand BusyBoxmajor,minorforms, each of which fails without the fix.
I verified the BusyBox column format against upstream source (procps/ps.c func_tty prints %u,%u; libbb/procps.c applies the glibc major/minor split), so the fallback now models a real -t-rejecting host. Re-ran the four changed suites: 74 passed. The primary macOS ps -t path is unchanged.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
… terminal An Orca close sent SIGKILL to the PTY process groups, so Claude SessionEnd never ran. SIGTERM those groups first and keep the grace inside the existing physical-exit budget. A process that is still alive is still SIGKILLed. Plain shells and Windows stay on the direct force-kill.
A shell can die on SIGTERM while a child group ignores it. Treating that root exit as a finished close skipped the group SIGKILL. Co-authored-by: Cursor <[email protected]>
The root exit marks the handle dead before listeners run, so the close-time group SIGKILL returned without reaching the OS. Remember the groups captured with SIGTERM and signal those ids after exit. A rejected force-kill retry also stays inside the caller's close budget.
A group id captured at SIGTERM can be reused after the root exits. The close-time SIGKILL now reads the terminal process table and signals only ids that are still attached. An unreadable table signals nothing.
…ejects -t Co-authored-by: Cursor <[email protected]>
Linux ps prints pts/N and BusyBox prints the device major,minor. The full-table fallback compared only the path and its last segment, so those rows never matched and a child that ignored SIGTERM was left running. The shared ps reader now lives with that fallback.
bd879f6 to
e07f4d5
Compare
|
Thanks @innocarpe! On the default daemon backend this was already fixed by #22232 (v1.4.210, SIGTERM + grace before SIGKILL — we confirmed SessionEnd fires on macOS and Linux). The one remaining SIGKILL-first path was the in-process local provider, fixed via #33367 (credited with Co-authored-by). This branch also made agent closes ~2s slower on Linux and conflicts with current main, so closing as superseded. |
…r close SIGKILLs them (#33367) Local (in-process) PTY provider: an immediate close now SIGTERMs descendants and waits up to the shutdown grace before SIGKILL (same as the daemon path since #22232), so Claude's SessionEnd hooks run. Refs #23865, #22039. Supersedes #24314. Co-authored-by: innocarpe <[email protected]>

Description
Closing a terminal from Orca sent
SIGKILLto the PTY process groups. Claude Code's SessionEnd hooks run onSIGTERMorSIGHUP, so an Orca close skipped them./exitstill ran the hooks. On macOS the PTY root islogin, so a signal to that pid does not reach the agent in the foreground group.Focused fix
SIGTERM, waits up to 2 seconds taken out of the existing physical-exit budget, thenSIGKILLif the process is still alive.Preserves
SIGKILLed, and the two waits together stay inside the caller's timeout.forceKillitself does not wait, so worktree removal's fail-closed path is unchanged.Evidence
node node_modules/vitest/vitest.mjs run --config config/vitest.config.ts src/main/daemon/session-termination-controller.test.ts src/main/daemon/terminal-session-teardown.test.ts src/main/runtime/terminal-close-slow-agent-exit.test.tsUser-regression-tradeoffs
SIGKILL, inside the budget that close already had. Plain shells are unchanged.Fixes #23865