Repository navigation
fix(editor): evict stale mirrored file tabs - #21363
Conversation
|
This run was cancelled 🛑 The workflow was cancelled before completion. Please check the link below for details. |
|
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 (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe retry hook now accepts a Priority: ⚪ Not assessed Merge Risk: ⚪ Minimal · up to The exhausted selector-not-found path closes the intended mirrored tab through the established cleanup action. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
This reverts commit 07e8c85. The eviction keys on `selector_not_found`, which this repo documents twice as UNKNOWN rather than absence: - `remote-browser-stream-errors.ts`: "it means 'I could not resolve this right now', which is UNKNOWN, not proof the target is gone. Its producer is a live worktree scan behind a 1s-TTL cache ... a slow scan can surface it transiently. Treating that as permanent would strand the pane forever, which is the exact bug this file exists to prevent." - `web-runtime-session-tab-lifecycle.ts`, added by #21277: "'selector_not_found' is a transient worktree resolver state (e.g. during scans or cache warm-up) and must not become a durable close tombstone." Two unambiguous absence codes exist for this purpose -- `tab_not_found` and `terminal_tab_not_found` -- and #21277 had just finished excluding `selector_not_found` from them. This keyed on the excluded one. Consequences, after roughly 3.75s of retries: 1. `closeFile` deletes `editorDrafts[fileId]` with no dirty check and no confirmation, so a transient resolver blip discards unsaved edits. 2. `closeFile` calls `notifyHostOfMirroredEditorClose`, so the host closes its copy too -- the eviction is not local and not recoverable. The `!ownerNotReady` guard does not cover this: `ownerNotReady` means the host is still connecting, while `selector_not_found` is emitted for a cold resolver cache or an unhydrated catalog, which is a different state. #21041 is still open. A correct fix keys on the two definitive absence codes, refuses to evict a tab that has a draft, and has a test proving a dirty mirrored tab survives `selector_not_found`.
…ful terminal state (#21375) * fix(editor): keep an unresolvable mirrored file tab open with a truthful terminal state A host-mirrored file whose read keeps answering `selector_not_found` used to sit on the raw code forever (and, in the reverted #21363, was closed outright, discarding drafts). `selector_not_found` is the host's "could not resolve right now", not proof the workspace is gone, and the file-read path has no definitive absence code. Bound the retries as before, then swap in a truthful terminal message with Retry and Close tab. The tab is never closed automatically; Close routes through the unsaved-changes queue so a dirty draft is confirmed. Fixes #21041 * fix(editor): classify selector_not_found by RPC code, not message text Preserve `RuntimeRpcCallError.code` on `FileContent.loadErrorCode` and gate the host-unresolved terminal transition with `hasRuntimeRpcErrorCode`, so a host that sends `{ code: 'selector_not_found', message: 'Selector not found' }` reaches the same truthful state as one that puts the bare token on the message. Also drop the Close action on inline conflict-review rows, which are not open tabs and would have been a dead control. * fix(editor): localize the host-unresolved copy by sentinel, and pin the token matcher Separate the terminal state's comparison key from its display text: the retry hook stores `WORKTREE_HOST_UNRESOLVED_CODE` on `loadErrorCode`, and the error view localizes by that code (`editor.fileLoad.hostUnresolved`), so translating the message can never break the terminal check. Export the selector_not_found matcher and cover near misses (case, suffix, prose, wrong code) so only the defined token classifies. * test(editor): name the it.each parameter for the host answer it labels * fix(editor): drop the load-error Close action; closing stays with the tab strip The Close button routed through `requestEditorFileClose`, which skips the pinned-tab and shared-reference checks the tab strip applies, has no listener outside the Terminal workbench (floating editor panels), and on the conflict-review overview could target an unrelated open tab whose id is the same absolute path as a synthesized inline row. Rather than reimplement the tab strip's close semantics in a second place, the error view keeps Retry and its copy points the user at closing the tab. * fix(editor): reword the host-unresolved copy and namespace its sentinel The copy no longer points at a Close control that is gone ("close this tab from the tab strip") and no longer claims a scan is in progress, since `selector_not_found` is also thrown synchronously for unregistered folder workspaces and removed repos. The sentinel becomes `editor_host_workspace_unresolved` so it cannot be confused with the CLI's `worktree_host_unresolved` client error. The doc comment narrows the "no definitive absence code" claim to git worktrees and names the two host codes that are definitive but not yet classified. Refs #21041
…ful terminal state (#21375) * fix(editor): keep an unresolvable mirrored file tab open with a truthful terminal state A host-mirrored file whose read keeps answering `selector_not_found` used to sit on the raw code forever (and, in the reverted #21363, was closed outright, discarding drafts). `selector_not_found` is the host's "could not resolve right now", not proof the workspace is gone, and the file-read path has no definitive absence code. Bound the retries as before, then swap in a truthful terminal message with Retry and Close tab. The tab is never closed automatically; Close routes through the unsaved-changes queue so a dirty draft is confirmed. Fixes #21041 * fix(editor): classify selector_not_found by RPC code, not message text Preserve `RuntimeRpcCallError.code` on `FileContent.loadErrorCode` and gate the host-unresolved terminal transition with `hasRuntimeRpcErrorCode`, so a host that sends `{ code: 'selector_not_found', message: 'Selector not found' }` reaches the same truthful state as one that puts the bare token on the message. Also drop the Close action on inline conflict-review rows, which are not open tabs and would have been a dead control. * fix(editor): localize the host-unresolved copy by sentinel, and pin the token matcher Separate the terminal state's comparison key from its display text: the retry hook stores `WORKTREE_HOST_UNRESOLVED_CODE` on `loadErrorCode`, and the error view localizes by that code (`editor.fileLoad.hostUnresolved`), so translating the message can never break the terminal check. Export the selector_not_found matcher and cover near misses (case, suffix, prose, wrong code) so only the defined token classifies. * test(editor): name the it.each parameter for the host answer it labels * fix(editor): drop the load-error Close action; closing stays with the tab strip The Close button routed through `requestEditorFileClose`, which skips the pinned-tab and shared-reference checks the tab strip applies, has no listener outside the Terminal workbench (floating editor panels), and on the conflict-review overview could target an unrelated open tab whose id is the same absolute path as a synthesized inline row. Rather than reimplement the tab strip's close semantics in a second place, the error view keeps Retry and its copy points the user at closing the tab. * fix(editor): reword the host-unresolved copy and namespace its sentinel The copy no longer points at a Close control that is gone ("close this tab from the tab strip") and no longer claims a scan is in progress, since `selector_not_found` is also thrown synchronously for unregistered folder workspaces and removed repos. The sentinel becomes `editor_host_workspace_unresolved` so it cannot be confused with the CLI's `worktree_host_unresolved` client error. The doc comment narrows the "no definitive absence code" claim to git worktrees and names the two host codes that are definitive but not yet classified. Refs #21041 (cherry picked from commit 2cc34de)
…stablyai#21368) This reverts commit 07e8c85. The eviction keys on `selector_not_found`, which this repo documents twice as UNKNOWN rather than absence: - `remote-browser-stream-errors.ts`: "it means 'I could not resolve this right now', which is UNKNOWN, not proof the target is gone. Its producer is a live worktree scan behind a 1s-TTL cache ... a slow scan can surface it transiently. Treating that as permanent would strand the pane forever, which is the exact bug this file exists to prevent." - `web-runtime-session-tab-lifecycle.ts`, added by stablyai#21277: "'selector_not_found' is a transient worktree resolver state (e.g. during scans or cache warm-up) and must not become a durable close tombstone." Two unambiguous absence codes exist for this purpose -- `tab_not_found` and `terminal_tab_not_found` -- and stablyai#21277 had just finished excluding `selector_not_found` from them. This keyed on the excluded one. Consequences, after roughly 3.75s of retries: 1. `closeFile` deletes `editorDrafts[fileId]` with no dirty check and no confirmation, so a transient resolver blip discards unsaved edits. 2. `closeFile` calls `notifyHostOfMirroredEditorClose`, so the host closes its copy too -- the eviction is not local and not recoverable. The `!ownerNotReady` guard does not cover this: `ownerNotReady` means the host is still connecting, while `selector_not_found` is emitted for a cold resolver cache or an unhydrated catalog, which is a different state. stablyai#21041 is still open. A correct fix keys on the two definitive absence codes, refuses to evict a tab that has a draft, and has a test proving a dirty mirrored tab survives `selector_not_found`.

ELI5
When Orca restored a remote markdown tab whose worktree no longer existed, it kept selecting that broken tab after every refresh. Closing it after the normal read retries removes the stale tab and lets the remaining terminal or file tabs work normally.
What Changed
The editor now closes a host-mirrored file when its read still returns
selector_not_foundafter the existing bounded retry window. It uses the normal close action, so local editor state, the unified tab, and the host close intent stay consistent. Transient read failures and locally opened files keep their existing behavior.Why
The close lifecycle fix prevents stale host tabs from being re-mirrored after an explicit close, but this issue can fail before that path: the stale file is selected and read directly. Evicting it at the file-load boundary addresses that path without making every
selector_not_foundresponse globally durable.Linked Issue
Fixes #21041
Visual Proof
N/A — this is a state reconciliation fix with no new visual design or layout.
Testing
pnpm exec vitest run src/renderer/src/components/editor/useEditorPanelFileLoadRetry.test.tsxpnpm tcpnpm run check:code-quality:changedAI Disclosure
Review
Self-reviewed for correctness, security, performance, SSH/remote behavior, and cross-platform compatibility. The normal close action remains the single cleanup path.
Agent skill upstream boundary
Notes
The behavior is scoped to mirrored runtime tabs after bounded retries; local files and transient failures are unchanged.
Checklist