Help us shape the future of Go! Take the 2026 Go Developer Survey

tui

package
v0.1.36 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: AGPL-3.0 Imports: 43 Imported by: 0

Documentation

Overview

Package tui — autodev_command.go implements the /autodev builtin. The actual orchestrator lives behind the Config.Autodev launcher injected by internal/app, keeping the tui → autodev dependency one-way (Decision 2).

Package tui — autodev_reporter.go bridges autodev orchestration events into the Bubble Tea update loop. It mirrors the asker.go pattern: the orchestrator goroutine sends messages over the model's events channel and the update loop renders them in the session area (REQ-025, TC-017).

Package tui — slash_registry.go bridges the file-based slash command system (internal/slash) into the existing TUI dispatch and autocomplete.

The TUI keeps a hand-curated set of 10 built-in commands in the global `slashCommands` slice; this file adds a layer on top so that prompt-style commands discovered from .foxharness/ or Claude-compatible .claude/ directories appear in the same autocomplete menu and dispatch through the same entry point. Built-in behavior is unchanged when no registry is attached.

Index

Constants

View Source
const SnapshotBackground = "#2d2a2e"

SnapshotBackground is the window background fill used when exporting a scene to an image. It matches the Monokai Pro dark background so image exports have a fixed, terminal-independent appearance.

Variables

This section is empty.

Functions

func RecolorForImage added in v0.1.36

func RecolorForImage(frame string) string

RecolorForImage rewrites the 16-color ANSI SGR codes in a rendered frame to fixed Monokai Pro truecolor and pins the default foreground. The result is a deterministic, terminal-independent frame suitable for image export; layout and content are untouched.

func RenderSceneANSI added in v0.1.36

func RenderSceneANSI(name string, width, height int) (string, error)

RenderSceneANSI builds the named scene at the given terminal size and returns its View() output, including ANSI styling. The result is deterministic: the scene is rendered with a fixed clock and a fixed spinner frame. An unknown name returns an error listing the available scenes.

func RenderSceneHTML added in v0.1.36

func RenderSceneHTML(name string, width, height int) (string, error)

RenderSceneHTML renders the named scene at the given terminal size to a self-contained HTML document. The document embeds the Monokai Pro palette and the Sarasa Mono SC font, so a browser reproduces the frame faithfully — including glyphs a single Latin font would drop. Unknown scene names return an error listing the available scenes.

func RenderSessionANSI added in v0.1.36

func RenderSessionANSI(records []app.ConversationRecord, width, height int) string

RenderSessionANSI renders a real session's model-visible message records — as the TUI transcript would show them — to a deterministic ANSI frame. Records are converted with the same history→entry mapping the live TUI uses.

func RenderSessionHTML added in v0.1.36

func RenderSessionHTML(records []app.ConversationRecord, width, height int) string

RenderSessionHTML renders a real session's message records into the same self-contained HTML document, so an actual conversation can be inspected the way a browser would show it.

func Run

func Run(ctx context.Context, cfg Config) (runErr error)

Run owns interactive port creation, application initialization, and terminal program lifetime.

func SceneNames added in v0.1.36

func SceneNames() []string

SceneNames returns the available snapshot scene names in catalog order.

Types

type Asker added in v0.1.21

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

Asker is the interactive UserAsker. It bridges the synchronous tool Execute (running on the engine goroutine) and the Bubble Tea update loop using a long-lived request channel; each request carries its own reply channel. The TUI model listens on Requests() and replies once the user has answered.

func NewAsker added in v0.1.21

func NewAsker() *Asker

NewAsker creates an Asker with an unbuffered request channel.

func (*Asker) AskQuestions added in v0.1.36

func (a *Asker) AskQuestions(ctx context.Context, request app.QuestionRequest) (app.QuestionResponse, error)

AskQuestions sends the questions to the UI loop and blocks until the user answers or the context is cancelled. It returns app.ErrQuestionCancelled if the user dismissed the prompt, or the context error if cancelled while sending or waiting.

func (*Asker) Requests added in v0.1.21

func (a *Asker) Requests() <-chan askRequest

Requests exposes the channel the model listens on for incoming questions.

type AutodevLauncher added in v0.1.36

type AutodevLauncher func(context.Context, string, autodev.Reporter) error

AutodevLauncher starts one Autodev control-plane operation for the TUI adapter.

type Config

