controller

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 10 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func BulkDeleteSessions

func BulkDeleteSessions(sessions []history.Session) (int, error)

BulkDeleteSessions removes multiple sessions, returning the count of successfully deleted sessions and the first error encountered.

func DeleteSession

func DeleteSession(s history.Session) error

DeleteSession removes a session's JSONL file and its sidecar .meta.json.

func FilterHidden

func FilterHidden(agents []agent.Agent, hidden map[string]bool) []agent.Agent

FilterHidden removes agents whose session key is in the hidden set. The key is derived from SessionID, SessionFile, or PID (in that priority).

Types

type ActionInput

type ActionInput struct {
	Tool    string
	Input   string
	Success bool
	Error   string
}

ActionInput is a tool invocation within a trace turn.

type Controller

type Controller struct {
	Nav *Navigator
	// 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 Navigator struct {
	CurrentView ViewType
	Breadcrumbs []string
	Zoomed      bool
	SplitMode   bool
	SplitFocus  string // "trace" or "session"
}

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 (n *Navigator) EnterZoom()

EnterZoom enters zoomed session mode with split view.

func (n *Navigator) ExitZoom() (exitedFully bool)

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 (n *Navigator) NavigateBack()

NavigateBack returns to the agents view.

func (n *Navigator) NavigateTo(v ViewType, label string)

NavigateTo switches to a new view with a breadcrumb label.

func (n *Navigator) ToggleSplit()

ToggleSplit toggles between split and full-screen mode.

func (n *Navigator) ToggleSplitFocus()

ToggleSplitFocus switches focus between "trace" and "session" panes.

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.

type ViewType

type ViewType int

ViewType identifies which view is active.

const (
	ViewAgents ViewType = iota
	ViewLogs
	ViewCosts
	ViewTeams
	ViewSessions
	ViewHelp
)

Jump to

Keyboard shortcuts

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