Skip to content

Revert "fix(editor): evict stale mirrored file tabs (#21363)" - #21368

Merged
nwparker merged 1 commit into
mainfrom
revert/21363-selector-not-found-eviction
Sep 18, 2026
Merged

nwparker merged 1 commit into
mainfrom
revert/21363-selector-not-found-eviction

Conversation

@nwparker

@nwparker nwparker commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 0 $\color{#cf222e}{\Huge{\mathbf{−}}}$​32 $\color{#cf222e}{\Huge{\mathbf{−}}}$​32
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20

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 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 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_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.

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`.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Reverts the selector_not_found eviction — useEditorPanelFileLoadRetry.ts drops the closeFile param, isSelectorNotFoundError, and the branch that evicted a mirroredFromRuntimeSession tab after retries exhausted, plus its useEffect deps.
  • Unwires the eviction from the panel — useEditorPanelContentState.ts stops passing closeFile: useAppStore.getState().closeFile and returns the import to type-only.
  • Removes the eviction test — useEditorPanelFileLoadRetry.test.tsx drops the evicts a mirrored tab after selector resolution stays missing case 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The file-load retry hook now retries owner-not-ready loads every 750 ms for up to 160 attempts. It then sets WORKTREE_OWNER_UNREACHABLE_ERROR and stops automatic retries. The closeFile dependency and mirrored-runtime selector cleanup path were removed. Related editor-panel wiring and tests were updated.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 97c68

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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, re… Complete the required template sections. Add Fixes #21041`` or the correct issue link, provide visual proof or state N/A with a reason, document manual and automated testing, complete the applicable checkboxes, and add any required AI dis…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states that the pull request reverts the stale mirrored file tab eviction change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

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 Fixes #21041`` or the correct issue link, provide visual proof or state N/A with a reason, document manual and automated testing, complete the applicable checkboxes, and add any required AI disclosure and review details.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 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 win

Add the dirty mirrored-tab no-eviction regression. Commit 97c682c7b7 removed the only selector_not_found test. That test asserted eviction and used a clean file with empty content. The current hook no longer accepts or calls closeFile, and no current test combines a dirty mirroredFromRuntimeSession file with draft preservation. Add one case at the retry boundary with isDirty: true, draft content, and an exhausted selector_not_found retry 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b4ee04 and 97c682c.

📒 Files selected for processing (3)
  • src/renderer/src/components/editor/useEditorPanelContentState.ts
  • src/renderer/src/components/editor/useEditorPanelFileLoadRetry.test.tsx
  • src/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.

@nwparker
nwparker merged commit 945ea33 into main Sep 18, 2026
29 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant