Documentation
¶
Overview ¶
file_view.go is the drill-in view for a touched file, opened from the FILES sidebar section (files_panel.go). It reuses the subchat pattern: while active, the chat column's body swaps to this file's content — the sidebar, composer, and scroll engine keep working unchanged (transcriptBodyItems is the single source the viewport, renderer, and hit-testers all read, so swapping there keeps every consumer consistent). Two modes:
diff (default) — the file's edit cards from this session, full-depth
full — the file as it stands on disk, syntax highlighted, with
gutter markers on the lines this session's diffs added
d/f switch modes (with an empty composer), Esc returns to the chat at the scroll position it was left at.
files_git_sweep.go fills the FILES sidebar's blind spot: mutations that bypass the file tools entirely — bash/exec_command scaffolding (npm create, go generate, heredoc writes) and subagents editing the shared workspace. None of those produce a changedFiles-carrying tool result, so the transcript-derived roster (files_panel.go) never sees them. The sweep asks git instead: a baseline `git status --porcelain` snapshot is taken at startup (Init), and a re-run after each command tool result / turn end reports any NEWLY dirty paths, which merge into the roster with a diffstat from `git diff --numstat`. Pre-existing dirty state stays in the baseline and never shows; a non-git workspace fails the first command and the sweep silently stays off.
files_panel.go renders the FILES section of the right context sidebar: the workspace files this session has touched, newest first, with an A/M badge and a +added/−removed diffstat per file, plus a pulsing row for the file whose write is streaming right now. Like the swarm roster (sidebar.go), the touched set is not separate model state — it is recovered on demand from the transcript's tool-result rows (their changedFiles), so it survives resume for free and can never drift from what the chat shows.
The same compact rows feed the run-details overlay; selecting a file from a visible transcript card opens the file drill-in (file_view.go).
keybinding_help.go renders the `?` keyboard-shortcut overlay. Zero has a rich set of chord bindings (Ctrl+T effort, drill-in subchat, Shift+Tab permission mode, …) that are otherwise invisible — only learnable by reading the source. A single-key `?` overlay (opened on an empty composer) lists them grouped, so the keymap is discoverable the way the reference TUIs do it. The list is declarative and hand-curated to match the real handlers in model.go's Update switch; keep them in sync when a binding changes.
Configurable bindings (toggleDetailed, toggleMouse, cycleReasoning, toggleSidebar) pull their key label from m.keyBindings so a user who remaps them in config.json sees the actual chords, not the defaults.
plan_panel.go maintains the current task-plan state for run details and step drill-in. The update_plan result itself renders as a transcript checklist, while planPanelState preserves per-step timestamps across the tool's full-replacement updates for the contextual detail view.
plan_step_detail.go makes the context-sidebar plan steps clickable: each step records the file mutations made while it was in_progress ("what was built"), and clicking a step drops a transcript card listing them. The work is captured from tool-result rows as they stream; the click maps a sidebar y-coordinate to a step, mirroring sidebarAgentSelectables' offset accounting.
Provider manager: the list-first /provider surface. It shares providerWizardState (steps providerWizardStepManage / EditMenu / EditValue) so the existing overlay gating, key routing, and mouse plumbing that check m.providerWizard cover it without touching those call sites.
UX contract: the list IS the home screen — Enter activates the selected provider, `a` opens the add wizard, `e` opens a field-level editor, `d` asks inline and deletes. Esc walks back one level and closes from the list.
sidebar.go retains compact data-formatting helpers used by the run-details surface. Conversation rendering is single-column.
specialist_card.go renders specialist/subagent cards in the transcript.
A specialist card summarises one spawned sub-agent (worker, explorer, code review, ...): its name, task description, elapsed time, tool-call count, and token usage. The SpecialistTracker holds the live state that the transcript view consults each render; the session store feeds it via start/complete/ incrementToolCount/addTokens as specialist events arrive.
Index ¶
- func Run(ctx context.Context, options Options) int
- func ValidThemeArg(s string) bool
- func WatchPRStateContext(ctx context.Context, service *PrService, onChange func(PrState)) func()
- func Wordmark() string
- type Color
- type CompactRequest
- type CompactResult
- type MCPCommandResult
- type MCPOAuthServerView
- type MCPOAuthSummary
- type MCPPermissionGrantView
- type MCPPermissionSummary
- type MCPServerView
- type MCPStateOptions
- type MCPToolView
- type MCPViewState
- type Options
- type PrProvider
- type PrSegment
- type PrService
- type PrState
- type PrStatus
- type Recorder
- type SandboxSetupCommandResult
- type SessionCompactor
- type SetupOptions
- type SetupProviderOption
- type SetupResult
- type SetupSelection
- type Transcriber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidThemeArg ¶
ValidThemeArg reports whether s is an acceptable --theme / ZERO_THEME value. It accepts retired dark/light preferences so existing scripts and environment variables migrate to System, while validThemeMode keeps them out of the picker.
func WatchPRStateContext ¶
func Wordmark ¶
func Wordmark() string
Wordmark renders the brand ASCII art shown on the TUI's empty state, for reuse outside the TUI (e.g. `zero --version`). It is deliberately uncolored: only newModel resolves --theme/ZERO_THEME, so painting the global palette here would ignore a selected light theme and be unreadable on light terminals. The terminal's default foreground works everywhere.
Types ¶
type CompactRequest ¶
type CompactResult ¶
type MCPCommandResult ¶
type MCPOAuthServerView ¶
type MCPOAuthSummary ¶
type MCPOAuthSummary struct {
Servers []MCPOAuthServerView
}
type MCPPermissionGrantView ¶
type MCPPermissionSummary ¶
type MCPServerView ¶
type MCPStateOptions ¶
type MCPToolView ¶
type MCPViewState ¶
type MCPViewState struct {
Servers []MCPServerView
Tools []MCPToolView
Permissions MCPPermissionSummary
OAuth MCPOAuthSummary
}
func BuildMCPViewState ¶
func BuildMCPViewState(options MCPStateOptions) MCPViewState
type Options ¶
type Options struct {
ModelRPM *zeroruntime.ModelRPMLimiter
Cwd string
Version string // CLI build version, shown on the home screen; empty hides it
UserConfigPath string
DoctorUserConfigPath string
ProjectConfigPath string
ProviderName string
ModelName string
ProviderProfile config.ProviderProfile
SavedProviders []config.ProviderProfile // all configured providers, for the /model multi-provider list
FavoriteModels []string
RecentModels []config.RecentModelEntry
RecapsEnabled bool
// CompactionModel is the resolved preferences.compactionModel value; see
// providers.CompactionModelID for how it combines with the env override
// and the curated cheap defaults.
CompactionModel string
Provider zeroruntime.Provider
NewProvider func(config.ProviderProfile) (zeroruntime.Provider, error)
NewTurnSessionProvider func(config.ProviderProfile, zeroruntime.Provider) zeroruntime.TurnSessionProvider
ProbeProviderHealth func(context.Context, providerhealth.Options) providerhealth.Result
DiscoverProviderModels func(context.Context, config.ProviderProfile) ([]providermodeldiscovery.Model, error)
DiscoverOllamaContextWindow func(ctx context.Context, baseURL string, model string) (int, error)
RuntimeMessageSink func(tea.Msg)
PrepareRunCompletionWarning func()
RunCompletionWarning func() string
Registry *tools.Registry
// AwaitToolReadiness gives prompt-critical integration startup a bounded
// chance to publish its tools before this turn snapshots the registry. The
// wait runs inside the asynchronous agent command, so the TUI stays usable.
AwaitToolReadiness func(context.Context)
SessionStore *sessions.Store
SandboxStore *sandbox.GrantStore
MCPConfig config.MCPConfig
MCPPermissionStore *mcp.PermissionStore
MCPTokenStore *mcp.TokenStore
MCPCommand func(context.Context, []string) MCPCommandResult
SandboxSetupCommand func(context.Context) SandboxSetupCommandResult
UsageTracker *usage.Tracker
SessionCompactor SessionCompactor
PrService *PrService
PeerService *peermsg.Service
AgentOptions agent.Options
// LoadSkills returns the installed skills (default skills dir merged with any
// plugin skill roots), bodies included, for /skills and direct /<skill-name>
// invocation. Called lazily per use so newly installed skills are picked up
// without a restart. Nil means the session has no skills wiring (skills stay
// model-pulled via the skill tool only).
LoadSkills func() []skills.Skill
// AllowEscalation opts this session into mid-run model escalation, set from
// --allow-escalation. It wires the model switchers onto every turn's options;
// the escalate_model tool itself is registered by the caller on the same flag.
// Both halves are required: the tool without the switchers is inert, and the
// switchers without the tool are unreachable.
AllowEscalation bool
PermissionMode agent.PermissionMode
ReasoningEffort modelregistry.ReasoningEffort
ResponseStyle string
// Theme is the operator's palette preference: "auto" (default), a built-in
// ("dark"/"light"), or a registered color theme. Set from the --theme flag;
// falls back to ZERO_THEME, then the persisted SavedTheme, then auto.
Theme string
// SavedTheme is the theme persisted in user config (Preferences.Theme). Applied
// at startup below --theme and ZERO_THEME, so a /theme choice survives restart.
SavedTheme string
// SavedPet is the persisted terminal companion id. Empty means no pet has
// been selected yet; "disabled" records an explicit opt-out.
SavedPet string
UserAgent string
// Notify configures completion / awaiting-input notifications.
Notify config.NotifyConfig
// KeyBindings configures remappable TUI keybindings. An empty/zero
// KeyBindingsConfig means "use built-in defaults" for each action.
KeyBindings config.KeyBindingsConfig
// StartupNotices are shown as system notices when the session opens: facts
// about the session the user should see before the first prompt, decided by
// the caller that built it. Blank entries are skipped.
StartupNotices []string
// STT configures speech-to-text dictation (§ docs/dictation.md).
STT config.STTConfig
// BuildDictationTranscriber constructs the transcriber for the current STT
// config. It lives in the CLI layer because it resolves provider API keys
// (credstore + env) and base URLs; the TUI only calls it when a recording
// starts. preferStreaming asks for the streaming backend; the returned
// `streaming` bool reports whether streaming is actually available (false
// falls the caller back to the batch pipeline). Nil disables dictation (the
// keybinding shows a "not configured" hint). cfg is passed each call (not
// captured) so a mid-session config change — e.g. the auto-download writing
// localModelPath — takes effect on the next recording.
BuildDictationTranscriber func(cfg config.STTConfig, preferStreaming bool) (t Transcriber, streaming bool, err error)
// ShutdownDictationServer tears down the warm sherpa-onnx streaming server (if
// one was started), called alongside the LSP manager's shutdown on exit. Nil
// when dictation is not wired.
ShutdownDictationServer func(context.Context) error
// STTDownloadRoot is where the auto-download stores the sherpa-onnx engine
// and model (e.g. ~/.config/zero/stt). Empty disables auto-download (the F9
// setup message then only points at manual setup / cloud providers).
STTDownloadRoot string
// STTKeyStatus reports whether an API key is already resolvable for a cloud
// STT provider ("groq"/"openai"/"deepgram"). Nil disables the inline key
// prompt (dictation then just shows the "run zero auth" setup error).
STTKeyStatus func(provider string) bool
// SaveSTTKey stores an API key for a cloud STT provider in the credential
// store, so the inline prompt can capture and persist it.
SaveSTTKey func(provider, key string) error
// AltScreen tells the model it is running inside Bubble Tea's alternate
// screen. Run sets this for the interactive app; tests can leave it false
// to exercise the native scrollback renderer.
AltScreen bool
// Setup configures the first-run/setup takeover. It is shown before the
// normal chat surface when Visible is true.
Setup SetupOptions
}
Options configures the reusable Zero terminal UI shell.
type PrProvider ¶
type PrProvider string
const ( ProviderGitHub PrProvider = "github" ProviderGitLab PrProvider = "gitlab" )
type PrSegment ¶
func BuildPRSegments ¶
type PrService ¶
type PrService struct {
// contains filtered or unexported fields
}
func NewPrService ¶
type Recorder ¶
Transcriber and Recorder are re-exported so Options and the model can refer to the dictation interfaces without importing the package everywhere.
type SessionCompactor ¶
type SessionCompactor interface {
CompactSession(context.Context, CompactRequest) (CompactResult, error)
}
type SetupOptions ¶
type SetupOptions struct {
Visible bool
Required bool
ConfigPath string
Providers []SetupProviderOption
Save func(SetupSelection) (SetupResult, error)
}
SetupOptions configures the guided first-run provider setup takeover.
type SetupProviderOption ¶
type SetupProviderOption struct {
ID string
Name string
DefaultModel string
EnvVar string
RequiresAuth bool
Local bool
Recommended bool
}
SetupProviderOption is one provider choice offered by the setup takeover.
type SetupResult ¶
type SetupResult struct {
ConfigPath string
Provider config.ProviderProfile
}
SetupResult describes a completed setup write.
type SetupSelection ¶
type SetupSelection struct {
CatalogID string
Name string
BaseURL string
Model string
APIKey string
}
SetupSelection is the user's setup choice.
type Transcriber ¶
type Transcriber = dictation.Transcriber
Transcriber and Recorder are re-exported so Options and the model can refer to the dictation interfaces without importing the package everywhere.
Source Files
¶
- add_dir.go
- aimlapi_onboard.go
- ask_user_prompt.go
- assistant_markdown.go
- attachment_preview.go
- autocomplete.go
- background_terminals.go
- btw.go
- clipboard.go
- coalesce.go
- command_bash.go
- command_center.go
- command_output.go
- command_views.go
- commands.go
- composer.go
- dictation.go
- dictation_download.go
- dictation_stream.go
- dictation_voice.go
- diff_viewer.go
- doctor_view.go
- file_view.go
- files_git_sweep.go
- files_panel.go
- flush.go
- goal.go
- hover.go
- image_attach.go
- init_command.go
- input_compat.go
- keybinding_help.go
- keybindings.go
- leader.go
- loop.go
- mcp_add_wizard.go
- mcp_add_wizard_view.go
- mcp_manager.go
- mcp_setup_intent.go
- mcp_state.go
- mcp_view.go
- modal_selection.go
- model.go
- model_catalog.go
- mouse.go
- mouse_filter.go
- notify_select.go
- oauth_device.go
- onboarding.go
- options.go
- peer_messages.go
- permission_prompt.go
- pet_output.go
- pets.go
- picker.go
- plan_command.go
- plan_panel.go
- plan_step_detail.go
- plan_update_card.go
- pr_status.go
- provider_manager.go
- provider_wizard.go
- provider_wizard_discovery.go
- provider_wizard_models.go
- queued_message.go
- recap.go
- render_cache.go
- rendering.go
- run.go
- run_details.go
- sandbox_setup_command.go
- selectable_list.go
- session.go
- session_controls.go
- session_rename.go
- session_title.go
- sidebar.go
- skill_commands.go
- spec_mode.go
- specialist_card.go
- startup.go
- streaming_decoder.go
- streaming_fade.go
- streaming_tool_call.go
- stt_key_prompt.go
- stt_model_picker.go
- subchat.go
- syntax_highlight.go
- terminal_attach.go
- theme.go
- theme_palettes.go
- theme_select.go
- tool_render_registry.go
- transcript.go
- transcript_body_cache.go
- transcript_export.go
- transcript_selection.go
- transcript_view.go
- transcript_viewport.go
- transient_notice.go
- turn_timer.go
- user_commands.go
- view.go
- working_status_animation.go