Skip to content

Commit 6fd6e23

Browse files
committed
add diff to tool call summary
1 parent eb9b738 commit 6fd6e23

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

lua/eca/sidebar.lua

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,7 @@ function M:_focus_input()
913913
local first_line = lines[1] or ""
914914
local cursor_col = math.max(#prefix, #first_line)
915915

916-
-- Set cursor to end of content or after prefix
917-
vim.api.nvim_win_set_cursor(input.winid, { 1, cursor_col })
916+
-- Set cursor to end of content or after prefix vim.api.nvim_win_set_cursor(input.winid, { 1, cursor_col })
918917
else
919918
-- If no lines, add input line and focus
920919
self:_add_input_line()
@@ -1246,7 +1245,13 @@ function M:_handle_server_content(params)
12461245
end
12471246
Logger.debug(tool_log)
12481247

1249-
local tool_text_completed = "" .. (content.summary or content.name or "Tool call completed")
1248+
local tool_text_completed = ""
1249+
1250+
if content.error then
1251+
tool_text_completed = ""
1252+
end
1253+
1254+
tool_text_completed = tool_text_completed .. (content.summary or content.name or "Tool call completed")
12501255

12511256
if not self:_replace_text(tool_text, tool_text_completed) then
12521257
self:_add_message("assistant", tool_text_completed)
@@ -1527,8 +1532,9 @@ function M:_handle_tool_call_prepare(content)
15271532
self._is_tool_call_streaming = true
15281533
self._current_tool_call = {
15291534
name = "",
1535+
summary = "",
15301536
arguments = "",
1531-
summary = ""
1537+
details = {}
15321538
}
15331539
end
15341540

@@ -1554,20 +1560,20 @@ end
15541560
function M:_display_tool_call()
15551561
if not self._current_tool_call then return "" end
15561562

1563+
local diff = ""
15571564
local tool_text = "🔧 " .. (self._current_tool_call.summary or "Tool call prepared")
15581565
local tool_log = string.format("**Tool Call**: %s", self._current_tool_call.name or "unknown")
15591566

15601567
if self._current_tool_call.arguments and self._current_tool_call.arguments ~= "" then
15611568
tool_log = tool_log .. "\n```json\n" .. self._current_tool_call.arguments .. "\n```"
15621569
end
15631570

1564-
15651571
if self._current_tool_call.details and self._current_tool_call.details.diff then
1566-
tool_log = tool_log .. "\n\n**Diff**:\n```diff\n" .. self._current_tool_call.details.diff .. "\n```"
1572+
diff = "\n\n**Diff**:\n```diff\n" .. self._current_tool_call.details.diff .. "\n```"
15671573
end
15681574

1569-
Logger.debug(tool_log)
1570-
self:_add_message("assistant", tool_text)
1575+
Logger.debug(tool_log .. diff)
1576+
self:_add_message("assistant", tool_text .. diff)
15711577

15721578
return tool_text
15731579
end

lua/eca/utils.lua

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ end
4343
---@param text string
4444
---@return string[]
4545
function M.split_lines(text)
46-
local lines = {}
47-
for line in text:gmatch("[^\r\n]+") do
48-
table.insert(lines, line)
49-
end
50-
return lines
46+
return vim.split(text, "\n", { plain = true, trimempty = false })
5147
end
5248

5349
---@param path string

0 commit comments

Comments
 (0)