Repository navigation
Revert "fix(editor): evict stale mirrored file tabs (#21363)" - #21368
Conversation
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`.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Reverts the
selector_not_foundeviction —useEditorPanelFileLoadRetry.tsdrops thecloseFileparam,isSelectorNotFoundError, and the branch that evicted amirroredFromRuntimeSessiontab after retries exhausted, plus itsuseEffectdeps. - Unwires the eviction from the panel —
useEditorPanelContentState.tsstops passingcloseFile: useAppStore.getState().closeFileand returns the import to type-only. - Removes the eviction test —
useEditorPanelFileLoadRetry.test.tsxdrops theevicts a mirrored tab after selector resolution stays missingcase and the optional harness prop.
I verified the diff is a byte-for-byte inverse of 07e8c851, and git log on the touched file confirms the revert sits directly on top of the reverted commit with no intervening edits, so nothing landed between them to lose. The rationale checks out against the repo: remote-browser-stream-errors.ts:17 explicitly excludes selector_not_found from the permanent/gone set, and web-runtime-session-tab-lifecycle.ts:165 documents tab_not_found / terminal_tab_not_found as the definitive absence codes while calling selector_not_found a transient resolver state that must not become a durable close tombstone. The reverted code keyed on the excluded one. I also confirmed the removed eviction had no other consumers and no other test pinned it. The touched test file still passes (4 tests).
This leaves #21041 open — the stranding symptom #21363 set out to fix — but the PR body already says so and the reverted behavior is strictly the pre-#21363 state, so the revert trades a silent data-loss failure mode back for a pre-existing, recoverable one. Reasonable call.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
📝 WalkthroughWalkthroughThe file-load retry hook now retries owner-not-ready loads every 750 ms for up to 160 attempts. It then sets Priority: ➖ Normal Merge Risk: 🔵 Low · up to The production eviction path is removed, but the critical unsaved-draft protection lacks regression coverage before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description clearly explains the reverted behavior, the risk to unsaved edits, and the intended follow-up. However, it omits required template sections for visual proof, testing, AI disclosure, review, checklist status, and an explicit linked issue entry. Resolution Complete the required template sections. Add
✨ 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.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Add the dirty mirrored-tab no-eviction regression. · useEditorPanelFileLoadRetry.test.tsx:109-137
src/renderer/src/components/editor/useEditorPanelFileLoadRetry.test.tsx:109-137
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winAdd the dirty mirrored-tab no-eviction regression. Commit
97c682c7b7removed the onlyselector_not_foundtest. That test asserted eviction and used a clean file with empty content. The current hook no longer accepts or callscloseFile, and no current test combines a dirtymirroredFromRuntimeSessionfile with draft preservation. Add one case at the retry boundary withisDirty: true, draft content, and an exhaustedselector_not_foundretry path. Assert that the open-file entry and draft content remain unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 660c4ee5-e009-4ffc-9274-5bbb9a71b620
📒 Files selected for processing (3)
src/renderer/src/components/editor/useEditorPanelContentState.tssrc/renderer/src/components/editor/useEditorPanelFileLoadRetry.test.tsxsrc/renderer/src/components/editor/useEditorPanelFileLoadRetry.ts
💤 Files with no reviewable changes (2)
- src/renderer/src/components/editor/useEditorPanelFileLoadRetry.test.tsx
- src/renderer/src/components/editor/useEditorPanelFileLoadRetry.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
…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`.

Revert "fix(editor): evict stale mirrored file tabs (#21363)"
This reverts commit 07e8c85.
The eviction keys on
selector_not_found, which this repo documents twice asUNKNOWN rather than absence:
remote-browser-stream-errors.ts: "it means 'I could not resolve this rightnow', 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 fix(runtime): keep absent session tab close intents durable (#21189) #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_foundandterminal_tab_not_found-- and #21277 had just finished excludingselector_not_foundfrom them. This keyed on the excluded one.Consequences, after roughly 3.75s of retries:
closeFiledeleteseditorDrafts[fileId]with no dirty check and noconfirmation, so a transient resolver blip discards unsaved edits.
closeFilecallsnotifyHostOfMirroredEditorClose, so the host closes itscopy too -- the eviction is not local and not recoverable.
The
!ownerNotReadyguard does not cover this:ownerNotReadymeans the host isstill connecting, while
selector_not_foundis emitted for a cold resolver cacheor 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.