wip: refactoring tui

This commit is contained in:
adamdottv
2025-05-30 06:47:44 -05:00
parent b1b402faa7
commit 189d0e5fb2
5 changed files with 27 additions and 21 deletions

View File

@@ -143,28 +143,32 @@ 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 := make([]client.SessionInfo, len(infos))
for i, info := range infos {
sessions[i] = client.SessionInfo{
Id: info.Id,
Title: info.Title,
}
}
sessions := *resp.JSON200
return sessions, nil
}
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
}
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
func (app *App) initTheme() {
cfg := config.Get()