Skip to content

Fix Files v2 agent reads ignoring unsaved editor buffers#452

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-2b20
Draft

Fix Files v2 agent reads ignoring unsaved editor buffers#452
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-2b20

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 31, 2026

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 readAgentAccessibleFileByteswindow.__ADE_GET_DIRTY_FILE_TEXT__dirtyWorkspaceBuffers. v1 FilesPage keeps that map updated via replaceDirtyBuffersForWorkspace, but FilesWorkbench never called it despite tracking dirty state in the Monaco model registry.

Fix

  • Track saved baseline text in the Monaco model registry (getSavedValue).
  • Sync open v2 tab buffers into dirtyWorkspaceBuffers on tab layout / dirty changes and on buffer edits (throttled).
  • Clear workspace dirty entries on workspace switch and unmount.

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

Open in Web View Automation 

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>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ade Building Building Preview, Comment May 31, 2026 6:08am

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