common

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package common holds UI building blocks shared across panes: theming (colors, styles, icons), widgets (dialogs, file picker, toasts), text selection, and the low-level PTY/tmux plumbing used by the center and sidebar terminals.

Package common re-exports the internal/ui/theme symbols so existing common.* references keep working after theme was split into its own package. New code should import internal/ui/theme directly.

Index

Constants

View Source
const (
	OSC52ClipboardEnv      = "AMUX_ENABLE_OSC52_CLIPBOARD"
	OSC52ClipboardMaxBytes = 64 * 1024
)
View Source
const (
	ThemeTokyoNight      = theme.ThemeTokyoNight
	ThemeDracula         = theme.ThemeDracula
	ThemeNord            = theme.ThemeNord
	ThemeCatppuccin      = theme.ThemeCatppuccin
	ThemeGruvbox         = theme.ThemeGruvbox
	ThemeSolarized       = theme.ThemeSolarized
	ThemeMonokai         = theme.ThemeMonokai
	ThemeRosePine        = theme.ThemeRosePine
	ThemeOneDark         = theme.ThemeOneDark
	ThemeKanagawa        = theme.ThemeKanagawa
	ThemeEverforest      = theme.ThemeEverforest
	ThemeAyuDark         = theme.ThemeAyuDark
	ThemeGitHubDark      = theme.ThemeGitHubDark
	ThemeSolarizedLight  = theme.ThemeSolarizedLight
	ThemeGitHubLight     = theme.ThemeGitHubLight
	ThemeCatppuccinLatte = theme.ThemeCatppuccinLatte
	ThemeOneLight        = theme.ThemeOneLight
	ThemeGruvboxLight    = theme.ThemeGruvboxLight
	ThemeRosePineDawn    = theme.ThemeRosePineDawn
)
View Source
const AgentPickerDialogID = "agent-picker"

AgentPickerDialogID is the dialog ID assigned to the agent selection dialog produced by NewAgentPicker. The app layer matches on it to route confirm results, and dialog rendering branches on it for the picker's custom layout.

View Source
const SelectionScrollTickInterval = 100 * time.Millisecond

SelectionScrollTickInterval is the interval between auto-scroll ticks during mouse-drag selection past viewport edges.

View Source
const TabBarHeight = 1

TabBarHeight is the height, in rows, of the compact pane tab strip. Both the center and sidebar terminal panes render their tab strip as a single borderless line, and both use this when converting between screen and content coordinates.

Variables

View Source
var (
	AgentColor         = theme.AgentColor
	AvailableThemes    = theme.AvailableThemes
	ColorBackground    = theme.ColorBackground
	ColorBorder        = theme.ColorBorder
	ColorBorderFocused = theme.ColorBorderFocused
	ColorError         = theme.ColorError
	ColorForeground    = theme.ColorForeground
	ColorInfo          = theme.ColorInfo
	ColorMuted         = theme.ColorMuted
	ColorPrimary       = theme.ColorPrimary
	ColorSecondary     = theme.ColorSecondary
	ColorSelection     = theme.ColorSelection
	ColorSuccess       = theme.ColorSuccess
	ColorSurface0      = theme.ColorSurface0
	ColorSurface1      = theme.ColorSurface1
	ColorSurface2      = theme.ColorSurface2
	ColorWarning       = theme.ColorWarning
	DefaultStyles      = theme.DefaultStyles
	GetCurrentTheme    = theme.GetCurrentTheme
	GetTheme           = theme.GetTheme
	HexColor           = theme.HexColor
	SetCurrentTheme    = theme.SetCurrentTheme
	SpinnerFrame       = theme.SpinnerFrame
	Icons              = theme.Icons
	ColorClaude        = theme.ColorClaude
	ColorCodex         = theme.ColorCodex
	ColorGemini        = theme.ColorGemini
	ColorAmp           = theme.ColorAmp
	ColorOpencode      = theme.ColorOpencode
	ColorDroid         = theme.ColorDroid
	ColorCline         = theme.ColorCline
	ColorCursor        = theme.ColorCursor
	ColorPi            = theme.ColorPi
)

Functions

func CopyToClipboard

func CopyToClipboard(text string) error

CopyToClipboard writes text to the system clipboard with a macOS pbcopy fallback.

func CopyToClipboardWithLog added in v0.0.20

func CopyToClipboardWithLog(text, label string)

CopyToClipboardWithLog copies text to the clipboard (a no-op for empty text), logging success or failure with label for context. It shells out to pbcopy on macOS, so callers MUST NOT hold a tab/terminal mutex while calling it — capture the text under the lock, release it, then call this.

func DragSelect added in v0.0.20

func DragSelect(
	v *vterm.VTerm,
	sel *SelectionState,
	scrollState *SelectionScrollState,
	termX, termY, termWidth, termHeight int,
	lastTermX *int,
	scroll func(delta int),
	screenYToAbs func(screenY int) int,
) (needTick bool, gen, seq uint64)

DragSelect advances an in-progress drag selection toward the pointer at (termX, termY) and reports whether an auto-scroll tick loop should be (re)started. The caller must hold the owning tab/terminal mutex and must have already confirmed sel.Active and a non-nil v.

termX is clamped to [0, termWidth); the unclamped termY drives the scroll direction (scrollState.SetDirection) before being clamped to the viewport. When the pointer is above or below the viewport, scroll is invoked with +1 (up into history) or -1 (down toward live) and termY is pinned to the matching edge. The clamped termY is mapped to an absolute line via screenYToAbs and the selection endpoint is extended there. The clamped termX is written to *lastTermX so tick-driven edge extension can reuse it.

The two closures absorb the only per-pane divergence: scroll performs the pane's viewport move (center's chat-history-aware scroll vs the sidebar's raw ScrollView+note), and screenYToAbs maps a screen row to an absolute line. The returned (needTick, gen, seq) come straight from scrollState.NeedsTick(); the caller owns scheduling the actual tick command.

func ExtendSelection added in v0.0.20

func ExtendSelection(v *vterm.VTerm, sel *SelectionState, endX, endAbsLine int)

ExtendSelection moves the far endpoint of an in-progress selection to (endX, endAbsLine). The anchor is read from the live vterm selection, falling back to sel's stored start when the vterm has no selection yet, then written back to sel so the two stay in sync. This block is order-sensitive; callers must hold the owning tab/terminal mutex. It performs no I/O.

func KeyToBytes

func KeyToBytes(msg tea.KeyPressMsg) []byte

KeyToBytes converts a key press message to bytes for the terminal.

func MergeByID added in v0.0.20

func MergeByID[T any, K comparable](existing, incoming []T, incomingActive int, id func(T) K, isNil func(T) bool) ([]T, int)

MergeByID merges incoming into existing, de-duplicating by id while preserving order (existing first, then new incoming items). It returns the merged slice and the index that incoming[incomingActive] maps to in the result (-1 if the active item was nil or out of range). isNil filters out nil/zero entries.

func OSC52ClipboardText added in v0.0.20

func OSC52ClipboardText(payload []byte) (string, bool)

OSC52ClipboardText returns text that is allowed to be copied from an OSC 52 terminal sequence. OSC 52 is disabled by default because terminal output is an untrusted boundary; enable with AMUX_ENABLE_OSC52_CLIPBOARD=1.

func RebindTabMaps added in v0.0.20

func RebindTabMaps[T any, K comparable](
	tabsByWorkspace map[string][]T,
	activeByWorkspace map[string]int,
	oldID, newID string,
	id func(T) K, isNil func(T) bool,
) []T

RebindTabMaps migrates a workspace's tab slice and active-tab index from oldID to newID across the two per-workspace maps: it merges any tabs already present under newID (via MergeByID), writes the result under newID, deletes oldID from both maps, and clamps the surviving active index. It returns the merged slice.

Callers keep their own surrounding logic (the "seen but empty" special case, workspace-pointer fixups, PTY restarts) and delegate only this reconciliation, which was byte-identical between the center and sidebar panes — so a clamp fix now happens once instead of being mirrored.

func RenderHelpItem

func RenderHelpItem(styles Styles, key, desc string) string

RenderHelpItem renders a single help item for inline help bars.

func ReportError added in v0.0.12

func ReportError(context string, err error, toastMessage string) tea.Cmd

ReportError logs, emits an Error message, and shows a toast.

func SafeBatch added in v0.0.5

func SafeBatch(cmds ...tea.Cmd) tea.Cmd

SafeBatch wraps commands in panic recovery before batching.

func SafeCmd added in v0.0.5

func SafeCmd(cmd tea.Cmd) tea.Cmd

SafeCmd wraps a command with panic recovery.

func SafeTick added in v0.0.5

func SafeTick(d time.Duration, fn func(time.Time) tea.Msg) tea.Cmd

SafeTick wraps tea.Tick with panic recovery in the callback.

func ScrollDeltaForHeight added in v0.0.3

func ScrollDeltaForHeight(height, factor int) int

ScrollDeltaForHeight calculates proportional scroll delta. Returns max(1, height/factor) to ensure minimum 1 line scroll.

func SelectionScrollTickStep added in v0.0.20

func SelectionScrollTickStep(
	v *vterm.VTerm,
	sel *SelectionState,
	scrollState *SelectionScrollState,
	termHeight int,
	lastTermX int,
	scroll func(delta int),
	screenYToAbs func(screenY int) int,
)

SelectionScrollTickStep performs one auto-scroll tick of a drag selection: it scrolls the viewport one line in scrollState.ScrollDir and extends the selection endpoint to the now-exposed viewport edge. The caller must hold the owning tab/terminal mutex and must have already validated the tick via scrollState.HandleTick (which confirms the generation, tick sequence, direction, and active state) plus sel.Active and a non-nil v.

The edge row is the top of the viewport when scrolling up into history and the bottom (termHeight-1) when scrolling down toward live; screenYToAbs maps it to an absolute line. lastTermX supplies the horizontal endpoint. scroll and screenYToAbs carry the same per-pane meaning as in DragSelect. The caller owns scheduling the next tick command.

func SortLRUTabCandidates added in v0.0.20

func SortLRUTabCandidates[P any](candidates []LRUTabCandidate[P])

SortLRUTabCandidates orders candidates least-recently-active first. The zero time naturally sorts before every real timestamp, so tabs with unknown recency are evicted first. Ties break by workspace ID, then tab index, keeping eviction deterministic.

func WrapHelpItems

func WrapHelpItems(items []string, width int) []string

WrapHelpItems wraps pre-rendered help items into multiple lines constrained by width.

Types

type CriticalExternalMsg added in v0.0.17

type CriticalExternalMsg interface {
	MarkCriticalExternalMsg()
}

CriticalExternalMsg marks messages that must bypass the normal lossy external message queue and go through the critical path instead.

Critical messages are non-evicting: when the critical queue is full they drop themselves rather than evicting a queued non-critical message. (An evicting tier used to exist, but no real message ever needed it, so the distinction was removed.)

type Dialog

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

Dialog is a modal dialog component

func NewAgentPicker

func NewAgentPicker(options []string) *Dialog

NewAgentPicker creates a new agent selection dialog with fuzzy filtering

func NewConfirmDialog

func NewConfirmDialog(id, title, message string) *Dialog

NewConfirmDialog creates a new confirmation dialog

func NewInputDialog

func NewInputDialog(id, title, placeholder string) *Dialog

NewInputDialog creates a new input dialog

func (*Dialog) Cursor

func (d *Dialog) Cursor() *tea.Cursor

Cursor returns the cursor position relative to the dialog view.

func (*Dialog) Hide

func (d *Dialog) Hide()

Hide hides the dialog

func (*Dialog) SetDefaultOption added in v0.0.20

func (d *Dialog) SetDefaultOption(index int)

SetDefaultOption sets the option selected whenever the dialog is shown.

func (*Dialog) SetInputTransform

func (d *Dialog) SetInputTransform(fn InputTransformFunc) *Dialog

SetInputTransform sets a transform function that will be applied to input text

func (*Dialog) SetInputValidate

func (d *Dialog) SetInputValidate(fn InputValidateFunc) *Dialog

SetInputValidate sets a validation function that runs on each keystroke

func (*Dialog) SetInputValue added in v0.0.20

func (d *Dialog) SetInputValue(s string)

SetInputValue prefills the input field's current value so a dialog opened for editing (e.g. rename) renders the existing value ready to edit. It affects input dialogs only. Call it after Show(), which resets the input to empty.

func (*Dialog) SetShowKeymapHints

func (d *Dialog) SetShowKeymapHints(show bool)

SetShowKeymapHints controls whether helper text is rendered.

func (*Dialog) SetSize

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

SetSize sets the dialog size

func (*Dialog) SetWarning added in v0.0.20

func (d *Dialog) SetWarning(text string)

SetWarning sets optional informational warning text rendered below the message on a confirm dialog. Passing "" clears it. This is purely advisory (e.g. surfacing in-repo script indirection at trust time); an empty warning must never be read or presented as a safety guarantee.

func (*Dialog) Show

func (d *Dialog) Show()

Show makes the dialog visible

func (*Dialog) Update

func (d *Dialog) Update(msg tea.Msg) (*Dialog, tea.Cmd)

Update handles messages

func (*Dialog) View

func (d *Dialog) View() string

View renders the dialog

func (*Dialog) Visible

func (d *Dialog) Visible() bool

Visible returns whether the dialog is visible

type DialogResult

type DialogResult struct {
	ID        string
	Confirmed bool
	Value     string
	Index     int
}

DialogResult is sent when a dialog is completed

type DialogType

type DialogType int

DialogType identifies the type of dialog

const (
	DialogNone DialogType = iota
	DialogInput
	DialogConfirm
	DialogSelect
)

type EnvDialog added in v0.0.20

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

EnvDialog is a modal dialog that edits a single workspace's environment-variable map. It mirrors SettingsDialog's Assistants section (handleAssistantFieldKey in settings_assistants.go): rows render as "key: value", Up/Down move a row cursor, printable runes edit the focused row's value, Backspace deletes the last rune of the focused value, and Ctrl+D removes the focused pair outright.

This widget is domain-agnostic on purpose (internal/ui/common imports neither internal/data nor internal/process elsewhere): it just edits whatever map[string]string it is given. Excluding reserved keys (process.IsReservedScriptEnvKey) is the caller's job -- see internal/app's handleShowWorkspaceEnvDialog, which filters ws.Env before calling NewEnvDialog and filters again defensively before persisting.

First-cut scope (plan 058's Design decision): only EDITING an existing pair's value and REMOVING a pair are supported. Adding a brand-new key needs a second input target inside a row (a name field, with its own validation) -- a materially different widget than every other multi-row editor in this package -- so "add" is deferred to a follow-up, the same escape hatch plan 031 used for "add a new assistant".

func NewEnvDialog added in v0.0.20

func NewEnvDialog(env map[string]string) *EnvDialog

NewEnvDialog seeds the dialog from env, which is copied so later edits in the dialog cannot alias the caller's map (mirroring SetAssistants).

func (*EnvDialog) Cursor added in v0.0.20

func (d *EnvDialog) Cursor() *tea.Cursor

func (*EnvDialog) Env added in v0.0.20

func (d *EnvDialog) Env() map[string]string

Env returns the (possibly edited) map for read-back on close: a copy so the caller cannot mutate the dialog's internal state through the returned map. Removed pairs are simply absent (deleteFocusedPair drops them from both keys and values), so there is no separate "removed" set to reconcile.

func (*EnvDialog) Hide added in v0.0.20

func (d *EnvDialog) Hide()

func (*EnvDialog) SetSize added in v0.0.20

func (d *EnvDialog) SetSize(w, _ int)

func (*EnvDialog) Show added in v0.0.20

func (d *EnvDialog) Show()

func (*EnvDialog) Update added in v0.0.20

func (d *EnvDialog) Update(msg tea.Msg) (*EnvDialog, tea.Cmd)

Update handles input. Like SettingsDialog, Esc always cancels. While a row is focused, only Up/Down/Ctrl+D/Backspace are structural; every other printable rune (including j/k and space) is typed into the focused row's value -- there is no "leave the field" key distinct from Enter here, since (unlike Settings) this dialog has only one section to route around.

func (*EnvDialog) View added in v0.0.20

func (d *EnvDialog) View() string

func (*EnvDialog) Visible added in v0.0.20

func (d *EnvDialog) Visible() bool

type EnvDialogResult added in v0.0.20

type EnvDialogResult struct {
	Canceled bool
}

EnvDialogResult is sent when the workspace environment-variable dialog closes. Canceled is true when the user dismissed via Esc, in which case the caller must discard every edit (no mutation, no persist) -- the same cancel contract SettingsResult uses.

type FilePicker

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

FilePicker is a file/directory picker dialog

func NewFilePicker

func NewFilePicker(id, startPath string, directoriesOnly bool) *FilePicker

NewFilePicker creates a new file picker starting at the given path

func (*FilePicker) Cursor

func (fp *FilePicker) Cursor() *tea.Cursor

Cursor returns the cursor position relative to the file picker view.

func (*FilePicker) Hide

func (fp *FilePicker) Hide()

Hide hides the picker

func (*FilePicker) SetPrimaryActionLabel added in v0.0.2

func (fp *FilePicker) SetPrimaryActionLabel(label string)

SetPrimaryActionLabel updates the primary action label.

func (*FilePicker) SetShowKeymapHints

func (fp *FilePicker) SetShowKeymapHints(show bool)

SetShowKeymapHints controls whether helper text is rendered.

func (*FilePicker) SetSize

func (fp *FilePicker) SetSize(width, height int)

SetSize sets the picker size

func (*FilePicker) SetStyles

func (fp *FilePicker) SetStyles(styles Styles)

SetStyles updates the file picker styles (for theme changes).

func (*FilePicker) SetTitle added in v0.0.2

func (fp *FilePicker) SetTitle(title string)

SetTitle updates the dialog title.

func (*FilePicker) Show

func (fp *FilePicker) Show()

Show makes the picker visible

func (*FilePicker) Update

func (fp *FilePicker) Update(msg tea.Msg) (*FilePicker, tea.Cmd)

Update handles messages

func (*FilePicker) View

func (fp *FilePicker) View() string

View renders the picker

func (*FilePicker) Visible

func (fp *FilePicker) Visible() bool

Visible returns whether the picker is visible

type HitRegion

type HitRegion struct {
	ID     string
	X      int
	Y      int
	Width  int
	Height int
}

HitRegion represents a rectangular hit target in view-local coordinates.

func (HitRegion) Contains

func (h HitRegion) Contains(x, y int) bool

Contains reports whether the point is within the hit region bounds.

type InputTransformFunc

type InputTransformFunc func(string) string

InputTransformFunc transforms input text before it's added to the input field

type InputValidateFunc

type InputValidateFunc func(string) string

InputValidateFunc validates input and returns an error message (empty = valid)

type LRUTabCandidate added in v0.0.20

type LRUTabCandidate[P any] struct {
	WorkspaceID string
	Index       int
	LastActive  time.Time
	Payload     P
}

LRUTabCandidate is one auto-detach candidate for attached-PTY limit enforcement, shared by the center agent-tab and sidebar terminal-tab limiters so both panes evict in the same order.

type SelectionScrollState added in v0.0.10

type SelectionScrollState struct {
	// Gen is a generation counter used to invalidate stale tick loops.
	Gen uint64
	// TickSeq is the next tick sequence expected for Gen. Duplicate requests for
	// the same sequence are harmless: the first tick advances TickSeq and later
	// copies are ignored without stopping the loop.
	TickSeq uint64
	// ScrollDir is +1 (scroll up into history) or -1 (scroll down toward
	// live output) or 0 (no auto-scroll).
	ScrollDir int
	// Active is true when a tick loop is currently running.
	Active bool
}

SelectionScrollState is the shared state machine for tick-based auto-scrolling during mouse-drag text selection. Both the sidebar terminal and the center pane embed this struct.

func (*SelectionScrollState) HandleTick added in v0.0.10

func (s *SelectionScrollState) HandleTick(gen, seq uint64) bool

HandleTick checks whether an incoming tick with the given generation is still valid. Returns true if the tick loop should continue (caller should scroll and schedule the next tick). Stale generations or duplicate sequences are ignored without stopping the current generation; explicit stop conditions (direction cleared or inactive state) end the loop.

func (*SelectionScrollState) NeedsTick added in v0.0.10

func (s *SelectionScrollState) NeedsTick() (bool, uint64, uint64)

NeedsTick reports whether the caller should schedule an auto-scroll tick and, if so, returns the current generation and next expected tick sequence. Motions while a loop is already active re-request the same generation/sequence instead of invalidating the live timer. If a request was dropped, the next motion can replace it; if both copies arrive, HandleTick accepts whichever one arrives first and rejects the duplicate by sequence number.

func (*SelectionScrollState) Reset added in v0.0.10

func (s *SelectionScrollState) Reset()

Reset clears the scroll state and bumps the generation counter to invalidate any in-flight tick. Call on mouse release, selection clear, or any event that should stop auto-scrolling.

func (*SelectionScrollState) SetDirection added in v0.0.10

func (s *SelectionScrollState) SetDirection(termY, termHeight int)

SetDirection updates ScrollDir based on the unclamped terminal Y coordinate. Call this before clamping termY to [0, termHeight).

type SelectionState added in v0.0.14

type SelectionState struct {
	Active    bool // Selection in progress (mouse button down)?
	StartX    int  // Start column (terminal coordinates)
	StartLine int  // Start row (absolute line number, 0 = first scrollback line)
	EndX      int  // End column
	EndLine   int  // End row (absolute line number)
}

SelectionState tracks mouse selection state for copy/paste.

type SettingsDialog

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

SettingsDialog is a modal dialog for application settings.

func NewSettingsDialog

func NewSettingsDialog(currentTheme ThemeID, tmuxServer, tmuxConfig, tmuxSync string) *SettingsDialog

NewSettingsDialog creates a new settings dialog with current values.

func (*SettingsDialog) AssistantCommands added in v0.0.20

func (s *SettingsDialog) AssistantCommands() map[string]string

AssistantCommands returns the (possibly edited) assistant command map so the caller can persist changes to config when the dialog closes.

func (*SettingsDialog) Cursor

func (s *SettingsDialog) Cursor() *tea.Cursor

func (*SettingsDialog) Hide

func (s *SettingsDialog) Hide()

func (*SettingsDialog) SelectedTheme added in v0.0.16

func (s *SettingsDialog) SelectedTheme() ThemeID

func (*SettingsDialog) SetAssistants added in v0.0.20

func (s *SettingsDialog) SetAssistants(names []string, commands map[string]string)

SetAssistants sets the assistant roster the Assistants section lists: names in display order plus their current commands. Like SetUpdateInfo, this is populated after construction since the roster is late-bound app state (the caller reads it from config), not part of the dialog's core theme setup. Commands is copied so later edits to the dialog's in-memory copy cannot alias the caller's map.

func (*SettingsDialog) SetSelectedTheme added in v0.0.16

func (s *SettingsDialog) SetSelectedTheme(theme ThemeID)

func (*SettingsDialog) SetSession added in v0.0.16

func (s *SettingsDialog) SetSession(session int)

func (*SettingsDialog) SetSize

func (s *SettingsDialog) SetSize(w, h int)

func (*SettingsDialog) SetUpdateHint added in v0.0.11

func (s *SettingsDialog) SetUpdateHint(hint string)

SetUpdateHint sets a hint shown under the current version.

func (*SettingsDialog) SetUpdateInfo added in v0.0.3

func (s *SettingsDialog) SetUpdateInfo(current, latest string, available bool)

SetUpdateInfo sets version information for the updates section.

func (*SettingsDialog) Show

func (s *SettingsDialog) Show()

func (*SettingsDialog) TmuxConfigPath added in v0.0.20

func (s *SettingsDialog) TmuxConfigPath() string

func (*SettingsDialog) TmuxServer added in v0.0.20

func (s *SettingsDialog) TmuxServer() string

TmuxServer, TmuxConfigPath, and TmuxSyncInterval return the current (possibly edited) tmux values so the app can persist them into UISettings on close.

func (*SettingsDialog) TmuxSyncInterval added in v0.0.20

func (s *SettingsDialog) TmuxSyncInterval() string

func (*SettingsDialog) Update

func (s *SettingsDialog) Update(msg tea.Msg) (*SettingsDialog, tea.Cmd)

Update handles input.

func (*SettingsDialog) View

func (s *SettingsDialog) View() string

func (*SettingsDialog) Visible

func (s *SettingsDialog) Visible() bool

type SettingsResult

type SettingsResult struct {
	Canceled bool
}

SettingsResult is sent when the settings dialog is closed. Canceled is true when the user dismissed via Esc (revert any live theme preview) rather than confirming via [Close].

type Styles

type Styles = theme.Styles

type TabSet added in v0.0.20

type TabSet[T any] struct {
	ByWorkspace       map[string][]T
	ActiveByWorkspace map[string]int
}

TabSet tracks per-workspace tab lists and the active tab index. It is the shared storage + navigation core behind the center tab strip and the sidebar terminal tabs: both keep a map of workspaceID → tabs plus a map of workspaceID → active index, with circular next/prev selection.

The maps are exported because both consumers iterate and mutate them directly in workspace-rebind and session-discovery paths; TabSet owns the navigation math so it is written once.

func NewTabSet added in v0.0.20

func NewTabSet[T any]() TabSet[T]

NewTabSet returns an empty TabSet with initialized maps.

func (*TabSet[T]) ActiveIdx added in v0.0.20

func (s *TabSet[T]) ActiveIdx(wsID string) int

ActiveIdx returns the workspace's active tab index (0 when unset).

func (*TabSet[T]) DeleteWorkspace added in v0.0.20

func (s *TabSet[T]) DeleteWorkspace(wsID string)

DeleteWorkspace drops all tab tracking for a workspace.

func (*TabSet[T]) NextIdx added in v0.0.20

func (s *TabSet[T]) NextIdx(wsID string) (int, bool)

NextIdx advances the active index circularly. It reports the new index and whether a move happened (false when the workspace has no tabs).

func (*TabSet[T]) PrevIdx added in v0.0.20

func (s *TabSet[T]) PrevIdx(wsID string) (int, bool)

PrevIdx moves the active index back circularly. It reports the new index and whether a move happened (false when the workspace has no tabs).

func (*TabSet[T]) SelectIdx added in v0.0.20

func (s *TabSet[T]) SelectIdx(wsID string, idx int) bool

SelectIdx sets the active index when it is in range, reporting success.

func (*TabSet[T]) SetActiveIdx added in v0.0.20

func (s *TabSet[T]) SetActiveIdx(wsID string, idx int)

SetActiveIdx records the workspace's active tab index.

func (*TabSet[T]) Tabs added in v0.0.20

func (s *TabSet[T]) Tabs(wsID string) []T

Tabs returns the workspace's tabs (nil when none).

type Theme

type Theme = theme.Theme

type ThemeColors

type ThemeColors = theme.ThemeColors

type ThemeID

type ThemeID = theme.ThemeID

type ThemePreview

type ThemePreview struct {
	Theme   ThemeID
	Session int
}

ThemePreview is sent when user navigates through themes for live preview.

type Toast

type Toast struct {
	Message  string
	Type     ToastType
	Duration time.Duration
}

Toast represents a notification message

type ToastDismissed

type ToastDismissed struct{}

ToastDismissed is sent when a toast should be dismissed

type ToastModel

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

ToastModel manages toast notifications

func NewToastModel

func NewToastModel() *ToastModel

NewToastModel creates a new toast model

func (*ToastModel) Dismiss

func (m *ToastModel) Dismiss()

Dismiss immediately hides the toast

func (*ToastModel) SetStyles

func (m *ToastModel) SetStyles(styles Styles)

SetStyles updates the toast styles (for theme changes).

func (*ToastModel) Show

func (m *ToastModel) Show(message string, toastType ToastType, duration time.Duration) tea.Cmd

Show displays a toast notification

func (*ToastModel) ShowError

func (m *ToastModel) ShowError(message string) tea.Cmd

ShowError shows an error toast

func (*ToastModel) ShowInfo

func (m *ToastModel) ShowInfo(message string) tea.Cmd

ShowInfo shows an info toast

func (*ToastModel) ShowSuccess

func (m *ToastModel) ShowSuccess(message string) tea.Cmd

ShowSuccess shows a success toast

func (*ToastModel) ShowWarning

func (m *ToastModel) ShowWarning(message string) tea.Cmd

ShowWarning shows a warning toast

func (*ToastModel) Update

func (m *ToastModel) Update(msg tea.Msg) (*ToastModel, tea.Cmd)

Update handles messages

func (*ToastModel) View

func (m *ToastModel) View() string

View renders the toast notification

func (*ToastModel) Visible

func (m *ToastModel) Visible() bool

Visible returns whether the toast is currently visible

type ToastType

type ToastType int

ToastType identifies the type of toast notification

const (
	ToastInfo ToastType = iota
	ToastSuccess
	ToastError
	ToastWarning
)

Jump to

Keyboard shortcuts

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