Documentation
¶
Overview ¶
pi: src/modes/interactive/bug-report.ts — the `/bug` flow: consent, optional model-written summary, then upload or zip export (pi v0.86.0). pig concurrency: the flow runs on the caller's goroutine inside mutateUI-serialized steps; dialog callbacks cross back through channels (pi resolves Promises from event-loop callbacks).
chat_viewport.go (pi: modes/interactive/chat-viewport.ts, v0.85.1) — shared fullscreen transcript and fixed input-dock layout.
Package interactive corresponds to pi's packages/coding-agent/src/modes/interactive.
interactive_mode.go (pi: src/modes/interactive/interactive-mode.ts) — interactive-mode shell: startup/main-screen assembly, the transcript container, footer, the prompt submit/steer/queue chain, and the agent event → UI pipeline. Targets milestone M4 (interactive chat usable).
interactive-mode.ts is the largest pi file (~6.5k lines); per the T5b handoff this file carries the shell subset and DECLARES the deferred segments (each lands with the T5b-2/T6 batches):
- selectors: settings/models/scoped-models/thinking/session/tree/trust/ login/oauth/user-message selectors and their submit-command handlers (/settings /scoped-models /model /thinking /fork /clone /tree /trust /login /logout /resume /session); deferred commands surface a declared warning instead of a silent no-op
- showLoadedResources + the compact resource path-label helpers (getShortPath/getCompact*/buildScopeGroups/formatScopeGroups/...)
- extension UI surface: widgets above/below editor, custom header/ footer, extension selector/input/editor/notify/error paths, extension shortcuts, extension statuses, terminal-input listeners, and the ExtensionUIContext factory (createExtensionUIContext) — DELIVERED T5b-3 (see extension UI section)
- fullscreen (alt-screen) mode: createInteractiveTui's TuiAltScreen branch, switchTuiMode/stopInteractiveTui/mountInteractiveTui and the fullscreen layout root — DELIVERED T5b-3 (unexercised in real TTY smoke; declared)
- changelog display, version/package/tmux startup checks, install telemetry, anthropic-subscription auth warning, model-catalog refresh wiring (refreshModelCatalogs call)
- external editor, clipboard text/image paste, right-click paste
- suspend (Ctrl+Z) — pi's SIGTSTP dance is Node-event-loop specific
- autocomplete: setupAutocompleteProvider/createBaseAutocompleteProvider land with the selectors batch (editor works without a provider)
- custom editor component factory (EditorFactory) and the TUI reference proxy (createInteractiveTuiReference) — DELIVERED T5b-3
- checkForPackageUpdates (P7 package manager); theme registration from the resource loader: DefaultResourceLoader.GetThemes() returns nil until its theme half lands; builtins and the startup theme come from theme.InitTheme via the theme controller
Declared deviations:
- pi is a single event loop; pig runs the editor submit body on a serialized submit-worker goroutine (never blocks the TUI input goroutine) and consumes user input from Run()'s goroutine via a gate that mirrors getUserInput/pendingUserInputs/onInputCallback.
- pi's onSubmit is `async`; Go callbacks are synchronous (repo rule), hence the worker.
- handleEvent runs on the session's event goroutine(s); containers are only mutated here, matching pi's ownership.
- pi's stdout/stderr 'error' events (dead-terminal detection) have no direct Go equivalent; isDeadTerminalError is kept for the TUI write path and emergencyTerminalExit stays reachable from it.
pi: src/modes/interactive/model-catalog-refresh.ts — share concurrent interactive all-catalog refreshes while keeping each caller's cancellation independent.
Segment deviations (declared): pi keys the active refresh in a WeakMap and races every waiter against its own signal; pig keys on the runtime (a comparable interface value here — the registry facade pointer) and uses a per-refresh context. A cancelled waiter returns immediately; the shared operation keeps running until the last waiter leaves.
model_search.go (pi: modes/interactive/model-search.ts) — model search text ranking helpers shared by the /model autocomplete and selector.
pig placement note: the canonical implementation lives in components (the /model selector consumes it there); this file re-exports for the interactive package (pi: same directory import surface).
pi: src/modes/interactive/session-share.ts — the trailing `pi.share` entry carrying the system prompt and tool schemas for the session viewer (pi v0.86.0 createShareTrailingEntries refactor). Deviation: the share command half (shareSession — Radius/gist upload with loader + HTML export) stays deferred with pig's other network-delivery commands; pig's /share is in the deferred-command list in interactive_mode.go.
tui_renderer.go (pi: modes/interactive/tui-renderer.ts, v0.85.1) — composition root for the interactive terminal renderer, extracted from interactive-mode.ts so presentation variants can share it.
Index ¶
- func GetModelSearchText(item modelSearchItem) string
- func GetModelSelectorSearchText(item modelSearchItem) string
- func RefreshModelCatalogs(ctx context.Context, modelRuntime ModelCatalogRuntime) (ai.ModelsRefreshResult, error)
- type CompactionCostNotice
- type CompactionQueuedMessage
- type InteractiveMode
- type InteractiveModeOptions
- type ModelCatalogRuntime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetModelSearchText ¶
func GetModelSearchText(item modelSearchItem) string
GetModelSearchText builds the fuzzy search text for a model (pi: getModelSearchText).
func GetModelSelectorSearchText ¶
func GetModelSelectorSearchText(item modelSearchItem) string
GetModelSelectorSearchText ranks exact provider-prefixed queries before proxy-provider IDs like openrouter/openai/gpt-5 (pi: getModelSelectorSearchText).
func RefreshModelCatalogs ¶
func RefreshModelCatalogs(ctx context.Context, modelRuntime ModelCatalogRuntime) (ai.ModelsRefreshResult, error)
RefreshModelCatalogs shares concurrent interactive all-catalog refreshes while keeping each caller's cancellation independent (pi: refreshModelCatalogs).
Types ¶
type CompactionCostNotice ¶
type CompactionCostNotice struct {
Kind string // "compaction" | "branch_summary"
Usage types.Usage
}
CompactionCostNotice renders billing usage for a compaction or branch summary; derived from persisted summary usage, not stored as an entry (pi: CompactionCostNotice).
type CompactionQueuedMessage ¶
CompactionQueuedMessage is a message queued while compaction runs (pi: CompactionQueuedMessage).
type InteractiveMode ¶
type InteractiveMode struct {
// contains filtered or unexported fields
}
InteractiveMode is the TUI application (pi: class InteractiveMode).
func NewInteractiveMode ¶
func NewInteractiveMode(runtimeHost *core.AgentSessionRuntime, options InteractiveModeOptions) *InteractiveMode
NewInteractiveMode builds the mode (pi: constructor).
func (*InteractiveMode) Init ¶
func (m *InteractiveMode) Init() error
Init initializes the UI (pi: init).
func (*InteractiveMode) Run ¶
func (m *InteractiveMode) Run(ctx context.Context) error
Run runs the interactive mode: initializes the UI, shows warnings, processes initial messages, and starts the interactive loop (pi: run).
func (*InteractiveMode) ShowError ¶
func (m *InteractiveMode) ShowError(errorMessage string)
ShowError shows an error in the chat (pi: showError).
func (*InteractiveMode) ShowWarning ¶
func (m *InteractiveMode) ShowWarning(warningMessage string)
ShowWarning shows a warning in the chat (pi: showWarning).
type InteractiveModeOptions ¶
type InteractiveModeOptions struct {
// MigratedProviders are providers migrated to auth.json (warning shown).
MigratedProviders []string
// StartupDiagnostics were collected before the TUI initialized.
StartupDiagnostics []core.AgentSessionRuntimeDiagnostic
// ModelFallbackMessage warns when the session model couldn't be
// restored.
ModelFallbackMessage string
// AutoTrustOnReloadCwd is the cwd to trust after reload if it gained a
// .pi directory during this implicitly trusted session.
AutoTrustOnReloadCwd string
// InitialMessage is sent on startup (can include @file content).
InitialMessage string
// InitialImages are attached to the initial message.
InitialImages []types.ImageContent
// InitialMessages are sent after the initial message.
InitialMessages []string
// Verbose forces verbose startup (overrides quietStartup).
Verbose bool
// TuiMode is the TUI layout mode ("regular" in this batch; fullscreen
// lands with the T6 batch).
TuiMode core.TuiMode
// InitialThemeSetting is the initial interactive theme setting for this
// invocation.
InitialThemeSetting string
}
InteractiveModeOptions configure the interactive session (pi: InteractiveModeOptions; deferred members carry their deferral note).
type ModelCatalogRuntime ¶
type ModelCatalogRuntime interface {
Refresh(ctx context.Context, options *ai.ModelsRefreshOptions) ai.ModelsRefreshResult
}
ModelCatalogRuntime is the refresh surface of the runtime (pi: ModelCatalogRuntime = Pick<ModelRuntime, "refresh">).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
armin.go (pi: components/armin.ts) — "Armin says hi!" easter egg with animated half-block XBM art and 7 random effects.
|
armin.go (pi: components/armin.ts) — "Armin says hi!" easter egg with animated half-block XBM art and 7 random effects. |
|
fs_watch.go (pi: src/modes/interactive/theme — theme file watching).
|
fs_watch.go (pi: src/modes/interactive/theme — theme file watching). |