Fix Files v2 workbench overwriting disk after external edits#450
Draft
cursor[bot] wants to merge 1 commit into
Draft
Fix Files v2 workbench overwriting disk after external edits#450cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Files tab v2 invalidated the read cache on watcher events but never reloaded open editors. Monaco models kept stale buffers, so a save after an agent or git edit could overwrite newer on-disk content. Reload clean tabs from disk, surface a disk-changed banner on dirty tabs, and update cached Monaco models when revisiting a clean path. Co-authored-by: Arul Sharma <arul28@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
With the Files tab v2 workbench enabled (
ade.files.workbenchV2), opening a file and then having another process modify it on disk (agent edit, git checkout, terminal write) left the Monaco buffer stale. The watcher only invalidated the read cache and refreshed the tree; open editors never reloaded.Trigger: User opens
foo.tsin Files v2, an agent editsfoo.tson disk, user saves (or saves without noticing stale content). The save writes the old buffer and overwrites the newer on-disk file — data loss.Root cause
FilesWorkbenchcalledinvalidateFileContentonade.files.changebut did not mirror v1FilesPagebehavior: nosyncCleanTabFromDisk, no reload token foruseFileContent, andmonacoModelRegistry.getOrCreatereturned cached models without applying fresh disk text for clean tabs.Fix
ViewerHostrefetches.Validation
npx vitest run src/renderer/components/files/monacoModelRegistry.test.ts src/renderer/components/files/v2/editorGroupsStore.test.ts(24 tests passed)