diff options
| author | adamdottv <[email protected]> | 2025-06-27 06:30:40 -0500 |
|---|---|---|
| committer | Jay V <[email protected]> | 2025-06-27 19:10:41 -0400 |
| commit | 8455029de18b39c524fe7808b9d01b67c8e90a76 (patch) | |
| tree | 43182ae74e18f25b9c1a8d3b883a7bb606a62b2f | |
| parent | 9f07f89384907e57c42317b63d8316701bba8f25 (diff) | |
| download | opencode-8455029de18b39c524fe7808b9d01b67c8e90a76.tar.gz opencode-8455029de18b39c524fe7808b9d01b67c8e90a76.zip | |
fix(tui): min width on user messages
| -rw-r--r-- | packages/tui/internal/components/chat/message.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/packages/tui/internal/components/chat/message.go b/packages/tui/internal/components/chat/message.go index f547907ee..6fa52c1f4 100644 --- a/packages/tui/internal/components/chat/message.go +++ b/packages/tui/internal/components/chat/message.go @@ -226,11 +226,18 @@ func renderText(message client.MessageInfo, text string, author string) string { if message.Role == client.Assistant { markdownWidth = width - padding - 4 - 3 } - if message.Role == client.User { - text = strings.ReplaceAll(text, "<", "\\<") - text = strings.ReplaceAll(text, ">", "\\>") + minWidth := max(markdownWidth, (width-4)/2) + messageStyle := styles.NewStyle(). + Width(minWidth). + Background(t.BackgroundPanel()). + Foreground(t.Text()) + if textWidth < minWidth { + messageStyle = messageStyle.AlignHorizontal(lipgloss.Right) + } + content := messageStyle.Render(text) + if message.Role == client.Assistant { + content = toMarkdown(text, markdownWidth, t.BackgroundPanel()) } - content := toMarkdown(text, markdownWidth, t.BackgroundPanel()) content = strings.Join([]string{content, info}, "\n") switch message.Role { @@ -409,7 +416,7 @@ func renderToolInvocation( title = fmt.Sprintf("WRITE %s", relative(filename)) if content, ok := toolArgsMap["content"].(string); ok { body = renderFile(filename, content) - + // Add diagnostics at the bottom if they exist if diagnostics := renderDiagnostics(metadata, filename); diagnostics != "" { body += "\n" + renderContentBlock(diagnostics, WithFullWidth(), WithBorderColor(t.Error())) @@ -753,7 +760,7 @@ func renderDiagnostics(metadata client.MessageMetadata_Tool_AdditionalProperties continue } - line := diag.Range.Start.Line + 1 // 1-based + line := diag.Range.Start.Line + 1 // 1-based column := diag.Range.Start.Character + 1 // 1-based errorDiagnostics = append(errorDiagnostics, fmt.Sprintf("Error [%d:%d] %s", line, column, diag.Message)) } |
