supervisor

package
v1.107.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package supervisor manages agent sessions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionRunner

type SessionRunner struct {
	ID         string
	App        *app.App
	WorkingDir string
	Title      string
	IsRunning  bool // True when stream is active
	NeedsAttn  bool // True when user attention is needed
	// PendingEvents queues attention events (tool confirmation, max
	// iterations, elicitation) that arrived while this tab was inactive, in
	// arrival order, for replay when the user switches to it. A single slot
	// used to overwrite an earlier event with a later one, silently dropping
	// it (#3584) — e.g. two concurrent background-job elicitations on the
	// same unfocused tab would leave only the second visible.
	PendingEvents []tea.Msg
	// contains filtered or unexported fields
}

SessionRunner represents a running session.

type SessionSpawner

type SessionSpawner func(ctx context.Context, workingDir string) (*app.App, *session.Session, func(), error)

SessionSpawner is a function that creates new sessions. It takes a working directory and returns the app, session, and cleanup function.

type Supervisor

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

Supervisor manages agent sessions.

func New

func New(spawner SessionSpawner) *Supervisor

New creates a new supervisor.

func (*Supervisor) ActiveID

func (s *Supervisor) ActiveID() string

ActiveID returns the ID of the currently active session.

func (*Supervisor) ActiveRunner

func (s *Supervisor) ActiveRunner() *SessionRunner

ActiveRunner returns the currently active session runner.

func (*Supervisor) AddSession

func (s *Supervisor) AddSession(ctx context.Context, a *app.App, sess *session.Session, workingDir string, cleanup func()) string

AddSession adds an existing session to the supervisor.

func (*Supervisor) CloseSession

func (s *Supervisor) CloseSession(sessionID string) string

CloseSession closes a session and removes it from the supervisor.

func (*Supervisor) ConsumePendingEvent

func (s *Supervisor) ConsumePendingEvent(sessionID string) tea.Msg

ConsumePendingEvent pops and returns the oldest pending event for the given session (FIFO). Returns nil if none is pending.

func (*Supervisor) Count

func (s *Supervisor) Count() int

Count returns the number of sessions.

func (*Supervisor) GetRunner

func (s *Supervisor) GetRunner(sessionID string) *SessionRunner

GetRunner returns the runner for the given session ID, or nil if not found.

func (*Supervisor) GetTabs

func (s *Supervisor) GetTabs() ([]messages.TabInfo, int)

GetTabs returns the current tab info.

func (*Supervisor) ReorderTab

func (s *Supervisor) ReorderTab(fromIdx, toIdx int)

ReorderTab moves the tab at fromIdx to toIdx, shifting others accordingly.

func (*Supervisor) ReplaceRunnerApp

func (s *Supervisor) ReplaceRunnerApp(ctx context.Context, sessionID string, newApp *app.App, workingDir string, cleanup func())

ReplaceRunnerApp replaces the app, working directory, and cleanup function for an existing runner. The old app's context is cancelled and its cleanup is run asynchronously. A new subscription goroutine is started for the new app. This is used when restoring a session whose working directory differs from the runner's current one, requiring a fresh runtime.

func (*Supervisor) SetPendingEvent added in v1.55.0

func (s *Supervisor) SetPendingEvent(sessionID string, event tea.Msg)

SetPendingEvent re-queues an attention event at the FRONT of the given session's pending queue, ahead of anything queued behind it, so it can be replayed when the user later switches to that tab. Used to re-stash a background dialog's originating event when the user navigates away from the tab that opened it.

NeedsAttention is intentionally NOT set here: the user is already aware of the prompt (they just chose to step away from it) and we don't want to flag the tab as if a brand-new event had arrived.

func (*Supervisor) SetProgram

func (s *Supervisor) SetProgram(p *tea.Program)

SetProgram sets the Bubble Tea program for sending messages.

func (*Supervisor) SetRunnerTitle

func (s *Supervisor) SetRunnerTitle(sessionID, title string)

SetRunnerTitle updates the title of the runner for the given session ID. It also triggers a tab update notification.

func (*Supervisor) Shutdown

func (s *Supervisor) Shutdown()

Shutdown closes all sessions.

func (*Supervisor) SpawnSession

func (s *Supervisor) SpawnSession(ctx context.Context, workingDir string) (string, error)

SpawnSession creates and adds a new session.

func (*Supervisor) Spawner

func (s *Supervisor) Spawner() SessionSpawner

Spawner returns the session spawner function, or nil if none is configured.

func (*Supervisor) SwitchTo

func (s *Supervisor) SwitchTo(sessionID string) *SessionRunner

SwitchTo switches to a different session.

Jump to

Keyboard shortcuts

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