Fix agent reads for unsaved new files not yet on disk#397
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
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>
|
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.
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).
readFileand attachment paths returned file-not-found even when the user had draft content open.Root cause
readAgentAccessibleFileBytesresolved paths withallowMissing: false, so missing files threw before the dirty-buffer lookup ran.readFileRangehad the same early exit whengetDirtyFileTextForPathwas wired.Fix
allowMissing: truebefore consulting dirty buffers.readFileRangeallow 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)