codexsession

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package codexsession discovers and selects materialized interactive Codex sessions through app-server.

Index

Constants

View Source
const DefaultPageSize uint32 = 50

Variables

View Source
var (
	ErrNoCandidates = errors.New("codexsession: no resumable sessions")
	ErrNotResumable = errors.New("codexsession: session is not resumable by this picker")
)
View Source
var ErrCanceled = errors.New("codexsession: selection canceled")

Functions

func SanitizeDisplay

func SanitizeDisplay(value string, maxRunes int) string

SanitizeDisplay converts untrusted session metadata to one printable line. maxRunes <= 0 disables truncation. Unicode format characters and terminal controls are replaced, and all whitespace runs collapse to one ASCII space.

func ValidateID

func ValidateID(id string) error

ValidateID performs transport-safe validation without assuming that future Codex thread identifiers will remain UUIDs.

Types

type Candidate

type Candidate struct {
	Thread appserver.Thread
	Source appserver.ThreadSourceKind
}

Candidate is a non-archived, non-ephemeral CLI or VS Code thread that satisfies the requested cwd filter.

func List

func List(ctx context.Context, client Client, opts Options) ([]Candidate, error)

List collects all eligible pages and returns a globally newest-first, thread-ID-deduplicated slice.

func Pick

func Pick(in io.Reader, out io.Writer, candidates []Candidate) (Candidate, error)

Pick writes a numbered session list and reads a selection. Terminal detection and the choice of output stream belong to the caller.

func Read

func Read(ctx context.Context, client Client, id string, opts Options) (Candidate, error)

Read resolves an explicit thread ID through the non-archived list, then refreshes it with thread/read. This applies the same source, cwd, ephemeral, and archive eligibility contract as interactive selection while retaining a current status and ancestry snapshot for adoption.

func (Candidate) Recency

func (c Candidate) Recency() time.Time

Recency returns the protocol recency timestamp, falling back to updated and created timestamps for older session metadata.

func (Candidate) Title

func (c Candidate) Title() string

Title returns the user-facing name when present, then the first-message preview, then a fixed placeholder.

type Client

Client is the read-only app-server surface used for session discovery.

type Options

type Options struct {
	CWD      string
	AllCWDs  bool
	PageSize uint32
}

Options defines the sessions eligible for selection. By default, CWD is an exact project-directory filter. AllCWDs suppresses that filter.

type Page

type Page struct {
	Candidates []Candidate
	More       bool
}

type Pager

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

Pager follows opaque thread/list cursors. It requests newest-first CLI and VS Code sessions and defensively reapplies all eligibility filters to every returned page.

func NewPager

func NewPager(client Client, opts Options) (*Pager, error)

func (*Pager) Next

func (p *Pager) Next(ctx context.Context) (Page, error)

Next returns the next non-empty eligible page. An empty page with More false denotes exhaustion. A Pager must not be used concurrently.

Jump to

Keyboard shortcuts

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