The open source coding agent.
TypeScript
wip: refactoring tui
adamdottv189d0e5fb2fc
diff --git a/internal/tui/app/app.go b/internal/tui/app/app.goindex 3ee0f564dda..b00a6d61a64 100644--- a/internal/tui/app/app.go+++ b/internal/tui/app/app.go@@ -143,26 +143,30 @@ func (a *App) ListSessions(ctx context.Context) ([]client.SessionInfo, error) {if err != nil {return nil, err}-if resp.StatusCode() != 200 {return nil, fmt.Errorf("failed to list sessions: %d", resp.StatusCode())}-if resp.JSON200 == nil {return []client.SessionInfo{}, nil}- infos := *resp.JSON200+ sessions := *resp.JSON200+ return sessions, nil+}- sessions := make([]client.SessionInfo, len(infos))- for i, info := range infos {- sessions[i] = client.SessionInfo{- Id: info.Id,- Title: info.Title,- }+func (a *App) ListMessages(ctx context.Context, sessionId string) ([]client.MessageInfo, error) {+ resp, err := a.Client.PostSessionMessagesWithResponse(ctx, client.PostSessionMessagesJSONRequestBody{SessionID: sessionId})+ if err != nil {+ return nil, err}-- return sessions, nil+ if resp.StatusCode() != 200 {+ return nil, fmt.Errorf("failed to list messages: %d", resp.StatusCode())+ }+ if resp.JSON200 == nil {+ return []client.MessageInfo{}, nil+ }+ messages := *resp.JSON200+ return messages, nil}// initTheme sets the application theme based on the configurationdiff --git a/internal/tui/components/chat/messages.go b/internal/tui/components/chat/messages.goindex 0dda7ae32ae..ae6f2a687dc 100644--- a/internal/tui/components/chat/messages.go+++ b/internal/tui/components/chat/messages.go@@ -73,8 +73,8 @@ func (m *messagesCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {cmd := m.Reload()return m, cmdcase state.SessionClearedMsg:- m.rendering = false- return m, nil+ cmd := m.Reload()+ return m, cmdcase tea.KeyMsg:if key.Matches(msg, messageKeys.PageUp) || key.Matches(msg, messageKeys.PageDown) ||key.Matches(msg, messageKeys.HalfPageUp) || key.Matches(msg, messageKeys.HalfPageDown) {diff --git a/internal/tui/components/dialog/session.go b/internal/tui/components/dialog/session.goindex fd08a7db576..99aa415151c 100644--- a/internal/tui/components/dialog/session.go+++ b/internal/tui/components/dialog/session.go@@ -74,6 +74,9 @@ func (s *sessionDialogCmp) Init() tea.Cmd {func (s *sessionDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {switch msg := msg.(type) {+ case tea.WindowSizeMsg:+ s.width = msg.Width+ s.height = msg.Heightcase tea.KeyMsg:switch {case key.Matches(msg, sessionKeys.Up) || key.Matches(msg, sessionKeys.K):@@ -98,9 +101,6 @@ func (s *sessionDialogCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {case key.Matches(msg, sessionKeys.Escape):return s, util.CmdHandler(CloseSessionDialogMsg{})}- case tea.WindowSizeMsg:- s.width = msg.Width- s.height = msg.Height}return s, nil}diff --git a/internal/tui/page/chat.go b/internal/tui/page/chat.goindex 134de6afd83..bf30193f527 100644--- a/internal/tui/page/chat.go+++ b/internal/tui/page/chat.go@@ -114,6 +114,7 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {// Continue sending keys to layout->chatcase key.Matches(msg, keyMap.NewSession):p.app.Session = &client.SessionInfo{}+ p.app.Messages = []client.MessageInfo{}return p, tea.Batch(p.clearSidebar(),util.CmdHandler(state.SessionClearedMsg{}),diff --git a/internal/tui/tui.go b/internal/tui/tui.goindex 1c20f5c8a5f..024abe00077 100644--- a/internal/tui/tui.go+++ b/internal/tui/tui.go@@ -271,10 +271,6 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {case page.PageChangeMsg:return a, a.moveToPage(msg.ID)- case state.SessionSelectedMsg:- a.app.Session = msg- return a.updateAllPages(msg)-case dialog.CloseQuitMsg:a.showQuit = falsereturn a, nil@@ -286,6 +282,11 @@ func (a appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {}return a, nil+ case state.SessionSelectedMsg:+ a.app.Session = msg+ a.app.Messages, _ = a.app.ListMessages(context.Background(), msg.Id)+ return a.updateAllPages(msg)+case dialog.CloseCommandDialogMsg:a.showCommandDialog = falsereturn a, nil