mirror of
https://github.com/sst/opencode.git
synced 2025-08-02 21:02:15 +00:00
perf: scroll to bottom in thread
This commit is contained in:
parent
8f64c4b312
commit
9af92b6914
2 changed files with 6 additions and 5 deletions
|
@ -102,9 +102,6 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
m.loading = false
|
m.loading = false
|
||||||
m.tail = m.viewport.AtBottom()
|
m.tail = m.viewport.AtBottom()
|
||||||
m.viewport = msg.viewport
|
m.viewport = msg.viewport
|
||||||
if m.tail {
|
|
||||||
m.viewport.GotoBottom()
|
|
||||||
}
|
|
||||||
if m.dirty {
|
if m.dirty {
|
||||||
cmds = append(cmds, m.renderView())
|
cmds = append(cmds, m.renderView())
|
||||||
}
|
}
|
||||||
|
@ -138,6 +135,7 @@ func (m *messagesComponent) renderView() tea.Cmd {
|
||||||
m.rendering = true
|
m.rendering = true
|
||||||
|
|
||||||
viewport := m.viewport
|
viewport := m.viewport
|
||||||
|
tail := m.tail
|
||||||
|
|
||||||
return func() tea.Msg {
|
return func() tea.Msg {
|
||||||
measure := util.Measure("messages.renderView")
|
measure := util.Measure("messages.renderView")
|
||||||
|
@ -402,6 +400,9 @@ func (m *messagesComponent) renderView() tea.Cmd {
|
||||||
content := "\n" + strings.Join(blocks, "\n\n")
|
content := "\n" + strings.Join(blocks, "\n\n")
|
||||||
viewport.SetHeight(m.height - lipgloss.Height(m.header))
|
viewport.SetHeight(m.height - lipgloss.Height(m.header))
|
||||||
viewport.SetContent(content)
|
viewport.SetContent(content)
|
||||||
|
if tail {
|
||||||
|
viewport.GotoBottom()
|
||||||
|
}
|
||||||
|
|
||||||
return renderCompleteMsg{
|
return renderCompleteMsg{
|
||||||
viewport: viewport,
|
viewport: viewport,
|
||||||
|
|
|
@ -528,17 +528,17 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a appModel) View() string {
|
func (a appModel) View() string {
|
||||||
|
measure := util.Measure("app.View")
|
||||||
|
defer measure()
|
||||||
t := theme.CurrentTheme()
|
t := theme.CurrentTheme()
|
||||||
|
|
||||||
var mainLayout string
|
var mainLayout string
|
||||||
|
|
||||||
measure := util.Measure("app.View")
|
|
||||||
if a.app.Session.ID == "" {
|
if a.app.Session.ID == "" {
|
||||||
mainLayout = a.home()
|
mainLayout = a.home()
|
||||||
} else {
|
} else {
|
||||||
mainLayout = a.chat()
|
mainLayout = a.chat()
|
||||||
}
|
}
|
||||||
measure()
|
|
||||||
mainLayout = styles.NewStyle().
|
mainLayout = styles.NewStyle().
|
||||||
Background(t.Background()).
|
Background(t.Background()).
|
||||||
Padding(0, 2).
|
Padding(0, 2).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue