Skip to content

fix(editor): drop per-tab watch probe and disk-check generations once superseded or closed - #31128

Merged
nwparker merged 1 commit into
mainfrom
nwparker/watch-probe-generation-cleanup
Oct 20, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/watch-probe-generation-cleanup

Conversation

@nwparker

@nwparker nwparker commented Oct 20, 2026 •

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

ELI5

When Orca checks whether an open file still exists after missing file-change events, it keeps a small note per tab so a late answer can be ignored. Some of those notes were never thrown away. This PR throws them away once they can no longer matter.

What Changed

Nothing visible changes for the user; this removes a slow memory leak in the editor.

  • Existence probe notes (editor-external-watch-overflow.ts). When a real file-change event arrives for a tab while its existence check is still pending, the pending answer is ignored. Before, that was done by writing a newer number into the tab's note, which then sat there forever because nothing was waiting to clean it up. Now the note is simply deleted. The numbers come from one shared counter, so the old answer still can't match any later check. With that change, every remaining note belongs to a check that is still running, and that check deletes its note when it finishes, whether or not the tab is still open (checks time out after 15 seconds, so they always finish).
  • Dirty-tab disk-check notes (editor-restored-tab-conflict-scan.ts). The map of "a newer disk check was requested" numbers never removed anything. Now entries for closed tabs are dropped from the scan's existing listener for changes to the open-tab list, so no new subscription is added. The numbers also now come from one shared counter instead of counting per tab. Without that, a tab closed and reopened at the same path could count back up to a number an older, still-running read was holding, and that stale read would be accepted.

Why

Deleting a note is the cleanest way to say "ignore the pending answer" once the shared counter already guarantees that old answers can't match. For the disk-check map, the scan already watches the open-tab list, so pruning there reuses a close hook that exists instead of adding a new one. Switching to a shared counter is what makes deleting entries safe.

Linked Issue

Follow-up to #30415.

Visual Proof

N/A: internal bookkeeping only, with no visible or interaction change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

New tests check that the existence-probe map is empty after a watch event supersedes a pending check, and after a tab closes while its check is pending. A third test checks that the disk-check request map is empty after the tab closes. The existing tests for both modules pass, along with pnpm lint, oxlint, check:code-quality:changed and pnpm tc.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The change runs only in the renderer and only tracks tab ids, so it behaves the same on every platform and for SSH and remote tabs. Pruning walks the small map only when the open-tab list changes and the map is not empty.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…seded or closed

Follow-up to #30415. A watch event that superseded a pending overflow existence
probe left the tab's entry behind forever, and the dirty-tab disk-check request
map never removed anything. Superseding now deletes the entry, and closed tabs'
disk-check requests are dropped by the scan's existing open-tabs subscription.
The disk-check map uses a global sequence so a reopened tab can't reuse an old
read's number.
@nwparker
nwparker marked this pull request as ready for review October 20, 2026 13:03
@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eed29438-fe2a-4a1e-a17f-9d872d2439b3
📥 Commits

Reviewing files that changed from the base of the PR and between cf94325 and 20f5e9c.

📒 Files selected for processing: 4
  • src/renderer/src/components/editor/editor-restored-tab-conflict-scan.recheck.test.ts
  • src/renderer/src/components/editor/editor-restored-tab-conflict-scan.ts
  • src/renderer/src/hooks/editor-external-watch-overflow.test.ts
  • src/renderer/src/hooks/editor-external-watch-overflow.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

The restored-tab conflict scan now uses a global sequence for reverification requests and removes requests for closed tabs. The external-watch overflow logic removes superseded probe entries. Tests verify request and probe counts, including cleanup after tab closure and handling of delayed probe results.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 20f5e

The bookkeeping cleanup appears mergeable after normal checks; no editor behavior regression was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: removing obsolete per-tab watch-probe and disk-check generations when superseded or closed.
Description check Passed The description follows the repository template and explains the problem, implementation, rationale, linked issue, lack of visual changes, tests, scope, and checklist status. The unchecked manual-test…
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 follows the repository template and explains the problem, implementation, rationale, linked issue, lack of visual changes, tests, scope, and checklist status. The unchecked manual-test item and unreported build/test commands are non-critical because automated validation is documented.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@nwparker
nwparker merged commit 1c5d4ee into main Oct 20, 2026
58 checks passed
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