ui

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package ui holds Loom's Bubble Tea view components.

The layout splits the screen into a left-hand List of instances (≈20 % width) and a right-hand SplitPane (≈80 %) with stacked Agent and Terminal panes plus a hotkey-toggled diff overlay. Secondary widgets — the workspace tab bar, quick-input bar, and menu bar — compose around that main split.

Modal dialogs (text input, confirmation, branch/profile/workspace pickers) live in ui/overlay. Renderers here are pure: they read session.Instance state and emit strings; they do not mutate instances or spawn goroutines. Event handling happens in the app layer.

Index

Constants

View Source
const (
	// RailCardLines is lines per DensityRail card incl. trailing gap.
	RailCardLines = 3
	// RailHeaderLines is the section-label header at the top of the rail.
	RailHeaderLines = 2
)

Rail layout constants (used by List height math).

View Source
const (
	// ListWidthPercent is the fraction of terminal width allotted to the
	// left-hand session list.
	ListWidthPercent = 0.2

	// SplitAgentPercent is the fraction of the right-hand pane height
	// given to the agent view; the terminal pane gets the remainder.
	SplitAgentPercent = 0.7

	// OverlayWidthPercent / OverlayHeightPercent size modal overlays
	// (text input, confirmation, pickers).
	OverlayWidthPercent  = 0.6
	OverlayHeightPercent = 0.4

	// PreviewWidthPercent sizes the preview-pane capture column.
	PreviewWidthPercent = 0.9
)

Layout proportions used across the TUI. Keeping them centralized prevents drift between app.go's sizing math and the component-level calculations.

View Source
const (
	FocusAgent int = iota
	FocusTerminal
)

FocusAgent and FocusTerminal are the SplitPane focus values: the top (agent) or bottom (terminal) pane. Focus determines which pane receives scroll and attach keypresses.

View Source
const DefaultThemeName = "afterglow"

DefaultThemeName is applied at startup when config names no theme (or an unknown one).

View Source
const MarkdownMaxBytes = 256 * 1024

MarkdownMaxBytes caps how much of a document is fed to glamour; the tail beyond it is dropped with a truncation notice. Glamour renders synchronously on the Update goroutine (lazily, once per content/width/theme change), so the cap bounds that stall.

Variables

View Source
var (
	Ground      = current.Ground
	Panel       = current.Panel
	Text        = current.Text
	Dim         = current.Dim
	Faint       = current.Faint
	Rule        = current.Rule
	Accent      = current.Accent
	Attention   = current.Attention
	Highlight   = current.Highlight
	OK          = current.OK
	ErrorColor  = current.Error
	Workspace   = current.Workspace
	Info        = current.Info
	SelectionBg = current.SelectionBg
	SelectionFg = current.SelectionFg
)

Active color roles. Reassigned (main goroutine only: startup, or the settings overlay's Update-goroutine handler) by ApplyTheme.

View Source
var (
	AdditionStyle, DeletionStyle, HunkStyle lipgloss.Style
)

AdditionStyle, DeletionStyle, and HunkStyle are the lipgloss styles applied line-by-line by colorizeDiff to render a colorized git diff. They are exported so tests and callers composing their own diff renderers can reuse the same palette.

View Source
var FallBackText = `` /* 637-byte string literal not displayed */

FallBackText is the ASCII splash rendered in empty-state panes when no instance is selected or a newly created instance has not yet started.

Functions

func AdjustPreviewWidth

func AdjustPreviewWidth(width int) int

AdjustPreviewWidth adjusts the width of the preview pane per PreviewWidthPercent.

func ApplyTheme added in v0.13.0

func ApplyTheme(name string) bool

ApplyTheme activates the named theme, reassigns every role var, and re-runs all registered hooks. Unknown or empty names activate the default theme and return false. Main-goroutine only.

func ContentTailLines added in v0.13.0

func ContentTailLines(screen string, n int) []string

ContentTailLines is TailLines minus trailing agent chrome. Coding-agent TUIs (Claude Code and friends) pin an input area — delimited by horizontal rules or a box — plus footer lines to the bottom of the screen, so a bottom-anchored tail shows only that chrome and never the conversation. This scans the trailing lines for that shape and anchors the tail above it; a dialog rendered inside the input area (permission prompt) is real content, so its interior is returned instead. Any screen without the shape (shells, aider, half-drawn panes) falls back to the plain TailLines behavior.

func CurrentThemeName added in v0.13.0

func CurrentThemeName() string

CurrentThemeName returns the active theme's name.

func DisplayIndex added in v0.3.0

func DisplayIndex(items []*session.Instance, i int) int

DisplayIndex returns the 1-based number shown in the list UI for the item at position i in items. A leading workspace terminal (position 0) is numbered 0, not 1, so every other item's displayed number is offset by one relative to its slice position. Exported so callers that build a session-index picker from the same items (e.g. the merge picker) label rows with the exact number the user already saw in the main list.

func IsMarkdownPath added in v0.13.0

func IsMarkdownPath(path string) bool

IsMarkdownPath reports whether path has a markdown extension.

func RegisterThemeHook added in v0.13.0

func RegisterThemeHook(fn func())

RegisterThemeHook registers fn to rebuild theme-derived styles and invokes it immediately. Call from init() in the file that owns the styles. Main-goroutine only.

func RenderCard added in v0.13.0

func RenderCard(d CardData, density CardDensity, width int) string

RenderCard renders d at the given density and total width. DensityCard is rendered by Overview (overview.go) which owns border/grid layout; RenderCard handles DensityLine and DensityRail.

func SortForOverview added in v0.13.0

func SortForOverview(items []*session.Instance) []int

SortForOverview returns display order (indices into items) for the overview grid and overview cursor movement: workspace terminal pinned first, then attention > running/loading > ready > paused/recoverable, stable by title within a tier. Deleting sorts last.

func TailLines added in v0.13.0

func TailLines(screen string, n int) []string

TailLines returns the last n non-blank-tail lines of screen with ANSI styling stripped (card chrome owns the styling; embedded SGR would bleed). C0 controls survive ansi.Strip, so tabs are normalized to a single space and carriage returns dropped — emulator output never contains them today, but the helper is exported and generic. Returns nil for an effectively empty screen.

func ThemeNames added in v0.13.0

func ThemeNames() []string

ThemeNames returns all registered theme names, sorted.

Types

type CardData added in v0.13.0

type CardData struct {
	Title               string
	Index               int // 1-based display number (0 for workspace terminal)
	Status              session.Status
	IsWorkspaceTerminal bool
	BellPending         bool
	Selected            bool
	Branch              string
	DiffAdded           int
	DiffRemoved         int
	HasDiff             bool
	TailLines           []string
	StatusAge           time.Duration // 0 = unknown/not applicable
	Spinner             string        // current spinner frame for Running/Loading
	// WaitReason is Claude's own account of what a Prompting session is
	// blocked on ("sandbox request", "dialog open"), from the agent roster
	// via sanitizeCardText. Empty when unknown — non-Claude agents, and any
	// status the pane scraper rather than the roster decided.
	WaitReason string
	// Subagents lists the session's live subagents and teammates, working
	// first, with names and descriptions passed through sanitizeCardText.
	// Empty for most cards; see session.Instance.Subagents.
	Subagents []SubagentRow
	// GitHub is the poller's join for this session (issue, PR, checks).
	// Known=false renders nothing. See app/github.go.
	GitHub github.State
	// Ahead/Behind count commits relative to the base branch; HasParity
	// is false until a count succeeded.
	Ahead, Behind int
	HasParity     bool
}

CardData is the render-ready view-model for one instance card. It is plain data so RenderCard stays a pure, table-testable function; build it from a live instance with BuildCardData.

func BuildCardData added in v0.13.0

func BuildCardData(inst *session.Instance, selected bool, spinnerFrame string, tailN int) CardData

BuildCardData snapshots inst into a CardData. spinnerFrame is the current spinner view (pass "" when unavailable). tailN caps the live tail; 0 skips the screen read entirely (DensityLine callers). The tail comes from AgentPane.EmulatorScreen — in-memory only, so calling this per visible card per frame forks no subprocesses; snapshot-path instances simply render their status label instead of a tail.

func (CardData) NeedsAttention added in v0.13.0

func (d CardData) NeedsAttention() bool

NeedsAttention reports whether this card should carry the Attention accent — the only loud signal in the UI. A Deleting instance never needs attention: a stale bell on a mid-kill card must not paint it gold or float it into the attention tier.

type CardDensity added in v0.13.0

type CardDensity int

CardDensity selects how much of an instance a card shows.

const (
	// DensityLine is a one-line row (height-starved fallback).
	DensityLine CardDensity = iota
	// DensityRail is the focus-mode rail mini-card: title line + one
	// tail/status line, with a left accent bar.
	DensityRail
	// DensityCard is the overview card: bordered box with metadata and
	// a multi-line tail (rendered by Overview in overview.go).
	DensityCard
)

type DiffPane

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

DiffPane renders the colorized git diff overlay shown when the user toggles it on with `d`. It caches the last rendered diff content so tick-driven redraws skip re-colorization when the underlying diff has not changed — cheap on every render, noticeable at large diffs.

func NewDiffPane

func NewDiffPane() *DiffPane

NewDiffPane constructs a DiffPane with a zero-sized viewport; the caller must SetSize before the first render.

func (*DiffPane) GotoBottom

func (d *DiffPane) GotoBottom()

GotoBottom jumps the viewport to the end.

func (*DiffPane) GotoTop

func (d *DiffPane) GotoTop()

GotoTop jumps the viewport to the start.

func (*DiffPane) PageDown

func (d *DiffPane) PageDown()

PageDown scrolls the viewport down by half a view.

func (*DiffPane) PageUp

func (d *DiffPane) PageUp()

PageUp scrolls the viewport up by half a view.

func (*DiffPane) ScrollDown

func (d *DiffPane) ScrollDown()

ScrollDown scrolls the viewport down

func (*DiffPane) ScrollPercent

func (d *DiffPane) ScrollPercent() float64

ScrollPercent returns the viewport position as a fraction [0, 1].

func (*DiffPane) ScrollUp

func (d *DiffPane) ScrollUp()

ScrollUp scrolls the viewport up

func (*DiffPane) SetDiff

func (d *DiffPane) SetDiff(instance *session.Instance)

SetDiff replaces the rendered diff from instance's current diff stats. No-ops when the content has not changed since the last call, and shows fallback text for nil / unstarted / errored instances.

func (*DiffPane) SetSize

func (d *DiffPane) SetSize(width, height int)

SetSize resizes the embedded viewport and invalidates the cached colorized diff so the next SetDiff re-renders even when the underlying content is unchanged.

func (*DiffPane) String

func (d *DiffPane) String() string

type ErrBox

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

ErrBox is the bottom-row error surface. It renders a single-line, centered red message and collapses embedded newlines into `//` so multi-line errors still fit one row.

func NewErrBox

func NewErrBox() *ErrBox

NewErrBox constructs an empty ErrBox; the caller must SetSize before the first render.

func (*ErrBox) Clear

func (e *ErrBox) Clear()

Clear removes the currently displayed error and info line immediately.

func (*ErrBox) ExpireIfDue added in v0.13.0

func (e *ErrBox) ExpireIfDue(now time.Time)

ExpireIfDue clears the box once its armed deadline has passed. Intended to be called from an existing periodic tick rather than scheduling a timer per message — without this, SetInfo/SetError have no way to expire on their own and a toast lingers on screen indefinitely once shown.

func (*ErrBox) SetError

func (e *ErrBox) SetError(err error)

SetError replaces the currently displayed error and arms its auto-clear deadline (see ExpireIfDue). Pass nil to hide the box on the next render; prefer Clear for clarity.

func (*ErrBox) SetInfo added in v0.3.0

func (e *ErrBox) SetInfo(msg string)

SetInfo sets a non-error status line (e.g. the recovery summary) and arms its auto-clear deadline, mirroring SetError. An active error takes precedence over info in String().

func (*ErrBox) SetSize

func (e *ErrBox) SetSize(width, height int)

SetSize updates the rendering bounds.

func (*ErrBox) String

func (e *ErrBox) String() string

type GroupState added in v0.13.0

type GroupState int

GroupState classifies how an overview group renders.

const (
	GroupLoaded GroupState = iota // reconciled; render cards
	GroupEmpty                    // loaded but no instances
)

type List

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

List is the left-panel session rail. It owns the selection cursor and viewport scroll offset, and delegates per-item rendering to RenderCard at DensityRail. The list does not spawn goroutines or mutate Instance state beyond reordering; all status is read via the Instance accessors.

func NewList

func NewList(spinner *spinner.Model) *List

NewList constructs an empty List bound to the given spinner. Items are added later via AddInstance; the list is ready to render immediately.

func (*List) AddInstance

func (l *List) AddInstance(instance *session.Instance)

AddInstance adds a new instance to the list.

func (*List) Bottom

func (l *List) Bottom()

Bottom selects the last non-Deleting item.

func (*List) Down

func (l *List) Down()

Down selects the next non-Deleting item in the list. If every item below the cursor is Deleting (or the cursor is already on the last selectable item), selectedIdx stays put.

func (*List) GetInstanceByTitle added in v0.8.0

func (l *List) GetInstanceByTitle(title string) *session.Instance

GetInstanceByTitle returns the instance with the given title, or nil.

func (*List) GetInstances

func (l *List) GetInstances() []*session.Instance

GetInstances returns all instances in the list

func (*List) GetSelectedInstance

func (l *List) GetSelectedInstance() *session.Instance

GetSelectedInstance returns the currently selected instance

func (*List) NumInstances

func (l *List) NumInstances() int

NumInstances returns the number of instances currently held by the list. Used by GlobalInstanceLimit checks in the app layer before admitting a new instance.

func (*List) PageDown

func (l *List) PageDown()

PageDown jumps the selection down by one visible page, skipping Deleting items.

func (*List) PageUp

func (l *List) PageUp()

PageUp jumps the selection up by one visible page, skipping Deleting items. If every candidate in the target window is Deleting, the cursor stays put.

func (*List) PeerSections added in v0.13.0

func (l *List) PeerSections() []PeerSection

PeerSections returns the peer-workspace summaries currently set.

func (*List) RemoveInstance added in v0.13.0

func (l *List) RemoveInstance(inst *session.Instance)

RemoveInstance removes the given instance by pointer identity, no-oping when this list does not contain it. It is the list's only removal: identity, never the selection or a title, since two workspaces can hold same-titled instances, and completions resolve against every slot's list, not just the focused one. Only in-memory bookkeeping happens here; the caller runs any Kill (tmux, worktree) off the Update goroutine.

func (*List) ReplaceInstance added in v0.13.0

func (l *List) ReplaceInstance(old, replacement *session.Instance) bool

ReplaceInstance puts replacement in old's row (old found by identity), so the list order and the selection's row are unchanged. Reports whether old was in the list.

func (*List) SelectInstance

func (l *List) SelectInstance(target *session.Instance)

SelectInstance finds and selects the given instance in the list.

func (*List) SelectedIdx added in v0.13.0

func (l *List) SelectedIdx() int

SelectedIdx returns the current selection index (for jump helpers).

func (*List) SetPeerSections added in v0.13.0

func (l *List) SetPeerSections(peers []PeerSection)

SetPeerSections sets the peer-workspace summaries rendered under the rail.

func (*List) SetSelectedInstance

func (l *List) SetSelectedInstance(idx int)

SetSelectedInstance sets the selected index. Noop if the index is out of bounds.

func (*List) SetSessionPreviewSize

func (l *List) SetSessionPreviewSize(width, height int) (err error)

SetSessionPreviewSize sets the height and width for the tmux sessions. This makes the stdout line have the correct width and height.

func (*List) SetSize

func (l *List) SetSize(width, height int)

SetSize sets the height and width of the list.

func (*List) SetWorkspaceName

func (l *List) SetWorkspaceName(name string)

SetWorkspaceName sets the workspace name displayed in the title.

func (*List) String

func (l *List) String() string

func (*List) Top

func (l *List) Top()

Top selects the first non-Deleting item.

func (*List) Up

func (l *List) Up()

Up selects the prev non-Deleting item in the list. If every item above the cursor is Deleting, selectedIdx stays put.

type MarkdownPane added in v0.13.0

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

MarkdownPane is the workbench's markdown viewer/editor: a glamour-rendered scrollable view with follow/pin semantics and a raw-text textarea edit mode. Not goroutine-safe; Update-goroutine only (renders lazily inside View, same discipline as ScrollModel.AdvanceAndRender).

func NewMarkdownPane added in v0.13.0

func NewMarkdownPane() *MarkdownPane

func (*MarkdownPane) ApplySaved added in v0.13.0

func (m *MarkdownPane) ApplySaved(raw string, mtime time.Time)

ApplySaved is called after a successful disk write: adopt the saved content as the new baseline and drop back to the rendered view.

func (*MarkdownPane) CancelEdit added in v0.13.0

func (m *MarkdownPane) CancelEdit()

func (*MarkdownPane) Clear added in v0.13.0

func (m *MarkdownPane) Clear()

Clear empties the pane (file deleted / no markdown in tree).

func (*MarkdownPane) EditDirty added in v0.13.0

func (m *MarkdownPane) EditDirty() bool

func (*MarkdownPane) EditValue added in v0.13.0

func (m *MarkdownPane) EditValue() string

func (*MarkdownPane) Editing added in v0.13.0

func (m *MarkdownPane) Editing() bool

func (*MarkdownPane) Following added in v0.13.0

func (m *MarkdownPane) Following() bool

func (*MarkdownPane) HandleEditKey added in v0.13.0

func (m *MarkdownPane) HandleEditKey(msg tea.KeyPressMsg)

HandleEditKey forwards a key to the textarea.

func (*MarkdownPane) Mtime added in v0.13.0

func (m *MarkdownPane) Mtime() time.Time

func (*MarkdownPane) PageDown added in v0.13.0

func (m *MarkdownPane) PageDown()

func (*MarkdownPane) PageUp added in v0.13.0

func (m *MarkdownPane) PageUp()

func (*MarkdownPane) Path added in v0.13.0

func (m *MarkdownPane) Path() string

func (*MarkdownPane) Scroll added in v0.13.0

func (m *MarkdownPane) Scroll() int

func (*MarkdownPane) ScrollBottom added in v0.13.0

func (m *MarkdownPane) ScrollBottom()

func (*MarkdownPane) ScrollDown added in v0.13.0

func (m *MarkdownPane) ScrollDown()

func (*MarkdownPane) ScrollTop added in v0.13.0

func (m *MarkdownPane) ScrollTop()

func (*MarkdownPane) ScrollUp added in v0.13.0

func (m *MarkdownPane) ScrollUp()

func (*MarkdownPane) SetDocument added in v0.13.0

func (m *MarkdownPane) SetDocument(path, raw string, mtime time.Time)

SetDocument replaces the shown document. A path change resets scroll; a same-path reload (follow refresh) preserves it, clamped.

func (*MarkdownPane) SetFollowing added in v0.13.0

func (m *MarkdownPane) SetFollowing(f bool)

func (*MarkdownPane) SetSize added in v0.13.0

func (m *MarkdownPane) SetSize(width, height int)

func (*MarkdownPane) StartEdit added in v0.13.0

func (m *MarkdownPane) StartEdit() bool

StartEdit flips to the raw-text editor seeded with the loaded content. Returns false when there is nothing to edit.

func (*MarkdownPane) View added in v0.13.0

func (m *MarkdownPane) View() string
type Menu struct {
	// contains filtered or unexported fields
}

Menu is the bottom-row keybinding hint strip. It reads GlobalkeyBindings to render labels and tracks the most recent keypress so the UI can momentarily underline the matching entry for visual feedback.

func NewMenu

func NewMenu() *Menu

NewMenu constructs a Menu in StateEmpty with no active keypress. The caller must SetSize before the first render.

func (m *Menu) ClearKeydown()

ClearKeydown removes any active key-press highlight.

func (m *Menu) Instance() *session.Instance

Instance returns the instance the menu was last pointed at (nil for none).

func (m *Menu) Keydown(name keys.KeyName)

Keydown marks name as the most recently pressed key so the next render underlines its menu entry. ClearKeydown resets this.

func (m *Menu) SetInstance(instance *session.Instance)

SetInstance updates the current instance and refreshes menu options

func (m *Menu) SetSize(width, height int)

SetSize sets the width of the window. The menu will be centered horizontally within this width.

func (m *Menu) SetState(state MenuState)

SetState updates the menu state and options accordingly

func (m *Menu) State() MenuState

State returns the menu's current state.

func (m *Menu) String() string
type MenuState int

MenuState represents different states the menu can be in

const (
	StateDefault MenuState = iota
	StateEmpty
	StateNewInstance
	StatePrompt
	StateQuickInteract
	StateInlineAttach
)

StateDefault through StateInlineAttach enumerate the menu's display modes. The active state selects which subset of keybindings the menu-bar shows and how they are grouped visually.

type Overview added in v0.13.0

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

Overview renders the triage card grid: every open workspace group's instances as bordered cards under a collapsible group header, with empty groups rendered inline. The render cursor spans groups (OverviewCursor{Group,Item}).

func NewOverview added in v0.13.0

func NewOverview() *Overview

NewOverview constructs an empty overview component.

func (*Overview) IsCollapsed added in v0.13.0

func (o *Overview) IsCollapsed(name string) bool

IsCollapsed reports a group's collapsed state.

func (*Overview) Render added in v0.13.0

func (o *Overview) Render(d OverviewData) string

Render draws the multi-group fleet overview. Height is hard-clamped; the combined vertical window (Task 7) keeps the cursor group/card visible.

func (*Overview) SetSize added in v0.13.0

func (o *Overview) SetSize(w, h int)

SetSize sets the render bounds.

func (*Overview) ToggleCollapse added in v0.13.0

func (o *Overview) ToggleCollapse(name string)

ToggleCollapse flips a group's collapsed state (case-insensitive name).

type OverviewCursor added in v0.13.0

type OverviewCursor struct {
	Group int
	Item  int
}

OverviewCursor is the render-space selection: a group index into Groups and an item position within that group's Order.

type OverviewData added in v0.13.0

type OverviewData struct {
	Groups  []OverviewGroup
	Cursor  OverviewCursor
	Spinner string
}

OverviewData is everything Render needs, assembled by the app on the Update goroutine each frame (same pattern as List reading instances).

type OverviewGroup added in v0.13.0

type OverviewGroup struct {
	Name  string
	Items []*session.Instance
	Order []int // SortForOverview(Items); empty when the group is empty
	State GroupState
}

OverviewGroup is one open workspace's slice of the overview.

type PeerSection added in v0.13.0

type PeerSection struct {
	Name      string
	Attention int // Prompting or bell-pending
	Running   int // Running/Loading
	Idle      int // everything else
}

PeerSection summarizes a non-focused workspace slot for the rail footer (live counts from that slot's list; selection stays scoped to the focused workspace until cross-workspace lands).

type PreviewPane

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

PreviewPane renders the agent tmux pane's content in the top half of the split view. It tails the emulator's live screen at the live tail, and when scrolled windows the emulator's scrollback in-process (ScrollModel); on the no-emulator path (snapshot mode / Windows) it paints a window into tmux's authoritative history (capture-pane -S -) via snapFallback. Either way live output keeps flowing. lastInstanceTitle resets the scroll position on selection change rather than persisting a stale offset.

func NewPreviewPane

func NewPreviewPane() *PreviewPane

NewPreviewPane constructs a PreviewPane at live tail; the caller must SetSize before the first render.

func (*PreviewPane) BeginSelection added in v0.3.0

func (p *PreviewPane) BeginSelection(row, col int)

BeginSelection starts a selection anchored at content (row, col).

func (*PreviewPane) ClearSelection added in v0.3.0

func (p *PreviewPane) ClearSelection()

ClearSelection clears any active selection.

func (*PreviewPane) ExtendSelection added in v0.3.0

func (p *PreviewPane) ExtendSelection(row, col int)

ExtendSelection moves the active selection's cursor to content (row, col).

func (*PreviewPane) GotoBottom

func (p *PreviewPane) GotoBottom(instance *session.Instance) error

GotoBottom returns to the live tail (TUI: a large wheel-down burst).

func (*PreviewPane) GotoTop

func (p *PreviewPane) GotoTop(instance *session.Instance) error

GotoTop jumps to the oldest line of captured history (TUI: a large wheel-up burst).

func (*PreviewPane) IsScrolling

func (p *PreviewPane) IsScrolling() bool

IsScrolling reports whether the pane is scrolled away from the live tail.

func (*PreviewPane) PageDown

func (p *PreviewPane) PageDown(instance *session.Instance) error

PageDown scrolls down by half a pane height (or forwards a burst of wheel-downs).

func (*PreviewPane) PageUp

func (p *PreviewPane) PageUp(instance *session.Instance) error

PageUp scrolls up by half a pane height (or forwards a burst of wheel-ups).

func (*PreviewPane) ResetToNormalMode

func (p *PreviewPane) ResetToNormalMode(instance *session.Instance) error

ResetToNormalMode returns the pane to the live tail on both paths.

func (*PreviewPane) ScrollDown

func (p *PreviewPane) ScrollDown(instance *session.Instance) error

ScrollDown scrolls one line down toward the live tail (or forwards a damped wheel-down).

func (*PreviewPane) ScrollPercent

func (p *PreviewPane) ScrollPercent() float64

ScrollPercent returns the scroll position as a fraction [0, 1]; 1.0 == live tail (bottom).

func (*PreviewPane) ScrollUp

func (p *PreviewPane) ScrollUp(instance *session.Instance) error

ScrollUp scrolls one line up into history (or forwards a damped wheel-up to a TUI agent).

func (*PreviewPane) SelectedText added in v0.3.0

func (p *PreviewPane) SelectedText() string

SelectedText returns the currently selected text (plain), or "" if none.

func (*PreviewPane) SetSize

func (p *PreviewPane) SetSize(width, maxHeight int)

SetSize records the pane dimensions. maxHeight caps the visible height — content exceeding it is truncated with an ellipsis at live tail or windowed when scrolled.

func (*PreviewPane) ShowingFallback added in v0.8.0

func (p *PreviewPane) ShowingFallback() bool

ShowingFallback reports whether the pane is displaying splash/fallback text instead of live terminal content (no cursor applies there).

func (*PreviewPane) String

func (p *PreviewPane) String() string

Returns the preview pane content as a string.

func (*PreviewPane) UpdateContent

func (p *PreviewPane) UpdateContent(instance *session.Instance) error

UpdateContent refreshes the pane from the given instance. At the live tail it tails the live emulator screen; when scrolled it windows the emulator's scrollback in-process (ScrollModel), or, on the no-emulator path, tmux's authoritative history (capture-pane -S -) at the current offset, anchoring the view to its content as live output accrues below. Falls back to splash text for nil/loading/paused instances and resets the offset on instance change.

type QuickInputAction

type QuickInputAction int

QuickInputAction represents the result of handling a key press in the input bar.

const (
	QuickInputContinue QuickInputAction = iota
	QuickInputSubmit
	QuickInputCancel
)

QuickInputContinue, QuickInputSubmit, and QuickInputCancel are the terminal states HandleKey returns so the parent model knows whether to keep the bar open, dispatch the contents, or dismiss the bar.

type QuickInputBar

type QuickInputBar struct {
	Target QuickInputTarget
	// contains filtered or unexported fields
}

QuickInputBar is a single-line input bar for quick interactions with tmux sessions.

func NewQuickInputBar

func NewQuickInputBar(target QuickInputTarget) *QuickInputBar

NewQuickInputBar creates a focused input bar ready for typing.

func (*QuickInputBar) HandleKeyPress

func (q *QuickInputBar) HandleKeyPress(msg tea.KeyPressMsg) QuickInputAction

HandleKeyPress processes a key event and returns the resulting action.

func (*QuickInputBar) Height

func (q *QuickInputBar) Height() int

Height returns the number of lines the input bar occupies.

func (*QuickInputBar) SetWidth

func (q *QuickInputBar) SetWidth(w int)

SetWidth sets the rendering width of the input bar.

func (*QuickInputBar) Value

func (q *QuickInputBar) Value() string

Value returns the current text in the input bar.

func (*QuickInputBar) View

func (q *QuickInputBar) View() string

View renders the input bar.

type QuickInputTarget

type QuickInputTarget int

QuickInputTarget specifies where submitted text should be routed.

const (
	QuickInputTargetAgent QuickInputTarget = iota
	QuickInputTargetTerminal
)

QuickInputTargetAgent sends submitted text to the agent pane; the terminal variant routes to the bottom pane. The target is chosen at construction time and is immutable for the life of the bar.

type ReviewPane added in v0.13.0

type ReviewPane interface {
	SetSize(width, height int)
	View() string
}

ReviewPane is the workbench's view of the review panel. The concrete *reviewui.Pane lives in the app layer: ui/review imports ui for theme roles, so package ui must not import it back.

type ScrollModel added in v0.13.0

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

ScrollModel owns pane scroll state for the emulator path: the lines-from-bottom offset, output anchoring, the new-lines-below footer count, wheel damping, and alt-screen routing. Both panes embed one. All methods run on the Update goroutine (no locking; TerminalPane's own mutex wraps its calls).

func (*ScrollModel) AdvanceAndRender added in v0.13.0

func (m *ScrollModel) AdvanceAndRender(src scrollSource, rows int) (window string, live bool, ok bool)

AdvanceAndRender renders `rows` lines at the current offset. live=true means the pane is at the live tail (offset 0) and the caller should render its normal live view instead. ok=false means no emulator (snapshot fallback).

It also performs the per-render anchoring bump and clamping (hence the name — it advances the anchor state AND renders), so it must be called exactly once per render pass. A repeat call with no intervening output is idempotent: sbLen is unchanged so the anchor bump is a no-op and the window is identical. The only failure mode of an extra call is NewLinesBelow drift if output *did* arrive between the two calls — never corruption of the rendered window.

Limitation: at the emulator's scrollback cap (x/vt default 10k lines) sbLen plateaus, so the anchor bump stops compensating for further scroll-off and the view drifts up by at most the overflow. Bounded, graceful degradation — accepted.

func (*ScrollModel) GotoTop added in v0.13.0

func (m *ScrollModel) GotoTop(src scrollSource)

GotoTop pins the view to the oldest line (clamped in Window).

func (*ScrollModel) IsScrolling added in v0.13.0

func (m *ScrollModel) IsScrolling() bool

IsScrolling reports whether the pane is away from the live tail.

func (*ScrollModel) NeedsAltProbe added in v0.13.0

func (m *ScrollModel) NeedsAltProbe() bool

NeedsAltProbe reports whether the alt-screen TTL cache is stale, i.e. the next isAltScreen would run a subprocess probe. It only reads cache timestamps, so a caller holding its own mutex can consult it, drop the mutex, run the probe (IsAlternateScreen — a tmux subprocess) off-lock, then SetAltProbe the result before invoking a routing method. That keeps the subprocess out of the caller's lock while a subsequent route()/PageUp on the now-fresh cache never re-probes. Used by TerminalPane, whose t.mu wraps all ScrollModel access; PreviewPane is unlocked and calls the routers directly.

func (*ScrollModel) NewLinesBelow added in v0.13.0

func (m *ScrollModel) NewLinesBelow() int

NewLinesBelow is the footer count: scroll-off lines accrued since the gesture began. Limitation: at the scrollback cap (x/vt default 10k lines) sbLen plateaus, so the count stops growing even as new output arrives — bounded, graceful degradation, accepted.

func (*ScrollModel) PageDown added in v0.13.0

func (m *ScrollModel) PageDown(src scrollSource, height int) error

func (*ScrollModel) PageUp added in v0.13.0

func (m *ScrollModel) PageUp(src scrollSource, height int) error

PageUp/PageDown move by half the given pane height (or forward a burst).

func (*ScrollModel) Reset added in v0.13.0

func (m *ScrollModel) Reset()

Reset returns to the live tail (resize, instance switch, Esc/End) and forces the next alt-screen probe.

func (*ScrollModel) ScrollBy added in v0.13.0

func (m *ScrollModel) ScrollBy(src scrollSource, delta int)

ScrollBy moves the offset by delta (positive = up into history). The gesture baseline is captured on the first move away from the tail.

func (*ScrollModel) ScrollDown added in v0.13.0

func (m *ScrollModel) ScrollDown(src scrollSource) error

func (*ScrollModel) ScrollPercent added in v0.13.0

func (m *ScrollModel) ScrollPercent(src scrollSource) float64

ScrollPercent maps the offset to [0,1]; 1.0 = live tail.

func (*ScrollModel) ScrollUp added in v0.13.0

func (m *ScrollModel) ScrollUp(src scrollSource) error

ScrollUp/ScrollDown route one wheel/key tick: alt-screen TUIs get damped forwarded wheel events; everything else moves the window.

func (*ScrollModel) SetAltProbe added in v0.13.0

func (m *ScrollModel) SetAltProbe(alt bool)

SetAltProbe stores a freshly-probed alt-screen result and stamps the TTL, so the next isAltScreen within agentScrollTTL is a cache hit. Pairs with NeedsAltProbe for off-lock probing (see there).

type SplitPane

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

SplitPane composes the right-hand side of the TUI: an agent preview on top, a terminal pane below (split by the adjustable agentRatio, default SplitAgentPercent; the terminal pane can be hidden entirely), and a hotkey-toggled diff overlay that replaces both. SplitPane holds the currently-focused pane index and inline-attach flag but does not own scroll state — each child pane manages its own viewport.

func NewSplitPane

func NewSplitPane(agent *PreviewPane, diff *DiffPane, terminal *TerminalPane) *SplitPane

NewSplitPane wires the three child panes into a SplitPane with the agent pane focused by default. The caller retains ownership of the child panes; SplitPane borrows them for routing.

func (*SplitPane) AdjustAgentRatio added in v0.13.0

func (s *SplitPane) AdjustAgentRatio(delta float64) float64

AdjustAgentRatio nudges the split by delta and returns the new ratio.

func (*SplitPane) AgentContentHeight added in v0.13.0

func (s *SplitPane) AgentContentHeight() int

AgentContentHeight is the agent pane's inner height — the app's mouse hit-test anchor mirrors layout through this instead of duplicating the math.

func (*SplitPane) AgentRatio added in v0.13.0

func (s *SplitPane) AgentRatio() float64

AgentRatio returns the agent pane's height share (default SplitAgentPercent when unset).

func (*SplitPane) BeginSelection added in v0.3.0

func (s *SplitPane) BeginSelection(pane, row, col int)

BeginSelection starts a selection on the given content pane (clearing any selection on the other pane first).

func (*SplitPane) CleanupTerminal

func (s *SplitPane) CleanupTerminal()

CleanupTerminal closes the terminal session.

func (*SplitPane) ClearSelections added in v0.3.0

func (s *SplitPane) ClearSelections()

ClearSelections clears the selection on both content panes.

func (*SplitPane) CurrentTerminalSessionName added in v0.8.0

func (s *SplitPane) CurrentTerminalSessionName() string

CurrentTerminalSessionName returns the tmux session name backing the currently displayed terminal pane, or "" if none — the key pane events are routed by.

func (*SplitPane) CursorScreenPosition added in v0.8.0

func (s *SplitPane) CursorScreenPosition(instance *session.Instance) (x, y int, cur vt.Cursor, ok bool)

CursorScreenPosition returns the focused pane's live cursor as split-local coordinates plus its full state, or ok=false whenever no hardware cursor should be shown: diff overlay up, focused pane scrolled off the live tail or showing fallback text, no emulator-backed session, cursor hidden (DECTCEM), or the cell out of the pane's bounds.

func (*SplitPane) DetachTerminalForInstance

func (s *SplitPane) DetachTerminalForInstance(title string) *tmux.TmuxSession

DetachTerminalForInstance removes the cached terminal entry for the given instance title and returns the popped tmux session, so the caller can Close it off the update goroutine. Returns nil if nothing was cached.

func (*SplitPane) ExtendSelection added in v0.3.0

func (s *SplitPane) ExtendSelection(pane, row, col int)

ExtendSelection moves the active selection's cursor on the given content pane.

func (*SplitPane) ForwardTerminalFocus added in v0.8.0

func (s *SplitPane) ForwardTerminalFocus(in bool)

ForwardTerminalFocus forwards a focus event to the terminal pane's session.

func (*SplitPane) ForwardTerminalMouse added in v0.3.0

func (s *SplitPane) ForwardTerminalMouse(cb, col, row int, press bool) error

ForwardTerminalMouse forwards one SGR mouse event to the terminal pane's session.

func (*SplitPane) GetAgentSize

func (s *SplitPane) GetAgentSize() (width, height int)

GetAgentSize returns the current width and height of the agent pane, primarily used by the attach flow to size the PTY before handing it to the user.

func (*SplitPane) GetFocusedPane

func (s *SplitPane) GetFocusedPane() int

GetFocusedPane returns the currently focused pane constant.

func (*SplitPane) GotoBottom

func (s *SplitPane) GotoBottom()

GotoBottom jumps the active pane to the live tail, exiting scroll mode.

func (*SplitPane) GotoTop

func (s *SplitPane) GotoTop()

GotoTop jumps the active pane to the start of its scrollback.

func (*SplitPane) HitTest added in v0.3.0

func (s *SplitPane) HitTest(localX, y int) (pane, row, col int, ok bool)

HitTest maps split-pane-local coordinates (x relative to the split's left edge, y from the top of the split) to a content pane and (row, col) within it. Returns ok=false for the diff overlay, borders, the title/bottom-border rows, or coordinates outside any content area. The returned pane is FocusAgent or FocusTerminal. Geometry mirrors renderPane: each box is a title row, a body bordered left/right/bottom (no top), stacked agent-over-terminal.

func (*SplitPane) InjectTerminalSessionForTest added in v0.6.0

func (s *SplitPane) InjectTerminalSessionForTest(title string, ts *tmux.TmuxSession, worktreePath string)

InjectTerminalSessionForTest installs ts as the cached terminal session for the given instance title, bypassing the terminal pane's normal lazy-spawn path. Test-only: the name and doc comment are guardrails, nothing about the method enforces test-only use.

func (*SplitPane) Instance added in v0.13.0

func (s *SplitPane) Instance() *session.Instance

Instance returns the instance set by SetInstance (nil for none).

func (*SplitPane) IsAgentInScrollMode

func (s *SplitPane) IsAgentInScrollMode() bool

IsAgentInScrollMode returns true if the agent pane is scrolled away from the live tail.

func (*SplitPane) IsDiffVisible

func (s *SplitPane) IsDiffVisible() bool

IsDiffVisible returns true if the diff overlay is currently shown.

func (*SplitPane) IsTerminalHidden added in v0.13.0

func (s *SplitPane) IsTerminalHidden() bool

IsTerminalHidden reports whether the terminal pane is hidden.

func (*SplitPane) IsTerminalInScrollMode

func (s *SplitPane) IsTerminalInScrollMode() bool

IsTerminalInScrollMode returns true if the terminal pane is in scroll mode.

func (*SplitPane) PageDown

func (s *SplitPane) PageDown()

PageDown scrolls the active pane down by half a view.

func (*SplitPane) PageTerminalDown

func (s *SplitPane) PageTerminalDown()

PageTerminalDown pages the terminal pane explicitly.

func (*SplitPane) PageTerminalUp

func (s *SplitPane) PageTerminalUp()

PageTerminalUp pages the terminal pane explicitly.

func (*SplitPane) PageUp

func (s *SplitPane) PageUp()

PageUp scrolls the active pane (diff if visible, else focused) up by half a view.

func (*SplitPane) PasteTerminal added in v0.3.0

func (s *SplitPane) PasteTerminal(text string) error

PasteTerminal sends text to the terminal pane's session as a bracketed paste.

func (*SplitPane) ResetAgentToNormalMode

func (s *SplitPane) ResetAgentToNormalMode(instance *session.Instance) error

ResetAgentToNormalMode resets the agent pane to normal mode.

func (*SplitPane) ResetTerminalToNormalMode

func (s *SplitPane) ResetTerminalToNormalMode()

ResetTerminalToNormalMode exits scroll mode on the terminal pane.

func (*SplitPane) ScrollAgentDown

func (s *SplitPane) ScrollAgentDown()

ScrollAgentDown scrolls the agent pane explicitly (mouse wheel).

func (*SplitPane) ScrollAgentUp

func (s *SplitPane) ScrollAgentUp()

ScrollAgentUp scrolls the agent pane explicitly, ignoring focus/diff (mouse wheel).

The explicit scrollers re-render their pane themselves: a scroll only moves the ScrollModel offset, and the displayed text is rebuilt by UpdateContent. The keyboard path gets that refresh for free from handleScriptDone → instanceChanged, but the wheel handler calls nothing else, so without this the pane sat frozen at the old window until the agent's next output event (or a stray keypress) happened to redraw it.

func (*SplitPane) ScrollDiffDown

func (s *SplitPane) ScrollDiffDown()

ScrollDiffDown scrolls the diff overlay explicitly (no-op if not visible).

func (*SplitPane) ScrollDiffUp

func (s *SplitPane) ScrollDiffUp()

ScrollDiffUp scrolls the diff overlay explicitly (no-op if not visible).

func (*SplitPane) ScrollDown

func (s *SplitPane) ScrollDown()

ScrollDown is the counterpart of ScrollUp; see ScrollUp for routing and error-handling rules.

func (*SplitPane) ScrollTerminalDown

func (s *SplitPane) ScrollTerminalDown()

ScrollTerminalDown scrolls the terminal pane explicitly (mouse wheel).

func (*SplitPane) ScrollTerminalUp

func (s *SplitPane) ScrollTerminalUp()

ScrollTerminalUp scrolls the terminal pane explicitly (mouse wheel). Re-renders for the same reason as ScrollAgentUp.

func (*SplitPane) ScrollUp

func (s *SplitPane) ScrollUp()

ScrollUp scrolls the active pane up by one line. Routing order: diff overlay (when visible) beats the focused pane. Scroll errors are logged rather than propagated because scroll is a view-only operation and should not abort the caller's update cycle.

func (*SplitPane) SelectedText added in v0.3.0

func (s *SplitPane) SelectedText(pane int) string

SelectedText returns the selected text of the given content pane.

func (*SplitPane) SendTerminalKeysRaw

func (s *SplitPane) SendTerminalKeysRaw(b []byte) error

SendTerminalKeysRaw writes raw bytes to the terminal pane's tmux PTY.

func (*SplitPane) SendTerminalKeysToInstance added in v0.1.2

func (s *SplitPane) SendTerminalKeysToInstance(title, text string) error

SendTerminalKeysToInstance sends text followed by Enter to the named instance's cached terminal session. Unlike SendTerminalPrompt, this does not require the instance to be currently displayed.

func (*SplitPane) SendTerminalPrompt

func (s *SplitPane) SendTerminalPrompt(text string) error

SendTerminalPrompt sends text followed by Enter to the terminal pane's tmux session.

func (*SplitPane) SetAgentRatio added in v0.13.0

func (s *SplitPane) SetAgentRatio(r float64)

SetAgentRatio sets the agent share (clamped to [0.2, 0.9]) and re-lays-out at the current size. The ratio is snapped to two decimals so repeated ±delta nudges don't accumulate float drift (0.7+0.1 = 0.7999… would truncate a row short in SetSize).

func (*SplitPane) SetFocusedPane

func (s *SplitPane) SetFocusedPane(pane int)

SetFocusedPane sets focus to the specified pane.

func (*SplitPane) SetInlineAttach

func (s *SplitPane) SetInlineAttach(attached bool)

SetInlineAttach toggles whether inline-attach mode is active, controlling whether the focused-pane highlight is rendered.

func (*SplitPane) SetInstance

func (s *SplitPane) SetInstance(instance *session.Instance)

SetInstance sets the instance whose state the child panes will render on the next UpdateAgent/UpdateDiff/UpdateTerminal call. The child panes read their content from the instance, so switching here without calling the Update* methods leaves the previously-rendered content in place until the next tick.

func (*SplitPane) SetSize

func (s *SplitPane) SetSize(width, height int)

SetSize recomputes the agent/terminal split (per AgentRatio, or all agent when the terminal is hidden) for the given container dimensions and propagates widths to every child pane, including the diff overlay which uses the full inner height.

func (*SplitPane) SetTerminalHidden added in v0.13.0

func (s *SplitPane) SetTerminalHidden(h bool)

SetTerminalHidden shows/hides the terminal pane; hidden gives the agent pane the full height.

func (*SplitPane) String

func (s *SplitPane) String() string

func (*SplitPane) Terminal added in v0.13.0

func (s *SplitPane) Terminal() *TerminalPane

Terminal exposes the terminal child pane so workbench mode can render/size the same TerminalPane instance in its right panel. Ordering contract: in workbench mode the app calls SplitPane.SetSize (which, with the terminal hidden, sizes it to zero) BEFORE Workbench.SetSize re-sizes it for the panel — keep that order.

func (*SplitPane) TerminalTmuxSession

func (s *SplitPane) TerminalTmuxSession() *tmux.TmuxSession

TerminalTmuxSession returns the live tmux session backing the currently displayed terminal pane, or nil if none exists. Callers use this to drive a full-screen attach via tea.ExecProcess.

func (*SplitPane) ToggleDiff

func (s *SplitPane) ToggleDiff()

ToggleDiff shows or hides the diff overlay.

func (*SplitPane) UpdateAgent

func (s *SplitPane) UpdateAgent(instance *session.Instance) error

UpdateAgent updates the agent (preview) pane content. Always updates since it's always visible.

func (*SplitPane) UpdateDiff

func (s *SplitPane) UpdateDiff(instance *session.Instance)

UpdateDiff updates the diff pane content. Only updates when the overlay is visible.

func (*SplitPane) UpdateTerminal

func (s *SplitPane) UpdateTerminal(instance *session.Instance) error

UpdateTerminal updates the terminal pane content. It intentionally keeps updating while the pane is hidden so the content stays warm for an instant unhide.

type SubagentRow added in v0.13.0

type SubagentRow struct {
	Name        string
	Description string
	Idle        bool
}

SubagentRow is one live subagent or teammate shown on a card.

type TabStatus

type TabStatus int

TabStatus represents the highest-priority instance status within a workspace tab. Precedence (high→low): Prompting > Running > Ready > Loading > Paused > None.

const (
	TabStatusNone TabStatus = iota
	TabStatusPaused
	TabStatusLoading
	TabStatusReady
	TabStatusRunning
	TabStatusPrompting
)

TabStatusNone through TabStatusPrompting rank an instance status by display priority. A tab aggregates statuses by taking the max across its instances so the most urgent one shows through in the tab dot.

type TerminalPane

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

TerminalPane manages shell tmux sessions in the worktree directory of selected instances. Sessions are cached per instance so switching between instances preserves terminal state.

func NewTerminalPane

func NewTerminalPane() *TerminalPane

NewTerminalPane constructs a TerminalPane with an empty session cache at the live tail. The caller must SetSize before the first render and feed instances via UpdateContent.

func (*TerminalPane) BeginSelection added in v0.3.0

func (t *TerminalPane) BeginSelection(row, col int)

BeginSelection starts a selection anchored at content (row, col).

func (*TerminalPane) ClearSelection added in v0.3.0

func (t *TerminalPane) ClearSelection()

ClearSelection clears any active selection.

func (*TerminalPane) Close

func (t *TerminalPane) Close()

Close kills all cached terminal tmux sessions and cleans up.

func (*TerminalPane) CurrentTmuxSession

func (t *TerminalPane) CurrentTmuxSession() *tmux.TmuxSession

CurrentTmuxSession returns the cached tmux session for the currently displayed instance, or nil if none exists or the session is dead. Intended for callers that drive full-screen attach via tea.ExecProcess.

func (*TerminalPane) CursorState added in v0.8.0

func (t *TerminalPane) CursorState() (vt.Cursor, bool)

CursorState returns the current terminal session's live cursor state, or ok=false when no live emulator-backed session is displayed.

func (*TerminalPane) DetachAll added in v0.13.0

func (t *TerminalPane) DetachAll() []*tmux.TmuxSession

DetachAll empties the session cache and returns the cached tmux sessions, for a caller dropping this pane to release their attach clients (PausePreview) off the Update goroutine. Unlike Close, nothing is killed: the shells keep running for the next pane that shows them. Pure bookkeeping — no blocking I/O — so it is safe to call from Update.

func (*TerminalPane) DetachExcept added in v0.13.0

func (t *TerminalPane) DetachExcept(keep map[string]bool) []*tmux.TmuxSession

DetachExcept is DetachAll for the cache entries whose instance titles are not in keep: a pane that stays in use hands over only the sessions its new owner can't show.

func (*TerminalPane) DetachSessionForInstance

func (t *TerminalPane) DetachSessionForInstance(title string) *tmux.TmuxSession

DetachSessionForInstance removes the cached terminal entry for the given title and returns the extracted tmux session so the caller can Close() it off the update goroutine. Returns nil if no session was cached. This is pure state bookkeeping — no blocking I/O — so it is safe to call from Update.

func (*TerminalPane) ExtendSelection added in v0.3.0

func (t *TerminalPane) ExtendSelection(row, col int)

ExtendSelection moves the active selection's cursor to content (row, col).

func (*TerminalPane) ForwardFocus added in v0.8.0

func (t *TerminalPane) ForwardFocus(in bool)

ForwardFocus forwards a host focus in/out event to the current terminal session, gated on mode 1004. Best-effort.

func (*TerminalPane) ForwardMouse added in v0.3.0

func (t *TerminalPane) ForwardMouse(cb, col, row int, press bool) error

ForwardMouse forwards one SGR mouse event to the current terminal session.

func (*TerminalPane) GotoBottom

func (t *TerminalPane) GotoBottom()

GotoBottom returns to the live tail on both paths.

func (*TerminalPane) GotoTop

func (t *TerminalPane) GotoTop() error

GotoTop jumps to the oldest line of history (TUI: a large wheel-up burst).

func (*TerminalPane) InjectSessionForTest added in v0.6.0

func (t *TerminalPane) InjectSessionForTest(title string, ts *tmux.TmuxSession, worktreePath string)

InjectSessionForTest installs ts as the cached terminal session for the given instance title, bypassing ensureSessionLocked's normal lazy-spawn path so a test can pin a specific (possibly dead) session in place. Test-only: the name and doc comment are guardrails, nothing about the method enforces test-only use.

func (*TerminalPane) IsScrolling

func (t *TerminalPane) IsScrolling() bool

IsScrolling reports whether the pane is scrolled away from the live tail.

func (*TerminalPane) PageDown

func (t *TerminalPane) PageDown() error

PageDown scrolls down by half a pane height (or forwards a burst of wheel-downs).

func (*TerminalPane) PageUp

func (t *TerminalPane) PageUp() error

PageUp scrolls up by half a pane height (or forwards a burst of wheel-ups).

func (*TerminalPane) Paste added in v0.3.0

func (t *TerminalPane) Paste(text string) error

Paste sends text to the current terminal session as a bracketed paste.

func (*TerminalPane) ResetToNormalMode

func (t *TerminalPane) ResetToNormalMode()

ResetToNormalMode returns the pane to the live tail on both paths.

func (*TerminalPane) ScrollDown

func (t *TerminalPane) ScrollDown() error

ScrollDown scrolls one line down toward the live tail (or forwards a damped wheel-down to a TUI agent).

func (*TerminalPane) ScrollPercent

func (t *TerminalPane) ScrollPercent() float64

ScrollPercent returns the scroll position as a fraction [0, 1]; 1.0 == live tail (bottom).

func (*TerminalPane) ScrollUp

func (t *TerminalPane) ScrollUp() error

ScrollUp scrolls one line up into history (or forwards a damped wheel-up to a TUI agent on the alternate screen).

func (*TerminalPane) SelectedText added in v0.3.0

func (t *TerminalPane) SelectedText() string

SelectedText returns the currently selected text (plain), or "" if none.

func (*TerminalPane) SendKeysRaw

func (t *TerminalPane) SendKeysRaw(b []byte) error

SendKeysRaw writes raw bytes to the current terminal tmux PTY.

func (*TerminalPane) SendKeysToInstance added in v0.1.2

func (t *TerminalPane) SendKeysToInstance(title, text string) error

SendKeysToInstance sends text followed by Enter to the cached terminal session for the named instance, regardless of which instance is currently displayed. Returns an error if no session is cached for that title or the session has died — callers (typically scripts) should surface the error rather than silently no-op'ing so the user knows the keystroke didn't land.

func (*TerminalPane) SendPrompt

func (t *TerminalPane) SendPrompt(text string) error

SendPrompt sends text followed by Enter to the current terminal session.

func (*TerminalPane) SetSize

func (t *TerminalPane) SetSize(width, height int)

SetSize resizes the pane under the internal mutex. The internal tmux session owned by TerminalPane is resized lazily on the next tick so this call remains cheap.

func (*TerminalPane) ShowingFallback added in v0.8.0

func (t *TerminalPane) ShowingFallback() bool

ShowingFallback reports whether the pane is displaying fallback text instead of live terminal content (no cursor applies there).

func (*TerminalPane) String

func (t *TerminalPane) String() string

func (*TerminalPane) UpdateContent

func (t *TerminalPane) UpdateContent(instance *session.Instance) error

UpdateContent captures the terminal pane output. At the live tail it tails the live emulator screen (capture-pane fallback when no emulator); when scrolled it windows the emulator's scrollback in-process (ScrollModel), or, on the no-emulator path, tmux's authoritative history at the current offset.

type Theme added in v0.13.0

type Theme struct {
	Name string

	// Surfaces and text.
	Ground color.Color // full-bleed background (reserved; no style paints it yet)
	Panel  color.Color // raised-surface background (workspace-terminal rows, selected cards)
	Text   color.Color // primary foreground
	Dim    color.Color // secondary labels, hints
	Faint  color.Color // barely-there text (aux hints, disabled)
	Rule   color.Color // unfocused borders, separators

	// Accents. Attention is reserved for "an agent needs the user" —
	// nothing else may use it, so a calm screen has no loud color.
	Accent    color.Color // focus, activity, selected borders
	Attention color.Color // needs-input / bell — the ONLY loud color
	Highlight color.Color // key glyphs, scroll footers
	OK        color.Color // ready status, added lines
	Error     color.Color // errors, removed lines, destructive accents
	Workspace color.Color // workspace labels, workspace-terminal identity
	Info      color.Color // informational text, hunk headers, running tabs

	// Selection (list rows, pickers).
	SelectionBg color.Color
	SelectionFg color.Color
}

Theme is a named palette of semantic color roles. Components never reference literal colors — they reference the package-level role vars below, which ApplyTheme reassigns. Styles built from roles at package init would capture stale values, so any package-level lipgloss.Style derived from a role must be (re)built inside a RegisterThemeHook callback (see rebuildListStyles in list.go for the pattern).

type Workbench added in v0.13.0

type Workbench struct {
	Markdown *MarkdownPane
	// contains filtered or unexported fields
}

Workbench renders the right panel of workbench mode: a tab strip over one of markdown / diff / files / terminal. It owns its MarkdownPane and DiffPane; the TerminalPane is the session's shared pane (see SplitPane.Terminal for the sizing-order contract).

func NewWorkbench added in v0.13.0

func NewWorkbench(diff *DiffPane, terminal *TerminalPane) *Workbench

func (*Workbench) Diff added in v0.13.0

func (w *Workbench) Diff() *DiffPane

func (*Workbench) FileUnderCursor added in v0.13.0

func (w *Workbench) FileUnderCursor() (string, bool)

FileUnderCursor resolves the cursor to an absolute path.

func (*Workbench) FilesBottom added in v0.13.0

func (w *Workbench) FilesBottom()

func (*Workbench) FilesDown added in v0.13.0

func (w *Workbench) FilesDown()

func (*Workbench) FilesTop added in v0.13.0

func (w *Workbench) FilesTop()

FilesTop/FilesBottom jump the files cursor to the first/last entry.

func (*Workbench) FilesUp added in v0.13.0

func (w *Workbench) FilesUp()

func (*Workbench) Review added in v0.13.0

func (w *Workbench) Review() ReviewPane

func (*Workbench) Root added in v0.13.0

func (w *Workbench) Root() string

func (*Workbench) SessionTitle added in v0.13.0

func (w *Workbench) SessionTitle() string

SessionTitle reports the session the panel is currently targeting ("" before the first SetSession).

func (*Workbench) SetFiles added in v0.13.0

func (w *Workbench) SetFiles(root string, paths []string)

SetFiles installs the files-tab listing (repo-relative paths).

func (*Workbench) SetReview added in v0.13.0

func (w *Workbench) SetReview(p ReviewPane)

SetReview installs (or clears, with nil) the review pane and sizes it. Callers must pass either a non-nil ReviewPane or an untyped nil; a nil typed pointer boxed into the interface would make the != nil check below misbehave.

func (*Workbench) SetSession added in v0.13.0

func (w *Workbench) SetSession(title, root string)

SetSession retargets the panel to a different session. Clears the per-session content (document, file list) and resumes follow mode. No-op when the title is unchanged.

func (*Workbench) SetSize added in v0.13.0

func (w *Workbench) SetSize(width, height int)

func (*Workbench) SetTab added in v0.13.0

func (w *Workbench) SetTab(t WorkbenchTab)

func (*Workbench) String added in v0.13.0

func (w *Workbench) String() string

String renders the panel: tab strip as the first content row inside the border, body clipped to the remaining inner box. lipgloss Width/Height are total (border-inclusive) and Height is a minimum — MaxHeight does the capping (repo gotcha). MaxHeight's own truncation is not trusted here either: the body is explicitly clipped to its line budget before rendering, since Height/MaxHeight interaction with border styles has misbehaved in this repo before.

func (*Workbench) Tab added in v0.13.0

func (w *Workbench) Tab() WorkbenchTab

type WorkbenchTab added in v0.13.0

type WorkbenchTab int

WorkbenchTab enumerates the right panel's content tabs.

const (
	WbTabMarkdown WorkbenchTab = iota
	WbTabDiff
	WbTabFiles
	WbTabTerminal
	WbTabReview
)

type WorkspaceTabBar

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

WorkspaceTabBar renders a row of workspace tabs at the top of the TUI.

func NewWorkspaceTabBar

func NewWorkspaceTabBar() *WorkspaceTabBar

NewWorkspaceTabBar creates a new workspace tab bar.

func (*WorkspaceTabBar) Height

func (b *WorkspaceTabBar) Height() int

Height returns the rendered height: 0 when empty, 3 when tabs are present (top border + content + bottom border).

func (*WorkspaceTabBar) SetStatuses

func (b *WorkspaceTabBar) SetStatuses(statuses []TabStatus)

SetStatuses updates the per-tab status indicators.

func (*WorkspaceTabBar) SetWidth

func (b *WorkspaceTabBar) SetWidth(w int)

SetWidth sets the available width for the tab bar.

func (*WorkspaceTabBar) SetWorkspaces

func (b *WorkspaceTabBar) SetWorkspaces(names []string, focused int)

SetWorkspaces updates the displayed workspace names and focused index.

func (*WorkspaceTabBar) String

func (b *WorkspaceTabBar) String() string

String renders the tab bar. Returns "" when there are no workspaces.

Directories

Path Synopsis
Package overlay implements the modal dialogs layered above the main TUI — the text-input overlay for new instances and prompts, the confirmation overlay for destructive actions, and the branch, profile, and workspace pickers.
Package overlay implements the modal dialogs layered above the main TUI — the text-input overlay for new instances and prompts, the confirmation overlay for destructive actions, and the branch, profile, and workspace pickers.

Jump to

Keyboard shortcuts

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