Repository navigation
fix(worktrees): close an idle structured chat on delete instead of refusing - #19762
Conversation
…fusing `worktree rm` refused whenever any structured chat session was attached to the workspace, so an idle Codex/Claude chat that had already answered was harder to delete than a terminal actively running the same agent. The PTY sweep stops every terminal it owns and refuses only for the ones whose exit it could not verify. The structured sweep refused on `live` alone and never attempted the close, which ran only under force. `live` is lease state — a provider child is attached — not work in flight, so it was never the right proxy for "you would lose something". Close first, refuse only on what did not settle. The refusal now means the same thing the unverified-PTY one does, so the toast takes that wording.
|
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⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughWorktree teardown now fences structured sessions to the resolved execution host. It starts structured-session closure before PTY sweeps and joins it afterward. Failed or timed-out closes are classified as live or unverifiable. Removal messages and force-delete behavior now distinguish these states. Tests cover host isolation, timeout handling, provider aggregation, and concurrent sweeps. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to Worktree deletion now attempts to close matching structured chat sessions before removal and accurately distinguishes sessions still running from closures that cannot be confirmed. Current coverage supports the changed deletion and warning behavior with no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the bug, cause, implementation, behavior changes, testing, and known limitations. However, it omits the required template sections and information, including a Resolution Restructure the description using the repository template. Add the required
✨ Finishing Touches 💡 1📝 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: 37308494-89d5-44d6-a3a3-947d65ac792d
📒 Files selected for processing (5)
src/main/runtime/structured-session-worktree-teardown.test.tssrc/main/runtime/structured-session-worktree-teardown.tssrc/main/runtime/worktree-teardown.tssrc/renderer/src/components/sidebar/delete-worktree-toast.tssrc/renderer/src/i18n/locales/en.json
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.
ℹ️ No critical issues — one minor suggestion inline, plus a nitpick.
Reviewed changes
- Close-before-refuse structured sweep —
sweepStructuredSessionsnow closes live sessions on the ordinary destructive path and refuses only when a close does not settle, matching the PTY sweeps' stop-first-then-verify bargain. - Toast copy — the
running-agent-sessiontoast now uses the "could not confirm … has closed" wording, mirroringunstoppedPtyunder the same i18n key. - Tests — the four refuse-on-existence cases now seed a stuck close, and an ordinary-removal-closes case is added; force, folder-workspace and reconciliation paths stay covered.
ℹ️ Nitpicks
- The CLI refusal still reads "Refusing to remove worktree with running agent sessions … 1 running agent session (claude)" (
RUNNING_AGENT_SESSION_REMOVAL_PREFIXplusdescribeLiveStructuredSessions), while the toast was changed to "could not confirm … has closed". "Running" sits oddly against the PR's own "live is lease state, not work in flight" argument once the refusal is fired by an un-settled close rather than a proven-running session.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Review follow-ups on the close-first structured sweep. The close-first direction is unchanged; four things it got wrong are not. Host fence. `listLiveStructuredSessionsForWorktree` matched on `location.workspaceId` alone, and a `repoId::path` id names a DIFFERENT workspace on every host (STA-4343). Once the sweep started closing rather than refusing, deleting a local workspace could close a live chat on an SSH or paired-runtime copy of the same id. It now takes the same two host fields the PTY sweeps already fence on, compared against the session's own `location.executionHostId`; neither field set means this machine. Shared budget. The close ran to completion before the first PTY sweep was constructed, and it is serial with a provider round trip per session — so a slow one spent the whole budget and the sweeps then rejected with a timeout for a stop they never attempted. It is now issued first but joined before the verdict, so the agent plane is still asked ahead of the terminal plane while the two share the clock. Timeout wording. The close raced the deadline fail-closed, and that sentinel carries the PTY timeout prefix, which the classifier reads first — so a wedged session close refused in terminal wording and refused identically again under the Force Delete meant to clear it (#11960). A close that ran out of time is now a session the removal could not confirm closed, which is what the refusal already words. Tracked, so a forced removal still waits out the abandoned-sweep grace before deleting files. Verdict fidelity. `closeStructuredAgentSessionChild` re-observes after the close, and that verdict was being discarded — so a session Orca watched stay attached and one it merely could not reach produced the same message, while the toast asserted "could not confirm" for both. `removal.ts` documents flattening those two as the thing not to do. The unclosed sessions now carry their post-close status, the detail uses the shared `still live:` marker, and the toast branches on it like the PTY pair above it. Also: the close takes the enumerated list instead of re-deriving it, so it no longer runs every liveness observation twice or names a session it never touched; and both teardown log lines count structured closes, since closing a chat is now an ordinary outcome of this verb.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Host-fenced the structured sweep —
listLiveStructuredSessionsForWorktreenow filters onlocation.executionHostId, resolved fromresolvedRuntimeEnvironmentId/resolvedConnectionIdwith the same precedence as the PTY fence (worktree-pty-host-fence.ts), so arepoId::pathid no longer closes a like-named chat on another machine. - Bounded the close without the PTY-timeout sentinel —
sweepStructuredSessionsracescloseStructuredSessionsForWorktreeagainstsettleBeforeDeadlinewith a fallback (unverifiable) instead ofdeadlineError, so a wedged close refuses inrunning-agent-sessionwording rather than classifying asunstopped-pty; the prior review's timeout-misclassification finding is resolved. - Worded the refusal by post-close verdict —
describeUnclosedStructuredSessionsdistinguishes "still live:" from "could not confirm these closed:", the sharedSTILL_LIVE_DETAIL_PREFIXbacks a newisProvenLiveStructuredSessionRemovalError, and the delete toast splits intorunningAgentSessionLive/runningAgentSession. - Counted structured stops in the teardown log — both the IPC and pty-foreground kill paths now include
structured=in their summary.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
The structured sweep re-observes after a close that reported `stopped: false`, but folded a proven `exited` into `unverifiable` — so a close that threw past its own observation, or one whose death evidence landed a beat later, refused a delete over a child that is demonstrably gone. That is the defect this sweep exists to remove, and the PTY gate it mirrors never refuses on a proven exit. Take the proof, and run the tab retirement the close skipped when it gave up: a chat tab left behind re-attaches a released session pointing at a workspace that is about to be deleted.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Took a proven
exitedover a failed close's verdict —closeStructuredSessionsForWorktreenow re-reads the post-close observation and, when it isexited, retires the session's chat tab and counts it closed, rather than folding a demonstrably-gone child intounverifiableand refusing the delete. - Added a discriminating regression test — a
settledThenThrowsfixture arm models a close that records death evidence and then fails, and the newtakes the proof when a failed close is re-observed as exitedcase pins the refusal-vs-close ordering; reverting this one lever fails the case with the field refusal.
The change is the direct analogue of the guarantee closeStructuredAgentSessionChild already makes on its own success path: past the proof of exit, it retires the tab. The re-read pulled that retirement into the sweep so a close that gave up before its own retirement step no longer refuses over a provably-gone session.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Validated 6d05fb8 ( The disposable The workspace’s sidebar Delete action opened this confirmation dialog. The completed Codex chat remains open behind it, and the dialog identifies the workspace folder that will be removed. Immediately after clicking Delete Workspace, the target workspace is gone from the sidebar and its chat tab is closed. No running-agent-session refusal or other toast appeared; a toast observer installed before confirmation recorded no notifications. The settled view shows only the fixture’s primary |
…live ones The refusal named only the proven-live subset when any session was live, so a sweep that left one attached and two unconfirmed told the user "1 agent session (claude)" while three were about to be discarded — and dropped the providers of the ones it hid. The PTY sibling may drop everything outside its live list because a fresh inventory PROVED those exited; nothing proves that here, so both groups are counted. The `still live:` marker still leads, so the delete toast keeps showing the stronger warning. Also carries the structured close count through the forced-removal early return: that path skips the per-PTY verdict, not the sweep that already ended a user's chats, so the removal log claimed `structured=0` for chats it had just closed.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Named both unclosed-session verdicts —
describeUnclosedStructuredSessionsnow reports theunverifiablesessions alongside theliveones, so a mixed refusal names both groups instead of silently dropping the unconfirmed subset when a proven-live session leads the message. - Propagated the structured close count — the
forced.incompleteearly return inkillAllProcessesForWorktreenow carriesstructuredStopped, so a forced removal whose PTY sweep failed still logs the chats it closed instead of reportingstructured=0.
The split message keeps isProvenLiveStructuredSessionRemovalError leading with the stronger warning (so the delete toast stays correct in the mixed case), and the new tests are discriminating — names the unconfirmed sessions too fails against the previous drop-only-live wording, and still reports what it closed fails against the bare forced.stopped return. Both changed test files pass locally.
DeepSeek Pro (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: d851c05e-9010-4d78-a474-2f58af0407d7
📒 Files selected for processing (3)
src/main/runtime/structured-session-worktree-teardown.test.tssrc/main/runtime/structured-session-worktree-teardown.tssrc/main/runtime/worktree-teardown.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| return `could not confirm these closed: ${countStructuredSessions(unconfirmed)}` | ||
| } | ||
| const live = `${STILL_LIVE_DETAIL_PREFIX} ${countStructuredSessions(stillLive)}` | ||
| return unconfirmed.length === 0 | ||
| ? live | ||
| : `${live}; could not confirm these closed: ${countStructuredSessions(unconfirmed)}` |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Use a localization payload for the new closure detail.
could not confirm these closed reaches the desktop toast and CLI output. A raw string prevents the renderer from localizing the new message or using named placeholders for the count and providers. Keep the classifier marker stable, but return an intent and named values that each surface formats through its localization path. Update src/main/runtime/structured-session-worktree-teardown.test.ts to assert the intent and values instead of the English sentence.
Based on learnings: For newly added user-facing strings in TypeScript and TSX files, use intent-named localization IDs with named interpolation placeholders.
Source: Learnings
…oes not have The structured sweep splits its post-close verdict in two on purpose: "we watched it stay attached" and "we could not confirm it closed" are different things to waive, and `removal.ts` keeps a marker and a matcher together so the delete toast can tell them apart. The force-path warn then appended "still attached" to whichever verdict it got, so a removal forced over a close that merely ran out of time logged that Orca had seen the session running. That line is the only record a forced removal leaves of a child left pointing at a deleted `cwd`, so it is the one place the two must not be flattened. Carry the verdict verbatim, the way the unstopped-PTY warn above already does.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Stopped the forced-removal warn from asserting a live verdict —
sweepStructuredSessions'sconsole.warnnow emits…${UNSTOPPED_PTY_DETAIL_SEPARATOR}${describeUnclosedStructuredSessions(unstopped)}instead of appendingstill attached, so an unprovencould not confirm these closedverdict is no longer worded as a session Orca watched stay attached. - Pinned both post-close verdicts in the warning — the test file's new
structuredSessionWarninghelper isolates the structured sweep's warn from the PTY-sweep warn, and the forced-removal cases now assertstill live: 1 agent session (claude)for the live arm andcould not confirm these closed: …with nostill attachedfor the timeout arm.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…xpires The structured close loop is serial, so the shared sweep budget can expire part-way through it. The timeout fallback was assembled by the caller and could only name the whole list: sessions this removal had already closed were reported as unclosed, named in the refusal the user reads, and logged as `structured=0`. The loop now records progress into a structure the timeout path reads, so both the refusal and the count say only what was observed. A session with no recorded outcome reports `unverifiable` — the same verdict as an attempted close that stayed unproven, because "never asked" and "asked, unconfirmed" are both exactly "not observed exited", and neither may claim `live`. The loop also checks the deadline before each close, so one slow provider round trip no longer starves every session behind it. It stops ISSUING closes; an in-flight one is left to finish, since nothing here can cancel a round trip. The structured host fence now reuses the PTY fence's own type instead of a look-alike that read `undefined` as local while the other read it as match-all, with both claiming the same precedence. `null` means this machine on both sides; ABSENT stays narrowed to local here, documented and pinned, because a single-host-id comparison cannot express match-all. Also pins a tradeoff that was accepted rather than wanted: the PTY sweeps run concurrently with the structured close, so a removal that refuses over a stuck session has already killed that workspace's terminals.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Progress-accounted structured sweep —
closeStructuredSessionsForWorktreenow writes its outcome into a mutableStructuredSweepProgressas the serial loop runs (and takes the absolutedeadline), sosweepStructuredSessionsreads the actualclosed/unstoppedcounts offprogressinstead of a whole-list fallback that reportedstructured=0and named every session unverifiable when the budget expired mid-loop. - Bounded the close loop — the loop stops issuing new closes once the budget is spent, leaving only the in-flight close to finish, so one slow provider round trip no longer starves every session queued behind it.
- Shared the PTY fence type —
StructuredSessionHostFenceis nowWorktreePtyHostFence(resolvedConnectionId?: string | null), withnull/undefinedcollapsing to local instructuredSessionTeardownHostIdand the absent-fence divergence documented and pinned by test.
ℹ️ Force delete stops closing sessions queued behind a slow close
The new if (Date.now() >= deadline) return is a deliberate reversal of the loop's old run-to-completion behavior, and on the ordinary path it is strictly better (the removal refuses, so nothing should keep closing). On the force path it has one narrow cost: settleSweepsForForcedRemoval's awaitAbandonedSweeps grace used to let a mid-loop close finish closing the sessions queued behind a slow-but-eventually-completing one, and now those queued sessions are left un-closed, orphaning their provider children against a deleted cwd. This only bites when a single close outlives the 10s budget while more sessions wait behind it, and force is the explicit escape hatch, so I don't think it blocks — flagging so the tradeoff reads as a confirmed decision rather than an accident.
Technical details
# Force-path orphan window from the close-loop deadline check
## Affected sites
- src/main/runtime/structured-session-worktree-teardown.ts:231 — `if (Date.now() >= deadline) return` stops issuing closes at the budget, leaving `progress.sessions.slice(settled)` un-closed.
- src/main/runtime/worktree-teardown.ts:341 — the tracked close is no longer run-to-completion, so `awaitAbandonedSweeps` (forced-sweep-settlement.ts) has nothing left to wait out on the structured sweep.
## Required outcome
- Confirm the force-delete tradeoff is intended: sessions queued behind a close that outlives the budget are now orphaned instead of closed during the abandoned-sweep grace.
## Open questions for the human
- Should the force path keep the serial loop running (bounded by the grace) while the ordinary path stops at the deadline?DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Review status — ready to mergeReviewed at The PR's direction was assessed independently and kept: Defects found and fixed during review
Items 2, 3, 7 and 8 were introduced by earlier review passes, not by the original commit — which is the argument for running the loops to convergence rather than stopping at the first clean-looking result. The final pass found nothing. Live validationElectron QA at That Commits after that QA touch only refusal wording, a Not covered by QA: Claude (only Codex was exercised), mid-turn active sessions, SSH, and folder workspaces. Behaviour changes worth explicit sign-off
Correction to the description
True on the desktop path, not on the CLI SSH route: Known, non-blocking, not fixed here
Validation performed
|
…t land `closeStructuredAgentSessionChild` hides the session's chat tab before it issues the close, so every failure past that point left a refused delete having still taken the tab out of the durable restore index. The conversation survived under `userData`, but nothing brought the tab back at the next launch. Both failure shapes now roll the hide back: `host.close` throwing, and the post-close observation coming back not-`exited`. The restore is gated on the visibility read taken BEFORE the hide, so it never publishes a tab for a session that was already hidden, and on a fresh observation, so it never resurrects one for a child a throwing close still took with it — which is what the worktree sweep reads when it counts such a session closed. It cannot throw out of the function, so the caller's original reason is still what the user is asked to act on.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Restored the chat tab after an unsettled structured close —
closeStructuredAgentSessionChildnow reads the session's persisted tab visibility before the hide and, when the close throws past it or the post-close observation is notexited, restores the tab viarestorePersistedTabVisibility, which re-observes first so a close that threw past its own proof (session demonstrably gone) stays retired. - Added a discriminating regression test — the new
structured-agent-session-close.test.tscovers the success path and every failure shape (close throws, stuck close, throws-past-proven-exit, already-hidden tab, failed visibility write, failed restore, unreadable index, no host), pinning the exactsetSessionTabVisibilitycall sequence for each.
The rollback reads visibility before the hide and only restores what was actually visible, so it cannot resurrect a user-closed tab, and its re-observe guard keeps it from republishing a tab for a session the sweep already proved gone.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Re-validation at 5e62f61 (5e62f61), rebuilt from The actual teardown line was: Before deletion: The real Delete Workspace confirmation names the disposable workspace and its folder. Deletion was confirmed through this UI button. The first screenshot immediately after confirming catches the “Deleting…” transition, with the completed chat still painted. The DOM read immediately after this screenshot briefly contained “Could not load conversation / RuntimeRpcCallError: agent_session_ownership_unknown”; that transient inline message was not captured in the image. A toast observer recorded no toast, including no running-agent-session refusal. Deletion completed successfully: the workspace is gone from the sidebar and both chat tabs are gone from the rendered tab bar, leaving the fixture primary workspace. No toast appeared; Git also lists only the fixture primary worktree. After stopping and relaunching the app against the SAME isolated profile, the rendered UI still shows only main and no chat tab. The message-bearing chat Coverage: local macOS, Codex, completed turn, successful workspace deletion, and same-profile app restart. Claude, active turns, SSH, and folder workspaces were not exercised. No source changes or code push. |
…e the workspace The rollback added for a refused close ran on every unproven close, including the two shapes of removal that cannot refuse. Force Delete warns and deletes the checkout; a folder-workspace removal never refuses at all. Putting the tab back on those paths leaves a durable restore-index entry for a workspace that is then gone, and the chat republishes at the next launch pointing at it — the outcome this sweep exists to remove. The close now takes `restoreTabOnUnprovenClose`, on by default so `worker-stop` and `worker-release` keep the rollback, and the teardown sweep passes it only when the removal can still refuse. Second hole, same chain: `host.close` can return before the child's exit is recorded, so the close's own observation reads unverifiable and restores the tab, while the sweep's re-read one store write later proves the exit and counts the session closed. The two observations straddle that write and disagree. The sweep now re-drops the tab reference when it takes that proof, and the comment claiming the re-observation alone covers this is corrected.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Gated the chat-tab rollback on a removable refusal —
closeStructuredAgentSessionChildtakesrestoreTabOnUnprovenClose(default on, so the orchestration stop path is unchanged), and the sweep passesmayRefuse === true— the same condition as the refusal atworktree-teardown.ts:360— so a force or folder-workspace removal no longer re-publishes a tab for a workspace it is about to delete. - Dropped the restored tab when the sweep proves the exit — the re-read-
exitedbranch now also callsdropDurableChatTabReference, clearing the durable reference the rollback had re-added for a session the sweep counts closed (the two observations straddle the restore's store write). - Added four discriminating tests — ordinary-refusal restore, force no-restore, folder-workspace no-restore, and the restore-then-drop disagreement, backed by new
visible/exitsDuringTabRestorefixture arms.
The mayRefuse mapping exactly mirrors the sweep's refusal condition, so the tab is only ever restored when the workspace (and its tabs) actually survives. The regression this fixes — a durable tab reference to a workspace that was just deleted — is the precise outcome the sweep exists to remove, and the rollback's own re-observe guard is preserved intact.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…would not load Deleting a workspace now closes the structured chats inside it, and the chat pane outlives that close by a few frames. Every read it makes in that window — `agentSession.history` on refresh, `agentSession.subscribe` on reconnect — resolves through the host's `requireSession`, which refuses with `agent_session_ownership_unknown` for a session it no longer holds. The pane turned that into its terminal error surface, so an ordinary delete flashed `Could not load conversation` over the transcript before the tab retired. That code, raised by a READ, never means the transcript could not be read. It means this host has no session object by that id: one it has just closed, or one it has not attached yet, since the surface's hold is what attaches a session at all. Both windows end on their own. The genuinely latched lease — Orca cannot prove the previous owner exited — reaches the client through the acquisition path instead, so narrowing on the code costs a read no real diagnosis. So the read transport classifies before it reports: an unattached refusal stays on the reconnect loop it is already the subject of, and the pane keeps the transcript it has. It is a window, not a mute. A read still refusing that way past the grace is no longer transitional, and the pane is owed the failure rather than a spinner that never resolves. Every other failure still surfaces immediately, unchanged. The refusal code now has one definition, shared by the host that raises it and the client that narrows on it, so the two cannot drift into a red error nobody meant. Deliberately NOT changed: the order of teardown. The tab is retired after the close proves, not before it, because a close that does not settle has to put the user's chat tab back — the rollback this PR already establishes. Retiring the pane first would unmount it ahead of a close that may be refused, so the pane instead treats a session that has gone as a neutral terminal state. Mobile's structured chat reaches the same reducer but has no reconnect loop, and its hold refusal is what carries the diagnosis there, so the grace does not transfer; it keeps reporting as before.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (since prior review at 5292373909)
- Shared the unattached-read refusal code —
AGENT_SESSION_UNATTACHED_REFUSAL_CODEnow has one definition insrc/shared/structured-agent-session-read-refusal.ts, and the host'sAGENT_SESSION_NOT_ATTACHEDuses it, so the host that raisesagent_session_ownership_unknownand the client that narrows on it can no longer drift apart. - Gated the pane's error on a grace window —
reportReadFailurein the read transport now classifies before it reports: an unattached refusal stays off the pane and on the reconnect loop it is already the subject of, surfacing as an error only once it outlivesAGENT_SESSION_UNATTACHED_READ_GRACE_MS. A closing chat no longer flashesCould not load conversationin the frames before its tab retires. - Suppressed the same refusal at the page level —
loadOlder's catch no longer errors the pane on an unattached older-page read, matching the transport's transitional treatment so a page that lost the close race doesn't repaint the pane red. - Added discriminating tests — the surface-lifetime test pins the host contract (
history/subscribethrow the code after a close); the transport tests cover grace expiry, grace restart once a read lands, immediate surfacing of unrelated failures, and raw-stream-payload classification; the hook test distinguishes an unattached page refusal from a genuine failure.
The grace is a window, not a mute — a read still refusing past 5s is owed the failure — and the genuinely latched lease reaches the client through the acquisition path rather than the read, so narrowing on the code costs a read no real diagnosis. The design reads as sound and well-bounded.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Re-validation at 0e041d4. The purpose of this run was to confirm that the red structured-chat load error no longer flashes while deleting a workspace. Result: PASS for the targeted flash. A MutationObserver plus a 50 ms polling sampler recorded 14 distinct document.body.innerText states and every notification-region child across the transition; it recorded 0 toast events. Literal search result: Could not load conversation = false; agent_session_ownership_unknown = false. The normal read path also passed: a new host-owned Codex Chat rendered the prompt and the real reply “Hi!”. The workspace disappeared from the sidebar and store, its folder and git worktree were removed, and the teardown log was:
After restarting Orca against the same isolated profile, neither the deleted workspace nor its Codex Chat tab reappeared. 1 — Read-path check: the answered Codex Chat is visibly rendered before deletion. 2 — Delete confirmation: the answered Codex Chat remains the visible pane behind the confirmation dialog. 3 — Initial delete frame: immediately after confirmation, the workspace is marked Deleting while the healthy chat transcript remains visible; no red load error or toast is present. 4 — One-second delete frame: the transition remains clean one second later. 5 — Later delete frame: the structured chat pane has closed and the workspace is still marked Deleting, with no load error or toast. 6 — Delete complete: the disposable workspace is gone from the sidebar and Orca has returned to the original worktree. 7 — Same-profile restart: the deleted workspace and its Codex Chat tab remain absent after relaunch. |

















Status: ready to merge. Reviewed over eight adversarial passes with live Electron validation at the final head. CI green. Follow-up in #19970.
The bug
You open a Codex or Claude chat in a workspace, it answers, you're done with it. You try to delete the workspace and Orca refuses: "This workspace still has running agent sessions."
Meanwhile, a workspace whose terminal is actively running the same agent deletes without a word — because that path kills the terminal for you.
That's backwards. The thing you were done with blocked you; the thing still working didn't.
How deleting a workspace used to work
Deleting a workspace sweeps every process Orca can attribute to it. There are three places a terminal can be registered — the renderer's view of the app, the terminal provider's own session list, and a local registry — and the delete sweeps all three, killing what it finds. If it kills something and then can't confirm it actually died, it stops and refuses, because deleting the files out from under a live process is how you get a program running against a directory that no longer exists.
Native chat sessions (Codex Chat, Claude Chat) appear on none of those three lists. They have no terminal. So all three sweeps found nothing, reported success, and the delete proceeded — leaving a chat's underlying process running with its working directory deleted.
A guard was added for that: a fourth check that looked for chats in the workspace and refused the delete if it found any attached. It never tried to close them. Closing only happened under
--force.Why that guard was wrong
It refused based on whether a chat was attached, not whether it was busy.
"Attached" just means a process is currently backing the chat. An idle chat that answered a greeting an hour ago is attached in exactly the same way as one mid-answer. So the guard couldn't tell "you're about to lose work" from "this panel is open" — and it chose to block on both.
The other three sweeps never worked that way. Each one issues a real stop, then checks what actually stopped, and refuses only for what it couldn't confirm. Refusing there means we tried and couldn't prove it worked — never something is attached.
How it works now
The fourth sweep behaves like the other three: it closes the chats, then checks each one actually closed.
No new capability was needed. The code to close a chat and verify it stopped already existed; it was just locked behind
--force.The practical result: an idle chat is no harder to delete than a terminal running the same agent. Which was the point.
What else the review found
Reworking the sweep surfaced several problems, fixed in the same PR:
Behaviour changes worth knowing
orca worktree rmand desktop Delete now close an attached chat instead of refusing. This is the point of the PR, but it is a new outcome on a destructive command.Existing "you might lose work" protection is unchanged: the uncommitted-changes confirmation still runs before any of this.
Testing
Known, not fixed here
A chat with no process backing it — because you'd switched away from it, or restarted the app — isn't seen by this sweep, so its tab can reappear after deletion pointing at a workspace that's gone. This behaves identically on
mainand is not caused by this PR. Fixed separately in #19970.