Repository navigation
Conversation
|
Warning Review limit reached
Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
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 |
Review: two defects found and fixedI reviewed this adversarially and found two bugs that let the original fix silently do nothing — including one where the exact scenario in #10562 still reproduced. Both are fixed in ELI5Think of each worktree as a room, and the terminals/agents inside it as people. When you delete a room from outside Orca ( This PR adds the missing step: before erasing the room from the map, ask the machine that owns it to clear the people out. The critical safety rule: "I can't see the room" is not the same as "the room is gone." If the SSH host is unreachable or the scan fails, Orca must assume the room is fine and touch nothing. Only a successful, authoritative scan that says "that room isn't here" is allowed to evict anyone. What I found wrong:
Defect 1 — coalesced callers purged state without ever requesting teardown
This is not a rare interleaving. Teardown is gated on Proof of bug — reverting only Zero teardown RPCs, yet Fix: the scan still coalesces; teardown now runs per caller against its own snapshot. To avoid trading one bug for N redundant host sweeps, teardown deduplicates on the request it actually produces (target + repo + connection + sorted missing IDs). Defect 2 — the authoritative recheck was served from a 30s cache
The renderer's scan uses a different 5s cache ( Proof of bug — reverting only Fix: invalidate the repo's scan cache before revalidating. Killing processes must be proven against the host now, not against a cached observation. This is scoped to the destructive path only — read-only listing keeps its cache. Proof of fixBoth regression tests fail on the parent commit and pass on
Proof of no regression
No existing assertion was changed or relaxed — the only edits to existing tests are additions. Adversarial checks that came back cleanI probed these and confirmed the existing behavior is correct — no changes needed:
One note for reviewers (not blocking)The renderer discards the teardown result and purges regardless of whether the sweep succeeded. That's the right call for UI responsiveness — but it means the sweep has exactly one chance to run, which is precisely what made Defect 2 permanent rather than transient. Worth keeping in mind for any future change to this path: there is no retry, so correctness here has to be right the first time. A follow-up backstop (e.g. reconciling on SSH reconnect, cf. #9820) would add defense in depth. |
|
The head branch
GitHub has not re-attached the PR to the restored branch, so the Files-changed tab still shows only To review the actual state, use the branch compare rather than this PR's cached diff: If the PR doesn't self-heal, closing and reopening it (or opening a fresh PR from the same branch) will re-sync the head. I didn't do either, since that's a call for whoever owns this PR — the code and branch are in their final state either way. |
Second review pass — one perf defect found and fixedRe-reviewed with a focus on performance. Found one real perf defect, fixed in Defect 3 — O(N) host enumerations per teardown sweep
So sweeping N missing worktrees costs N full host enumerations, each returning all N+ session rows: O(N) round-trips carrying O(N²) data. This is not a hypothetical batch size. It's the primary scenario in #10562 — "a CLI agent told to 'clean up workspaces' running raw git" deletes many worktrees at once, and every one of them lands in a single sweep. No layer coalesces these. Measured (30 worktrees, 80ms RTT — a normal cross-region SSH link):
The round-trip count is the load-bearing number — it scales linearly, so a 100-worktree cleanup was 100 enumerations. Wall clock understates the win because the remaining time is the Proof of bug — reverting only Fix: share one point-in-time process list across the sweep. Every worktree in the batch is already known-missing, so a single snapshot answers all of them. Two correctness traps in the fix itself, both caught by tests I wrote against itWorth calling out, because the naive version of this optimization is wrong in two ways:
Also verified the wrapper preserves Perf surfaces checked and found clean
Validation
Three new regression tests, all failing on the prior commit and passing on Branch tip is now |
|
Superseded by #11237. This PR became permanently detached from its head branch — GitHub kept it pinned at #11237 is the same branch with the complete work (5 commits, correctly synced). All review discussion from this PR is summarized in its description. |
ELI5
Think of each worktree as a room, and the terminals/agents running in it as people inside that room.
When you delete a room from outside Orca (
git worktree removein a shell, or a CLI agent "cleaning up workspaces"), Orca notices on its next look around and erases the room from its map. But nobody ever told the people inside to leave. They keep running — and now there's no door on the map to reach them. You can only find them withpson the host.This PR adds the missing step: before erasing the room from the map, ask the machine that owns it to clear the people out.
The critical safety rule: "I can't see the room" is not the same as "the room is gone." If the SSH host is unreachable or the scan fails, Orca must assume the room is fine and touch nothing. Only a successful, authoritative scan that says "that room isn't here" may evict anyone. That guard is enforced twice — once in the renderer, and again by the host, which re-checks for itself before killing anything rather than trusting the request.
Summary
Reproduction
Removing a worktree outside Orca updated the sidebar on the next authoritative scan, but the bulk purge path performed no terminal teardown. Local and SSH agents could therefore remain alive after all renderer ownership state was deleted. The new ordering waits for the host-scoped cleanup request before purging that state, while the runtime performs its own authoritative recheck before stopping anything.
Validation
pnpm typecheck:nodepnpm typecheck:webpnpm check:max-lines-ratchetgit diff origin/main...HEAD --checkTwo regression tests were added that fail on the pre-review commit and pass after it — see the review comment for the full proof-of-fix and proof-of-no-regression breakdown.
Closes #10562