Repository navigation
fix(pty): preserve child-process inspection uncertainty - #20756
Conversation
Separate foreground and child-process sampling. Sample child processes synchronously after confirming foreground availability, returning unverifiable verdicts when pty reads fail. Handle both transport loss and local read failures uniformly in the completion coordinator.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe change adds Merge Risk: 🔵 Low · up to The boolean compatibility test can pass even if it stops performing the descriptor inspection it is intended to protect. This is a bounded regression-coverage gap and is mergeable with follow-up awareness. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, the main changes, and validation commands, but it omits most required template sections, including Linked Issue, Visual Proof or an explicit N/A, Review, Agent skill upstream boundary, Notes, and the Checklist. Resolution Update the description to include all required template sections. Add the linked issue, state N/A with a reason for Visual Proof if there is no UI change, complete the testing checkboxes and platform coverage, address AI Disclosure as applicable, complete Review, confirm the Agent skill upstream boundary, add Notes, and complete the Checklist.
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
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.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 97323877-25ea-4744-9996-e3f9e93eafb0
📒 Files selected for processing (5)
src/main/providers/local-pty-child-process-verdict.test.tssrc/main/providers/local-pty-foreground-inspection.tssrc/main/providers/local-pty-provider.tssrc/renderer/src/components/terminal-pane/agent-completion-coordinator-process-cadence.test.tssrc/renderer/src/components/terminal-pane/agent-completion-inspection-result.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
Important
The new unverifiable verdict is only produced when proc.process throws, and with the shipped node-pty it does not. That would make the fix inert for the failure it targets — see the inline comment for the evidence and what to confirm.
Reviewed changes
- Local child-process verdict —
inspectLocalPtyChildProcessesreturns'children' | 'no-children' | 'unverifiable';hasLocalPtyChildProcessesbecomes a boolean adapter (=== 'children') soIPtyProvider.hasChildProcessesstays compatible. - Local
inspectProcess—LocalPtyProvidernow implements the optionalinspectProcess, reading foreground then child evidence in one call, soinspectPtyProviderProcessstops using itsgetForegroundProcess+hasChildProcessesfallback. - Renderer gating — local (
!remote) results withchildProcessEvidence === 'unverifiable'now reset pending exit confirmation and retry instead of confirming a process exit. - Tests — new
local-pty-child-process-verdict.test.tsand a parameterized cadence case for'host child-process uncertainty'.
ℹ️ probeTerminalLiveness never sees the new verdict
The workspace-cleanup liveness probe still reads the collapsed boolean (window.api.pty.hasChildProcesses), so it cannot distinguish "read it, found nothing" from "could not read it" — the same collapse the PR describes. If the symptom being fixed is premature cleanup, this guard is the other consumer worth migrating.
Technical details
# Workspace cleanup still collapses the child read
## Affected sites
- `src/renderer/src/store/slices/workspace-cleanup-local-evidence.ts:170-190` — `!hasChildProcesses && (shell || null)` → `continue` → `'idle'`; any rejection → `'unknown'`.
- `src/main/providers/local-pty-foreground-inspection.ts:43-45` — the boolean adapter discards `'unverifiable'`.
## Required outcome
- Decide whether this guard should read `inspectProcess` (which now carries `childProcessEvidence`) or stay boolean-only; document the intent either way.
## Open questions for the human
- Is workspace cleanup in scope for this PR's "premature cleanup" motivation, or is the close guard the only target?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Detect when node-pty retires the master fd (fd == -1) and return unverifiable instead of misreading the spawn file as an idle shell. Guard inspectProcess against PTY replacement mid-read to avoid pairing old foreground with replacement's children.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: af586e5f-54ad-42c3-8609-d29c83674944
📒 Files selected for processing (4)
src/main/providers/local-pty-child-process-verdict.test.tssrc/main/providers/local-pty-foreground-inspection.tssrc/main/providers/local-pty-provider.tssrc/main/pty/node-pty-master-fd-retirement.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/providers/local-pty-foreground-inspection.ts
- src/main/providers/local-pty-provider.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since the prior pullfrog review (a3f8b1c → 464328e): the fix now detects a retired node-pty master directly instead of waiting for proc.process to throw, and the local inspectProcess guards against a pane swap across its await.
- Retired-master detection — new
isRetiredPtyMasterreads node-pty's publicfdaccessor, andinspectLocalPtyChildProcessesreturns'unverifiable'when it is negative, making the previously unreachable verdict reachable for the state Orca's node-pty patch actually produces. - Pane-swap guard in
inspectProcess— captures theIPtybefore the foreground await and returns'unverifiable'when the map now holds a different instance, so one pane's foreground is never paired with its replacement's children. - Tests — the new
registerRetiredPanehelper spawns a realnode-ptyand asserts its silent spawn-file answer, so the'unverifiable'path is exercised against the shipped runtime rather than a throwing mock; apty-swappedcase covers the identity guard.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: de43750a-abd9-4f9c-88c0-540e83ac4a86
📒 Files selected for processing (2)
src/main/providers/local-pty-child-process-verdict.test.tssrc/main/providers/local-pty-foreground-inspection.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/providers/local-pty-foreground-inspection.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since the prior pullfrog review (464328e → 30eb2a9): a single test-only hardening, no production-code change.
- Deterministic retirement wait —
registerRetiredPaneinlocal-pty-child-process-verdict.test.tsreplaces the fixed 400 mssetTimeoutwithvi.waitFor(() => isRetiredPtyMaster(term)), so the fixture waits for the actual fd retirement rather than racing a wall-clock delay.
Verified locally: pnpm test src/main/providers/local-pty-child-process-verdict.test.ts → 13 passed (retired-master cases now resolve in milliseconds instead of a flat ~405 ms). No specialists dispatched — the delta has no behavioral surface beyond the fixture.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
* fix(pty): preserve unverifiable local child reads * fix(pty): make child-process inspection synchronous Separate foreground and child-process sampling. Sample child processes synchronously after confirming foreground availability, returning unverifiable verdicts when pty reads fail. Handle both transport loss and local read failures uniformly in the completion coordinator. * fix(pty): handle retired masters and pane instance swaps Detect when node-pty retires the master fd (fd == -1) and return unverifiable instead of misreading the spawn file as an idle shell. Guard inspectProcess against PTY replacement mid-read to avoid pairing old foreground with replacement's children. * fix test * fix tests

When a local PTY closes while its process descriptor is being read, the inspection can be temporarily unreadable. Treating that read as “no children” can incorrectly classify a live or closing pane as idle and trigger premature cleanup.
This PR:
unverifiablechild-process verdict for local PTYsValidation:
pnpm test src/main/providers/local-pty-child-process-verdict.test.ts src/renderer/src/components/terminal-pane/agent-completion-coordinator-process-cadence.test.tspnpm tcpnpm run check:code-quality:changed