tui

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ASCIIArt = `` /* 1004-byte string literal not displayed */

ASCIIArt is the polycode logo for use in splash screens and CLI output.

Variables

View Source
var CatppuccinMocha = Theme{
	Name:          "catppuccin-mocha",
	Primary:       lipgloss.Color("#cba6f7"),
	Secondary:     lipgloss.Color("#89b4fa"),
	Tertiary:      lipgloss.Color("#94e2d5"),
	Success:       lipgloss.Color("#a6e3a1"),
	Error:         lipgloss.Color("#f38ba8"),
	Warning:       lipgloss.Color("#fab387"),
	Info:          lipgloss.Color("#74c7ec"),
	Text:          lipgloss.Color("#cdd6f4"),
	TextMuted:     lipgloss.Color("#6c7086"),
	TextHint:      lipgloss.Color("#7f849c"),
	TextSubtle:    lipgloss.Color("#9399b2"),
	TextBright:    lipgloss.Color("#bac2de"),
	BgBase:        lipgloss.Color("#1e1e2e"),
	BgPanel:       lipgloss.Color("#313244"),
	BgSelected:    lipgloss.Color("#45475a"),
	BgFocused:     lipgloss.Color("#585b70"),
	BorderNormal:  lipgloss.Color("#45475a"),
	BorderFocused: lipgloss.Color("#89b4fa"),
	BorderAccent:  lipgloss.Color("#cba6f7"),
	DiffAdded:     lipgloss.Color("#a6e3a1"),
	DiffRemoved:   lipgloss.Color("#f38ba8"),
	DiffContext:   lipgloss.Color("#6c7086"),
	DiffHeader:    lipgloss.Color("#89b4fa"),
	ScrollTrack:   lipgloss.Color("#313244"),
	ScrollThumb:   lipgloss.Color("#585b70"),
	Shadow:        lipgloss.Color("#11111b"),
	Cyan:          lipgloss.Color("#89dceb"),
	YellowW:       lipgloss.Color("#f9e2af"),
}

CatppuccinMocha is a popular pastel dark theme.

View Source
var Dracula = Theme{
	Name:          "dracula",
	Primary:       lipgloss.Color("#bd93f9"),
	Secondary:     lipgloss.Color("#8be9fd"),
	Tertiary:      lipgloss.Color("#50fa7b"),
	Success:       lipgloss.Color("#50fa7b"),
	Error:         lipgloss.Color("#ff5555"),
	Warning:       lipgloss.Color("#ffb86c"),
	Info:          lipgloss.Color("#8be9fd"),
	Text:          lipgloss.Color("#f8f8f2"),
	TextMuted:     lipgloss.Color("#6272a4"),
	TextHint:      lipgloss.Color("#6272a4"),
	TextSubtle:    lipgloss.Color("#6272a4"),
	TextBright:    lipgloss.Color("#f8f8f2"),
	BgBase:        lipgloss.Color("#282a36"),
	BgPanel:       lipgloss.Color("#44475a"),
	BgSelected:    lipgloss.Color("#44475a"),
	BgFocused:     lipgloss.Color("#6272a4"),
	BorderNormal:  lipgloss.Color("#44475a"),
	BorderFocused: lipgloss.Color("#bd93f9"),
	BorderAccent:  lipgloss.Color("#ff79c6"),
	DiffAdded:     lipgloss.Color("#50fa7b"),
	DiffRemoved:   lipgloss.Color("#ff5555"),
	DiffContext:   lipgloss.Color("#6272a4"),
	DiffHeader:    lipgloss.Color("#8be9fd"),
	ScrollTrack:   lipgloss.Color("#383a46"),
	ScrollThumb:   lipgloss.Color("#6272a4"),
	Shadow:        lipgloss.Color("#21222c"),
	Cyan:          lipgloss.Color("#8be9fd"),
	YellowW:       lipgloss.Color("#f1fa8c"),
}

Dracula is a green/purple/pink dark theme.

