summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoradamdotdevin <[email protected]>2025-07-16 06:55:14 -0500
committeradamdotdevin <[email protected]>2025-07-16 06:55:14 -0500
commita563fdd287c69b283c2a8f28253d926720a3af9d (patch)
tree4d7b031c2f6c3263741059b7fb1ea348b44257dc
parent7c93bf5993c0a76a17547c51c8d6c3ad9b0df33c (diff)
downloadopencode-a563fdd287c69b283c2a8f28253d926720a3af9d.tar.gz
opencode-a563fdd287c69b283c2a8f28253d926720a3af9d.zip
fix(tui): diagnostics rendering
-rw-r--r--packages/tui/internal/components/chat/message.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/packages/tui/internal/components/chat/message.go b/packages/tui/internal/components/chat/message.go
index 635979194..35ff675bd 100644
--- a/packages/tui/internal/components/chat/message.go
+++ b/packages/tui/internal/components/chat/message.go
@@ -331,7 +331,7 @@ func renderToolDetails(
Padding(1, 2).
Width(width - 4)
- if diagnostics := renderDiagnostics(metadata, filename); diagnostics != "" {
+ if diagnostics := renderDiagnostics(metadata, filename, backgroundColor, width-6); diagnostics != "" {
diagnostics = style.Render(diagnostics)
body += "\n" + diagnostics
}
@@ -353,7 +353,7 @@ func renderToolDetails(
if filename, ok := toolInputMap["filePath"].(string); ok {
if content, ok := toolInputMap["content"].(string); ok {
body = util.RenderFile(filename, content, width)
- if diagnostics := renderDiagnostics(metadata, filename); diagnostics != "" {
+ if diagnostics := renderDiagnostics(metadata, filename, backgroundColor, width-4); diagnostics != "" {
body += "\n\n" + diagnostics
}
}
@@ -628,7 +628,12 @@ type Diagnostic struct {
}
// renderDiagnostics formats LSP diagnostics for display in the TUI
-func renderDiagnostics(metadata map[string]any, filePath string) string {
+func renderDiagnostics(
+ metadata map[string]any,
+ filePath string,
+ backgroundColor compat.AdaptiveColor,
+ width int,
+) string {
if diagnosticsData, ok := metadata["diagnostics"].(map[string]any); ok {
if fileDiagnostics, ok := diagnosticsData[filePath].([]any); ok {
var errorDiagnostics []string
@@ -664,9 +669,15 @@ func renderDiagnostics(metadata map[string]any, filePath string) string {
var result strings.Builder
for _, diagnostic := range errorDiagnostics {
if result.Len() > 0 {
- result.WriteString("\n")
+ result.WriteString("\n\n")
}
- result.WriteString(styles.NewStyle().Foreground(t.Error()).Render(diagnostic))
+ diagnostic = ansi.WordwrapWc(diagnostic, width, " -")
+ result.WriteString(
+ styles.NewStyle().
+ Background(backgroundColor).
+ Foreground(t.Error()).
+ Render(diagnostic),
+ )
}
return result.String()
}