-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: resolve focus and performance issues with file mentions in first message (#4127) #6180
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
fix: resolve focus and performance issues with file mentions in first message (#4127) #6180
Conversation
… message (RooCodeInc#4127) - Implement 3-message synthetic context generation pattern - Original user message stored without embedded file content in task history - Synthetic assistant message with read_file tool calls generated - File contents processed and added as separate user response - Prevents model focus degradation and UI performance issues - Add comprehensive tests for the new functionality
- Remove 'processed:' prefix from parseMentions mock - Update test expectations to match new behavior - Fix processUserContentMentions mock usage
KJ7LNW
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in addition to the comment below:
- we no longer need to modify the first message since you are injecting it in the rest of the body.
I do not remember where that is somewhere it changes @mention to @mention (see file below) or something like that.
this pull request makes it possible for the first message to arrive and modified.
- it was not clear to me whether or not the task.ts changes trigger to start after modifying the context: it would be a good idea to manually verify that when you create the mention that the task loads the files and continues without user intervention
- Fixed failing unit tests by properly mocking extractFileMentions and hasFileMentions - Removed 'see below for file content' text from file mentions as requested in PR review - Updated all related test expectations to match the new behavior - Ensured task continues automatically after synthetic message handling
- Moved shouldUseSyntheticMessages, handleFirstMessageWithFileMentions, and createSyntheticReadFileMessage to new synthetic-messages.ts module - Made addToApiConversationHistory public to allow access from the new module - Updated imports and function calls in Task.ts - Addresses PR feedback about Task.ts getting too large
- Modified createSyntheticReadFileMessage to batch files in groups of 5 - Updated tests to verify single read_file call with multiple files - Added test for batching behavior when more than 5 files are mentioned - This improves efficiency by reducing the number of tool calls needed
Changes MadeI've updated the synthetic message generation to use the multi-file read capability of the read_file tool: Key Changes:
Benefits:
Example:When a user mentions 2 files like <read_file>...</read_file>
<read_file>...</read_file>We now create: <read_file>
<args>
<file>
<path>file1.ts</path>
</file>
<file>
<path>file2.ts</path>
</file>
</args>
</read_file>All tests are passing ✅ |
Changes MadeI've updated the synthetic message generation to use the multi-file read capability of the read_file tool: Key Changes:
Benefits:
Example:When a user mentions 2 files like <read_file>...</read_file>
<read_file>...</read_file>We now create: <read_file>
<args>
<file>
<path>file1.ts</path>
</file>
<file>
<path>file2.ts</path>
</file>
</args>
</read_file>All tests are passing ✅ |
|
This looks good! I only noticed 1 issue but that's probably because it's such a new feature: When I mention an image the generated message tells Roo that it can't read images with the It would be great if we can re utilize the logic on the |
Related GitHub Issue
Closes: #4127
Roo Code Task Context (Optional)
No Roo Code task context for this PR
Description
This PR implements a 3-message synthetic context generation pattern to resolve focus and performance issues when file mentions (
@filename) are used in the first user message.Key implementation details:
extractFileMentionsutility to detect and extract file paths from@mentionsTask.initiateTaskLoopto intercept first messages containing file mentionshandleFirstMessageWithFileMentionsmethod that generates the synthetic message pattern:<read_file>tool callssaymethod) only sees the clean original message, preventing UI performance degradationTest Procedure
Automated Testing:
extractFileMentionsutility:Taskclass to verify the 3-message pattern generation:Manual Testing:
@src/index.ts explain this filePre-Submission Checklist
Screenshots / Videos
No UI changes in this PR
Documentation Updates
Additional Notes
This implementation ensures backward compatibility - tasks without file mentions in the first message continue to work exactly as before. The synthetic message pattern is only generated when needed.
Get in Touch
Discord username not provided
Important
Introduces a synthetic message pattern to handle file mentions in the first message, improving focus and performance.
Task.tsto handle file mentions in the first message.extractFileMentionsutility inextractFileMentions.tsto detect file paths from@mentions.Task.initiateTaskLoopto intercept first messages with file mentions.handleFirstMessageWithFileMentionsinsynthetic-messages.tsto generate synthetic messages.extractFileMentionsinextractFileMentions.spec.ts.Taskclass inTask.spec.tsto verify synthetic message pattern.parseMentionsinindex.tsto simplify file mention handling.This description was created by
for c59edca. You can customize this summary. It will automatically update as commits are pushed.