View Source
var GruvboxDark = Theme{
	Name:          "gruvbox-dark",
	Primary:       lipgloss.Color("#fe8019"),
	Secondary:     lipgloss.Color("#83a598"),
	Tertiary:      lipgloss.Color("#8ec07c"),
	Success:       lipgloss.Color("#b8bb26"),
	Error:         lipgloss.Color("#fb4934"),
	Warning:       lipgloss.Color("#fabd2f"),
	Info:          lipgloss.Color("#83a598"),
	Text:          lipgloss.Color("#ebdbb2"),
	TextMuted:     lipgloss.Color("#928374"),
	TextHint:      lipgloss.Color("#a89984"),
	TextSubtle:    lipgloss.Color("#a89984"),
	TextBright:    lipgloss.Color("#fbf1c7"),
	BgBase:        lipgloss.Color("#282828"),
	BgPanel:       lipgloss.Color("#3c3836"),
	BgSelected:    lipgloss.Color("#504945"),
	BgFocused:     lipgloss.Color("#665c54"),
	BorderNormal:  lipgloss.Color("#504945"),
	BorderFocused: lipgloss.Color("#83a598"),
	BorderAccent:  lipgloss.Color("#fe8019"),
	DiffAdded:     lipgloss.Color("#b8bb26"),
	DiffRemoved:   lipgloss.Color("#fb4934"),
	DiffContext:   lipgloss.Color("#928374"),
	DiffHeader:    lipgloss.Color("#83a598"),
	ScrollTrack:   lipgloss.Color("#3c3836"),
	ScrollThumb:   lipgloss.Color("#665c54"),
	Shadow:        lipgloss.Color("#1d2021"),
	Cyan:          lipgloss.Color("#8ec07c"),
	YellowW:       lipgloss.Color("#fabd2f"),
}

GruvboxDark is a warm retro dark theme.

View Source
var Nord = Theme{
	Name:          "nord",
	Primary:       lipgloss.Color("#88c0d0"),
	Secondary:     lipgloss.Color("#81a1c1"),
	Tertiary:      lipgloss.Color("#8fbcbb"),
	Success:       lipgloss.Color("#a3be8c"),
	Error:         lipgloss.Color("#bf616a"),
	Warning:       lipgloss.Color("#ebcb8b"),
	Info:          lipgloss.Color("#5e81ac"),
	Text:          lipgloss.Color("#eceff4"),
	TextMuted:     lipgloss.Color("#616e88"),
	TextHint:      lipgloss.Color("#7b88a1"),
	TextSubtle:    lipgloss.Color("#7b88a1"),
	TextBright:    lipgloss.Color("#d8dee9"),
	BgBase:        lipgloss.Color("#2e3440"),
	BgPanel:       lipgloss.Color("#3b4252"),
	BgSelected:    lipgloss.Color("#434c5e"),
	BgFocused:     lipgloss.Color("#4c566a"),
	BorderNormal:  lipgloss.Color("#434c5e"),
	BorderFocused: lipgloss.Color("#81a1c1"),
	BorderAccent:  lipgloss.Color("#88c0d0"),
	DiffAdded:     lipgloss.Color("#a3be8c"),
	DiffRemoved:   lipgloss.Color("#bf616a"),
	DiffContext:   lipgloss.Color("#616e88"),
	DiffHeader:    lipgloss.Color("#81a1c1"),
	ScrollTrack:   lipgloss.Color("#3b4252"),
	ScrollThumb:   lipgloss.Color("#4c566a"),
	Shadow:        lipgloss.Color("#242933"),
	Cyan:          lipgloss.Color("#88c0d0"),
	YellowW:       lipgloss.Color("#ebcb8b"),
}

Nord is a cool blue-gray dark theme.

View Source
var PolycodeDefault = Theme{
	Name:          "polycode",
	Primary:       lipgloss.Color("214"),
	Secondary:     lipgloss.Color("63"),
	Tertiary:      lipgloss.Color("86"),
	Success:       lipgloss.Color("42"),
	Error:         lipgloss.Color("196"),
	Warning:       lipgloss.Color("214"),
	Info:          lipgloss.Color("82"),
	Text:          lipgloss.Color("252"),
	TextMuted:     lipgloss.Color("241"),
	TextHint:      lipgloss.Color("243"),
	TextSubtle:    lipgloss.Color("245"),
	TextBright:    lipgloss.Color("250"),
	BgBase:        lipgloss.Color(""),
	BgPanel:       lipgloss.Color("235"),
	BgSelected:    lipgloss.Color("236"),
	BgFocused:     lipgloss.Color("238"),
	BorderNormal:  lipgloss.Color("240"),
	BorderFocused: lipgloss.Color("63"),
	BorderAccent:  lipgloss.Color("214"),
	DiffAdded:     lipgloss.Color("42"),
	DiffRemoved:   lipgloss.Color("196"),
	DiffContext:   lipgloss.Color("241"),
	DiffHeader:    lipgloss.Color("63"),
	ScrollTrack:   lipgloss.Color("237"),
	ScrollThumb:   lipgloss.Color("243"),
	Shadow:        lipgloss.Color("237"),
	Cyan:          lipgloss.Color("39"),
	YellowW:       lipgloss.Color("226"),
}

PolycodeDefault preserves the exact current hardcoded color palette.

