summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoradamdottv <[email protected]>2025-07-03 09:02:58 -0500
committeradamdottv <[email protected]>2025-07-03 09:03:04 -0500
commit0eadc50a3302d6916383f60203233aae754d27b0 (patch)
tree603fa227a73f20bdbaf5bce14c47e19fe8f268bf
parentaeea84a87762e94e5903942e8ef0727be9c159a5 (diff)
downloadopencode-0eadc50a3302d6916383f60203233aae754d27b0.tar.gz
opencode-0eadc50a3302d6916383f60203233aae754d27b0.zip
fix(tui): selected message visuals
-rw-r--r--packages/tui/internal/components/chat/messages.go42
1 files changed, 17 insertions, 25 deletions
diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.go
index 05fa30801..ac001cd7f 100644
--- a/packages/tui/internal/components/chat/messages.go
+++ b/packages/tui/internal/components/chat/messages.go
@@ -80,15 +80,11 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.showToolDetails = !m.showToolDetails
m.rendering = true
return m, m.Reload()
- case app.SessionLoadedMsg:
+ case app.SessionLoadedMsg, app.SessionClearedMsg:
m.cache.Clear()
m.tail = true
m.rendering = true
return m, m.Reload()
- case app.SessionClearedMsg:
- m.cache.Clear()
- m.rendering = true
- return m, m.Reload()
case renderFinishedMsg:
m.rendering = false
if m.tail {
@@ -153,13 +149,8 @@ func (m *messagesComponent) renderView(width int) {
m.cache.Set(key, content)
}
if content != "" {
- if m.selectedPart == m.partCount {
- m.viewport.SetYOffset(m.lineCount - 4)
- m.selectedText = part.Text
- }
+ m = m.updateSelected(content, part.Text)
blocks = append(blocks, content)
- m.partCount++
- m.lineCount += lipgloss.Height(content) + 1
}
}
}
@@ -216,13 +207,8 @@ func (m *messagesComponent) renderView(width int) {
)
}
if content != "" {
- if m.selectedPart == m.partCount {
- m.viewport.SetYOffset(m.lineCount - 4)
- m.selectedText = p.Text
- }
+ m = m.updateSelected(content, p.Text)
blocks = append(blocks, content)
- m.partCount++
- m.lineCount += lipgloss.Height(content) + 1
}
case opencode.ToolInvocationPart:
if !m.showToolDetails {
@@ -258,13 +244,8 @@ func (m *messagesComponent) renderView(width int) {
)
}
if content != "" {
- if m.selectedPart == m.partCount {
- m.viewport.SetYOffset(m.lineCount - 4)
- m.selectedText = ""
- }
+ m = m.updateSelected(content, "")
blocks = append(blocks, content)
- m.partCount++
- m.lineCount += lipgloss.Height(content) + 1
}
}
}
@@ -295,9 +276,20 @@ func (m *messagesComponent) renderView(width int) {
}
m.viewport.SetContent("\n" + strings.Join(blocks, "\n\n"))
- if m.selectedPart == m.partCount-1 {
+ if m.selectedPart == m.partCount {
m.viewport.GotoBottom()
}
+
+}
+
+func (m *messagesComponent) updateSelected(content string, selectedText string) *messagesComponent {
+ if m.selectedPart == m.partCount {
+ m.viewport.SetYOffset(m.lineCount - (m.viewport.Height() / 2) + 4)
+ m.selectedText = selectedText
+ }
+ m.partCount++
+ m.lineCount += lipgloss.Height(content) + 1
+ return m
}
func (m *messagesComponent) header(width int) string {
@@ -343,7 +335,7 @@ func (m *messagesComponent) View(width, height int) string {
height,
lipgloss.Center,
lipgloss.Center,
- styles.NewStyle().Background(t.Background()).Render("Loading session..."),
+ styles.NewStyle().Background(t.Background()).Render(""),
styles.WhitespaceStyle(t.Background()),
)
}