diff options
| author | adamdottv <[email protected]> | 2025-05-28 14:02:03 -0500 |
|---|---|---|
| committer | adamdottv <[email protected]> | 2025-05-28 15:36:35 -0500 |
| commit | 8863a499a9e311a48d6ab8bc05d267fb2a01f060 (patch) | |
| tree | 304aabab518270af4b2ca4c0870f3b1bf0012038 /internal/app | |
| parent | 15d21bf04acd6af75df97918f66df866c239b248 (diff) | |
| download | opencode-8863a499a9e311a48d6ab8bc05d267fb2a01f060.tar.gz opencode-8863a499a9e311a48d6ab8bc05d267fb2a01f060.zip | |
wip: refactoring tui
Diffstat (limited to 'internal/app')
| -rw-r--r-- | internal/app/services_bridge.go | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/internal/app/services_bridge.go b/internal/app/services_bridge.go index d7e032bfd..d3f2e9a23 100644 --- a/internal/app/services_bridge.go +++ b/internal/app/services_bridge.go @@ -24,20 +24,14 @@ func NewSessionServiceBridge(client *client.ClientWithResponses) *SessionService // Create creates a new session func (s *SessionServiceBridge) Create(ctx context.Context, title string) (session.Session, error) { - resp, err := s.client.PostSessionCreate(ctx) + resp, err := s.client.PostSessionCreateWithResponse(ctx) if err != nil { return session.Session{}, err } - defer resp.Body.Close() - - if resp.StatusCode != 200 { + if resp.StatusCode() != 200 { return session.Session{}, fmt.Errorf("failed to create session: %d", resp.StatusCode) } - - var info client.SessionInfo - if err := json.NewDecoder(resp.Body).Decode(&info); err != nil { - return session.Session{}, err - } + info := resp.JSON200 // Convert to old session type return session.Session{ @@ -68,17 +62,21 @@ func (s *SessionServiceBridge) Get(ctx context.Context, id string) (session.Sess // List retrieves all sessions func (s *SessionServiceBridge) List(ctx context.Context) ([]session.Session, error) { - resp, err := s.client.PostSessionList(ctx) + resp, err := s.client.PostSessionListWithResponse(ctx) if err != nil { return nil, err } - defer resp.Body.Close() - var infos []client.SessionInfo - if err := json.NewDecoder(resp.Body).Decode(&infos); 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 []session.Session{}, nil + } + + infos := *resp.JSON200 + // Convert to old session type sessions := make([]session.Session, len(infos)) for i, info := range infos { @@ -130,14 +128,10 @@ func (a *AgentServiceBridge) Run(ctx context.Context, sessionID string, text str }, }) - resp, err := a.client.PostSessionChat(ctx, client.PostSessionChatJSONRequestBody{ + go a.client.PostSessionChatWithResponse(ctx, client.PostSessionChatJSONRequestBody{ SessionID: sessionID, Parts: &parts, }) - if err != nil { - return "", err - } - defer resp.Body.Close() // The actual response will come through SSE // For now, just return success |