View Source
var PopularMCPServers = []MCPServerTemplate{
	{
		Name:        "filesystem",
		Description: "Read/write local files and directories",
		Command:     "npx",
		Args:        []string{"-y", "@modelcontextprotocol/server-filesystem", "{PATH}"},
		Category:    "filesystem",
	},
	{
		Name:        "github",
		Description: "GitHub API — repos, issues, PRs, search",
		Command:     "npx",
		Args:        []string{"-y", "@modelcontextprotocol/server-github"},
		EnvVars:     []MCPTemplateEnvVar{{Name: "GITHUB_TOKEN", IsSecret: true}},
		Category:    "dev-tools",
	},
	{
		Name:        "postgres",
		Description: "Query PostgreSQL databases (read-only)",
		Command:     "npx",
		Args:        []string{"-y", "@modelcontextprotocol/server-postgres", "{CONNECTION_STRING}"},
		ReadOnly:    true,
		Category:    "database",
	},
	{
		Name:        "brave-search",
		Description: "Web search via Brave Search API",
		Command:     "npx",
		Args:        []string{"-y", "@modelcontextprotocol/server-brave-search"},
		EnvVars:     []MCPTemplateEnvVar{{Name: "BRAVE_API_KEY", IsSecret: true}},
		ReadOnly:    true,
		Category:    "search",
	},
	{
		Name:        "memory",
		Description: "Persistent knowledge graph memory",
		Command:     "npx",
		Args:        []string{"-y", "@modelcontextprotocol/server-memory"},
		Category:    "ai",
	},
	{
		Name:        "puppeteer",
		Description: "Browser automation and web scraping",
		Command:     "npx",
		Args:        []string{"-y", "@modelcontextprotocol/server-puppeteer"},
		Category:    "dev-tools",
	},
	{
		Name:        "sqlite",
		Description: "Query SQLite databases",
		Command:     "npx",
		Args:        []string{"-y", "@modelcontextprotocol/server-sqlite", "{DB_PATH}"},
		ReadOnly:    true,
		Category:    "database",
	},
	{
		Name:        "slack",
		Description: "Slack workspace integration",
		Command:     "npx",
		Args:        []string{"-y", "@modelcontextprotocol/server-slack"},
		EnvVars:     []MCPTemplateEnvVar{{Name: "SLACK_BOT_TOKEN", IsSecret: true}, {Name: "SLACK_TEAM_ID", IsSecret: false}},
		Category:    "dev-tools",
	},
}

PopularMCPServers is the curated registry of well-known MCP servers.

View Source
var TokyoNight = Theme{
	Name:          "tokyo-night",
	Primary:       lipgloss.Color("#7aa2f7"),
	Secondary:     lipgloss.Color("#bb9af7"),
	Tertiary:      lipgloss.Color("#7dcfff"),
	Success:       lipgloss.Color("#9ece6a"),
	Error:         lipgloss.Color("#f7768e"),
	Warning:       lipgloss.Color("#e0af68"),
	Info:          lipgloss.Color("#2ac3de"),
	Text:          lipgloss.Color("#c0caf5"),
	TextMuted:     lipgloss.Color("#565f89"),
	TextHint:      lipgloss.Color("#737aa2"),
	TextSubtle:    lipgloss.Color("#a9b1d6"),
	TextBright:    lipgloss.Color("#a9b1d6"),
	BgBase:        lipgloss.Color("#1a1b26"),
	BgPanel:       lipgloss.Color("#24283b"),
	BgSelected:    lipgloss.Color("#292e42"),
	BgFocused:     lipgloss.Color("#33467c"),
	BorderNormal:  lipgloss.Color("#3b4261"),
	BorderFocused: lipgloss.Color("#7aa2f7"),
	BorderAccent:  lipgloss.Color("#bb9af7"),
	DiffAdded:     lipgloss.Color("#9ece6a"),
	DiffRemoved:   lipgloss.Color("#f7768e"),
	DiffContext:   lipgloss.Color("#565f89"),
	DiffHeader:    lipgloss.Color("#7aa2f7"),
	ScrollTrack:   lipgloss.Color("#24283b"),
	ScrollThumb:   lipgloss.Color("#3b4261"),
	Shadow:        lipgloss.Color("#16161e"),
	Cyan:          lipgloss.Color("#7dcfff"),
	YellowW:       lipgloss.Color("#e0af68"),
}

TokyoNight is a purple/blue dark theme.

Functions

func BuiltinThemeNames added in v1.23.0

func BuiltinThemeNames() []string

BuiltinThemeNames returns the names of all built-in themes in display order.

func ProviderStatusString added in v1.24.0

