The open source coding agent.
TypeScript
wip: refactoring tui
adamdottvc5413c8c8dc2
diff --git a/internal/tui/components/chat/message.go b/internal/tui/components/chat/message.goindex c7b8234a0fc..1dcdf8e46c9 100644--- a/internal/tui/components/chat/message.go+++ b/internal/tui/components/chat/message.go@@ -8,6 +8,7 @@ import ("github.com/charmbracelet/lipgloss""github.com/charmbracelet/x/ansi""github.com/sst/opencode/internal/config"+ "github.com/sst/opencode/internal/diff""github.com/sst/opencode/internal/tui/styles""github.com/sst/opencode/internal/tui/theme""github.com/sst/opencode/pkg/client"@@ -168,17 +169,31 @@ func renderAssistantMessage(for _, arg := range toolMap {toolArgs = append(toolArgs, fmt.Sprintf("%v", arg))}- result := truncateHeight(strings.TrimSpace(toolInvocationResult.Result), 10)params := renderParams(width-lipgloss.Width(toolName)-1, toolArgs...)title := styles.Padded().Render(fmt.Sprintf("%s: %s", toolName, params))- markdown := toMarkdown(result, width)-- content := toolStyle.Render(lipgloss.JoinVertical(lipgloss.Left,- title,- markdown,- ))- messages = append(messages, content)+ var markdown string+ if toolInvocationResult.ToolName == "edit" {+ filename := toolMap["filePath"].(string)+ oldString := toolMap["oldString"].(string)+ newString := toolMap["newString"].(string)+ patch, _, _ := diff.GenerateDiff(oldString, newString, filename)+ formattedDiff, _ := diff.FormatDiff(patch, diff.WithTotalWidth(width))+ markdown = truncateHeight(strings.TrimSpace(formattedDiff), 10)+ content := toolStyle.Render(lipgloss.JoinVertical(lipgloss.Left,+ toolName,+ markdown,+ ))+ messages = append(messages, content)+ } else {+ result := truncateHeight(strings.TrimSpace(toolInvocationResult.Result), 10)+ markdown = toMarkdown(result, width)+ content := toolStyle.Render(lipgloss.JoinVertical(lipgloss.Left,+ title,+ markdown,+ ))+ messages = append(messages, content)+ }}}}