threadindex

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package threadindex persists lightweight chat-thread metadata shared by UI transports. Transcript content remains in the history store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewID

func NewID(prefix string) (string, error)

NewID returns prefix plus a random hex token.

Types

type Index

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

Index is a JSON-file-backed registry of chat sessions.

func NewIndex

func NewIndex(stateDir string, now func() time.Time) (*Index, error)

NewIndex loads or initializes the shared chat-thread index under stateDir.

func (*Index) Create

func (x *Index) Create() (Session, error)

Create makes a new session with a fresh random id.

func (*Index) Delete

func (x *Index) Delete(id string) error

Delete drops id from the persisted registry.

func (*Index) List

func (x *Index) List() []Session

List returns sessions newest-updated first.

func (*Index) Rename

func (x *Index) Rename(id, titleText string) error

Rename sets a stable display title for an existing session.

func (*Index) Touch

func (x *Index) Touch(id, firstUserText string) error

Touch bumps updated time and derives an initial title from firstUserText.

type Session

type Session struct {
	ID      string `json:"id"`
	Title   string `json:"title"`
	Created int64  `json:"created"`
	Updated int64  `json:"updated"`
}

Session is a chat thread's display metadata for switchers.

type Store added in v0.0.2

type Store interface {
	List() []Session
	Create() (Session, error)
	Touch(id, firstUserText string) error
	Rename(id, titleText string) error
	Delete(id string) error
}

Store is the thread registry a UI needs: list the threads, make one, and keep its display metadata current. Index is the filesystem implementation; a backend that owns threads durably (e.g. MemoryLayer) implements the same surface so the UI can be pointed at either.

List returns a snapshot and is called from render paths, so an implementation must not block on a network round trip inside it.

type WorkspaceIndex added in v0.0.2

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

WorkspaceIndex keeps one filesystem Index per logical workspace. The selected workspace retains the Store surface, while explicit workspace operations lazily open the isolated state directory for that workspace.

func NewWorkspaceIndex added in v0.0.2

func NewWorkspaceIndex(stateDir, defaultWorkspaceID string, now func() time.Time) (*WorkspaceIndex, error)

NewWorkspaceIndex creates a workspace-aware filesystem thread registry.

func (*WorkspaceIndex) Create added in v0.0.2

func (x *WorkspaceIndex) Create() (Session, error)

func (*WorkspaceIndex) CreateWorkspaceThread added in v0.0.2

func (x *WorkspaceIndex) CreateWorkspaceThread(workspaceID string) (Session, error)

func (*WorkspaceIndex) Delete added in v0.0.2

func (x *WorkspaceIndex) Delete(id string) error

func (*WorkspaceIndex) DeleteWorkspaceThread added in v0.0.2

func (x *WorkspaceIndex) DeleteWorkspaceThread(workspaceID, id string) error

func (*WorkspaceIndex) List added in v0.0.2

func (x *WorkspaceIndex) List() []Session

func (*WorkspaceIndex) ListWorkspace added in v0.0.2

func (x *WorkspaceIndex) ListWorkspace(workspaceID string) []Session

func (*WorkspaceIndex) RefreshWorkspace added in v0.0.2

func (x *WorkspaceIndex) RefreshWorkspace(_ context.Context, workspaceID string) error

RefreshWorkspace loads the workspace's durable index into this process.

func (*WorkspaceIndex) Rename added in v0.0.2

func (x *WorkspaceIndex) Rename(id, titleText string) error

func (*WorkspaceIndex) RenameWorkspaceThread added in v0.0.2

func (x *WorkspaceIndex) RenameWorkspaceThread(workspaceID, id, titleText string) error

func (*WorkspaceIndex) Touch added in v0.0.2

func (x *WorkspaceIndex) Touch(id, firstUserText string) error

func (*WorkspaceIndex) TouchWorkspaceThread added in v0.0.2

func (x *WorkspaceIndex) TouchWorkspaceThread(workspaceID, id, firstUserText string) error

type WorkspaceLookup added in v0.0.2

type WorkspaceLookup interface {
	LookupWorkspaceThread(ctx context.Context, workspaceID, id string) (Session, bool, error)
}

WorkspaceLookup is the read-through thread metadata surface used by operational projections. Unlike WorkspaceStore.ListWorkspace, it may perform backend I/O and distinguishes a missing thread from a backend failure.

type WorkspaceStore added in v0.0.2

type WorkspaceStore interface {
	Store
	RefreshWorkspace(ctx context.Context, workspaceID string) error
	ListWorkspace(workspaceID string) []Session
	CreateWorkspaceThread(workspaceID string) (Session, error)
	TouchWorkspaceThread(workspaceID, id, firstUserText string) error
	RenameWorkspaceThread(workspaceID, id, titleText string) error
	DeleteWorkspaceThread(workspaceID, id string) error
}

WorkspaceStore is the additive multi-workspace thread registry surface used by hosts that serve more than one logical project from a single backend. Legacy UI instances continue to use Store against their selected default.

Jump to

Keyboard shortcuts

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