type Config struct {
	Model         string
	InitialPrompt string
	HomeDir       string
	// EffortOverride is the resolved session-level effort value that should
	// seed the /effort selector before the user changes it interactively.
	EffortOverride string

	ProviderID        string
	ProviderProfileID string
	ProviderProtocol  string

	// Registry, when non-nil, attaches a file-based slash command registry
	// to the TUI so that prompt commands from .foxharness/ and .claude/
	// command and skill directories appear alongside the built-ins.
	Registry *slash.Registry

	// Executor is the per-command pipeline used when a prompt command is
	// invoked. May be nil; a default executor with no fork runner is used
	// in that case.
	Executor *slash.Executor

	// Asker, when non-nil, enables the interactive ask_user_question overlay.
	// Only the TUI sets it; non-interactive runners leave it nil so the tool
	// is never offered to the model.
	Asker *Asker

	// PlanReviewer, when non-nil, enables submit_plan confirmation and revision.
	PlanReviewer *PlanReviewer
	Permissions  *PermissionBridge

	// Autodev, when non-nil, launches the backlog autopilot for the
	// /autodev builtin. The process composition root injects it so the tui -> autodev
	// dependency stays one-way.
	Autodev AutodevLauncher

	/* Initialize composes the UI-neutral application after the TUI creates its presentation-owned interaction ports. */
	Initialize func(context.Context, Interactions) (Startup, error)
	// contains filtered or unexported fields
}

Config controls the initial TUI presentation.

type Interactions added in v0.1.36

type Interactions struct {
	Permissions        app.PermissionPort
	Questions          app.QuestionPort
	PlanReview         app.PlanReviewPort
	InteractionNotices app.InteractionNoticeSink
}

Interactions contains the presentation-owned blocking and observation ports supplied to composition.

type Model

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

func NewModel

func NewModel(ctx context.Context, runner Runner, cfg Config) Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) SlashRegistry

func (m Model) SlashRegistry() *slash.Registry

SlashRegistry exposes the attached registry for callers (e.g. /refresh command or runtime introspection). May return nil.

func (Model) Update

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

func (Model) View

func (m Model) View() string

func (Model) WithRegistry

func (m Model) WithRegistry(registry *slash.Registry, executor *slash.Executor) Model

WithRegistry attaches a slash command registry and executor to the model. Tests that do not need file-based commands may construct the model without ever calling this; the existing built-in switch dispatch keeps working in that mode.

type PermissionBridge added in v0.1.30

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

PermissionBridge connects the permission coordinator to the TUI event loop.

func NewPermissionBridge added in v0.1.30

func NewPermissionBridge() *PermissionBridge

NewPermissionBridge creates an approval bridge.

func (*PermissionBridge) NotifyInteraction added in v0.1.36

func (b *PermissionBridge) NotifyInteraction(_ context.Context, notice app.InteractionNotice)

NotifyInteraction maps application interaction progress onto the TUI loop.

func (*PermissionBridge) RequestPermission added in v0.1.36

func (b *PermissionBridge) RequestPermission(ctx context.Context, request app.PermissionRequest) (app.PermissionResponse, error)

RequestPermission implements app.PermissionPort.

func (*PermissionBridge) SetEvents added in v0.1.30

func (b *PermissionBridge) SetEvents(events chan<- tea.Msg)

SetEvents attaches the model event channel used for review status updates.

type PlanReviewer added in v0.1.29

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

PlanReviewer bridges synchronous submit_plan execution to Bubble Tea.

func NewPlanReviewer added in v0.1.29

func NewPlanReviewer() *PlanReviewer

NewPlanReviewer creates an interactive plan reviewer request channel.

func (*PlanReviewer) Requests added in v0.1.29

func (r *PlanReviewer) Requests() <-chan planReviewRequest

Requests exposes incoming plan review requests to the TUI event loop.

func (*PlanReviewer) ReviewPlan added in v0.1.29

ReviewPlan blocks until the TUI approves, continues planning, or cancels.

type Runner

type Runner interface {
	app.InteractiveApplication
}

Runner is the application capability set required by the TUI.

type Startup added in v0.1.36

type Startup struct {
	Application   Runner
	Registry      *slash.Registry
	Executor      *slash.Executor
	SessionLogDir string
	Close         func(context.Context) error
}

Startup contains the composed application and session-scoped adapter resources.

type TUIReporter added in v0.1.21

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

