Skip to content

Commit d91cea7

Browse files
committed
fix(formatter): use display labels in child tool summaries
1 parent 1d40cc0 commit d91cea7

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

lua/opencode/ui/formatter.lua

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ function M._format_question_tool(output, input, metadata, status, duration_text)
668668
end
669669

670670
function M._resolve_file_name(file_path)
671-
if not file_path then
671+
if not file_path or file_path == '' then
672672
return ''
673673
end
674674
local cwd = vim.fn.getcwd()
@@ -773,44 +773,44 @@ end
773773

774774
local tool_summary_handlers = {
775775
bash = function(_, input)
776-
return 'run', input.description or ''
776+
return 'run', 'run', input.description or ''
777777
end,
778778
read = function(_, input)
779-
return 'read', M._resolve_file_name(input.filePath)
779+
return 'read', 'read', M._resolve_file_name(input.filePath)
780780
end,
781781
edit = function(_, input)
782-
return 'edit', M._resolve_file_name(input.filePath)
782+
return 'edit', 'edit', M._resolve_file_name(input.filePath)
783783
end,
784784
write = function(_, input)
785-
return 'write', M._resolve_file_name(input.filePath)
785+
return 'write', 'write', M._resolve_file_name(input.filePath)
786786
end,
787787
apply_patch = function(_, metadata)
788788
local file = metadata.files and metadata.files[1]
789789
local others_count = metadata.files and #metadata.files - 1 or 0
790790
local suffix = others_count > 0 and string.format(' (+%d more)', others_count) or ''
791791

792-
return 'write', file and M._resolve_file_name(file.filePath) .. suffix or ''
792+
return 'edit', 'apply patch', file and M._resolve_file_name(file.filePath) .. suffix or ''
793793
end,
794794
todowrite = function(part, _)
795-
return 'plan', part.state and part.state.title or ''
795+
return 'plan', 'plan', part.state and part.state.title or ''
796796
end,
797797
glob = function(_, input)
798-
return 'search', input.pattern or ''
798+
return 'search', 'glob', input.pattern or ''
799799
end,
800800
webfetch = function(_, input)
801-
return 'web', input.url or ''
801+
return 'web', 'fetch', input.url or ''
802802
end,
803803
list = function(_, input)
804-
return 'list', input.path or ''
804+
return 'list', 'list', input.path or ''
805805
end,
806806
task = function(_, input)
807-
return 'task', input.description or ''
807+
return 'task', 'task', input.description or ''
808808
end,
809809
grep = function(_, input)
810-
return 'search', M._resolve_grep_string(input)
810+
return 'search', 'grep', M._resolve_grep_string(input)
811811
end,
812812
tool = function(_, input)
813-
return 'tool', input.description or ''
813+
return 'tool', 'tool', input.description or ''
814814
end,
815815
}
816816

@@ -823,12 +823,12 @@ function M._tool_action_line(part, status)
823823
local tool = part.tool
824824
local input = part.state and part.state.input or {}
825825
local handler = tool_summary_handlers[tool] or tool_summary_handlers['tool']
826-
local icon_name, tool_value = handler(part, input)
826+
local icon_name, tool_label, tool_value = handler(part, input)
827827
if status ~= 'completed' then
828828
icon_name = status
829829
end
830830

831-
return M._build_action_line(icon_name, tool or 'tool', tool_value)
831+
return M._build_action_line(icon_name, tool_label or tool or 'tool', tool_value)
832832
end
833833

834834
---@param output Output Output object to write to

0 commit comments

Comments
 (0)