fix(TUI): make it less shimmer (#2076)

This commit is contained in:
Timo Clasen 2025-08-19 22:30:54 +02:00 committed by GitHub
parent c59ded82b3
commit 4913ee6afd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 36 additions and 11 deletions

View file

@ -382,11 +382,9 @@ func (m *editorComponent) Content() string {
status = "waiting for permission" status = "waiting for permission"
} }
if m.interruptKeyInDebounce && m.app.CurrentPermission.ID == "" { if m.interruptKeyInDebounce && m.app.CurrentPermission.ID == "" {
bright := t.Accent() hint = muted(
if status == "waiting for permission" { status,
bright = t.Warning() ) + m.spinner.View() + muted(
}
hint = util.Shimmer(status, t.Background(), t.TextMuted(), bright) + m.spinner.View() + muted(
" ", " ",
) + base( ) + base(
keyText+" again", keyText+" again",
@ -394,11 +392,7 @@ func (m *editorComponent) Content() string {
" interrupt", " interrupt",
) )
} else { } else {
bright := t.Accent() hint = muted(status) + m.spinner.View()
if status == "waiting for permission" {
bright = t.Warning()
}
hint = util.Shimmer(status, t.Background(), t.TextMuted(), bright) + m.spinner.View()
if m.app.CurrentPermission.ID == "" { if m.app.CurrentPermission.ID == "" {
hint += muted(" ") + base(keyText) + muted(" interrupt") hint += muted(" ") + base(keyText) + muted(" interrupt")
} }

View file

@ -213,6 +213,7 @@ func renderText(
extra string, extra string,
isThinking bool, isThinking bool,
isQueued bool, isQueued bool,
shimmer bool,
fileParts []opencode.FilePart, fileParts []opencode.FilePart,
agentParts []opencode.AgentPart, agentParts []opencode.AgentPart,
toolCalls ...opencode.ToolPart, toolCalls ...opencode.ToolPart,
@ -234,7 +235,12 @@ func renderText(
} }
content = util.ToMarkdown(text, width, backgroundColor) content = util.ToMarkdown(text, width, backgroundColor)
if isThinking { if isThinking {
label := util.Shimmer("Thinking...", backgroundColor, t.TextMuted(), t.Accent()) var label string
if shimmer {
label = util.Shimmer("Thinking...", backgroundColor, t.TextMuted(), t.Accent())
} else {
label = styles.NewStyle().Background(backgroundColor).Foreground(t.TextMuted()).Render("Thinking...")
}
label = styles.NewStyle().Background(backgroundColor).Width(width - 6).Render(label) label = styles.NewStyle().Background(backgroundColor).Width(width - 6).Render(label)
content = label + "\n\n" + content content = label + "\n\n" + content
} else if strings.TrimSpace(text) == "Generating..." { } else if strings.TrimSpace(text) == "Generating..." {

View file

@ -336,6 +336,25 @@ func (m *messagesComponent) renderView() tea.Cmd {
width := m.width // always use full width width := m.width // always use full width
// Find the last streaming ReasoningPart to only shimmer that one
lastStreamingReasoningID := ""
if m.showThinkingBlocks {
for mi := len(m.app.Messages) - 1; mi >= 0 && lastStreamingReasoningID == ""; mi-- {
if _, ok := m.app.Messages[mi].Info.(opencode.AssistantMessage); !ok {
continue
}
parts := m.app.Messages[mi].Parts
for pi := len(parts) - 1; pi >= 0; pi-- {
if rp, ok := parts[pi].(opencode.ReasoningPart); ok {
if strings.TrimSpace(rp.Text) != "" && rp.Time.End == 0 {
lastStreamingReasoningID = rp.ID
break
}
}
}
}
}
reverted := false reverted := false
revertedMessageCount := 0 revertedMessageCount := 0
revertedToolCount := 0 revertedToolCount := 0
@ -437,6 +456,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
files, files,
false, false,
isQueued, isQueued,
false,
fileParts, fileParts,
agentParts, agentParts,
) )
@ -513,6 +533,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
"", "",
false, false,
false, false,
false,
[]opencode.FilePart{}, []opencode.FilePart{},
[]opencode.AgentPart{}, []opencode.AgentPart{},
toolCallParts..., toolCallParts...,
@ -530,6 +551,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
"", "",
false, false,
false, false,
false,
[]opencode.FilePart{}, []opencode.FilePart{},
[]opencode.AgentPart{}, []opencode.AgentPart{},
toolCallParts..., toolCallParts...,
@ -600,6 +622,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
} }
if part.Text != "" { if part.Text != "" {
text := part.Text text := part.Text
shimmer := part.Time.End == 0 && part.ID == lastStreamingReasoningID
content = renderText( content = renderText(
m.app, m.app,
message.Info, message.Info,
@ -610,6 +633,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
"", "",
true, true,
false, false,
shimmer,
[]opencode.FilePart{}, []opencode.FilePart{},
[]opencode.AgentPart{}, []opencode.AgentPart{},
) )
@ -644,6 +668,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
"", "",
false, false,
false, false,
false,
[]opencode.FilePart{}, []opencode.FilePart{},
[]opencode.AgentPart{}, []opencode.AgentPart{},
) )