tui

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NimbusCloudSpinner = spinner.Spinner{
	Frames: []string{"☁ ✦", "☁ ✧", "☁ ˖", "☁ ⁺", "☁ ⋆", "☁ ⁺", "☁ ˖", "☁ ✧", "☁ ✦", "☁ ✧"},
	FPS:    time.Second / 10,
}

NimbusCloudSpinner provides an animated cloud icon with shimmering particles.

View Source
var WordBank = []string{

	"Pondering", "Noodling", "Percolating", "Marinating", "Ruminating", "Brewing",
	"Cogitating", "Simmering", "Brainstorming", "Contemplating", "Meditating", "Mulling",
	"Deliberating", "Daydreaming", "Envisioning", "Incubating", "Conjuring", "Weaving",
	"Cooking", "Fermenting", "Stewing", "Musing", "Formulating", "Scheming", "Ideating",

	"Compiling", "Refactoring", "Untangling", "Scaffolding", "Synthesizing", "Architecting",
	"Parsing", "Optimizing", "Indexing", "Wiring", "Inspecting", "Analyzing", "Structuring",
	"Composing", "Crafting", "Benchmarking", "Validating", "Assembling", "Decoupling",
	"Vectorizing", "Generating", "Calibrating", "Tracing", "Transforming", "Polishing",
	"Resolving", "Orchestrating", "Refining", "Linting", "Provisioning", "Connecting", "Formatting",
}

WordBank contains ~50 present-participle verbs mixing coding-flavored actions with whimsical generic thinking states.

Functions

func EstimateDeltaTokens

func EstimateDeltaTokens(delta string) int

EstimateDeltaTokens approximates token count for a stream delta string.

func NextRandomVerb

func NextRandomVerb(lastVerb string) string

NextRandomVerb returns a random verb from WordBank that does not match lastVerb.

func RenderColorizedDiff

func RenderColorizedDiff(diff string) string

RenderColorizedDiff formats unified diff strings with addition/deletion styling. Long diffs are capped so a big generated file doesn't swamp the transcript.

func RenderMarkdown

func RenderMarkdown(input string, maxWidth int) string

RenderMarkdown parses basic markdown constructs and converts them into Lipgloss styled strings.

func RenderThinkingStatus

func RenderThinkingStatus(m *Model) string

RenderThinkingStatus formats the animated activity line shown above the input while the agent works, e.g. "☁ ✦ Exploring the codebase… (12s · 340 tokens · esc to interrupt)". The agent's current phase is used when known; otherwise a random verb.

Types

type ChatItem

type ChatItem struct {
	Role      string // "user" | "assistant" | "tool" | "phase" | "error" | "system"
	Content   string
	Timestamp time.Time
	Plan      *ai.PlanSummary
	Diffs     []string
	ToolName  string
	ToolArgs  map[string]any
	IsError   bool
	Detail    string        // short tool-result summary, e.g. "120 lines"
	Diff      string        // inline diff shown under create/edit tool lines
	Elapsed   time.Duration // for phase lines
}

ChatItem represents a structured entry in the transcript.

type Mode

type Mode int
const (
	ModeChat Mode = iota
	ModePlanning
	ModeClarification
	ModePlanReview
	ModeExecuting
	ModeCompleted
	// ModeCommandApproval pauses a run to ask about a command the policy
	// flagged (see internal/ai/command_policy.go).
	ModeCommandApproval
	// ModeSettings is the /settings screen (see settings_view.go).
	ModeSettings
)

type Model

type Model struct {
	Agent    *ai.Agent
	Mode     Mode
	Viewport viewport.Model
	// TextInput is a textarea, not a single-line input: prompts are often
	// several sentences or contain pasted code, and a box that cannot grow
	// hides everything above the last line.
	TextInput          textarea.Model
	StepInput          textinput.Model
	CustomInput        textinput.Model
	Spinner            spinner.Model
	SelectedStep       int
	IsEditingStep      bool
	StreamBuffer       *strings.Builder
	Messages           []ChatItem
	CurrentDiffs       []string
	History            []string
	HistoryIndex       int
	Width              int
	Height             int
	StatusText         string
	ErrorMessage       string
	OneShot            bool
	Ready              bool
	OriginalPrompt     string
	ClarificationPlan  *ai.PlanSummary
	CurrentQuestionIdx int
	PendingApproval    *pendingApproval
	// PlanFirst routes requests through the staged plan → approve → execute
	// pipeline instead of the conversational loop (nimbus ai --plan-only).
	PlanFirst    bool
	SessionUsage ai.SessionUsage
	// ExpandDiffs shows full diffs instead of the collapsed change summary,
	// toggled with ctrl+o.
	ExpandDiffs bool
	// PaletteIndex is the highlighted row of the slash-command menu, which is
	// open whenever the input begins with "/".
	PaletteIndex int
	// QueuedPrompt is a message typed while the agent was working. It is sent
	// as soon as the current turn finishes, so a thought does not have to wait
	// for the run to end before it can be written down.
	QueuedPrompt string

	SelectedOptionIdx    int
	ClarificationAnswers map[string]string
	IsCustomInput        bool
	ExecChan             chan tea.Msg

	// Phase is the agent's current activity ("Exploring the codebase…").
	Phase      string
	PhaseStart time.Time
	ToolCalls  int
	// FinalSummary is the last completed run's summary (printed after a
	// one-shot run exits the alt screen).
	FinalSummary string

	// SettingsUI is the /settings screen's state, live only in ModeSettings.
	SettingsUI settingsState

	// Claude-Code-style thinking indicator state
	IsThinking        bool
	ThinkingStartTime time.Time
	ThinkingVerb      string
	LastThinkingVerb  string
	ThinkingTokens    int
	LastVerbChange    time.Time
	// contains filtered or unexported fields
}

func NewModel

func NewModel(agent *ai.Agent, initialPrompt string, oneShot bool) Model

func (*Model) AppRoot added in v1.6.0

func (m *Model) AppRoot() string

AppRoot is the workspace the agent is operating in, used to resolve tool paths into clickable links.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

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

func (Model) View

func (m Model) View() string

type SlashCommand added in v1.6.0

type SlashCommand struct {
	Name    string   // canonical form, with the leading slash
	Aliases []string // other spellings that dispatch to it
	Summary string   // one line, shown in the menu
}

SlashCommand is one entry in the palette.

Jump to

Keyboard shortcuts

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