session

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package session provides session management and persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultStorageDir

func DefaultStorageDir() (string, error)

DefaultStorageDir returns the default session storage path (~/.config/autocmd/sessions).

func GenerateName

func GenerateName(ctx context.Context, llm domain.LLM, target string) (string, error)

GenerateName creates a short title for a session based on the provided text. It uses the provided LLM to generate the title.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store manages session creation, loading, saving, and listing.

func NewStore

func NewStore(fs fileSystem, storageDir string) *Store

NewStore creates a new session store.

func (*Store) Create

func (st *Store) Create(workingDir string) (*domain.Session, error)

Create creates a new session with a unique ID and saves it.

func (*Store) Delete

func (st *Store) Delete(id string) error

Delete removes a session from disk by ID (entire session directory).

func (*Store) FindActiveForDir

func (st *Store) FindActiveForDir(dir string) (*domain.SessionMetadata, error)

FindActiveForDir returns the active session metadata for the given working directory.

func (*Store) FindBlank

func (st *Store) FindBlank(workingDir string) (*domain.SessionMetadata, error)

FindBlank returns the most recently updated session metadata that has no name and no messages.

func (*Store) GenerateName

func (st *Store) GenerateName(ctx context.Context, llm domain.LLM, target string) (string, error)

GenerateName is a facade for the session.GenerateName function.

func (*Store) GetMetadata

func (st *Store) GetMetadata(id string) (*domain.SessionMetadata, error)

GetMetadata reads only the metadata.json for a session.

func (*Store) GetSession

func (st *Store) GetSession(id string) (*domain.Session, error)

GetSession loads a full session from disk by ID (metadata, messages, displays).

func (*Store) List

func (st *Store) List() ([]domain.SessionMetadata, error)

List returns metadata for all sessions sorted by update time (newest first).

func (*Store) LoadChecksums

func (st *Store) LoadChecksums(sessionID string) (map[string]string, error)

LoadChecksums retrieves the stored checksums for a session.

func (*Store) Rename

func (st *Store) Rename(id, name string) error

Rename updates the name of a session.

func (*Store) SaveChecksums

func (st *Store) SaveChecksums(sessionID string, checksums map[string]string) error

SaveChecksums persists the checksums for a session.

func (*Store) SaveMetadata

func (st *Store) SaveMetadata(m *domain.SessionMetadata) error

SaveMetadata persists only the metadata.json for a session.

func (*Store) SaveSession

func (st *Store) SaveSession(s *domain.Session) error

SaveSession persists a full session to disk (metadata, messages, displays).

func (*Store) SetActive

func (st *Store) SetActive(id, workingDir string) error

SetActive marks the session with the given ID as active, deactivating any other active sessions in the same working directory. The workingDir parameter is used for scoping — it does not modify the session's own WorkingDir field.

Jump to

Keyboard shortcuts

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