Documentation
¶
Index ¶
- type Service
- func (s *Service) DeleteByWorkspace(ctx context.Context, workspaceID string) error
- func (s *Service) DeleteSession(ctx context.Context, workspaceID, sessionID string) error
- func (s *Service) ListByWorkspace(ctx context.Context, workspaceID string) ([]types.SessionListItem, error)
- func (s *Service) RecordMessage(workspaceID, sessionID, title string, at time.Time)
- func (s *Service) Start() error
- func (s *Service) Stop() error
- func (s *Service) UpdateLastSeen(ctx context.Context, workspaceID, sessionID string) error
- func (s *Service) UpsertContextUsed(ctx context.Context, workspaceID, sessionID string, contextUsed int64) error
- func (s *Service) UpsertParent(ctx context.Context, workspaceID, sessionID, parentID string) error
- func (s *Service) UpsertTitle(ctx context.Context, workspaceID, sessionID, title string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages the session_index table with non-blocking writes.
func New ¶
func New(db interfaces.DatabaseService, log *logger.Logger) *Service
New creates a new SessionIndexService.
func (*Service) DeleteByWorkspace ¶
DeleteByWorkspace removes all session index entries for a workspace.
func (*Service) DeleteSession ¶
DeleteSession removes a single session and its descendants from the session index.
func (*Service) ListByWorkspace ¶
func (s *Service) ListByWorkspace(ctx context.Context, workspaceID string) ([]types.SessionListItem, error)
ListByWorkspace returns session metadata ordered by last_message_at DESC.
func (*Service) RecordMessage ¶
RecordMessage is non-blocking: pushes to a bounded channel. If the channel is full, the oldest event is dropped.
func (*Service) UpdateLastSeen ¶
func (*Service) UpsertContextUsed ¶
func (s *Service) UpsertContextUsed(ctx context.Context, workspaceID, sessionID string, contextUsed int64) error
UpsertContextUsed persists the prompt token count from the most recent LLM step for this session. Called synchronously from the proxy's onRawEvent handler on every session.next.step.ended SSE event. Low frequency (at most once per LLM call), so a direct synchronous write is appropriate.
func (*Service) UpsertParent ¶
UpsertParent records the parent session of a (sub)session. Used by the proxy to mirror opencode's session.parentID into the sidebar's session_index so the sidebar can render hierarchy without round-tripping the agent. Empty parentID is allowed (top-level session) but uncommon — callers typically only invoke this when they have observed a non-empty parentID on a session.