sessions

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package sessions provides interactive session picking via fzf or bubbletea.

Index

Constants

View Source
const PickerStateEnv = "AIMUX_PICKER_STATE"

PickerStateEnv names the env var that points subprocesses at the state dir.

Variables

View Source
var DefaultRowLayout = RowColumns{Title: 44, Project: 14}

DefaultRowLayout is used when the terminal width is unknown.

View Source
var ErrCancelled = fmt.Errorf("selection cancelled")

ErrCancelled is returned when the user cancels the picker.

Functions

func FormatDetail added in v0.13.0

func FormatDetail(d search.Detail, snippet string, live bool) string

FormatDetail renders the preview pane for one session.

func FormatLine

func FormatLine(s history.Session) string

FormatLine formats a session as a single display line for the picker.

func FormatPreview

func FormatPreview(s history.Session) string

FormatPreview returns a second line with the first prompt in dim text, shown below the main FormatLine for extra context; empty when the first prompt is already the title.

func FormatRow added in v0.13.0

func FormatRow(r search.Result, live bool) string

FormatRow renders one session as "<id>\t<display>"; fzf hides the id.

func FormatRowLayout added in v0.13.0

func FormatRowLayout(r search.Result, live bool, l RowColumns) string

FormatRowLayout is FormatRow with explicit column widths.

func FzfArgs added in v0.13.0

func FzfArgs(self, query, header string, listenPort int) []string

FzfArgs builds the split-view fzf invocation; self is the aimux binary. A non-zero listenPort lets background work push a reload into fzf.

func ListPaneWidth added in v0.13.0

func ListPaneWidth(cols int) int

ListPaneWidth is the width fzf gives the list in a cols-wide terminal.

func ParseSelectedID

func ParseSelectedID(line string) string

ParseSelectedID extracts the session ID from a picker output line. Strips ANSI escape codes first, then takes the first whitespace-delimited field.

func PickSession

func PickSession(sessions []history.Session) (history.Session, error)

PickSession presents an interactive picker for the given sessions. Uses fzf if available, falls back to a bubbletea list. Returns the selected session or ErrCancelled.

func ReloadAction added in v0.13.0

func ReloadAction(self string) string

ReloadAction is the fzf action that re-runs the rows query.

func SearchPick added in v0.13.0

func SearchPick(self, query string, st PickerState, background func()) (string, error)

SearchPick runs the split-view picker and returns the chosen session id. The picker opens straight away on the cached index; background (index refresh, live-session discovery) runs meanwhile and its results are pushed into the open picker with a reload.

Types

type PickerState added in v0.13.0

type PickerState struct{ Dir string }

PickerState holds the picker's toggles in files so the short-lived rows and preview processes see the same settings.

func PickerStateFromEnv added in v0.13.0

func PickerStateFromEnv() PickerState

PickerStateFromEnv returns the state named by PickerStateEnv (zero if unset).

func (PickerState) Header added in v0.13.0

func (s PickerState) Header() string

Header is the status and key-hint line shown above the list.

func (PickerState) IncludeAutomated added in v0.13.0

func (s PickerState) IncludeAutomated() bool

IncludeAutomated reports whether automated sessions are shown (default no).

func (PickerState) Live added in v0.13.0

func (s PickerState) Live() map[string]bool

Live returns the session ids recorded by SetLive.

func (PickerState) LiveOnly added in v0.13.0

func (s PickerState) LiveOnly() bool

LiveOnly reports whether the picker shows only live sessions (default no).

func (PickerState) Mode added in v0.13.0

func (s PickerState) Mode() string

Mode is "keyword" (default), "hybrid" (keyword + semantic) or "semantic" (embeddings only, from an explicit --mode semantic).

func (PickerState) Scope added in v0.13.0

func (s PickerState) Scope() string

Scope is the directory the picker is limited to, or "" for all projects.

func (PickerState) SetLive added in v0.13.0

func (s PickerState) SetLive(ids []string) error

SetLive records which sessions are running in a terminal right now.

func (PickerState) SetMode added in v0.13.0

func (s PickerState) SetMode(mode string) error

SetMode sets the ranking mode: "keyword" or "hybrid".

func (PickerState) SetScope added in v0.13.0

func (s PickerState) SetScope(dir string) error

SetScope limits the picker to sessions under dir ("" = all projects).

func (PickerState) Toggle added in v0.13.0

func (s PickerState) Toggle(name string) error

Toggle flips "automated" or "semantic".

type RowColumns added in v0.13.0

type RowColumns struct{ Title, Project int }

RowColumns are the title and project column widths of a picker row.

func RowLayout added in v0.13.0

func RowLayout(cols int) RowColumns

RowLayout sizes the row columns to fit the list pane; cols <= 0 means unknown (FZF_COLUMNS unset).

Jump to

Keyboard shortcuts

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