tui

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package tui provides the unified Bubble Tea tracker for questmaster. It renders every known questmaster session in one hierarchy with per-session detail and a 3-second polling cadence.

Index

Constants

View Source
const (
	LabelMaster     = "Master"
	LabelWorker     = "Worker"
	LabelStandalone = "Standalone"
)

Display labels — single source of truth for user-facing strings.

Variables

View Source
var (
	// Diff semantics.
	Added      = palette.Added
	Deleted    = palette.Deleted
	HunkHeader = palette.HunkHeader

	// Status semantics.
	Clean = palette.Clean // green — same hue as diff additions
	Dirty = palette.Warn
	Error = palette.Error

	// Chrome.
	Accent     = palette.Accent
	Muted      = palette.Muted
	StatusBg   = palette.StatusBg
	StatusFg   = palette.StatusFg
	DividerFg  = palette.DividerFg
	BrightText = palette.BrightText

	// Divider color — matches gh-dash's rendered border (GitHub border.muted).
	DividerBorder = palette.DividerBorder
)

Semantic color tokens shared across TUI chrome and status views. All use standard ANSI codes so the terminal theme decides actual RGB.

Functions

func Launch

func Launch() error

Launch starts the Bubble Tea TUI application.

Types

type CurrentSessionDetail

type CurrentSessionDetail struct {
	Title       string
	SessionType string
}

CurrentSessionDetail carries the current session metadata needed by the tracker header.

type Model

type Model struct {
	SessionID string
	Width     int
	Height    int
	Err       error
	// contains filtered or unexported fields
}

Model is the shared Bubble Tea model for the questmaster TUI.

func NewModel

func NewModel(store *state.Store, tc *tmux.Client) Model

NewModel creates a Model with auto-discovery from environment, state, and tmux.

func NewModelWithResolver

func NewModelWithResolver(resolver SessionResolver) Model

NewModelWithResolver creates a Model with an injected resolver for testing.

func (Model) Init

func (m Model) Init() tea.Cmd

Init discovers the session and starts the polling loop.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages for the unified TUI shell.

func (Model) View

func (m Model) View() string

View renders the current TUI state.

type SessionFetcher

type SessionFetcher func(current SessionInfo) (TrackerSnapshot, error)

SessionFetcher loads all session data for the tracker.

func NewLiveSessionFetcher

func NewLiveSessionFetcher(tmuxClient *tmux.Client, store *state.Store) SessionFetcher

NewLiveSessionFetcher creates a SessionFetcher backed by shared services.

type SessionInfo

type SessionInfo struct {
	ID          string
	Title       string
	Cwd         string
	SessionType string
	Manifest    state.Manifest
	Registry    *agent.Registry
}

SessionInfo holds resolved session metadata.

type SessionResolver

type SessionResolver func() (SessionInfo, error)

SessionResolver discovers the current session. Injected for testability — production code auto-discovers from QUESTMASTER_SESSION.

type SessionRow

type SessionRow struct {
	ID           string
	Title        string
	Cwd          string
	PrimaryAgent string
	Status       string // "active" or "stopped"
	SessionType  string // "master", "worker", or "standalone"
	ParentID     string
	WorkerCount  int
	DisplayColor string
	Snippet      string
	State        string // working|blocked|done|idle|starting|stopped|unknown
	LastKind     string // last hook event kind (drives streaming-prose suffix)
	WorkingSince time.Time
	IsCurrent    bool

	// QuestID/QuestTitle carry the session's explicit quest attachment.
	// Derived from the session scan, never stored on the quest.
	QuestID    string
	QuestTitle string
	QuestLoop  *quest.LoopRuntime
}

SessionRow is the display-ready session data for the tracker.

State / LastKind come from the per-session state.json that hooks write.

type TrackerActions

type TrackerActions interface {
	Attach(ctx context.Context, currentID, targetID string) error
	Continue(ctx context.Context, sessionID string) error
	Relay(ctx context.Context, workerID, message string) error
	Broadcast(ctx context.Context, masterID, message string) (message.BroadcastResult, error)
	Spawn(ctx context.Context, masterID, title string) error
	Delete(ctx context.Context, masterID, workerID string) error
	SetDisplayColor(sessionID, color string) error
	ManifestJSON(sessionID string) (string, error)
}

TrackerActions defines the operations the tracker can perform.

func NewLiveTrackerActions

func NewLiveTrackerActions(
	sessionSvc *session.Service,
	messageSvc *message.Service,
	tmuxClient *tmux.Client,
	store *state.Store,
) TrackerActions

NewLiveTrackerActions creates a production TrackerActions backed by shared services.

type TrackerModel

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

TrackerModel is the Bubble Tea sub-model for the unified tracker view.

func NewTrackerModel

func NewTrackerModel(current SessionInfo, fetcher SessionFetcher, actions TrackerActions) TrackerModel

NewTrackerModel creates a tracker with injected dependencies.

func (*TrackerModel) SetCurrent

func (tm *TrackerModel) SetCurrent(current SessionInfo)

SetCurrent updates the running session metadata.

func (TrackerModel) Update

func (tm TrackerModel) Update(msg tea.Msg) (TrackerModel, tea.Cmd)

Update handles key messages for the tracker sub-model.

func (TrackerModel) View

func (tm TrackerModel) View() string

View renders the tracker body (session list or manifest inspect).

type TrackerSnapshot

type TrackerSnapshot struct {
	Sessions   []SessionRow
	Current    CurrentSessionDetail
	ObservedAt time.Time
}

TrackerSnapshot is the full rendered data set for one refresh tick.

Jump to

Keyboard shortcuts

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