func ProviderStatusString(s ProviderStatus) string

ProviderStatusString returns the string representation of a ProviderStatus.

Types

type ConfigChangedMsg

type ConfigChangedMsg struct {
	Config *config.Config
}

ConfigChangedMsg is sent when the config has been modified by the settings screens. The app layer handles this by rebuilding the registry and pipeline.

type ConfirmActionMsg

type ConfirmActionMsg struct {
	Description     string
	ResponseCh      chan ConfirmResult
	ToolName        string // e.g., "file_write", "shell_exec"
	RiskLevel       string // "read-only", "mutating", "destructive"
	EditableContent string // the content the user can edit (command, file content, etc.)
}

type ConfirmResult added in v1.23.0

type ConfirmResult struct {
	Approved      bool
	EditedContent *string // nil = use original; non-nil = substitute this content
}

ConfirmActionMsg asks the user to confirm an action. The ResponseCh is used to synchronously communicate the user's decision back to the goroutine that requested confirmation. ConfirmResult carries the user's confirmation decision, optionally with edited content.

type ConsensusAnalysisMsg added in v0.2.0

type ConsensusAnalysisMsg struct {
	Confidence string
	Agreements []string
	Minorities []string
	Evidence   []string
}

ConsensusAnalysisMsg delivers structured provenance from the consensus synthesis.

type ConsensusChunkMsg

type ConsensusChunkMsg struct {
	Delta  string
	Done   bool
	Error  error
	Status bool // true for tool status text (suppressed when concealTools is on)
}

ConsensusChunkMsg delivers a streaming chunk from the consensus synthesis.

type ErrorRecord added in v1.23.0

type ErrorRecord struct {
	Summary   string    // one-line summary
	Detail    string    // full error message
	Timestamp time.Time // when the error occurred
	Collapsed bool      // whether the detail is hidden
}

ErrorRecord holds structured error information for display.

type Exchange

type Exchange struct {
	Prompt             string
	ConsensusResponse  string
	IndividualResponse map[string]string         // provider name → response
	ProviderStatuses   map[string]ProviderStatus // provider name → final status
	ProviderTraces     map[string][]TraceSection // provider name → ordered trace sections
	ProviderOrder      []string                  // provider names in panel order at time of exchange
	PrimaryProvider    string                    // primary provider name at time of exchange
	ToolCalls          []ToolCallRecord          // tool calls executed during this exchange
	// contains filtered or unexported fields
}

Exchange represents a completed prompt/response pair in history.

type MCPCallCountMsg added in v1.19.0

type MCPCallCountMsg struct {
	Count int64
}

MCPCallCountMsg updates the MCP tool call count in the TUI.

type MCPDashboardDataMsg added in v1.20.1

type MCPDashboardDataMsg struct {
	Servers    []MCPDashboardServer
	TotalTools int
	TotalCalls int64
}

MCPDashboardDataMsg delivers full MCP dashboard data to the TUI.

type MCPDashboardServer added in v1.20.1

type MCPDashboardServer struct {
	Name          string
	Transport     string // "stdio" or "sse"
	Status        string // "connected", "failed", "disconnected"
	ToolCount     int
	ReadOnly      bool
	Error         string
	Tools         []string // prefixed tool names
	ResourceCount int
	PromptCount   int
}

MCPDashboardServer holds full display data for one server in the MCP dashboard.

type MCPRegistryEnvMeta added in v1.20.0

type MCPRegistryEnvMeta struct {
	Name        string
	Description string
	IsSecret    bool
	IsRequired  bool
}

MCPRegistryEnvMeta holds env var metadata for display in the wizard.

type MCPRegistryResult added in v1.20.0

type MCPRegistryResult struct {
	Name           string
	Description    string
	TransportLabel string
	PackageID      string
	EnvVars        []MCPRegistryEnvMeta // env var metadata for individual prompting
	// Full server data for config mapping (passed to app layer).
	ServerData any // *mcp.RegistryServer — stored as any to avoid import cycle
}

MCPRegistryResult holds a server from the MCP Registry for the wizard browse step.

type MCPRegistryResultsMsg added in v1.20.0

type MCPRegistryResultsMsg struct {
	Servers []MCPRegistryResult
	Error   error
}

MCPRegistryResultsMsg delivers registry search results to the TUI.

type MCPServerStatus added in v1.19.0

type MCPServerStatus struct {
	Name      string
	Transport string // "stdio" or "sse"
	Status    string // "connected", "failed", "disconnected"
	ToolCount int
	Error     string // populated on failure
}

MCPServerStatus holds display info for one MCP server in the settings view.

type MCPServerTemplate added in v1.19.0

