feat: thinking blocks rendered in tui and share page

This commit is contained in:
adamdotdevin
2025-08-10 19:24:16 -05:00
parent 20e818ad05
commit b8d2aebf09
17 changed files with 324 additions and 55 deletions

View File

@@ -208,6 +208,7 @@ func renderText(
showToolDetails bool,
width int,
extra string,
isThinking bool,
fileParts []opencode.FilePart,
agentParts []opencode.AgentPart,
toolCalls ...opencode.ToolPart,
@@ -219,8 +220,15 @@ func renderText(
var content string
switch casted := message.(type) {
case opencode.AssistantMessage:
bg := t.Background()
if isThinking {
bg = t.BackgroundPanel()
}
ts = time.UnixMilli(int64(casted.Time.Created))
content = util.ToMarkdown(text, width, t.Background())
content = util.ToMarkdown(text, width, bg)
if isThinking {
content = styles.NewStyle().Background(bg).Foreground(t.TextMuted()).Render("Thinking") + "\n\n" + content
}
case opencode.UserMessage:
ts = time.UnixMilli(int64(casted.Time.Created))
base := styles.NewStyle().Foreground(t.Text()).Background(backgroundColor)
@@ -385,6 +393,16 @@ func renderText(
WithBorderColor(t.Secondary()),
)
case opencode.AssistantMessage:
if isThinking {
return renderContentBlock(
app,
content,
width,
WithTextColor(t.Text()),
WithBackgroundColor(t.BackgroundPanel()),
WithBorderColor(t.BackgroundPanel()),
)
}
return renderContentBlock(
app,
content,