Skip to content

Fix agent reads for unsaved new files not yet on disk#397

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

Fix agent reads for unsaved new files not yet on disk#397
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-1b9e

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 29, 2026

Fixes ADE-62

Bug and impact

After #393, agents could read unsaved edits for existing files, but still failed on new files that only exist in the Files editor buffer (not saved to disk). readFile and attachment paths returned file-not-found even when the user had draft content open.

Root cause

readAgentAccessibleFileBytes resolved paths with allowMissing: false, so missing files threw before the dirty-buffer lookup ran. readFileRange had the same early exit when getDirtyFileTextForPath was wired.

Fix

  • Resolve agent read paths with allowMissing: true before consulting dirty buffers.
  • Let readFileRange allow missing paths when a dirty lookup is configured, and map ENOENT to the existing file-not-found tool error when no buffer exists.

Validation

  • npm run test -- --run src/main/services/shared/utils.test.ts src/main/services/ai/tools/readFileRange.test.ts (105 tests passed)
Open in Web View Automation 

readAgentAccessibleFileBytes and readFileRange required paths to exist
before consulting dirty editor buffers. New unsaved files in the Files tab
never reached the dirty lookup, so agents still saw file-not-found after #393.

Co-authored-by: Arul Sharma <arul28@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored May 29, 2026 8:05am

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 29, 2026

ADE-62

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