diff options
| author | adamdottv <[email protected]> | 2025-07-09 06:41:53 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-07-09 06:41:53 -0500 |
| commit | 269b43f4de80cc13b451c51daf18be90ded45e0e (patch) | |
| tree | 1d8213d2ee2608968b9ebbe28b6993ca46adada0 | |
| parent | 3f25e5bf869d70a06afab64ca7812930f06e4ed5 (diff) | |
| download | opencode-269b43f4de80cc13b451c51daf18be90ded45e0e.tar.gz opencode-269b43f4de80cc13b451c51daf18be90ded45e0e.zip | |
fix(tui): markdown wrapping off sometimes
| -rw-r--r-- | packages/tui/internal/components/chat/message.go | 15 | ||||
| -rw-r--r-- | packages/tui/internal/components/chat/messages.go | 1 |
2 files changed, 10 insertions, 6 deletions
diff --git a/packages/tui/internal/components/chat/message.go b/packages/tui/internal/components/chat/message.go index fe34ad5ab..4f3bfdfa2 100644 --- a/packages/tui/internal/components/chat/message.go +++ b/packages/tui/internal/components/chat/message.go @@ -134,7 +134,6 @@ func renderContentBlock( style := styles.NewStyle(). Foreground(renderer.textColor). Background(t.BackgroundPanel()). - Width(width). PaddingTop(renderer.paddingTop). PaddingBottom(renderer.paddingBottom). PaddingLeft(renderer.paddingLeft). @@ -232,16 +231,15 @@ func renderText( if highlight { backgroundColor = t.BackgroundElement() } - messageStyle := styles.NewStyle().Background(backgroundColor) - content := messageStyle.Render(text) - + var content string switch casted := message.(type) { case opencode.AssistantMessage: ts = time.UnixMilli(int64(casted.Time.Created)) content = util.ToMarkdown(text, width, backgroundColor) case opencode.UserMessage: ts = time.UnixMilli(int64(casted.Time.Created)) - messageStyle = messageStyle.Width(width - 6) + messageStyle := styles.NewStyle().Background(backgroundColor).Width(width - 6) + content = messageStyle.Render(text) } timestamp := ts. @@ -307,8 +305,10 @@ func renderToolDetails( return "" } - if toolCall.State.Status == opencode.ToolPartStateStatusPending || toolCall.State.Status == opencode.ToolPartStateStatusRunning { + if toolCall.State.Status == opencode.ToolPartStateStatusPending || + toolCall.State.Status == opencode.ToolPartStateStatusRunning { title := renderToolTitle(toolCall, width) + title = styles.NewStyle().Width(width - 6).Render(title) return renderContentBlock(app, title, highlight, width) } @@ -457,6 +457,7 @@ func renderToolDetails( } body = *result body = util.TruncateHeight(body, 10) + body = styles.NewStyle().Width(width - 6).Render(body) } } @@ -467,6 +468,7 @@ func renderToolDetails( if error != "" { body = styles.NewStyle(). + Width(width - 6). Foreground(t.Error()). Background(backgroundColor). Render(error) @@ -475,6 +477,7 @@ func renderToolDetails( if body == "" && error == "" && result != nil { body = *result body = util.TruncateHeight(body, 10) + body = styles.NewStyle().Width(width - 6).Render(body) } title := renderToolTitle(toolCall, width) diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.go index 6e9c26dfa..573acdfcc 100644 --- a/packages/tui/internal/components/chat/messages.go +++ b/packages/tui/internal/components/chat/messages.go @@ -328,6 +328,7 @@ func (m *messagesComponent) renderView(width int) { } if error != "" { + error = styles.NewStyle().Width(width - 6).Render(error) error = renderContentBlock( m.app, error, |
