From 189d0e5fb2fc728c639952dd17fef1abdf251c18 Mon Sep 17 00:00:00 2001 From: adamdottv <2363879+adamdottv@users.noreply.github.com> Date: Fri, 30 May 2025 06:47:44 -0500 Subject: wip: refactoring tui --- internal/tui/app/app.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'internal/tui/app') diff --git a/internal/tui/app/app.go b/internal/tui/app/app.go index 3ee0f564d..b00a6d61a 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 configuration -- cgit v1.2.3