diff options
Diffstat (limited to 'internal/tui/app')
| -rw-r--r-- | internal/tui/app/app.go | 55 | ||||
| -rw-r--r-- | internal/tui/app/bridge.go | 41 | ||||
| -rw-r--r-- | internal/tui/app/interfaces.go | 10 |
3 files changed, 18 insertions, 88 deletions
diff --git a/internal/tui/app/app.go b/internal/tui/app/app.go index 4939a5802..d169f6dc2 100644 --- a/internal/tui/app/app.go +++ b/internal/tui/app/app.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "sync" - "time" "log/slog" @@ -12,7 +11,6 @@ import ( "github.com/sst/opencode/internal/config" "github.com/sst/opencode/internal/fileutil" "github.com/sst/opencode/internal/message" - "github.com/sst/opencode/internal/session" "github.com/sst/opencode/internal/status" "github.com/sst/opencode/internal/tui/state" "github.com/sst/opencode/internal/tui/theme" @@ -26,13 +24,11 @@ type App struct { Session *client.SessionInfo Messages []client.MessageInfo - CurrentSessionOLD *session.Session - SessionsOLD SessionService - MessagesOLD MessageService - LogsOLD any // TODO: Define LogService interface when needed - HistoryOLD any // TODO: Define HistoryService interface when needed - PermissionsOLD any // TODO: Define PermissionService interface when needed - Status status.Service + MessagesOLD MessageService + LogsOLD any // TODO: Define LogService interface when needed + HistoryOLD any // TODO: Define HistoryService interface when needed + PermissionsOLD any // TODO: Define PermissionService interface when needed + Status status.Service PrimaryAgentOLD AgentService @@ -70,19 +66,16 @@ func New(ctx context.Context) (*App, error) { } // Create service bridges - sessionBridge := NewSessionServiceBridge(httpClient) messageBridge := NewMessageServiceBridge(httpClient) agentBridge := NewAgentServiceBridge(httpClient) app := &App{ - Client: httpClient, - Events: eventClient, - Session: &client.SessionInfo{}, - CurrentSessionOLD: &session.Session{}, - SessionsOLD: sessionBridge, - MessagesOLD: messageBridge, - PrimaryAgentOLD: agentBridge, - Status: status.GetService(), + Client: httpClient, + Events: eventClient, + Session: &client.SessionInfo{}, + MessagesOLD: messageBridge, + PrimaryAgentOLD: agentBridge, + Status: status.GetService(), // TODO: These services need API endpoints: LogsOLD: nil, // logging.GetService(), @@ -113,16 +106,7 @@ func (a *App) SendChatMessage(ctx context.Context, text string, attachments []me info := resp.JSON200 a.Session = info - // Convert to old session type for backwards compatibility - newSession := session.Session{ - ID: info.Id, - Title: info.Title, - CreatedAt: time.Now(), // API doesn't provide this yet - UpdatedAt: time.Now(), // API doesn't provide this yet - } - a.CurrentSessionOLD = &newSession - - cmds = append(cmds, util.CmdHandler(state.SessionSelectedMsg(&newSession))) + cmds = append(cmds, util.CmdHandler(state.SessionSelectedMsg(info))) } // TODO: Handle attachments when API supports them @@ -151,7 +135,7 @@ func (a *App) SendChatMessage(ctx context.Context, text string, attachments []me return tea.Batch(cmds...) } -func (a *App) ListSessions(ctx context.Context) ([]session.Session, error) { +func (a *App) ListSessions(ctx context.Context) ([]client.SessionInfo, error) { resp, err := a.Client.PostSessionListWithResponse(ctx) if err != nil { return nil, err @@ -162,19 +146,16 @@ func (a *App) ListSessions(ctx context.Context) ([]session.Session, error) { } if resp.JSON200 == nil { - return []session.Session{}, nil + return []client.SessionInfo{}, nil } infos := *resp.JSON200 - // Convert to old session type - sessions := make([]session.Session, len(infos)) + sessions := make([]client.SessionInfo, len(infos)) for i, info := range infos { - sessions[i] = session.Session{ - ID: info.Id, - Title: info.Title, - CreatedAt: time.Now(), // API doesn't provide this yet - UpdatedAt: time.Now(), // API doesn't provide this yet + sessions[i] = client.SessionInfo{ + Id: info.Id, + Title: info.Title, } } diff --git a/internal/tui/app/bridge.go b/internal/tui/app/bridge.go index b646ca455..74abd712a 100644 --- a/internal/tui/app/bridge.go +++ b/internal/tui/app/bridge.go @@ -8,50 +8,9 @@ import ( "github.com/sst/opencode/internal/message" "github.com/sst/opencode/internal/pubsub" - "github.com/sst/opencode/internal/session" "github.com/sst/opencode/pkg/client" ) -// SessionServiceBridge adapts the HTTP API to the old session.Service interface -type SessionServiceBridge struct { - client *client.ClientWithResponses -} - -// NewSessionServiceBridge creates a new session service bridge -func NewSessionServiceBridge(client *client.ClientWithResponses) *SessionServiceBridge { - return &SessionServiceBridge{client: client} -} - -// Create creates a new session -func (s *SessionServiceBridge) Create(ctx context.Context, title string) (session.Session, error) { - // Moved to app.CreateSession - return session.Session{}, fmt.Errorf("don't use this") -} - -// Get retrieves a session by ID -func (s *SessionServiceBridge) Get(ctx context.Context, id string) (session.Session, error) { - // Moved to app.GetSession - return session.Session{}, fmt.Errorf("don't use this") -} - -// List retrieves all sessions -func (s *SessionServiceBridge) List(ctx context.Context) ([]session.Session, error) { - // Moved to app.ListSessions - return []session.Session{}, fmt.Errorf("don't use this") -} - -// Update updates a session - NOT IMPLEMENTED IN API YET -func (s *SessionServiceBridge) Update(ctx context.Context, id, title string) error { - // TODO: Not implemented in TypeScript API yet - return fmt.Errorf("session update not implemented in API") -} - -// Delete deletes a session - NOT IMPLEMENTED IN API YET -func (s *SessionServiceBridge) Delete(ctx context.Context, id string) error { - // TODO: Not implemented in TypeScript API yet - return fmt.Errorf("session delete not implemented in API") -} - // AgentServiceBridge provides a minimal agent service that sends messages to the API type AgentServiceBridge struct { client *client.ClientWithResponses diff --git a/internal/tui/app/interfaces.go b/internal/tui/app/interfaces.go index 9729a3bcb..01271156e 100644 --- a/internal/tui/app/interfaces.go +++ b/internal/tui/app/interfaces.go @@ -6,18 +6,8 @@ import ( "github.com/sst/opencode/internal/message" "github.com/sst/opencode/internal/pubsub" - "github.com/sst/opencode/internal/session" ) -// SessionService defines the interface for session operations -type SessionService interface { - Create(ctx context.Context, title string) (session.Session, error) - Get(ctx context.Context, id string) (session.Session, error) - List(ctx context.Context) ([]session.Session, error) - Update(ctx context.Context, id, title string) error - Delete(ctx context.Context, id string) error -} - // MessageService defines the interface for message operations type MessageService interface { pubsub.Subscriber[message.Message] |
