Fix Files v2 agent reads ignoring unsaved editor buffers#452
Draft
cursor[bot] wants to merge 1 commit into
Draft
Fix Files v2 agent reads ignoring unsaved editor buffers#452cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Files workbench v2 tracked dirty state in Monaco but never published buffers to dirtyWorkspaceBuffers, so agent/tool reads used stale on-disk content while the user edited in the v2 editor. Sync open tab buffers on edit (throttled), dirty transitions, and tab layout changes; expose saved baseline text from the model registry. 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), agents and tools that read files (read_file, attachments, CTO operator reads, etc.) received on-disk content instead of the live Monaco buffer while the user had unsaved edits.Trigger: Enable v2 workbench, open a file, edit without saving, then run an agent read on that path. The agent sees stale or empty disk content and may generate wrong patches or overwrite based on outdated text.
Root cause
Agent reads use
readAgentAccessibleFileBytes→window.__ADE_GET_DIRTY_FILE_TEXT__→dirtyWorkspaceBuffers. v1FilesPagekeeps that map updated viareplaceDirtyBuffersForWorkspace, butFilesWorkbenchnever called it despite tracking dirty state in the Monaco model registry.Fix
getSavedValue).dirtyWorkspaceBufferson tab layout / dirty changes and on buffer edits (throttled).Validation
npx vitest run src/renderer/components/files/monacoModelRegistry.test.ts src/renderer/components/files/v2/filesWorkbenchDirtySync.test.ts(10 tests passed)Note: Distinct from PR #450 (external disk edits overwriting saves) and PR #397 (unsaved new files not yet on disk).