sidebar

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
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 added in v1.20.1

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.

Types

type ClickResult added in v1.20.0

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)
)

type CollapsedViewModel added in v1.20.1

type CollapsedViewModel struct {
	TitleWithStar    string
	WorkingIndicator string
	WorkingDir       string
	UsageSummary     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 added in v1.20.1

func (vm CollapsedViewModel) LineCount() int

LineCount returns the number of lines needed to render this layout.

type LayoutConfig added in v1.19.1

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 added in v1.19.1

func DefaultLayoutConfig() LayoutConfig

DefaultLayoutConfig returns the default sidebar layout configuration.

func (LayoutConfig) Compute added in v1.19.1

func (cfg LayoutConfig) Compute(outerWidth int, scrollbarVisible bool) Metrics

Compute calculates the layout metrics for the given outer width and scrollbar visibility.

type Metrics added in v1.19.1

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 added in v1.19.1

func (m Metrics) PaddingLeft() int

PaddingLeft returns the left padding from the config.

func (Metrics) PaddingRight added in v1.19.1

func (m Metrics) PaddingRight() int

PaddingRight returns the right padding from the config.

func (Metrics) ScrollbarGap added in v1.19.1

func (m Metrics) ScrollbarGap() int

ScrollbarGap returns the scrollbar gap from the config.

type Mode added in v1.8.2

type Mode int
const (
	ModeVertical Mode = iota
	ModeCollapsed
)

type Model

type Model interface {
	layout.Model
	layout.Sizeable
	layout.Positionable

	SetTokenUsage(event *runtime.TokenUsageEvent)
	SetTodos(result *tools.ToolCallResult) error
	SetMode(mode Mode)
	SetAgentInfo(agentName, model, description string)
	SetTeamInfo(availableAgents []runtime.AgentDetails)
	SetAgentSwitching(switching bool)
	SetToolsetInfo(availableTools int, loading bool)
	SetSessionStarred(starred bool)
	SetQueuedMessages(messages ...string)
	GetSize() (width, height int)
	LoadFromSession(sess *session.Session)
	// 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 (star, title, or none)
	HandleClickType(x, y int) ClickResult
	// 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
}

Model represents a sidebar component

func New

func New(sessionState *service.SessionState, opts ...Option) Model

type Option added in v1.19.1

type Option func(*model)

Option is a functional option for configuring the sidebar.

func WithLayoutConfig added in v1.19.1

func WithLayoutConfig(cfg LayoutConfig) Option

WithLayoutConfig sets a custom layout configuration.

Jump to

Keyboard shortcuts

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