tui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HighlightCode

func HighlightCode(source, languageHint string) string

HighlightCode runs source through chroma and returns ANSI-colored text. languageHint can be a chroma lexer name ("go", "python") or empty; in either case the helper does its best to detect from content if the hint doesn't match a known lexer. Falls back to plain text when chroma can't tokenize.

Used by the approval modal renderers to make code review easier: the user sees keywords / strings / comments in distinct colors rather than a wall of monochrome text.

func HighlightFromPath

func HighlightFromPath(source, path string) string

HighlightFromPath is the convenience form: derive the language hint from the file extension, then highlight. Used by approval renderers that have a path on hand (edit_file, write_file).

func Run

func Run(ctx context.Context, opts cli.ChatOptions) error

Run wires up session, permissions, adapter, and tools, then drives the Bubbletea program. The non-interactive sibling is oneshot.Run, which shares the same ChatOptions but emits one turn to stdout and exits.

Types

type Config

type Config struct {
	Cfg         agent.LoopConfig
	Session     *session.Session
	Permissions *permissions.Permissions
	Recall      *recall.Index // optional; nil disables /recall
	ModelName   string
	BaseURL     string
	APIKey      string
	Provider    string
	// ProviderLabel is the catalog identity ("nvidia-nim", "xai") of
	// the active profile, surfaced in the status bar instead of the
	// generic dispatch tag (Provider). Populated by Run() from the
	// loaded config; leave empty when no profile is matched and the
	// renderer falls back to Provider.
	ProviderLabel          string
	ReasoningEffort        string
	EnableWebSearch        bool
	DisableWebSearch       bool
	EnableXSearch          bool
	EnableCodeInterpreter  bool
	SearchAllowedDomains   string
	SearchExcludedDomains  string
	XSearchAllowedHandles  string
	XSearchExcludedHandles string
	XSearchFromDate        string
	XSearchToDate          string
	ProviderProfile        adapter.ProviderProfile
	Cwd                    string
	// BypassPermissions auto-approves every tool call. DANGEROUS — see
	// the flag help on --bypass-permissions. Explicit `deny` rules in
	// .yottacode/permissions.json still apply.
	BypassPermissions bool
	Version           string // e.g. "0.3.0" — shown in the header
	Commit            string // short SHA the binary was built from; "" when unknown (go run, tarball)
	Dirty             bool   // true when the build had uncommitted changes; renders a "*" beside the commit
	Branch            string // current git branch (empty if not in a repo)
	MemorySummary     string // "USER", "YOTTA", "USER+YOTTA", "UMEM", "USER+UMEM", or "" if none
	BaseSystemPrompt  string // pre-memory prompt — needed by /memory reload to recompose

	// FileCfg holds tunables loaded from ~/.yottacode/config.toml
	// (context watermarks, retrieval). The TUI reads these at session
	// start and re-reads them on /memory reload.
	FileCfg config.Config
}

Config carries everything Run needs to build a Model. Bundling these into a struct is just ergonomics — there are too many fields for a positional argument list to stay readable.

type Model

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

Model is the Bubbletea state for the chat TUI. The TUI runs in inline mode (no alt-screen): conversation lines flow into the terminal's native scrollback via tea.Println, while only the live footer (input box + status bar + transient overlays) redraws in place at the bottom. This means the terminal — not the app — owns history, so native selection, scroll-wheel, and copy work end-to-end.

func New

func New(parent context.Context, c Config) Model

New builds a Model wired with the given config.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

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

Update is the public Bubbletea entry point. It delegates to update() then flushes any tea.Println commands appendLine queued during the tick. Single chokepoint keeps the rest of the model from threading Cmds by hand.

func (Model) View

func (m Model) View() string

View renders the live footer that redraws in place at the bottom of the terminal. Conversation history is NOT in here — those lines live in terminal scrollback courtesy of tea.Println from appendLine.

Jump to

Keyboard shortcuts

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