mirror of
https://github.com/sst/opencode.git
synced 2025-07-08 00:25:00 +00:00
fix(tui): selected message visuals
This commit is contained in:
parent
aeea84a877
commit
0eadc50a33
1 changed files with 17 additions and 25 deletions
|
@ -80,15 +80,11 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
m.showToolDetails = !m.showToolDetails
|
m.showToolDetails = !m.showToolDetails
|
||||||
m.rendering = true
|
m.rendering = true
|
||||||
return m, m.Reload()
|
return m, m.Reload()
|
||||||
case app.SessionLoadedMsg:
|
case app.SessionLoadedMsg, app.SessionClearedMsg:
|
||||||
m.cache.Clear()
|
m.cache.Clear()
|
||||||
m.tail = true
|
m.tail = true
|
||||||
m.rendering = true
|
m.rendering = true
|
||||||
return m, m.Reload()
|
return m, m.Reload()
|
||||||
case app.SessionClearedMsg:
|
|
||||||
m.cache.Clear()
|
|
||||||
m.rendering = true
|
|
||||||
return m, m.Reload()
|
|
||||||
case renderFinishedMsg:
|
case renderFinishedMsg:
|
||||||
m.rendering = false
|
m.rendering = false
|
||||||
if m.tail {
|
if m.tail {
|
||||||
|
@ -153,13 +149,8 @@ func (m *messagesComponent) renderView(width int) {
|
||||||
m.cache.Set(key, content)
|
m.cache.Set(key, content)
|
||||||
}
|
}
|
||||||
if content != "" {
|
if content != "" {
|
||||||
if m.selectedPart == m.partCount {
|
m = m.updateSelected(content, part.Text)
|
||||||
m.viewport.SetYOffset(m.lineCount - 4)
|
|
||||||
m.selectedText = part.Text
|
|
||||||
}
|
|
||||||
blocks = append(blocks, content)
|
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 content != "" {
|
||||||
if m.selectedPart == m.partCount {
|
m = m.updateSelected(content, p.Text)
|
||||||
m.viewport.SetYOffset(m.lineCount - 4)
|
|
||||||
m.selectedText = p.Text
|
|
||||||
}
|
|
||||||
blocks = append(blocks, content)
|
blocks = append(blocks, content)
|
||||||
m.partCount++
|
|
||||||
m.lineCount += lipgloss.Height(content) + 1
|
|
||||||
}
|
}
|
||||||
case opencode.ToolInvocationPart:
|
case opencode.ToolInvocationPart:
|
||||||
if !m.showToolDetails {
|
if !m.showToolDetails {
|
||||||
|
@ -258,13 +244,8 @@ func (m *messagesComponent) renderView(width int) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if content != "" {
|
if content != "" {
|
||||||
if m.selectedPart == m.partCount {
|
m = m.updateSelected(content, "")
|
||||||
m.viewport.SetYOffset(m.lineCount - 4)
|
|
||||||
m.selectedText = ""
|
|
||||||
}
|
|
||||||
blocks = append(blocks, 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"))
|
m.viewport.SetContent("\n" + strings.Join(blocks, "\n\n"))
|
||||||
if m.selectedPart == m.partCount-1 {
|
if m.selectedPart == m.partCount {
|
||||||
m.viewport.GotoBottom()
|
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 {
|
func (m *messagesComponent) header(width int) string {
|
||||||
|
@ -343,7 +335,7 @@ func (m *messagesComponent) View(width, height int) string {
|
||||||
height,
|
height,
|
||||||
lipgloss.Center,
|
lipgloss.Center,
|
||||||
lipgloss.Center,
|
lipgloss.Center,
|
||||||
styles.NewStyle().Background(t.Background()).Render("Loading session..."),
|
styles.NewStyle().Background(t.Background()).Render(""),
|
||||||
styles.WhitespaceStyle(t.Background()),
|
styles.WhitespaceStyle(t.Background()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue