fix(worktrees): stop runtime-stamped folder PTYs and trust the resolved host on folder deletion - #12427
fix(worktrees): stop runtime-stamped folder PTYs and trust the resolved host on folder deletion#12427brennanb2025 wants to merge 1 commit into
Conversation
…ed repo host on folder deletion Two folder-workspace gaps in the #12388 fence audit, with red-before proof for each: removeManagedWorktree treated a runtime stamp as an external desktop-mirror namespace and skipped the selected runtime server's local PTYs, and desktop folder deletion trusted collision-prone global worktree metadata over the already-resolved repo host. Authored by the post-merge audit reviewer; committed by the coordinator for the gated follow-up PR.
📝 WalkthroughWalkthroughFolder workspace PTY cleanup now uses resolved repository or connection ownership instead of persisted metadata. Runtime deletion selects a local or SSH provider from 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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.
🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)
23514-23532: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCorrect fix; consider deduplicating the repeated connectionId→provider resolution pattern.
The change correctly derives PTY ownership from
repo.connectionIdalone, treating only a direct SSH connection as external. This matches the rationale in the added comment: thisOrcaRuntimeServiceinstance is itself the selected runtime forexecutionHostId: 'runtime:X'repos, so such repos' PTYs already live inthis.getLocalProvider()'s namespace.This brings the folder-repo branch in line with two other call sites in the same file that already use the identical
connectionId → sshProvider ?? localProviderpattern with matchingincludeProviderInventory/includeLocalRegistrygating:
stopPtysForDestructiveWorktreeRemoval(used for non-folder git-worktree removal).- The "repo not found" orphan branch inside
removeManagedWorktree, which derives its provider fromorphanHost?.kind === 'ssh'.The bug this PR fixes is exactly a divergence between this pattern and the folder-repo branch. With the pattern now duplicated a third time, a future change to one site (for example, adding a new host kind) risks the same class of divergence recurring in one of the other two sites.
Consider extracting a small private helper, for example
resolveWorktreeTeardownPtyRouting(connectionId: string | null): { provider: IPtyProvider | null; resolvedConnectionId?: string; includeProviderInventory?: boolean; includeLocalRegistry?: boolean }, and using it at all three call sites.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4c455f6e-9b78-4a0e-b91a-32e52cee7540
📒 Files selected for processing (4)
src/main/ipc/worktrees.test.tssrc/main/ipc/worktrees.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.ts
Summary
Fixes two folder-workspace gaps that the post-merge audit of #12388 found in the merged PTY-teardown fence, both with red-before evidence:
removeManagedWorktreetreated a runtime stamp as an external desktop-mirror namespace and skipped stopping the selected runtime server's ordinary local PTYs — a PTY leak on runtime-stamped folder removal.Authorship: the audit reviewer wrote and verified these changes in its worktree; the coordinator committed them verbatim for this gated follow-up. The deliberate residuals from #12388 (local-host fence,
stopMissingWorktreeTerminalsdirect-SSH-only scope) are unchanged on purpose — runtime-server-local PTYs are intentionally not remote-environment-prefixed there.Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildAudit-run evidence: each fix has a red-before proof (reverting the runtime-folder handling makes the runtime-stamped folder test report zero local-provider shutdowns; restoring old metadata precedence makes the SSH-folder test report zero SSH-provider lookups); green-after 1269 passed / 1 skipped across the affected suites, plus node typecheck, direct oxlint, max-lines ratchet, and diff check. The changed-code-quality wrapper alone hit its known Node 26 engine-warning JSON parser issue.
AI Review Report
This PR is itself the output of a subagents-until-clean post-merge audit of #12388 (adversarial fence verification across local/SSH/runtime hosts and folder/git worktrees). Per the standing merge gate it will additionally receive its own pre-merge review loop before merging. Cross-platform: host-kind logic only, no paths/shortcuts/shell changes.
Security Audit
No new inputs, IPC, command execution, or secrets; the changes narrow which PTYs are stopped (leak fix) and bind teardown to the resolved owner host (wrong-host fix) — both reduce blast radius.
Notes
Rides the next release train; not release-gating.