Pārlūkot izejas kodu

fix(tui): async load messages on theme/session switch

adamdottv 9 mēneši atpakaļ
vecāks
revīzija
9ea0d71e8d

+ 5 - 7
packages/tui/internal/components/chat/messages.go

@@ -60,17 +60,14 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		return m, nil
 	case dialog.ThemeSelectedMsg:
 		m.cache.Clear()
-		m.renderView()
-		return m, nil
+		return m, m.Reload()
 	case ToggleToolDetailsMsg:
 		m.showToolDetails = !m.showToolDetails
-		m.renderView()
-		return m, nil
+		return m, m.Reload()
 	case app.SessionSelectedMsg:
 		m.cache.Clear()
-		cmd := m.Reload()
-		m.viewport.GotoBottom()
-		return m, cmd
+		m.tail = true
+		return m, m.Reload()
 	case app.SessionClearedMsg:
 		m.cache.Clear()
 		cmd := m.Reload()
@@ -346,6 +343,7 @@ func (m *messagesComponent) home() string {
 		logoAndVersion,
 		lipgloss.WithWhitespaceStyle(lipgloss.NewStyle().Background(t.Background())),
 	)
+	m.commands.SetBackgroundColor(t.Background())
 	commands := lipgloss.PlaceHorizontal(
 		m.width,
 		lipgloss.Center,

+ 5 - 0
packages/tui/internal/components/commands/commands.go

@@ -18,6 +18,7 @@ type CommandsComponent interface {
 	tea.Model
 	tea.ViewModel
 	layout.Sizeable
+	SetBackgroundColor(color compat.AdaptiveColor)
 }
 
 type commandsComponent struct {
@@ -38,6 +39,10 @@ func (c *commandsComponent) GetSize() (int, int) {
 	return c.width, c.height
 }
 
+func (c *commandsComponent) SetBackgroundColor(color compat.AdaptiveColor) {
+	c.background = &color
+}
+
 func (c *commandsComponent) Init() tea.Cmd {
 	return nil
 }