-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: rename search_and_replace tool to edit and unify edit-family UI #11296
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
base: main
Are you sure you want to change the base?
Conversation
No new issues in latest commit. One pre-existing low-severity finding remains open.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
01335c6 to
0a1377c
Compare
52ad6f3 to
285a161
Compare
| switch (tool.tool as string) { | ||
| case "editedExistingFile": | ||
| case "appliedDiff": | ||
| case "newFileCreated": |
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.
Low severity: merging newFileCreated into the unified branch drops the onJumpToFile prop that the old dedicated case passed to CodeAccordian. That prop rendered an external-link icon in the accordian header, letting users click to open the newly created file. Without it, CodeAccordian falls back to showing an expand/collapse chevron instead. The other edit-family tools didn't have this prop, so it's only a regression for new-file-creation messages.
Fix it with Roo Code or mention @roomote and request a fix.
…ture - Add new 'edit' tool with file_path, old_string, new_string, replace_all params - Keep search_and_replace as backward-compatible alias via TOOL_ALIASES - Create EditTool execution handler with replace_all and uniqueness checking - Update NativeToolCallParser for both edit and search_and_replace names - Update presentAssistantMessage routing for both tool names - Add alias resolution to isToolAllowedForMode for customTools validation - Reduce SearchAndReplaceTool.ts to re-export wrapper from EditTool - Add 16 new EditTool tests, update searchAndReplaceTool tests - MiniMax includedTools: ['search_and_replace'] continues to work via alias
- route edit/search/patch-related tool events through the appliedDiff chat UI branch - ensure apply_patch partial rows emit a deterministic non-empty path - add apply_patch partial regression tests - expand ChatRow diff-actions tests for unified behavior
09a6b8a to
793be28
Compare
| let newContent: string | ||
| if (replaceAll) { | ||
| // Replace all occurrences | ||
| const searchPattern = new RegExp(escapeRegExp(normalizedOld), "g") | ||
| newContent = fileContent.replace(searchPattern, normalizedNew) | ||
| } else { | ||
| // Replace single occurrence (already verified uniqueness above) | ||
| newContent = fileContent.replace(normalizedOld, normalizedNew) | ||
| } |
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.
Low severity: both the replaceAll path (line 139) and the single-replace path (line 142) pass normalizedNew directly as the replacement string to String.prototype.replace(). JavaScript interprets special $-patterns in replacement strings: $$ becomes a single $, $& inserts the matched text, $` and $' insert surrounding text. This means edits whose new_string contains these patterns are silently corrupted. The most likely real-world case is $$ in JS template literals (e.g. `$${amount}` loses one $). Using a function replacer ((pattern, () => normalizedNew)) avoids special-pattern interpretation entirely.
| let newContent: string | |
| if (replaceAll) { | |
| // Replace all occurrences | |
| const searchPattern = new RegExp(escapeRegExp(normalizedOld), "g") | |
| newContent = fileContent.replace(searchPattern, normalizedNew) | |
| } else { | |
| // Replace single occurrence (already verified uniqueness above) | |
| newContent = fileContent.replace(normalizedOld, normalizedNew) | |
| } | |
| let newContent: string | |
| if (replaceAll) { | |
| // Replace all occurrences | |
| const searchPattern = new RegExp(escapeRegExp(normalizedOld), "g") | |
| newContent = fileContent.replace(searchPattern, () => normalizedNew) | |
| } else { | |
| // Replace single occurrence (already verified uniqueness above) | |
| newContent = fileContent.replace(normalizedOld, () => normalizedNew) | |
| } |
Fix it with Roo Code or mention @roomote and request a fix.
Summary
Renames the
search_and_replacetool toeditwith a new flat parameter structure (file_path,old_string,new_string,replace_all), replacing the old batch operations array. Keepssearch_and_replaceas a backward-compatible alias so models like MiniMax that reference it inincludedToolscontinue to work without changes.Changes
edittool definition (src/core/prompts/tools/native-tools/edit.ts) withfile_path,old_string,new_string,replace_allparametersEditToolexecution handler (src/core/tools/EditTool.ts) withreplace_allsupport and uniqueness checkingsearch_and_replace: "edit"toTOOL_ALIASES— models withincludedTools: ["search_and_replace"](e.g., MiniMax) get theedittool renamed assearch_and_replaceNativeToolCallParser.tshandles both"edit"and"search_and_replace"tool names with the new parameter structurepresentAssistantMessage.tsroutes both tool names toEditToolisToolAllowedForModenow resolves aliases when checking customTools, ensuringsearch_and_replaceinincludedToolscorrectly maps toeditSearchAndReplaceTool.tsreduced to a 2-line re-export fromEditTool"edit"totoolNames,"replace_all"totoolParamNames, updatedNativeToolArgsTest Results
src/suite: 341 passed (29 pre-existing failures from missing@ai-sdk/amazon-bedrock— unrelated)packages/types: 170/170 passingImportant
Renames
search_and_replacetool toedit, updates related components and tests, and maintains backward compatibility with an alias.search_and_replacetool toeditwith new parameters (file_path,old_string,new_string,replace_all).search_and_replaceas an alias for backward compatibility.EditToolinEditTool.tswith support forreplace_alland uniqueness checking.search_and_replace.ts, re-exportingEditToolasSearchAndReplaceToolfor compatibility.NativeToolCallParser.tsandpresentAssistantMessage.tsto handle both tool names.ChatRow.tsx.EditToolineditTool.spec.ts.TOOL_ALIASESintools.tsto mapsearch_and_replacetoedit.validateToolUse.tsto resolve tool aliases during validation.This description was created by
for e1a149c. You can customize this summary. It will automatically update as commits are pushed.
Additional updates in latest commits
searchAndReplace,search_and_replace,search_replace,edit,edit_file,apply_patch, and related edit-result events render through the sameappliedDiffbranch.apply_patchpartial preview payloads to emit a deterministic non-empty path, eliminating blank initial approval rows and aligning early UX withapply_diff.apply_patchpartial path extraction and unified chat diff-actions rendering.