fix bash tool rendering

This commit is contained in:
Dax Raad 2025-07-19 22:24:52 -04:00
parent 03de0c406d
commit a8b4aed446
2 changed files with 9 additions and 4 deletions

View file

@ -264,6 +264,8 @@ func renderToolDetails(
toolCall opencode.ToolPart, toolCall opencode.ToolPart,
width int, width int,
) string { ) string {
measure := util.Measure("chat.renderToolDetails")
defer measure("tool", toolCall.Tool)
ignoredTools := []string{"todoread"} ignoredTools := []string{"todoread"}
if slices.Contains(ignoredTools, toolCall.Tool) { if slices.Contains(ignoredTools, toolCall.Tool) {
return "" return ""
@ -368,13 +370,14 @@ func renderToolDetails(
} }
} }
case "bash": case "bash":
command := toolInputMap["command"].(string)
body = fmt.Sprintf("```console\n$ %s\n", command)
stdout := metadata["stdout"] stdout := metadata["stdout"]
if stdout != nil { if stdout != nil {
command := toolInputMap["command"].(string) body += ansi.Strip(fmt.Sprintf("%s", stdout))
out := ansi.Strip(fmt.Sprintf("%s", stdout))
body = fmt.Sprintf("```console\n> %s\n%s```", command, out)
body = util.ToMarkdown(body, width, backgroundColor)
} }
body += "```"
body = util.ToMarkdown(body, width, backgroundColor)
case "webfetch": case "webfetch":
if format, ok := toolInputMap["format"].(string); ok && result != nil { if format, ok := toolInputMap["format"].(string); ok && result != nil {
body = *result body = *result

View file

@ -234,6 +234,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
} }
case opencode.AssistantMessage: case opencode.AssistantMessage:
messageMeasure := util.Measure("messages.Render")
hasTextPart := false hasTextPart := false
for partIndex, p := range message.Parts { for partIndex, p := range message.Parts {
switch part := p.(type) { switch part := p.(type) {
@ -365,6 +366,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
} }
} }
} }
messageMeasure()
} }
error := "" error := ""