-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: enhance file history range tracking with comprehensive overlap handling #6053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@daniel-lxs this fixes the underlying readfile problem. you should probably run an eval and make sure there are no surprises |
- Add file history tracking system to avoid redundant reads - Optimize readFileTool to only read missing ranges from disk - Show informative notices when content already available in history - Integrate history tracking into writeToFile, applyDiff, insertContent tools - Add comprehensive tests for file history utilities - Support partial read rejection with detailed error messages Resolves issue where overlapping read requests would re-read entire ranges from disk instead of using previously read content from conversation history. Signed-off-by: Eric Wheeler <[email protected]>
…handling Improved calculateWriteRanges to properly detect modified content ranges by comparing original and modified content line-by-line instead of marking entire files as valid. - Added computeModifiedRanges function for precise change detection - Added adjustHistoricalRanges for proper range adjustment after modifications - Added comprehensive test coverage for all overlap scenarios - Tests validate range splitting, merging, and shift calculations - Handles partial overlaps, insertions, deletions, and edge cases The range tracking now accurately preserves historical valid ranges while only invalidating ranges that were actually modified. Fixes #5871 #1374 Signed-off-by: Eric Wheeler <[email protected]>
This fixes an issue where file metadata from read_file operations was not being properly attached to the API conversation history stream. The pendingFileMetadata was being set correctly in the Task object but never incorporated into the conversation stream, causing subsequent reads of the same file to not recognize previously read ranges. The fix modifies addToApiConversationHistory to check for and include any pending file metadata and tool metadata in the message before adding it to the conversation stream, ensuring proper tracking of file reads across multiple operations. Signed-off-by: Eric Wheeler <[email protected]>
67abb33 to
881fd20
Compare
if the line did not actually change, then they can be omitted. I have a feeling that the code that scans to see if lines change is somehow misbehaving on lines that are "falsy" |

Context
This PR significantly improves the file history range tracking system to handle complex overlapping scenarios that were previously causing issues with redundant file reads and incorrect range calculations.
Implementation
Enhanced Range Detection:
computeModifiedRanges()function for precise line-by-line change detectionadjustHistoricalRanges()for proper range adjustment after content modificationsgetChangedLineRanges()for comprehensive diff analysisImproved
calculateWriteRanges()Logic:Comprehensive Test Coverage:
How to Test
Run the comprehensive test suite:
Test various file modification scenarios:
Benefits
Fixes #5871 #1374
Important
Enhances file history range tracking with precise overlap handling and updates tools to utilize these improvements.
computeModifiedRanges(),adjustHistoricalRanges(), andgetChangedLineRanges()infileHistoryUtils.tsfor precise range detection and adjustment.calculateWriteRanges()to compare original vs modified content, preserving valid ranges and handling complex scenarios.writeToFileTool,insertContentTool, andreadFileToolto use enhanced range tracking.fileHistoryUtils.spec.tsfor partial overlaps, complete coverage, edge cases, and complex scenarios.FileLineRangeandFileMetadatainterfaces toapiMessages.ts.Task.tsto track file modification times and manage pending file metadata.This description was created by
for 79fcc89b2986484f1760f08ab14d12b511cc7429. You can customize this summary. It will automatically update as commits are pushed.