type MCPServerTemplate struct {
	Name        string
	Description string
	Command     string
	Args        []string
	EnvVars     []MCPTemplateEnvVar
	ReadOnly    bool
	Category    string
}

MCPServerTemplate defines a pre-configured MCP server for the curated registry.

type MCPStatusMsg added in v1.19.0

type MCPStatusMsg struct {
	Servers []MCPServerStatus
}

MCPStatusMsg is sent from app.go after MCP connect attempts to update the settings view with server status information.

type MCPTemplateEnvVar added in v1.20.0

type MCPTemplateEnvVar struct {
	Name     string
	IsSecret bool
}

MCPTemplateEnvVar describes an env var in a server template.

type MCPTestResultMsg added in v1.19.0

type MCPTestResultMsg struct {
	ServerName string
	Success    bool
	ToolCount  int
	Error      string
}

MCPTestResultMsg delivers the result of a connection test for an MCP server.

type MCPToolsChangedMsg added in v1.19.0

type MCPToolsChangedMsg struct {
	ServerName string
	ToolCount  int
}

MCPToolsChangedMsg notifies the TUI that an MCP server's tool list has changed.

type MemoryDisplayMsg added in v0.2.0

type MemoryDisplayMsg struct {
	Content string
}

MemoryDisplayMsg shows memory contents in the chat.

type ModeChangedMsg added in v0.2.0

type ModeChangedMsg struct {
	Mode string // "quick", "balanced", "thorough"
}

ModeChangedMsg updates the current operating mode display.

type Model

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

Model is the main Bubble Tea model for the polycode TUI.

func NewModel

func NewModel(providerNames []string, primaryName string, version string) Model

NewModel creates a new TUI model.

func (*Model) AppendHistory added in v0.2.0

func (m *Model) AppendHistory(ex Exchange)

AppendHistory adds an exchange to the display history (used for session restore).

func (Model) Init

func (m Model) Init() tea.Cmd

Init implements tea.Model.

func (*Model) InitFileIndex added in v1.23.0

func (m *Model) InitFileIndex(projectRoot string)

InitFileIndex builds the file index for @ file references.

func (*Model) RestorePanelsFromLastExchange added in v1.20.3

func (m *Model) RestorePanelsFromLastExchange()

RestorePanelsFromLastExchange populates provider panels with content from the most recent exchange. Called after session restore so individual provider responses are visible in the tab bar, not just consensus.

func (Model) SendConsensusChunk

func (m Model) SendConsensusChunk(delta string, done bool, err error) tea.Cmd

func (Model) SendProviderChunk

func (m Model) SendProviderChunk(name, delta string, done bool, err error) tea.Cmd

func (*Model) SetAutoNameSessionHandler added in v1.23.0

func (m *Model) SetAutoNameSessionHandler(handler func(prompt string, gen int))

SetAutoNameSessionHandler sets the callback for auto-naming sessions.

func (*Model) SetCancelProviderHandler added in v1.23.0

func (m *Model) SetCancelProviderHandler(handler func(providerName string))

SetCancelProviderHandler sets the callback for cancelling a provider mid-query.

func (*Model) SetClearHandler added in v0.2.0

func (m *Model) SetClearHandler(handler func())

SetClearHandler sets the callback for when the user runs /clear.

func (*Model) SetConfig

func (m *Model) SetConfig(cfg *config.Config)

SetConfig sets the config reference on the model so settings screens can perform CRUD operations. Also applies the persisted theme if set.

func (*Model) SetConfigChangeHandler

func (m *Model) SetConfigChangeHandler(handler func(*config.Config))

SetConfigChangeHandler sets the callback invoked when the config changes from the settings screen (add/edit/delete provider). The app layer uses this to rebuild the registry and pipeline.

func (*Model) SetExportHandler added in v1.4.0

func (m *Model) SetExportHandler(handler func(path string))

SetExportHandler sets the callback for /export command.

func (*Model) SetExportMarkdownHandler added in v1.23.0

func (m *Model) SetExportMarkdownHandler(handler func())

SetExportMarkdownHandler sets the callback for /export md.

func (*Model) SetMCPDashboardRefreshHandler added in v1.20.1

func (m *Model) SetMCPDashboardRefreshHandler(handler func())

SetMCPDashboardRefreshHandler sets the callback for refreshing dashboard data.

func (*Model) SetMCPHandler added in v1.19.0

func (m *Model) SetMCPHandler(handler func(subcommand, args string))

SetMCPHandler sets the callback for /mcp command.

func (*Model) SetMCPRegistryFetchHandler added in v1.20.0

