Repository navigation
Restored-tab disk re-check can't loop or raise a false conflict; drop test-only editor-state guard - #31250
Conversation
…xport; bound superseded restore re-reads - Remove isWholeEditorState; its callers take the real AppState. Tests that mocked partial stores now build full states from createTestStore. - Import getDiskBaselineSignature from shared/disk-baseline-signature directly and delete the re-export from diff-content-signature.ts. - Restored-tab conflict scan: count superseded re-reads toward MAX_VERIFY_ATTEMPTS, so a read slower than the re-verify interval gives up with the conflict banner instead of looping forever. Adds a regression test. Co-Authored-By: Claude <[email protected]>
… of giving up A matching read at the cap cleared nothing and showed a false changed-on-disk banner; it now resolves like any read. Only read failures give up. Co-Authored-By: Claude <[email protected]>
…ng them A superseded read may predate the newer check, so it never resolves the verification, even at the attempt cap. Overlapping checks now delay the next fresh read (bounded, one timer per tab) and keep verification pending; only failed reads count toward giving up. Co-Authored-By: Claude <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to
|
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:
9f9fe3a7-476c-403e-a5a6-d8ef88b5d450
📒 Files selected for processing: 23
src/renderer/src/components/editor/ExternalFileChangeBanner.test.tsxsrc/renderer/src/components/editor/ExternalFileChangeBanner.tsxsrc/renderer/src/components/editor/diff-content-signature.tssrc/renderer/src/components/editor/editor-changed-on-disk-mark.tssrc/renderer/src/components/editor/editor-clean-tab-disk-baseline.tssrc/renderer/src/components/editor/editor-restored-tab-conflict-scan.recheck.test.tssrc/renderer/src/components/editor/editor-restored-tab-conflict-scan.test.tssrc/renderer/src/components/editor/editor-restored-tab-conflict-scan.tssrc/renderer/src/components/editor/editor-save-disk-precondition.tssrc/renderer/src/components/editor/editor-save-queue.tssrc/renderer/src/components/editor/editor-stale-mount-guard.tssrc/renderer/src/components/editor/editor-untitled-dont-save-dialogs.test.tsxsrc/renderer/src/components/editor/editor-untitled-save-lifecycle.test.tssrc/renderer/src/components/editor/use-monaco-editor-mount.cursor-owner.test.tsxsrc/renderer/src/components/editor/useEditorPanelContentState.test.tsxsrc/renderer/src/components/editor/useEditorPanelExternalContentEvents.tssrc/renderer/src/components/editor/useEditorPanelVisibilityContentState.test.tsxsrc/renderer/src/hooks/editor-external-watch-disk-verification.tssrc/renderer/src/hooks/useEditorExternalWatch-self-move.test.tssrc/renderer/src/hooks/useEditorExternalWatch-switch-back.test.tsxsrc/renderer/src/hooks/useEditorExternalWatch.test.tssrc/renderer/src/lib/execute-open-editor-path-move.test.tssrc/renderer/src/store/slices/editor/tabs/untitled-file-cleanup.ts
💤 Files with no reviewable changes: 2
- src/renderer/src/components/editor/diff-content-signature.ts
- src/renderer/src/components/editor/editor-save-disk-precondition.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
| }) | ||
| // Why back off, not cap: a superseded answer may predate the newer check, so it never resolves; churn only delays the fresh read. | ||
| const superseded = (supersededReadsByFileId.get(fileId) ?? 0) + 1 | ||
| supersededReadsByFileId.set(fileId, superseded) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Clear superseded-read counts when a tab closes.
If a tab closes during a delayed retry, the timer can finish without removing its entry from supersededReadsByFileId. If the same file ID is reopened and another read is superseded, verification inherits the old count and can wait 15 seconds instead of starting with the initial retry delay. Clear the count on closure and other terminal paths that do not reach the accepted-read or give-up cleanup.
…ping-check tests After #31196 a server's tab is no longer keyed by its path, so these tests flagged a tab that does not exist and no read was ever issued. Co-Authored-By: Claude <[email protected]>
ELI5
Three small leftovers from the review of the watcher and safe-save PRs (#31216): delete a check that only existed for tests, import a helper from where it lives, and stop a background file re-check from either looping forever or crying wolf.
What Changed
isWholeEditorStateremoved. It guarded production code against partial stores that only tests passed. Callers now take the realAppState; seven test files build full states fromcreateTestStore()(which also removed 24as nevercasts).getDiskBaselineSignatureis imported fromsrc/shared/disk-baseline-signature.tsdirectly; the re-export throughdiff-content-signature.tsis gone.Why
The first version of the re-check fix capped overtaken reads and gave up at the cap. GPT's review caught that this turned an unchanged file into a false conflict and left autosave paused. Accepting the last read at the cap was also wrong, since that read may predate the newest request. Separating "overtaken" from "failed" is the smallest change that never infers a disk change from request churn and still can't loop.
Linked Issue
Follow-up to #31216.
Visual Proof
N/A: no layout change. The only behaviour change (no false banner, bounded re-reads) is covered by a regression test.
Testing
pnpm tc,pnpm run check:code-quality:changed,oxfmt --checkpass.Editor, hooks, lib, store and runtime tests pass (2048 files / 18,629 tests on the first commit; editor + hooks 556 files / 4,241 tests after the re-check fix).
New regression test: 45 overlapping checks (more than the 40-attempt cap) stay pending with no banner; the final fresh read clears when it matches and shows the banner when it differs. Existing test still covers giving up after repeated read failures.
remote-snapshot-alt-screen-host-chain.test.tstimes out on this machine with or without this change.Not manually tested in the app; macOS only.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
No wire or persisted-state change.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)