Documentation
¶
Overview ¶
Package controller provides UI-agnostic business logic for aimux. It orchestrates exports, session management, and agent coordination without depending on any TUI framework. Both the Bubble Tea TUI and a future web UI import this package.
Index ¶
- func BulkDeleteSessions(sessions []history.Session) (int, error)
- func DeleteSession(s history.Session) error
- func FilterAgents(agents []agent.Agent, query string) []agent.Agent
- func FilterHidden(agents []agent.Agent, hidden map[string]bool) []agent.Agent
- func NextAttend(agents []agent.Agent, currentIdx int) int
- func PartitionByArchive(agents []agent.Agent, threshold time.Duration) (active, archived []agent.Agent)
- func SetAnnotation(sessionFile, annotation string) error
- func SetNote(sessionFile, note string) error
- func SetROI(sessionFile string, multiplier float64, taskType string) error
- func SetTags(sessionFile string, tags []string) error
- func SortAgents(agents []agent.Agent, field string)
- func ToggleStar(sessionFile string) (bool, error)
- type ActionInput
- type Controller
- type ExportContext
- type ExportResult
- type KillAction
- type KillType
- type Navigator
- type Notification
- type TraceInput
- type ViewType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BulkDeleteSessions ¶
BulkDeleteSessions removes multiple sessions, returning the count of successfully deleted sessions and the first error encountered.
func DeleteSession ¶
DeleteSession removes a session's JSONL file and its sidecar .meta.json.
func FilterAgents ¶ added in v0.11.0
FilterAgents returns agents matching the query string. The match is case-insensitive and checks ShortProject, ShortModel, Status, Source, ProviderName, ShortDir, and LastAction. An empty query returns all agents.
func FilterHidden ¶
FilterHidden removes agents whose session key is in the hidden set. The key is derived from SessionID, SessionFile, or PID (in that priority).
func NextAttend ¶ added in v0.11.0
NextAttend returns the index of the next agent needing attention, prioritized by urgency: WaitingPermission first, then Error, then Idle, then Unknown. Active agents are always skipped.
Within the highest-priority tier, it cycles through candidates starting after currentIdx, wrapping around. Returns -1 if no agent needs attention.
func PartitionByArchive ¶ added in v0.11.0
func PartitionByArchive(agents []agent.Agent, threshold time.Duration) (active, archived []agent.Agent)
PartitionByArchive splits agents into active and archived based on idle duration. Only Idle, Error, and Unknown agents can be archived. Active and WaitingPermission agents are never archived. A zero threshold disables archiving (all agents returned in the active list).
func SetAnnotation ¶ added in v0.11.0
SetAnnotation updates the annotation field for a session.
func SortAgents ¶ added in v0.11.0
SortAgents sorts agents in place using sort.SliceStable. Supported fields: "", "name", "cost", "cpu", "mem", "age", "model". The default ("") sorts by status priority (active first) then name alphabetically.
func ToggleStar ¶ added in v0.11.0
ToggleStar flips the starred state for a session and persists it. Returns the new starred value.
Types ¶
type ActionInput ¶
ActionInput is a tool invocation within a trace turn.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller owns the business logic and state that is shared across all UI frontends. It does NOT import bubbletea or lipgloss.
func New ¶
func New(cfg config.Config) *Controller
New creates a new Controller with the given configuration.
func (*Controller) ExportJSONL ¶
func (c *Controller) ExportJSONL(ctx ExportContext) (ExportResult, error)
ExportJSONL exports trace turns and session metadata to a JSONL file. Returns the file path and turn count on success.
func (*Controller) ExportOTEL ¶
func (c *Controller) ExportOTEL(ctx ExportContext) (ExportResult, error)
ExportOTEL exports trace turns and session metadata as OTLP/HTTP spans. Returns the endpoint URL and turn count on success.
type ExportContext ¶
type ExportContext struct {
SessionID string
SessionFile string // path to session JSONL (for loading .meta.json)
ProviderName string
Turns []TraceInput
EvalStore *evaluation.Store
}
ExportContext holds the runtime context needed for an export operation. The UI layer populates this from its active state (which trace is open, which session file is loaded, etc.).
type ExportResult ¶
type ExportResult struct {
Path string // file path (JSONL) or endpoint URL (OTEL)
Count int // number of turns exported
}
ExportResult holds the outcome of an export operation.
type KillAction ¶ added in v0.11.0
KillAction holds the determined kill strategy and any provider-specific parameters (e.g., pod name and namespace for K8s agents).
func DetermineKillAction ¶ added in v0.11.0
func DetermineKillAction(ag agent.Agent) KillAction
DetermineKillAction inspects an agent and returns the appropriate kill strategy. The logic is:
- SessionID starting with "pod-" indicates a Kubernetes pod.
- PID == 0 with no pod prefix is a session-only entry (no live process).
- Otherwise it is a local process to be terminated via SIGTERM.
type KillType ¶ added in v0.11.0
type KillType int
KillType describes how an agent should be terminated.
type Navigator ¶
type Navigator struct {
}
Navigator manages the view navigation state machine. It tracks which view is active, breadcrumbs, and zoom/split state.
func NewNavigator ¶
func NewNavigator() *Navigator
NewNavigator creates a Navigator in the default state (agents view).
func (*Navigator) EnterZoom ¶
func (n *Navigator) EnterZoom()
EnterZoom enters zoomed session mode with split view.
func (*Navigator) ExitZoom ¶
ExitZoom implements hierarchical back navigation: fullscreen -> split view -> main view. Returns true if fully exited zoom (back to main), false if returned to split.
func (*Navigator) NavigateBack ¶
func (n *Navigator) NavigateBack()
NavigateBack returns to the agents view.
func (*Navigator) NavigateTo ¶
NavigateTo switches to a new view with a breadcrumb label.
func (*Navigator) ToggleSplit ¶
func (n *Navigator) ToggleSplit()
ToggleSplit toggles between split and full-screen mode.
func (*Navigator) ToggleSplitFocus ¶
func (n *Navigator) ToggleSplitFocus()
ToggleSplitFocus switches focus between "trace" and "session" panes.
type Notification ¶ added in v0.11.0
Notification describes a notification that should be delivered by the caller. The controller decides whether to notify; the UI layer decides how.
func ShouldNotify ¶ added in v0.11.0
func ShouldNotify(status agent.Status, projectName string, cfg config.NotificationsConfig) *Notification
ShouldNotify returns a Notification if the agent's current status warrants one, or nil if no notification should fire. The caller is responsible for delivering the notification (e.g., macOS notification center, SSE event).
type TraceInput ¶
type TraceInput struct {
Number int
Timestamp string // RFC3339
UserText string
OutputText string
Actions []ActionInput
TokensIn int64
TokensOut int64
CostUSD float64
DurationMs int64
Model string
}
TraceInput is the subset of trace.Turn fields needed for export, avoiding a direct dependency on the trace package's full type (which includes rendering-specific fields).
func TurnsToInputs ¶
func TurnsToInputs(turns []trace.Turn) []TraceInput
TurnsToInputs converts trace.Turn slices to the UI-agnostic TraceInput format. Called by the UI layer before passing data to the controller.