func (m *Model) SetMCPRegistryFetchHandler(handler func())

SetMCPRegistryFetchHandler sets the callback for triggering registry fetch.

func (*Model) SetMCPRegistrySelectHandler added in v1.20.0

func (m *Model) SetMCPRegistrySelectHandler(handler func(result MCPRegistryResult) config.MCPServerConfig)

SetMCPRegistrySelectHandler sets the callback for mapping a registry result to a config. The callback returns a config.MCPServerConfig that the wizard applies directly.

func (*Model) SetMCPWizardFromConfig added in v1.20.0

func (m *Model) SetMCPWizardFromConfig(cfg config.MCPServerConfig)

SetMCPWizardFromConfig populates the wizard data from a mapped MCPServerConfig (used when selecting a server from the registry).

func (*Model) SetMemoryHandler added in v0.2.0

func (m *Model) SetMemoryHandler(handler func(args string))

SetMemoryHandler sets the callback for /memory command.

func (*Model) SetModeChangeHandler added in v0.2.0

func (m *Model) SetModeChangeHandler(handler func(mode string))

SetModeChangeHandler sets the callback for /mode command.

func (*Model) SetModelLister added in v1.1.0

func (m *Model) SetModelLister(lister func(providerType string) []config.ModelSummary)

SetModelLister sets a callback that returns available models for a provider type. Used by the wizard to show a model list instead of requiring manual text entry.

func (*Model) SetNotifyEnabled added in v1.23.0

func (m *Model) SetNotifyEnabled(enabled bool)

SetNotifyEnabled enables or disables desktop notifications.

func (*Model) SetPlanHandler added in v0.2.0

func (m *Model) SetPlanHandler(handler func(request string))

SetPlanHandler sets the callback for when the user runs /plan.

func (*Model) SetReconnectMCPHandler added in v1.19.0

func (m *Model) SetReconnectMCPHandler(handler func(serverName string))

SetReconnectMCPHandler sets the callback for reconnecting an MCP server.

func (*Model) SetRedoHandler added in v1.23.0

func (m *Model) SetRedoHandler(handler func())

SetRedoHandler sets the callback for /redo.

func (*Model) SetSaveHandler added in v1.4.0

func (m *Model) SetSaveHandler(handler func())

SetSaveHandler sets the callback for /save command.

func (*Model) SetSessionName added in v1.23.0

func (m *Model) SetSessionName(name string)

SetSessionName sets the display session name.

func (*Model) SetSessionPickerRefreshHandler added in v1.23.0

func (m *Model) SetSessionPickerRefreshHandler(handler func())

SetSessionPickerRefreshHandler sets the callback for refreshing session picker data.

func (*Model) SetSessionsHandler added in v1.10.0

func (m *Model) SetSessionsHandler(handler func(subcommand, args string))

SetSessionsHandler sets the callback for /sessions command.

func (*Model) SetShellContextHandler added in v1.23.0

func (m *Model) SetShellContextHandler(handler func(command string))

SetShellContextHandler sets the callback for ! shell context injection.

func (*Model) SetSkillHandler added in v1.9.0

func (m *Model) SetSkillHandler(handler func(subcommand, args string))

SetSkillHandler sets the callback for /skill command.

func (*Model) SetSplashSessionInfo added in v1.23.0

func (m *Model) SetSplashSessionInfo(msg string)

SetSplashSessionInfo sets the session info shown on the splash screen.

func (*Model) SetSubmitHandler

func (m *Model) SetSubmitHandler(handler func(prompt string))

SetSubmitHandler sets the callback for when the user submits a prompt.

func (*Model) SetTestMCPHandler added in v1.19.0

func (m *Model) SetTestMCPHandler(handler func(cfg config.MCPServerConfig))

SetTestMCPHandler sets the callback for testing an MCP server connection.

func (*Model) SetTestProviderHandler

func (m *Model) SetTestProviderHandler(handler func(providerName string))

SetTestProviderHandler sets the callback invoked when the user presses 't' in the settings screen to test a provider connection.

func (*Model) SetUndoHandler added in v1.23.0

func (m *Model) SetUndoHandler(handler func())

SetUndoHandler sets the callback for /undo.

func (*Model) SetYoloToggleHandler added in v1.7.0

func (m *Model) SetYoloToggleHandler(handler func(enabled bool))

SetYoloToggleHandler sets the callback for /yolo toggle.

func (Model) Update

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

Update implements tea.Model.

func (Model) View

func (m Model) View() string

View implements tea.Model.

type PlanDoneMsg added in v0.2.0

type PlanDoneMsg struct {
	FinalOutput string
	Error       error
}

PlanDoneMsg signals that a /plan job has completed.

