mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 10:14:22 +01:00
fix(tui): min width on user messages
This commit is contained in:
@@ -226,11 +226,18 @@ func renderText(message client.MessageInfo, text string, author string) string {
|
|||||||
if message.Role == client.Assistant {
|
if message.Role == client.Assistant {
|
||||||
markdownWidth = width - padding - 4 - 3
|
markdownWidth = width - padding - 4 - 3
|
||||||
}
|
}
|
||||||
if message.Role == client.User {
|
minWidth := max(markdownWidth, (width-4)/2)
|
||||||
text = strings.ReplaceAll(text, "<", "\\<")
|
messageStyle := styles.NewStyle().
|
||||||
text = strings.ReplaceAll(text, ">", "\\>")
|
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")
|
content = strings.Join([]string{content, info}, "\n")
|
||||||
|
|
||||||
switch message.Role {
|
switch message.Role {
|
||||||
|
|||||||
Reference in New Issue
Block a user