TUIReporter implements autodev.Reporter over the TUI event channel. The embedded channelNotificationSink handles the shared core-event methods so core-Agent output renders exactly like a normal interactive run; the orchestration events render as system entries. Sends never block past context cancellation.

func NewTUIReporter added in v0.1.21

func NewTUIReporter(events chan<- tea.Msg) *TUIReporter

NewTUIReporter creates a TUIReporter sending into events.

func (*TUIReporter) Notify added in v0.1.36

func (s *TUIReporter) Notify(ctx context.Context, notification app.Notification)

func (*TUIReporter) OnCompaction added in v0.1.21

func (s *TUIReporter) OnCompaction(ctx context.Context, scope string)

func (*TUIReporter) OnEngineerDecision added in v0.1.21

func (r *TUIReporter) OnEngineerDecision(ctx context.Context, questions []autodev.Question, answers []autodev.Answer)

OnEngineerDecision implements autodev.Reporter.

func (*TUIReporter) OnEngineerReview added in v0.1.21

func (r *TUIReporter) OnEngineerReview(ctx context.Context, stage, instruction string)

OnEngineerReview implements autodev.Reporter.

func (*TUIReporter) OnGate added in v0.1.21

func (r *TUIReporter) OnGate(ctx context.Context, result autodev.GateResult)

OnGate implements autodev.Reporter.

func (*TUIReporter) OnInfo added in v0.1.21

func (r *TUIReporter) OnInfo(ctx context.Context, msg string)

OnInfo implements autodev.Reporter.

func (*TUIReporter) OnIssue added in v0.1.21

func (r *TUIReporter) OnIssue(ctx context.Context, number int)

OnIssue implements autodev.Reporter.

func (*TUIReporter) OnItemDone added in v0.1.21

func (r *TUIReporter) OnItemDone(ctx context.Context, item autodev.LedgerItem)

OnItemDone implements autodev.Reporter.

func (*TUIReporter) OnItemStart added in v0.1.21

func (r *TUIReporter) OnItemStart(ctx context.Context, index, total int, item autodev.LedgerItem)

OnItemStart implements autodev.Reporter.

func (*TUIReporter) OnMessage added in v0.1.21

func (s *TUIReporter) OnMessage(ctx context.Context, content string)

func (*TUIReporter) OnMessageDelta added in v0.1.33

func (s *TUIReporter) OnMessageDelta(ctx context.Context, content string)

func (*TUIReporter) OnPR added in v0.1.21

func (r *TUIReporter) OnPR(ctx context.Context, number int)

OnPR implements autodev.Reporter.

func (*TUIReporter) OnRemoteEvent added in v0.1.36

func (r *TUIReporter) OnRemoteEvent(ctx context.Context, event autodev.RemoteEvent) error

OnRemoteEvent implements autodev.Reporter with EventID deduplication.

func (*TUIReporter) OnRunComplete added in v0.1.21

func (r *TUIReporter) OnRunComplete(ctx context.Context, result autodev.CoreRunResult)

OnRunComplete maps the Autodev-owned terminal result to the existing TUI event.

func (*TUIReporter) OnRunError added in v0.1.21

func (s *TUIReporter) OnRunError(ctx context.Context, sessionID string, runID string, err error)

func (*TUIReporter) OnRunStart added in v0.1.21

func (s *TUIReporter) OnRunStart(ctx context.Context, sessionID string, runID string)

func (*TUIReporter) OnStageStart added in v0.1.21

func (r *TUIReporter) OnStageStart(ctx context.Context, slug, stage string)

OnStageStart implements autodev.Reporter.

func (*TUIReporter) OnThinking added in v0.1.21

func (s *TUIReporter) OnThinking(ctx context.Context, turn int)

func (*TUIReporter) OnToolCall added in v0.1.21

func (s *TUIReporter) OnToolCall(ctx context.Context, name string, arguments string)

func (*TUIReporter) OnToolResult added in v0.1.21

func (s *TUIReporter) OnToolResult(ctx context.Context, name string, result string, isError bool)

func (*TUIReporter) OnVerify added in v0.1.21

func (r *TUIReporter) OnVerify(ctx context.Context, stage string, ok bool, gap string)

OnVerify implements autodev.Reporter.

func (*TUIReporter) OnWorktree added in v0.1.21

func (r *TUIReporter) OnWorktree(ctx context.Context, wt autodev.Worktree)

OnWorktree implements autodev.Reporter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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