type ProviderChunkMsg

type ProviderChunkMsg struct {
	ProviderName string
	Delta        string
	Done         bool
	Error        error
}

ProviderChunkMsg delivers a streaming chunk from a provider.

type ProviderPanel

type ProviderPanel struct {
	Name      string
	IsPrimary bool
	Status    ProviderStatus
	Content   *strings.Builder
	Viewport  viewport.Model

	// Phase-ordered trace sections for structured provider activity.
	TraceSections []TraceSection
	// contains filtered or unexported fields
}

type ProviderStatus

type ProviderStatus int

ProviderStatus tracks the state of a single provider's response.

const (
	StatusIdle ProviderStatus = iota
	StatusLoading
	StatusDone
	StatusFailed
	StatusTimedOut
)
const StatusCancelled ProviderStatus = 5

ProviderPanel holds the state for one provider's response panel. StatusCancelled indicates the user cancelled this provider mid-query.

func ParseProviderStatus added in v1.24.0

func ParseProviderStatus(s string) ProviderStatus

ParseProviderStatus converts a string to a ProviderStatus. Returns StatusDone for unrecognized strings (safe default for historical data).

type ProviderTraceMsg added in v1.12.0

type ProviderTraceMsg struct {
	ProviderName string
	Phase        TracePhase
	Delta        string
	Done         bool
	Error        error
}

ProviderTraceMsg delivers a phase-aware trace event for a provider tab.

type QueryDoneMsg

type QueryDoneMsg struct{}

QueryDoneMsg signals that the full pipeline (fan-out + consensus) is complete.

type QueryStartMsg

type QueryStartMsg struct {
	// QueriedProviders lists the provider IDs being queried. If empty,
	// all panels are set to loading (backward compat). If set, only the
	// listed providers show as loading — others stay idle.
	QueriedProviders []string
	// RoutingReason is a human-readable explanation of why these providers
	// were selected (e.g., "balanced: primary + best-scoring secondary").
	RoutingReason string
}

QueryStartMsg signals that a query has begun.

type SessionNameMsg added in v1.23.0

type SessionNameMsg struct {
	Name       string
	Generation int // must match m.sessionNameGen or message is stale
}

SessionNameMsg delivers an auto-generated session name.

type SessionPickerMsg added in v1.23.0

type SessionPickerMsg struct {
	Sessions []config.SessionInfo
	Error    error
}

SessionPickerMsg delivers session list data for the picker overlay.

type ShellContextMsg added in v1.23.0

type ShellContextMsg struct {
	Command string
	Output  string
	Error   error
}

ShellContextMsg delivers the output of a ! shell command for context injection.

type Styles

type Styles struct {
	App             lipgloss.Style
	StatusBar       lipgloss.Style
	StatusHealthy   lipgloss.Style
	StatusUnhealthy lipgloss.Style
	StatusPrimary   lipgloss.Style
	PanelBorder     lipgloss.Style
	ConsensusBorder lipgloss.Style
	InputBorder     lipgloss.Style
	Title           lipgloss.Style
	Prompt          lipgloss.Style
	Dimmed          lipgloss.Style
}

Styles holds all lipgloss styles for the TUI.

type TerminalFocusMsg added in v1.23.0

type TerminalFocusMsg struct {
	Focused bool
}

TerminalFocusMsg reports terminal focus changes (from ANSI focus tracking).

type TestResultMsg

type TestResultMsg struct {
	ProviderName string
	Success      bool
	Duration     string
	Error        error
}

TestResultMsg is sent when a provider connection test completes.

type Theme added in v1.23.0

