-
Notifications
You must be signed in to change notification settings - Fork 2.8k
refactor(read_file): Codex-inspired read_file refactor EXT-617 #10981
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
Open
hannesrudolph
wants to merge
12
commits into
main
Choose a base branch
from
read-file-refactor-codex
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,765
−4,508
Conversation
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
Contributor
Re-review complete. 1 new issue found.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
5c7a773 to
5785b36
Compare
Member
|
This requires us to enable parallel tool calling by default, moving it out of experimental |
68ef238 to
9c670b4
Compare
123aacc to
1c3ef7d
Compare
- Replace multi-file read_file with single-file-per-call design - Add two reading modes: slice (default) and indentation - Implement bidirectional expansion algorithm for indentation mode - Add line truncation (500 chars) and limit (2000 lines default) - Remove legacy token-budget-based reading approach - Remove maxReadFileLine setting (replaced by limit parameter) - Add new IndentationParams and ReadFileParams types - Clean up stale FileEntry/LineRange types and helpers Known limitations: - Lines >500 chars are truncated (content lost) - No server-side max limit enforcement
This setting was never used after removing the batch file reading system. Removes dead code from UI, state management, and types.
- Fix formatPathTooltip to add space before additionalContent (fixes display bug where 'index.ts' + 'up to 50 lines' showed as 'index.tsup to 50 lines') - Add startLine field to ClineSayTool type for read_file operations - Update ReadFileTool to include startLine in the message - Update ChatRow to pass startLine to openFile for navigation to the correct line
…ines - Add explicit 'when to use' guidance for slice and indentation modes - Add indentation mode example alongside existing slice example - Fix confusing 'indentation.anchor_line' text in mode description - Add 'when NOT to use' guidance in anchor_line description - Enhance descriptions to help non-OpenAI models choose appropriate mode This follows Anthropic's documented best practices for tool descriptions: - Explain what the tool does - Specify when to use and when NOT to use - Describe parameter impact - Aim for 3-4+ sentences
- Remove terminalCompressProgressBar from SettingsView.tsx destructuring - Remove terminalCompressProgressBar from test mock objects - Property was never defined in GlobalSettings or ExtensionState types
When mode='indentation' but anchor_line is not provided, now defaults to the offset parameter (or 1 if neither is provided), rather than silently falling back to slice mode. This aligns with the documented behavior in packages/types/src/tool-params.ts.
- Add truncation support to extractTextFromFile via readWithSlice (2000 line limit) - Update parseMentions to return file content as separate MentionContentBlock objects - Update processUserContentMentions to handle new contentBlocks structure - Add Gemini-style truncation warnings with IMPORTANT header - Sync truncation message format between read_file tool and @ mentions - Put truncation warning at TOP (before content) in both implementations - Update test mocks and expectations for new behavior
- Changed getLineSnippet() to always return 'up to X lines' even for default limit - Previously only showed line count when limit < DEFAULT_LINE_LIMIT - Now users always see how many lines will be read (e.g., 'up to 2000 lines')
When the model makes multiple parallel read_file tool calls, the UI now consolidates consecutive read_file ask messages into a single batch view showing 'Roo wants to read these files' instead of showing repeated 'Roo wants to read this file' messages for each file. The groupedMessages useMemo in ChatView now detects consecutive read_file asks and creates a synthetic batch message with batchFiles, which triggers the existing BatchFilePermission component to render the files as a group. This improves the UX by reducing visual noise when reading multiple files.
Remove IndentationReadResult and MAX_LINE_LENGTH imports that were not being used, as flagged by the review bot.
…pproval flow Adds comprehensive tests for ReadFileTool covering: - Input validation (missing path parameter) - RooIgnore blocking - Directory read error handling - Image handling (memory limits, format detection, model support) - Binary file handling (PDF, DOCX, unsupported formats) - Text file processing (slice and indentation modes) - Approval flow (approve, deny, feedback) - Output structure formatting - Error handling (file read errors, stat errors) 29 new tests covering the orchestration layer that was previously untested after the Codex-inspired refactor.
3ae0e4d to
ff54851
Compare
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.
Summary
closes #10239
This PR introduces a smarter way for Roo to read your code files. Instead of just grabbing arbitrary line ranges, Roo can now intelligently extract complete functions, classes, and code blocks based on their structure.
What's New
Indentation Mode for Smart Code Extraction
When Roo needs to read code around a specific line (like when investigating an error or following a search result), it can now use indentation mode to automatically extract the complete containing function or class—not just a fixed number of lines that might cut off mid-block.
Example: If Roo finds an error on line 42 inside a function, indentation mode will return the entire function definition with proper context, instead of an arbitrary range like "lines 40-60" that might miss important context or include unrelated code.
Simplified File Reading
The
read_filetool now has two clear modes:Breaking Changes
Settings Removed
The following settings have been removed from the UI:
If you previously relied on
maxReadFileLineto limit file reads, this behavior is now handled automatically by the agent's per-request parameters.API Changes (for Custom Modes/Prompts)
The
line_rangesparameter has been replaced with a simpleroffset/limitapproach:Before:
{ "files": [{ "path": "app.ts", "line_ranges": [[1, 50]] }] }After:
{ "path": "app.ts", "mode": "slice", "offset": 1, "limit": 50 }For semantic code extraction, use the new indentation mode:
{ "path": "app.ts", "mode": "indentation", "indentation": { "anchor_line": 42 } }Benefits