Documentation
¶
Overview ¶
Derivation rules: how a palette becomes a consistent theme.
The rules are design constants, not preferences: three text levels, CIELAB diff tints over the app background, a contrast-checked badge ink, a destructive-subtle fallback, and the inline-code sentinel pair.
Package tui colour vocabulary.
Tokens are the semantic roles every theme is expressed in; the named palette below is plain colour data (names to hex). The token list and derivation rules are design data; the implementation is original GoCode code.
Package tui style tokens: single source of truth for visual language. Direction: cool chrome, warm content — colour alone distinguishes UI from output.
Every value here derives from the active theme's semantic tokens; there is no hex in this file. rebuildStyles is the one place styles are constructed, so a theme switch repaints the whole bag without touching a call site.
Themes: one generic builder from the token palette to the style bag, plus the six built-ins and the active-theme registry.
Token roles, built-in palettes and derivation rules are design data; the implementation is original GoCode code.
Built-in theme definitions, expressed as data: token name to colour spec. Values are design constants; the default theme refers to named palette colours so the names remain the contract.
User themes: JSON files in the config themes directory.
A file is {"base": "<built-in or user theme>", "<token>": "<colour>",...}. The theme's name is the file stem, the document is strict (unknown tokens and malformed colours are errors, not silent no-ops), and a failed theme is skipped with a warning so one bad file cannot break startup.
Index ¶
- Constants
- func NewCommandPalette(specs []agent.CommandSpec, width, height int) list.Model
- func NewModelPicker(items []list.Item, width, height int) list.Model
- func NewSessionPicker(items []list.Item, width, height int) list.Model
- func Run(ctx context.Context, registry *provider.Registry, session *agent.Session, ...) error
- type ApprovalBridge
- func (b *ApprovalBridge) RequestApproval(toolName string, args json.RawMessage, preview string) (bool, error)
- func (b *ApprovalBridge) RequestApprovalChoice(toolName string, args json.RawMessage, preview string) (tools.ApprovalChoice, error)
- func (b *ApprovalBridge) RequestApprovalPrompt(p tools.ApprovalPrompt) (tools.ApprovalChoice, error)
- type ApprovalRequest
- type ChatMessage
- type ChatRole
- type Model
- type ModelItem
- type MotionSettings
- type Overrides
- type SessionItem
- type SidebarInfo
- type Syntax
- type Theme
- type ThemeInfo
- type ThemeSettings
- type Tokens
Constants ¶
const ( MotionAuto = "auto" MotionReduced = "reduced" MotionOff = "off" )
Motion settings accepted by tui motion.
const ( // DefaultThemeName is the built-in default theme. DefaultThemeName = "gocode-dark" // LightThemeName is the built-in light theme. Light mode is a theme, not an // adaptive colour switch: the UI never asks the terminal for its background. LightThemeName = "rose-pine-dawn" )
Theme names that are part of the public contract.
Variables ¶
This section is empty.
Functions ¶
func NewCommandPalette ¶ added in v0.7.5
func NewCommandPalette(specs []agent.CommandSpec, width, height int) list.Model
NewCommandPalette builds the Ctrl+K overlay: a fuzzy list over the same registry dispatch and /help read.
func NewModelPicker ¶ added in v0.2.0
Caller frames with modalOverlayStyle, so no border here.
func NewSessionPicker ¶ added in v0.7.5
NewSessionPicker builds the /sessions overlay. Same list mechanics as the model picker, so filtering and cursor keys behave identically.
func Run ¶
func Run( ctx context.Context, registry *provider.Registry, session *agent.Session, toolRegistry *tools.Registry, approval *tools.ApprovalGate, version string, workspaceRoot string, guardCfg agent.LoopGuardConfig, maxContextTokens int, autoCompact bool, keepRecentTokens int, plan *tools.PlanStore, scratchpad *tools.ScratchpadStore, verifyCommand string, verifyTimeout time.Duration, motion MotionSettings, theme ThemeSettings, sidebar SidebarInfo, hookRunner *hooks.Runner, ) error
Run starts the Bubble Tea interface; agent behaviour lives in agent.AgentLoop.
Types ¶
type ApprovalBridge ¶
type ApprovalBridge struct {
RequestCh chan ApprovalRequest
}
func NewApprovalBridge ¶
func NewApprovalBridge() *ApprovalBridge
func (*ApprovalBridge) RequestApproval ¶
func (b *ApprovalBridge) RequestApproval(toolName string, args json.RawMessage, preview string) (bool, error)
RequestApproval is the legacy yes/no request. Grant and read-only choices still approve the pending call; only the additional scope is dropped.
func (*ApprovalBridge) RequestApprovalChoice ¶ added in v0.7.4
func (b *ApprovalBridge) RequestApprovalChoice(toolName string, args json.RawMessage, preview string) (tools.ApprovalChoice, error)
RequestApprovalChoice asks the TUI for a full decision. The gate installs this as OnPresentChoice so grants and the per-turn read-only flag can be expressed from the modal.
Limitation: the TUI has no argument editor, so ApprovalChoice.ApprovalEdit is never produced here. The plain loop wires tools.ApprovalGate.EditArgs; the TUI deliberately offers only y/a/r/n (no argument editing).
func (*ApprovalBridge) RequestApprovalPrompt ¶ added in v0.8.0
func (b *ApprovalBridge) RequestApprovalPrompt(p tools.ApprovalPrompt) (tools.ApprovalChoice, error)
RequestApprovalPrompt is the choice-aware request: it carries the classifier's danger reason so the modal starts focused on Deny with the warning line (the modal already renders ApprovalRequest.Danger). The gate installs this as OnPresentPrompt; the bridge stays the prompt transport while bus observers receive the same request in parallel.
type ApprovalRequest ¶
type ApprovalRequest struct {
ToolName string
Args json.RawMessage
Preview string
// Danger, when non-empty, marks the call as potentially destructive: the
// modal starts focused on Deny and restyles the approving button negative.
Danger string
// ReplyCh carries the legacy yes/no answer. It is nil when the requester
// made a choice-aware request.
ReplyCh chan bool
// ChoiceCh carries the full decision for choice-aware requesters.
ChoiceCh chan tools.ApprovalChoice
}
type ChatMessage ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func NewModel ¶
func NewModel(providerName, modelName, version, workspaceRoot string, bridge *ApprovalBridge, inputCh chan string, steerCh chan string, outputCh chan tea.Msg, cancelCh chan struct{}, pickerItems []list.Item, motion MotionSettings) Model
func (*Model) ApplyTheme ¶ added in v0.8.0
ApplyTheme switches the live theme and invalidates every cached transcript render: cached strings carry the old colours, so they must not be reused. The viewport keeps its cached item heights — only the rendered blocks are dropped, and the transcript is re-applied at the same width.
func (Model) Init ¶
Init arms only the commands that must run at startup. There is deliberately no mascot tick: the idle pose is static, and animation chains arm when a turn starts, so an open session costs no CPU while nothing moves.
type ModelItem ¶ added in v0.2.0
ModelItem is a selectable model in the fuzzy picker.
func (ModelItem) Description ¶ added in v0.2.0
func (ModelItem) FilterValue ¶ added in v0.2.0
type MotionSettings ¶ added in v0.7.5
type MotionSettings struct {
// Mode is "auto", "reduced" or "off"; empty behaves as "auto".
Mode string
// SmoothStreaming paces streamed text and tool-argument previews into the
// transcript instead of rendering them on arrival. Opt-in; the default
// renders text as it arrives.
SmoothStreaming bool
}
MotionSettings is the tui animation configuration handed to the UI.
type Overrides ¶ added in v0.8.0
type Overrides struct {
InlineCodeFg color.Color
InlineCodeBg color.Color
// Markdown roles.
Link color.Color
Image color.Color
SubduedIcon color.Color
// Prompt chrome.
PromptBadgeFg color.Color
PromptBadgeBg color.Color
PromptDotsFocused color.Color
PromptDotsBlurred color.Color
ShellBorderFocused color.Color
ShellBorderBlurred color.Color
ShellPrompt color.Color
// Toast and banner pins.
StatusToastBg color.Color
StatusToastInk color.Color
WarnFill color.Color
YoloBody color.Color
YoloInk color.Color
ToolName color.Color
SurfaceText color.Color
// Badge inks. The default is derived by badgeInk; a theme may pin it.
QuestionBadgeInk color.Color
PlanBadgeInk color.Color
H1Ink color.Color
Syntax Syntax
}
Overrides are theme-only roles that live outside the 40-token palette: syntax and markdown pins, inline-code colours, prompt chrome and badge inks. They exist so a built-in can keep an authored exception without widening the palette every theme must define.
type SessionItem ¶ added in v0.7.5
type SessionItem struct {
ID string
Excerpt string
Provider string
Model string
UpdatedAt time.Time
Messages int
}
SessionItem is one resumable session in the session picker. The full ID is what /resume receives; the row shows the generated suffix plus the same fields the text listing prints (title, updated time, message count), so the picker and `/sessions` describe a session the same way. The stored title is an excerpt of the first user message; Excerpt avoids colliding with the list.Item Title method.
func (SessionItem) Description ¶ added in v0.7.5
func (s SessionItem) Description() string
func (SessionItem) FilterValue ¶ added in v0.7.5
func (s SessionItem) FilterValue() string
FilterValue includes the whole ID so a user who knows it can paste it into the filter instead of scrolling.
func (SessionItem) Title ¶ added in v0.7.5
func (s SessionItem) Title() string
type SidebarInfo ¶ added in v0.8.0
SidebarInfo feeds the sidebar's session/MCP sections. The plan section is read live from the PlanStore instead, so it never goes stale mid-turn.
type Syntax ¶ added in v0.8.0
type Syntax struct {
Text color.Color
Name color.Color
Operator color.Color
Comment color.Color
CommentPreproc color.Color
NameBuiltin color.Color
Keyword color.Color
KeywordReserved color.Color
KeywordNamespace color.Color
KeywordType color.Color
NameAttribute color.Color
Punctuation color.Color
LiteralString color.Color
NameTag color.Color
NameClass color.Color
NameDecorator color.Color
NameFunction color.Color
GenericInserted color.Color
LiteralNumber color.Color
LiteralStringEscape color.Color
GenericDeleted color.Color
GenericSubheading color.Color
Error color.Color
ErrorBg color.Color
Background color.Color
}
Syntax is the single chroma role table. Markdown fenced blocks, file views and diffs all read it, so highlighting can never disagree with itself.
type Theme ¶ added in v0.8.0
type Theme struct {
Name string
Label string
Light bool
Tokens Tokens
Overrides Overrides
// contains filtered or unexported fields
}
Theme is a complete, resolved theme: no token is left to be derived at render time.
func ActivateTheme ¶ added in v0.8.0
ActivateTheme resolves a theme and rebuilds every style token from it. It is the programmatic switch: callers handle the error, ApplyThemeSettings logs.
func ActiveTheme ¶ added in v0.8.0
func ActiveTheme() Theme
ActiveTheme returns the theme styles are currently built from.
func ApplyThemeSettings ¶ added in v0.8.0
ApplyThemeSettings resolves the startup theme with the documented precedence: GOCODE_THEME (light/dark) overrides the configured name, which overrides the default. A broken selection never blocks startup: it logs and falls back to the default theme.
func ResolveTheme ¶ added in v0.8.0
ResolveTheme finds a built-in or user theme by name. It reports a clear error for an unknown name so the caller can fall back and log.
type ThemeInfo ¶ added in v0.8.0
ThemeInfo is the listing entry the theme picker consumes.
func ThemeCatalog ¶ added in v0.8.0
func ThemeCatalog() []ThemeInfo
ThemeCatalog lists every selectable theme: built-ins in canonical order, then user themes sorted by name. The picker consumes this.
type ThemeSettings ¶ added in v0.8.0
type ThemeSettings struct {
// Name selects a built-in or user theme; empty means the default.
Name string
// Transparent skips painting the app background.
Transparent bool
}
ThemeSettings is the tui theme configuration handed to the UI.
type Tokens ¶ added in v0.8.0
type Tokens struct {
// Brand.
Primary color.Color
Secondary color.Color
Accent color.Color
Keyword color.Color
// Text ramp.
FgBase color.Color
FgSubtle color.Color
FgMoreSubtle color.Color
FgMostSubtle color.Color
// Surfaces, strongest last.
BgBase color.Color
BgMostVisible color.Color
BgLessVisible color.Color
BgLeastVisible color.Color
OnPrimary color.Color
Separator color.Color
// Status semantics.
Destructive color.Color
DestructiveSubtle color.Color
Error color.Color
Warning color.Color
WarningSubtle color.Color
Attention color.Color
Busy color.Color
Info color.Color
InfoMoreSubtle color.Color
InfoMostSubtle color.Color
Success color.Color
SuccessMoreSubtle color.Color
SuccessMostSubtle color.Color
// Diffs: foreground ink and the two tinted bands per side.
DiffInsertFg color.Color
DiffInsertCodeBg color.Color
DiffInsertGutterBg color.Color
DiffDeleteFg color.Color
DiffDeleteCodeBg color.Color
DiffDeleteGutterBg color.Color
// Mode chrome.
Yolo color.Color
Plan color.Color
PlanMoreSubtle color.Color
// Buttons.
Button color.Color
ButtonSubtle color.Color
ButtonInactive color.Color
ButtonHovered color.Color
// ANSI is the 0-15 remap table for raw terminal output.
ANSI [16]color.Color
}
Tokens is one fully resolved palette: every semantic role the UI paints with, plus the 16-slot ANSI remap for raw terminal output.
A theme never stores partial colours: missing roles are filled by the derivation rules in derive.go before a Theme reaches the renderer.
func (Tokens) Hex ¶ added in v0.8.0
Hex returns the canonical #rrggbb form of a token, or "" for an unknown name. It is the comparison form used by the token-table tests.
func (Tokens) Lookup ¶ added in v0.8.0
Lookup resolves a token name to its colour. The second result is false for an unknown name, which is how strict theme files reject typos.
func (*Tokens) Set ¶ added in v0.8.0
Set assigns a token by name and reports whether the name was known.
func (Tokens) TextLevels ¶ added in v0.8.0
func (t Tokens) TextLevels() textLevels
TextLevels exposes the three text levels for style builders.
Source Files
¶
- anim.go
- animclock.go
- approval.go
- atfile.go
- banner.go
- capability.go
- chat_keys.go
- complete.go
- derive.go
- dialog.go
- diffview.go
- focus.go
- grace.go
- keymap.go
- layout.go
- markdown.go
- mascot.go
- model.go
- overlay.go
- palette.go
- picker.go
- prompt_history.go
- quit.go
- rendercache.go
- reveal.go
- run.go
- scramble.go
- session_dialog.go
- spinner.go
- styles.go
- theme.go
- theme_dialog.go
- themes_builtin.go
- toast.go
- user_theme.go