adamdottv 8 месяцев назад
Родитель
Сommit
1b8cfe9e99

+ 1 - 1
packages/tui/internal/components/chat/editor.go

@@ -273,7 +273,7 @@ func (m *editorComponent) View() string {
 		Width(m.width).
 		Background(t.BackgroundElement()).
 		Border(lipgloss.ThickBorder(), false, true).
-		BorderForeground(t.BorderActive()).
+		BorderForeground(t.BackgroundSubtle()).
 		BorderBackground(t.Background()).
 		Render(textarea)
 

+ 18 - 13
packages/tui/internal/components/chat/messages.go

@@ -245,7 +245,7 @@ func (m *messagesComponent) header() string {
 	base := styles.BaseStyle().Render
 	muted := styles.Muted().Render
 	headerLines := []string{}
-	headerLines = append(headerLines, toMarkdown("# "+m.app.Session.Title, width, t.Background()))
+	headerLines = append(headerLines, toMarkdown("# "+m.app.Session.Title, width-4, t.BackgroundElement()))
 	if m.app.Session.Share != nil && m.app.Session.Share.Url != "" {
 		headerLines = append(headerLines, muted(m.app.Session.Share.Url))
 	} else {
@@ -255,20 +255,25 @@ func (m *messagesComponent) header() string {
 
 	header = styles.BaseStyle().
 		Width(width).
-		PaddingTop(1).
-		BorderBottom(true).
-		BorderForeground(t.BorderSubtle()).
-		BorderStyle(lipgloss.NormalBorder()).
-		Background(t.Background()).
+		PaddingLeft(2).
+		Background(t.BackgroundElement()).
+		BorderLeft(true).
+		BorderRight(true).
+		BorderBackground(t.Background()).
+		BorderForeground(t.BackgroundSubtle()).
+		BorderStyle(lipgloss.ThickBorder()).
 		Render(header)
 
-	return header
+	return "\n" + header + "\n"
 }
 
 func (m *messagesComponent) View() string {
-	if len(m.app.Messages) == 0 || m.rendering {
+	if len(m.app.Messages) == 0 {
 		return m.home()
 	}
+	if m.rendering {
+		return m.viewport.View()
+	}
 	return lipgloss.JoinVertical(
 		lipgloss.Left,
 		lipgloss.PlaceHorizontal(m.width, lipgloss.Center, m.header()),
@@ -301,8 +306,8 @@ func (m *messagesComponent) home() string {
 		styles.Muted().Render(open),
 		styles.BaseStyle().Render(code),
 	)
-	cwd := app.Info.Path.Cwd
-	config := app.Info.Path.Config
+	// cwd := app.Info.Path.Cwd
+	// config := app.Info.Path.Config
 
 	commands := [][]string{
 		{"/help", "show help"},
@@ -329,9 +334,9 @@ func (m *messagesComponent) home() string {
 	lines = append(lines, "")
 	lines = append(lines, logoAndVersion)
 	lines = append(lines, "")
-	lines = append(lines, base("cwd ")+muted(cwd))
-	lines = append(lines, base("config ")+muted(config))
-	lines = append(lines, "")
+	// lines = append(lines, base("cwd ")+muted(cwd))
+	// lines = append(lines, base("config ")+muted(config))
+	// lines = append(lines, "")
 	lines = append(lines, commandLines...)
 	lines = append(lines, "")
 	if m.rendering {

+ 8 - 2
packages/tui/internal/components/dialog/models.go

@@ -112,8 +112,14 @@ func (m *modelDialog) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 			}
 		case key.Matches(msg, modelKeys.Enter):
 			models := m.models()
-			cmd := util.CmdHandler(state.ModelSelectedMsg{Provider: m.provider, Model: models[m.selectedIdx]})
-			return m, tea.Batch(cmd, util.CmdHandler(modal.CloseModalMsg{}))
+			return m, tea.Sequence(
+				util.CmdHandler(modal.CloseModalMsg{}),
+				util.CmdHandler(
+					state.ModelSelectedMsg{
+						Provider: m.provider,
+						Model:    models[m.selectedIdx],
+					}),
+			)
 		case key.Matches(msg, modelKeys.Escape):
 			return m, util.CmdHandler(modal.CloseModalMsg{})
 		}

+ 2 - 6
packages/tui/internal/components/dialog/quit.go

@@ -73,15 +73,11 @@ func (q *quitDialog) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 			if !q.selectedNo {
 				return q, tea.Quit
 			}
-			return q, tea.Batch(
-				util.CmdHandler(modal.CloseModalMsg{}),
-			)
+			return q, util.CmdHandler(modal.CloseModalMsg{})
 		case key.Matches(msg, helpKeys.Yes):
 			return q, tea.Quit
 		case key.Matches(msg, helpKeys.No):
-			return q, tea.Batch(
-				util.CmdHandler(modal.CloseModalMsg{}),
-			)
+			return q, util.CmdHandler(modal.CloseModalMsg{})
 		}
 	}
 	return q, nil

+ 2 - 2
packages/tui/internal/components/dialog/session.go

@@ -67,9 +67,9 @@ func (s *sessionDialog) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 			if item, idx := s.list.GetSelectedItem(); idx >= 0 {
 				selectedSession := item.session
 				s.selectedSessionID = selectedSession.Id
-				return s, tea.Batch(
-					util.CmdHandler(state.SessionSelectedMsg(&selectedSession)),
+				return s, tea.Sequence(
 					util.CmdHandler(modal.CloseModalMsg{}),
+					util.CmdHandler(state.SessionSelectedMsg(&selectedSession)),
 				)
 			}
 		}

+ 2 - 3
packages/tui/internal/components/dialog/theme.go

@@ -74,9 +74,9 @@ func (t *themeDialog) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 					status.Error(err.Error())
 					return t, nil
 				}
-				return t, tea.Batch(
-					util.CmdHandler(ThemeChangedMsg{ThemeName: selectedTheme}),
+				return t, tea.Sequence(
 					util.CmdHandler(modal.CloseModalMsg{}),
+					util.CmdHandler(ThemeChangedMsg{ThemeName: selectedTheme}),
 				)
 			}
 		}
@@ -125,4 +125,3 @@ func NewThemeDialog() ThemeDialog {
 		modal: modal.New(modal.WithTitle("Select Theme"), modal.WithMaxWidth(40)),
 	}
 }
-

+ 3 - 16
packages/tui/internal/theme/manager.go

@@ -6,6 +6,8 @@ import (
 	"slices"
 	"strings"
 	"sync"
+
+	"github.com/alecthomas/chroma/v2/styles"
 	// "github.com/alecthomas/chroma/v2/styles"
 )
 
@@ -45,22 +47,7 @@ func RegisterTheme(name string, theme Theme) {
 func SetTheme(name string) error {
 	globalManager.mu.Lock()
 	defer globalManager.mu.Unlock()
-	// delete(styles.Registry, "charm")
-
-	// Handle custom theme
-	// if name == "custom" {
-	// 	cfg := config.Get()
-	// 	if cfg == nil || cfg.TUI.CustomTheme == nil || len(cfg.TUI.CustomTheme) == 0 {
-	// 		return fmt.Errorf("custom theme selected but no custom theme colors defined in config")
-	// 	}
-	//
-	// 	customTheme, err := LoadCustomTheme(cfg.TUI.CustomTheme)
-	// 	if err != nil {
-	// 		return fmt.Errorf("failed to load custom theme: %w", err)
-	// 	}
-	//
-	// 	// Register the custom theme
-	// 	globalManager.themes["custom"] = customTheme
+	delete(styles.Registry, "charm")
 
 	if _, exists := globalManager.themes[name]; !exists {
 		return fmt.Errorf("theme '%s' not found", name)

+ 4 - 0
packages/tui/internal/tui/tui.go

@@ -271,6 +271,10 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 			cmds = append(cmds, cmd)
 		}
 
+		s, cmd := a.status.Update(msg)
+		cmds = append(cmds, cmd)
+		a.status = s.(core.StatusComponent)
+
 		t := theme.CurrentTheme()
 		cmds = append(cmds, tea.SetBackgroundColor(t.Background()))
 		return a, tea.Batch(cmds...)