sessionindex

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

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

New creates a new SessionIndexService.

func (*Service) DeleteByWorkspace

func (s *Service) DeleteByWorkspace(ctx context.Context, workspaceID string) error

DeleteByWorkspace removes all session index entries for a workspace.

func (*Service) DeleteSession

func (s *Service) DeleteSession(ctx context.Context, workspaceID, sessionID string) error

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

func (s *Service) RecordMessage(workspaceID, sessionID, title string, at time.Time)

RecordMessage is non-blocking: pushes to a bounded channel. If the channel is full, the oldest event is dropped.

func (*Service) Start

func (s *Service) Start() error

Start begins the background drainer goroutine.

func (*Service) Stop

func (s *Service) Stop() error

Stop signals the drainer to stop and waits for it to finish.

func (*Service) UpdateLastSeen

func (s *Service) UpdateLastSeen(ctx context.Context, workspaceID, sessionID string) error

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

func (s *Service) UpsertParent(ctx context.Context, workspaceID, sessionID, parentID string) error

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.

func (*Service) UpsertTitle

func (s *Service) UpsertTitle(ctx context.Context, workspaceID, sessionID, title string) error

UpsertTitle updates just the title for a session.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL