sessionservice

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package sessionservice stores CLI chat sessions so conversations persist across terminal restarts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service interface {
	// New creates a new named session and makes it active.
	// If name is empty, a UUID-based name is generated.
	New(ctx context.Context, identity, name string) (id string, err error)

	// List returns all sessions for the given identity with message counts.
	// The currently active session is marked IsActive = true.
	List(ctx context.Context, identity string) ([]*SessionInfo, error)

	// Switch changes the active session pointer to the session with the given name.
	Switch(ctx context.Context, identity, name string) error

	// Delete removes a session and its messages. Reports whether the session
	// that was deleted was the currently active one.
	Delete(ctx context.Context, identity, name string) (wasActive bool, err error)

	// GetActiveID reads the active session ID from the KV store.
	// Returns ("", nil) when no session is active.
	GetActiveID(ctx context.Context) (string, error)

	// SetActiveID persists an active session ID to the KV store.
	SetActiveID(ctx context.Context, id string) error

	// EnsureDefault creates (or reuses) a "default" session, sets it active,
	// and returns its ID. Idempotent.
	EnsureDefault(ctx context.Context, identity string) (string, error)
}

Service is the session management interface.

func New

func New(db libdb.DBManager, workspaceID string, tracker libtracker.ActivityTracker) Service

type SessionInfo

type SessionInfo struct {
	ID           string
	Name         string
	MessageCount int
	IsActive     bool
	UpdatedAt    time.Time
}

SessionInfo summarises a session for listing purposes.

Jump to

Keyboard shortcuts

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