type Theme struct {
	Name string

	// Base palette
	Primary   lipgloss.Color // main accent (default: 214 orange)
	Secondary lipgloss.Color // interactive elements (default: 63 blue)
	Tertiary  lipgloss.Color // active/selected (default: 86 cyan)
	Success   lipgloss.Color // healthy/done (default: 42 green)
	Error     lipgloss.Color // failure/error (default: 196 red)
	Warning   lipgloss.Color // attention (default: 214 orange)
	Info      lipgloss.Color // informational (default: 82 bright green)

	// Text
	Text       lipgloss.Color // primary text (default: 252)
	TextMuted  lipgloss.Color // dimmed/secondary (default: 241)
	TextHint   lipgloss.Color // hints/descriptions (default: 243)
	TextSubtle lipgloss.Color // subtle/version text (default: 245)
	TextBright lipgloss.Color // highlights, selected items (default: 250)

	// Backgrounds
	BgBase     lipgloss.Color // app background
	BgPanel    lipgloss.Color // panel/card background (default: 235)
	BgSelected lipgloss.Color // selected row (default: 236)
	BgFocused  lipgloss.Color // focused element (default: 238)

	// Borders
	BorderNormal  lipgloss.Color // default borders (default: 240)
	BorderFocused lipgloss.Color // focused borders (default: 63)
	BorderAccent  lipgloss.Color // accent borders (default: 214)

	// Diff
	DiffAdded   lipgloss.Color // added lines (default: 42 green)
	DiffRemoved lipgloss.Color // removed lines (default: 196 red)
	DiffContext lipgloss.Color // context lines (default: 241)
	DiffHeader  lipgloss.Color // diff headers (default: 63)

	// Scrollbar
	ScrollTrack lipgloss.Color // scrollbar track (default: 237)
	ScrollThumb lipgloss.Color // scrollbar thumb (default: 243)

	// Shadow
	Shadow lipgloss.Color // drop shadow (default: 237)

	// Special
	Cyan    lipgloss.Color // splash art (default: 39)
	YellowW lipgloss.Color // yellow warning band (default: 226)
}

Theme defines the semantic color palette for the TUI. All rendering code references these fields instead of hardcoded color numbers.

func ThemeByName added in v1.23.0

func ThemeByName(name string) Theme

ThemeByName returns a built-in theme by name, or the default if not found.

type Toast added in v1.23.0

type Toast struct {
	ID        int
	Variant   ToastVariant
	Text      string
	CreatedAt time.Time
}

Toast represents a single transient notification.

type ToastMsg added in v1.23.0

type ToastMsg struct {
	Variant ToastVariant
	Text    string
}

ToastMsg triggers a new toast notification.

type ToastVariant added in v1.23.0

type ToastVariant int

ToastVariant determines the visual style of a toast notification.

const (
	ToastInfo ToastVariant = iota
	ToastSuccess
	ToastWarning
	ToastError
)

type TokenUpdateMsg

type TokenUpdateMsg struct {
	Usage []tokens.ProviderUsage
}

TokenUpdateMsg delivers a snapshot of token usage for all providers.

type ToolCallDoneMsg added in v1.23.0

type ToolCallDoneMsg struct {
	ToolName string
	Duration time.Duration
	Error    string // empty if no error
}

ToolCallDoneMsg notifies the TUI that a tool call has completed.

type ToolCallMsg added in v0.2.0

type ToolCallMsg struct {
	ToolName    string
	Description string    // e.g., "Reading main.go" or "Running `go test`"
	StartTime   time.Time // when the tool call started (zero if not tracked)
}

ToolCallMsg notifies the TUI that a tool is being executed.

type ToolCallRecord added in v1.23.0

type ToolCallRecord struct {
	ToolName    string
	Description string
	StartTime   time.Time
	Duration    time.Duration
	Done        bool
	Error       string
}

ToolCallRecord tracks a single tool call for display.

type TracePhase added in v1.12.0

type TracePhase string

TracePhase identifies which phase of provider activity a trace event belongs to.

const (
	PhaseFanout    TracePhase = "fanout"
	PhaseSynthesis TracePhase = "synthesis"
	PhaseTool      TracePhase = "tool"
	PhaseVerify    TracePhase = "verify"
)

type TraceSection added in v1.12.0

type TraceSection struct {
	Phase   string // "fanout", "synthesis", "tool", "verify"
	Content string
}

TraceSection holds accumulated content for one phase of provider activity.

type UndoAppliedMsg added in v1.23.0

type UndoAppliedMsg struct {
	Description string
	Error       error
	IsRedo      bool
}

UndoAppliedMsg is sent when an undo/redo operation completes.

type UndoSnapshot added in v1.23.0

type UndoSnapshot struct {
	Tag         string // git tag name used for this snapshot
	Description string // human-readable description (e.g., "file_write view.go")
}

UndoSnapshot represents a git snapshot taken before a mutating tool call.

type UndoSnapshotMsg added in v1.23.0

type UndoSnapshotMsg struct {
	Snapshot UndoSnapshot
}

UndoSnapshotMsg pushes a new undo snapshot onto the stack.

type WizardTestResultMsg added in v1.1.0

type WizardTestResultMsg struct {
	Success bool
	Error   error
}

WizardTestResultMsg is sent when a wizard connection test completes.

type WorkerProgressMsg added in v0.2.0

type WorkerProgressMsg struct {
	StageName    string
	Role         string
	ProviderName string
	Status       string // "pending", "running", "complete"
	Summary      string // one-line summary of output (set when complete)
}

WorkerProgressMsg updates a worker's status in the TUI during /plan execution.

Jump to

Keyboard shortcuts

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