mirror of
https://github.com/sst/opencode.git
synced 2025-08-31 18:27:22 +00:00
fix(tui): min width on user messages
This commit is contained in:
parent
9f07f89384
commit
8455029de1
1 changed files with 13 additions and 6 deletions
|
@ -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 {
|
||||
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue