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 ¶
const ( LabelMaster = "Master" LabelWorker = "Worker" LabelStandalone = "Standalone" )
Display labels — single source of truth for user-facing strings.
Variables ¶
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 ¶
Types ¶
type CurrentSessionDetail ¶
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 NewModelWithResolver ¶
func NewModelWithResolver(resolver SessionResolver) Model
NewModelWithResolver creates a Model with an injected resolver for testing.
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. The repo-resolution cache and repo-color store are created once and captured by the returned closure so they persist across refresh ticks (a session's cwd does not change repos within a run, and repo colors only change on a C).
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 // effective (last-write-wins) gutter color
Snippet string
// Repo grouping. RepoIdentity is the canonical parent-repo key (shared by
// all worktrees of a repo); "" means the cwd is not in a git repo and the
// row lands in the trailing ungrouped section. RepoColor is the repo's own
// persisted color (drives the section header), independent of any session
// override folded into DisplayColor.
RepoIdentity string
RepoName string
RepoColor 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
SetRepoColor(repoIdentity, color string) error
ManifestJSON(sessionID string) (string, error)
}
TrackerActions defines the operations the tracker can perform.
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.