Documentation
¶
Index ¶
- Constants
- func RenderCollapsedView(vm CollapsedViewModel) string
- func SetWorkingDirectoryForTesting(dir, branch string) (restore func())
- type AgentInfoMode
- type AgentSwitchResult
- type ClickResult
- type CollapsedViewModel
- type LayoutConfig
- type Metrics
- type Mode
- type Model
- type SectionVisibility
- type TransferTimer
Constants ¶
const ( // DefaultWidth is the default sidebar width in vertical mode. DefaultWidth = 40 // MinWidth is the minimum sidebar width before auto-collapsing. MinWidth = 20 // MaxWidthPercent is the maximum sidebar width as a percentage of window. MaxWidthPercent = 0.5 )
Layout constants for sidebar elements.
Variables ¶
This section is empty.
Functions ¶
func RenderCollapsedView ¶
func RenderCollapsedView(vm CollapsedViewModel) string
RenderCollapsedView renders the collapsed sidebar from a CollapsedViewModel. This is a pure function that takes data and returns a string.
func SetWorkingDirectoryForTesting ¶ added in v1.138.1
func SetWorkingDirectoryForTesting(dir, branch string) (restore func())
SetWorkingDirectoryForTesting makes every sidebar created afterwards report dir and branch instead of the process's working directory and its git branch, with no branch watcher, and returns a function restoring the defaults. Call it from TestMain: it is not safe alongside running tests.
Types ¶
type AgentInfoMode ¶ added in v1.112.0
type AgentInfoMode int
AgentInfoMode selects how the vertical sidebar's Agents section renders each agent. The zero value is the compact roster.
const ( // AgentInfoCompact renders each agent as a two-line entry: name with // thinking badge and shortcut, then provider/model with the context // percentage. This is the default. AgentInfoCompact AgentInfoMode = iota // AgentInfoDetailed renders each agent as a mini-card with labeled // Effort / Context / Cost metric lines. AgentInfoDetailed )
type AgentSwitchResult ¶ added in v1.104.0
type AgentSwitchResult struct {
Cmd tea.Cmd
Timers []TransferTimer
Accepted bool
}
AgentSwitchResult is the outcome of SetAgentSwitching. Cmd carries the animation-subscription command and must be dispatched; Timers are the presentation-window timers armed by the boundary and must be scheduled by the owner (see TransferTimer). Accepted reports whether the boundary matched the sidebar's delegation state — a recorded start, or a stop that closed its exact inverse hop; only an accepted stop presents a Return, so callers gate their own return feedback on it.
type ClickResult ¶
type ClickResult int
ClickResult indicates what was clicked in the sidebar
const ( ClickNone ClickResult = iota ClickStar ClickTitle // Click on the title area (use double-click to edit) ClickWorkingDir // Click on the working directory line ClickAgent // Click on an agent name in the sidebar ClickUsageContext // Click on the token/context part of the usage reading (glyph, tokens, context %/compacting, ⚠ capped) ClickUsage // Click on the cost part of the usage reading, or a budget line )
type CollapsedViewModel ¶
type CollapsedViewModel struct {
TitleWithStar string
WorkingIndicator string
WorkingDir string
UsageSummary string
// InfoLine is the compact agents/tools/todos summary shown when the
// sidebar renders as a horizontal band.
InfoLine string
// Layout decisions computed from the data
TitleAndIndicatorOnOneLine bool
WdAndUsageOnOneLine bool
ContentWidth int
}
CollapsedViewModel holds the computed layout decisions for collapsed mode. This is a pure data structure - rendering is handled by separate view functions. Computing this once avoids duplicating the layout logic between CollapsedHeight and collapsedView.
func (CollapsedViewModel) LineCount ¶
func (vm CollapsedViewModel) LineCount() int
LineCount returns the number of lines needed to render this layout.
type LayoutConfig ¶
type LayoutConfig struct {
// PaddingLeft is the space between the left edge of the sidebar and content.
// This replaces the external wrapper padding that was previously in chat.go.
PaddingLeft int
// PaddingRight is the space between the content and the right edge (when no scrollbar).
PaddingRight int
// ScrollbarGap is the space between content and the scrollbar when visible.
ScrollbarGap int
}
LayoutConfig defines the spacing and sizing parameters for the sidebar. All values are in terminal columns.
Layout diagram for vertical mode:
|<-- outerWidth (m.width) ----------------------->| |<-PL->|<-- contentWidth -->|<-SG->|<-SW->| | | Tab Title────────| | │ | | | Content here | | │ | | | | | │ |
PL = PaddingLeft, SG = ScrollbarGap, SW = scrollbar.Width
func DefaultLayoutConfig ¶
func DefaultLayoutConfig() LayoutConfig
DefaultLayoutConfig returns the default sidebar layout configuration.
type Metrics ¶
type Metrics struct {
// OuterWidth is the total width allocated to the sidebar.
OuterWidth int
// ContentWidth is the width available for actual content (tabs, text, etc.).
ContentWidth int
// ScrollbarVisible indicates whether the scrollbar will be rendered.
ScrollbarVisible bool
// contains filtered or unexported fields
}
Metrics holds the computed layout metrics for a given render pass.
func (Metrics) PaddingLeft ¶
PaddingLeft returns the left padding from the config.
func (Metrics) PaddingRight ¶
PaddingRight returns the right padding from the config.
func (Metrics) ScrollbarGap ¶
ScrollbarGap returns the scrollbar gap from the config.
type Model ¶
type Model interface {
layout.Model
layout.Sizeable
layout.Positionable
SetTokenUsage(event *runtime.TokenUsageEvent)
SetTodos(result *tools.ToolCallResult) error
SetMode(mode Mode)
// SetMirroredPadding swaps the horizontal edge padding so the sidebar hugs
// the terminal edge when rendered on the left of the chat.
SetMirroredPadding(mirrored bool)
SetAgentInfo(agentName, model, description string, contextLimit int64, compactionModel string, primaryContextLimit int64) tea.Cmd
SetTeamInfo(availableAgents []runtime.AgentDetails)
// SetAgentSwitching records the start (switching=true) or end of a
// transfer_task hop between fromAgent and toAgent. Stops carry the
// inverse pair of their start (start A→B is closed by stop B→A) and are
// only accepted when that exact hop is live. A start presents the
// outbound transfer box for a bounded window (≥ ~1.5s, until the
// destination's first useful activity, ≤ ~3s); an accepted stop replaces
// it with a transient child→parent Return box shown for up to ~1.5s —
// it may disappear earlier when the enclosing turn/stream ends, since
// the outermost StreamStopped intentionally clears any leftover
// presentation. Callers must dispatch the result's Cmd and schedule its
// Timers (see AgentSwitchResult).
SetAgentSwitching(switching bool, fromAgent, toAgent string) AgentSwitchResult
// SetAgentActivity records the first useful activity (reasoning, content
// or a tool call) attributed to agentName, acknowledging the outbound
// transfer box of the innermost hop targeting that agent.
SetAgentActivity(agentName string) tea.Cmd
SetToolsetInfo(availableTools int, loading bool)
SetSkillsInfo(availableSkills int)
SetSessionStarred(starred bool)
SetQueuedMessages(messages ...string)
// SetSectionVisibility controls which optional sidebar sections are rendered.
SetSectionVisibility(v SectionVisibility)
// SetSectionGap sets the number of blank lines between sidebar sections.
SetSectionGap(lines int)
// SetAgentInfoMode selects how the vertical Agents section renders each
// agent: the compact two-line roster (default) or detailed mini-cards.
SetAgentInfoMode(mode AgentInfoMode)
// SetActiveAgentsOnly filters the Agents roster (vertical panel and
// collapsed band) to agents active in the current session instead of the
// whole configured team.
SetActiveAgentsOnly(enabled bool)
GetSize() (width, height int)
LoadFromSession(sess *session.Session)
// ResetStreamTracking clears the active-stream stack so a new top-level run
// starts from a clean slate, even if a previous run's stream events were
// left unbalanced (e.g. cancelled without a StreamCancelledMsg).
ResetStreamTracking()
// HandleClick checks if click is on the star or title and returns true if handled
HandleClick(x, y int) bool
// HandleClickType returns the type of click (see ClickResult).
// For ClickAgent, the second return value is the agent name.
HandleClickType(x, y int) (ClickResult, string)
// IsCollapsed returns whether the sidebar is collapsed
IsCollapsed() bool
// ToggleCollapsed toggles the collapsed state
ToggleCollapsed()
// SetCollapsed sets the collapsed state directly
SetCollapsed(collapsed bool)
// CollapsedHeight returns the number of lines needed for collapsed mode
CollapsedHeight(contentWidth int) int
// GetPreferredWidth returns the user's preferred width (for resize persistence)
GetPreferredWidth() int
// SetPreferredWidth sets the user's preferred width
SetPreferredWidth(width int)
// ClampWidth ensures width is within valid bounds for the given window width
ClampWidth(width, windowInnerWidth int) int
// HandleTitleClick handles a click on the title area and returns true if
// edit mode should start (on double-click)
HandleTitleClick() bool
// BeginTitleEdit starts inline editing of the session title
BeginTitleEdit()
// IsEditingTitle returns true if the title is being edited
IsEditingTitle() bool
// CommitTitleEdit commits the current title edit and returns the new title
CommitTitleEdit() string
// CancelTitleEdit cancels the current title edit
CancelTitleEdit()
// UpdateTitleInput passes a key message to the title input
UpdateTitleInput(msg tea.Msg) tea.Cmd
// SetTitleRegenerating sets the title regeneration state and returns a command to start/stop spinner
SetTitleRegenerating(regenerating bool) tea.Cmd
// IsScrollbarDragging returns true when the scrollbar thumb is being dragged.
IsScrollbarDragging() bool
// VisualGeneration increments whenever an update changes rendered sidebar state.
VisualGeneration() uint64
// WorkingDirectory returns the working directory path displayed in the sidebar.
WorkingDirectory() string
}
Model represents a sidebar component
type SectionVisibility ¶ added in v1.102.0
type SectionVisibility struct {
HideSessionPath bool
HideUsage bool
HideAgents bool
HideTools bool
HideTodos bool
}
SectionVisibility controls which optional sidebar sections are rendered. The zero value shows everything.
type TransferTimer ¶ added in v1.104.0
TransferTimer is a one-shot presentation-window timer the sidebar asks its owner to schedule: after Duration, Msg must be delivered back to this sidebar's Update. Descriptors are returned instead of pre-built tick commands so the owning page can address the expiry to itself (wrapping Msg in a routed envelope); a deadline armed on one tab is then neither lost nor applied to whichever tab happens to be active when it fires.
func (TransferTimer) Cmd ¶ added in v1.104.0
func (t TransferTimer) Cmd() tea.Cmd
Cmd schedules the timer as a plain tick delivered to the active page — sufficient for single-page setups; multi-tab owners wrap Msg in their own routed envelope instead.