Skip to content

Commit 4843748

Browse files
Merge pull request #1666 from codeflash-ai/feat/subagent-ide-diff
feat: surface subagent optimization diffs in IDE's native diff view
2 parents cbc66e2 + c9a7fd0 commit 4843748

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

codeflash/cli_cmds/console.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,18 @@ def subagent_log_optimization_result(
468468
if new_code[path] != original_code.get(path, ""):
469469
xml.append(f' <optimized-code file="{escape(str(path))}">{escape(new_code[path])}</optimized-code>')
470470
xml.append(" <action>")
471-
xml.append(" Present this optimization to the user using AskUserQuestion.")
472-
xml.append(" Show the function name, performance improvement, and explanation as the question text.")
473-
xml.append(" Provide two options: 'Apply' (write the optimized code to the file) and 'Reject' (do nothing).")
471+
xml.append(" First, present a short summary: function name, performance improvement, and explanation.")
472+
xml.append(" If you are running inside an IDE (VS Code, Cursor, Windsurf, etc.):")
473+
xml.append(" For each optimized-code element, use the Write tool to write the optimized code to the file.")
474+
xml.append(" This will surface the diff in the IDE's native diff view for the user to accept or reject.")
475+
xml.append(" If you are running in a terminal without an IDE connection:")
476+
xml.append(" Present this optimization to the user using AskUserQuestion.")
477+
xml.append(" Show the function name, performance improvement, and explanation as the question text.")
478+
xml.append(" Provide two options: 'Apply' (write the optimized code to the file) and 'Reject' (do nothing).")
474479
xml.append(
475-
" Put the full diff in the 'Apply' option's markdown preview so the user can review the exact changes."
480+
" Put the full diff in the 'Apply' option's markdown preview so the user can review the exact changes."
476481
)
477-
xml.append(" If the user chooses 'Apply', write the content from optimized-code to the corresponding file.")
482+
xml.append(" If the user chooses 'Apply', write the content from optimized-code to the corresponding file.")
478483
xml.append(" </action>")
479484
xml.append("</codeflash-optimization>")
480485

0 commit comments

Comments
 (0)