Skip to content

Conversation

joaopluigi
Copy link
Contributor

Before After
Screenshot 2025-08-19 at 13 49 39 Screenshot 2025-08-19 at 13 47 40

@Copilot Copilot AI review requested due to automatic review settings August 19, 2025 16:55
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Updates the tool call display logic to show a more user-friendly summary instead of raw arguments text, improving the UI presentation of tool calls in the sidebar.

  • Replaces tool call arguments display with summary text for better readability
  • Adds text replacement functionality to update tool call status from preparation to completion
  • Refactors message display logic to separate user-facing content from debug logging

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lua/eca/utils.lua Simplifies line splitting by using vim.split instead of custom implementation
lua/eca/sidebar.lua Updates tool call display to show summary instead of arguments, adds text replacement logic

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

-- IMPORTANT: Return immediately - do NOT display anything for toolCallPrepare
return
elseif content.type == "toolCalled" then
local tool_text = ""
Copy link
Preview

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable tool_text is initialized as an empty string but only conditionally assigned a value. Consider initializing it to a meaningful default value or restructuring the logic to ensure it's always assigned before use.

Suggested change
local tool_text = ""
local tool_text = nil

Copilot uses AI. Check for mistakes.

changed = true
break
end
end
Copy link
Preview

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function searches through all buffer lines from bottom to top and performs string operations on each line. For large buffers, this could be inefficient. Consider adding a limit on how many lines to search or using a more targeted approach if the expected location is known.

Copilot uses AI. Check for mistakes.


tool_text_completed = tool_text_completed .. (content.summary or content.name or "Tool call completed")

if not self:_replace_text(tool_text, tool_text_completed) then
Copy link
Preview

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If tool_text is an empty string (when self:_display_tool_call() is not called), the replacement will fail and fall back to adding a new message. This could result in unexpected behavior where tool completion messages are always added as new messages instead of replacing existing ones.

Suggested change
if not self:_replace_text(tool_text, tool_text_completed) then
if tool_text ~= "" then
if not self:_replace_text(tool_text, tool_text_completed) then
self:_add_message("assistant", tool_text_completed)
end
else

Copilot uses AI. Check for mistakes.

ericdallo
ericdallo previously approved these changes Aug 19, 2025
end
return lines
return vim.split(text, "\n", { plain = true, trimempty = false })
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this because it treated texts with two consecutive \n as one \n. Also, vim.split seems more straightforward.

Copy link
Member

@tomgeorge tomgeorge Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a capture group, either /r or /n or \r\n

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that not capturing "[^\r\n]+" will be a problem or it should be fine?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe \r\n is a newline on windows, \n is a newline for unix systems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it seems that on Windows, when using vim.split(..., '\n'), it would be necessary to remove \r left in the line, but I am still not sure if this needs to be handled (or would not make difference on that case).

tomgeorge
tomgeorge previously approved these changes Aug 19, 2025
@joaopluigi joaopluigi dismissed stale reviews from tomgeorge and ericdallo via 49074d5 August 19, 2025 19:19
@joaopluigi joaopluigi merged commit 6822d74 into main Aug 20, 2025
3 checks passed
@joaopluigi joaopluigi deleted the tool-call-summary branch August 20, 2025 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants