diff options
| author | Dax Raad <[email protected]> | 2025-07-19 17:55:01 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-07-19 17:55:01 -0400 |
| commit | 9af92b6914a630ca62b91d181fbf758beb3e9a21 (patch) | |
| tree | 3c805e6c088dd23bbbc5de2f0b46fbf69fcb5134 | |
| parent | 8f64c4b3129b1e767477c9f3fbae420df7aa7340 (diff) | |
| download | opencode-9af92b6914a630ca62b91d181fbf758beb3e9a21.tar.gz opencode-9af92b6914a630ca62b91d181fbf758beb3e9a21.zip | |
perf: scroll to bottom in thread
| -rw-r--r-- | packages/tui/internal/components/chat/messages.go | 7 | ||||
| -rw-r--r-- | packages/tui/internal/tui/tui.go | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.go index 9b6920adf..7d8b1b3a9 100644 --- a/packages/tui/internal/components/chat/messages.go +++ b/packages/tui/internal/components/chat/messages.go @@ -102,9 +102,6 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.loading = false m.tail = m.viewport.AtBottom() m.viewport = msg.viewport - if m.tail { - m.viewport.GotoBottom() - } if m.dirty { cmds = append(cmds, m.renderView()) } @@ -138,6 +135,7 @@ func (m *messagesComponent) renderView() tea.Cmd { m.rendering = true viewport := m.viewport + tail := m.tail return func() tea.Msg { measure := util.Measure("messages.renderView") @@ -402,6 +400,9 @@ func (m *messagesComponent) renderView() tea.Cmd { content := "\n" + strings.Join(blocks, "\n\n") viewport.SetHeight(m.height - lipgloss.Height(m.header)) viewport.SetContent(content) + if tail { + viewport.GotoBottom() + } return renderCompleteMsg{ viewport: viewport, diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.go index d09f3d343..c6c8fa13d 100644 --- a/packages/tui/internal/tui/tui.go +++ b/packages/tui/internal/tui/tui.go @@ -528,17 +528,17 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (a appModel) View() string { + measure := util.Measure("app.View") + defer measure() t := theme.CurrentTheme() var mainLayout string - measure := util.Measure("app.View") if a.app.Session.ID == "" { mainLayout = a.home() } else { mainLayout = a.chat() } - measure() mainLayout = styles.NewStyle(). Background(t.Background()). Padding(0, 2). |
