workspacelist

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package workspacelist is the presentation component shared by the project Workspaces sidebar and the global Workspaces browser.

It owns the parts of a workspace list that both consumers must agree on — stable-ID selection, the filter input and its pure multi-field matcher, sort modes and their stable ordering, activity grouping, the viewport and its scrollbar, and the empty/no-match rows. It owns none of the parts that belong to a data owner: it cannot inspect tmux, read Git, switch projects, create worktrees, or attach to a terminal. Callers project their own records into Item and hand back a row renderer for source-specific metadata.

The rule that keeps this honest: nothing in this package imports a plugin, the app, or the inventory. It receives resolved display fields only.

Both consumers render through RenderSidebar. Global Model supplies sort sections and a sort action; project Workspaces supplies Shells/Workspaces sections and optional creation actions. The component lays out both without learning what those actions do.

Index

Constants

View Source
const (
	// KeyIgnored: the filter did not want this key. Navigation keys land here
	// on purpose — arrows and ctrl+n/ctrl+p must stay live while filtering.
	KeyIgnored = queryfield.KeyIgnored
	// KeyHandled: the query or the caret moved (or a first escape cleared it).
	KeyHandled = queryfield.KeyHandled
	// KeyAccept: enter — leave the focused item selected, return to the list.
	KeyAccept = queryfield.KeyAccept
	// KeyExit: escape on an empty query — filter focus is released.
	KeyExit = queryfield.KeyExit
)
View Source
const (
	RecentNew      = "New"
	RecentToday    = "Today"
	RecentThisWeek = "This week"
	RecentOlder    = "Older"
)

Recent time-bucket headings. Empty buckets are omitted.

View Source
const (
	KindWorktree = "worktree"
	KindShell    = "shell"
)

Kind is a presentation identity for a row. These strings match the catalog kinds the caller already resolved; this package never imports inventory.

View Source
const HostGlyph = "⇅"

HostGlyph marks a row that lives on another machine. It sits beside KindGlyph deliberately: both projections of the shared catalog — the Sessions list and the Activity board — read their provenance mark from here, so a remote row cannot come to look remote on one surface and local on the other.

It is not a status marker. The gutter marker means agent activity (working / blocked / live / ambiguous), and overloading it with provenance would cost the thing it is for; see RowPresentation.

View Source
const HostHiddenGlyph = HostGlyph + "\u0338"

HostHiddenGlyph is HostGlyph struck through: some machines' rows are being withheld from the list on purpose.

It is the host glyph rather than a new symbol because the thing being hidden is exactly what that glyph marks, and it is struck rather than bare because the control it appears on already leads with SortGlyph — the same character. The slash is the only part a reader has to tell apart, and it is the part that carries the meaning.

View Source
const PulseInterval = 175 * time.Millisecond

PulseInterval is the frame period every surface that breathes a working or blocked marker advances on. Sharing it keeps the project sidebar and the global Workspaces list visually in step rather than beating against each other at different rates.

View Source
const SortGlyph = "⇅"

SortGlyph marks the header control as a sort rather than a caption. A bare "Activity" in the corner of a panel says nothing about why it is there; the same word behind ⇅ says the list is ordered by it and that the control is worth pressing.

It is ⇅ rather than the word "Sort:" because the control shares its row with the create button and, on a narrow sidebar, six columns of label is the difference between both controls fitting and neither. It is ⇅ rather than a single arrow because the list offers no direction to point in — a ↓ would be answering a question nobody asked. U+21C5 is ordinary Unicode, not a Nerd Font glyph, so it survives a plain terminal font.

Variables

View Source
var (
	WorkingPulse = []float64{1.00, 0.96, 0.87, 0.75, 0.62, 0.50, 0.42, 0.38, 0.42, 0.50, 0.62, 0.75, 0.87, 0.96}
	BlockedPulse = []float64{1.00, 0.78, 0.52, 0.88, 1.00, 0.68, 0.43, 0.38, 0.38, 0.38, 0.38, 0.38, 0.43, 0.52, 0.68, 0.84}
)

Working breathes evenly. Blocked uses two brighter beats followed by a longer rest so it attracts attention without making the whole row blink.

SortModes is the cycle order behind the global list's sort control. Manual is absent: it means something only to a consumer that owns its input order.

Functions

func ApplySelection

func ApplySelection(content string, width int, selected, focused bool) string

ApplySelection gives both consumers the same focused and unfocused cursor treatment while leaving their row text and icons caller-owned. Do not wrap a pre-rendered marker: lipgloss.Render resets all attributes, and the name after the icon will lose the fill. Use RenderRow, which paints the marker and the name as sibling spans.

func BlendColor added in v1.0.0

func BlendColor(low, high color.Color, amount float64) color.Color

func Hidden added in v1.16.0

func Hidden(group Group, visibility Visibility) bool

Hidden reports whether the view preference hides a row. An explicitly revealed worktree wins over both idle filtering and the remote project-home exclusion. Managed shells and agent states are not inferred to be idle.

func HostHue added in v1.11.0

func HostHue(hostID string) color.Color

HostHue is the colour a machine is drawn in, everywhere it appears.

The theme's project ramp is the cycle, hashed from the host ID, for the same three reasons ProjectHue exists: it survives a theme switch, every curated theme has already chosen a ramp that reads in its own light or dark, and the hash is stable, so a host keeps its colour across restarts. Nothing here depends on map iteration or on the order hosts were registered in.

func IsPinned added in v1.16.0

func IsPinned(ids []string, id string) bool

IsPinned reports membership independently of whether the row is visible.

func IsScrollbarRegion added in v1.4.0

func IsScrollbarRegion(kind RegionKind) bool

IsScrollbarRegion reports whether kind belongs to the list's bar rather than to its content.

func KindGlyph

func KindGlyph(kind string) string

KindGlyph is the Agents-board pair: worktree ⑂, shell ❯. Unknown or empty kinds render nothing so a project-plugin row can omit them.

func Match

func Match(item Item, query string) bool

Match reports whether an item satisfies a query. Matching is case-insensitive and space-separated: every token must appear somewhere in the item's promised fields, so "sidecar modal" narrows rather than widens. An empty or whitespace-only query matches everything.

func MatchFields

func MatchFields(query string, fields ...string) bool

MatchFields is the same matcher for callers that have not built an Item — the project sidebar filters its own worktree and shell records this way, so both consumers share one definition of "matches".

func MoveIndex

func MoveIndex(index, delta, count int) int

MoveIndex applies the shared clamped selection semantics used by keyboard and wheel navigation in both workspace sidebars.

func NoMatchRow

func NoMatchRow(width int, query string) string

NoMatchRow is the honest empty state for a query that matches nothing. A blank list would read as "nothing exists" rather than "nothing matches".

func NormalizePins added in v1.16.0

func NormalizePins(ids []string) []string

NormalizePins removes empty and duplicate identities without consulting a catalog. Missing rows retain their pin while inventory is still arriving.

func PulseCircle added in v1.0.0

func PulseCircle(level float64) string

func PulseDiamond added in v1.0.0

func PulseDiamond(level float64) string

func PulseLane added in v1.0.0

func PulseLane(lane string) bool

PulseLane reports whether a lane is one of the two live states that breathe.

func PulseLevel added in v1.0.0

func PulseLevel(levels []float64, frame int) float64

func PulseMarker added in v1.0.0

func PulseMarker(lane string, frame int) (icon string, style lipgloss.Style, ok bool)

PulseMarker is the animated form of a working or blocked marker at a given frame. ok is false for every other lane, so callers can fall back to the static marker they already resolved.

func PulseStyle added in v1.0.0

func PulseStyle(base color.Color, level float64, bold bool) lipgloss.Style

func RelativeAge

func RelativeAge(changedAt, now time.Time) string

RelativeAge formats freshness in the same small units the Agents board uses, so one item does not read "3m" on one tab and "3 minutes" on the other.

Everything under a minute reads "now". A second-level countdown is a claim to precision this data cannot back: last-interaction time is inferred from tmux and session files and is routinely off by more than the digits it is showing. It also churned — every row that had just moved redrew its number once a second, so the weakest number on the surface was also the one drawing the eye. "now" is the honest form of the same fact and it holds still.

func RenderRow

func RenderRow(row RowPresentation, width int, selected, focused bool) []string

RenderRow renders one or two physical lines. Line one carries the row's whole identity — kind glyph, project, name, and its age — so a reader can scan shells and worktrees apart without dropping to the second line. Line two is agent detail alone and collapses to nothing when there is none. Narrow rows retain the status marker and name first, then add secondary identity only while space remains.

func ResizePercent

func ResizePercent(start, deltaColumns, viewportWidth int) int

ResizePercent applies the shared percentage delta and bounds used by both workspace dividers.

func RetainPins added in v1.16.0

func RetainPins(ids, knownIDs []string) []string

RetainPins prunes identities absent from the complete known catalog. Use the unfiltered catalog, including hidden hosts and idle rows, so a view preference or query never deletes a durable pin. Callers decide when their inventory is complete enough to prune.

func SectionTitle

func SectionTitle(name string, count int) string

SectionTitle words the semantic name/count pair for a list section. The shared sidebar renderer adds the category glyph, uppercase treatment, and trailing rule around the same pair for both project and global surfaces.

The Kanban board words its lane headers itself: a column is as narrow as 17 columns there, which "Needs Attention (0)" overruns, and its label and count carry different colours rather than one string.

func SortActionID added in v1.0.0

func SortActionID(mode Sort) string

SortActionID names the choice a View surface reports when a sort is picked. Both surfaces build their own sections — they offer different modes and different extra toggles — but they must not invent two names for the same choice, or a shared handler would answer to one and ignore the other.

func SortIndex added in v1.0.0

func SortIndex(mode Sort, modes []Sort) int

SortIndex is a mode's position in the offered set, for a list cursor.

func SortPillLabel added in v1.0.0

func SortPillLabel(mode Sort) string

SortPillLabel is what the header control reads.

func TogglePinned added in v1.16.0

func TogglePinned(ids []string, id string) []string

TogglePinned returns a new pin order. New pins are appended, preserving first-pinned-first order, and an empty target leaves the order unchanged.

Types

type Filter

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

Filter is the workspace sidebar's inline `/` query and its focus state. It is the shared queryfield.Field wearing this surface's placeholder and count: cursor movement, word forward and back, word delete, home and end, and paste come from the field rather than from a second implementation here.

It is deliberately still a plain value: filter state is in-memory per consumer and is never written to config or project state.

func (*Filter) Active

func (f *Filter) Active() bool

Active reports that the filter still affects the list. A query survives losing focus so a user can filter, press enter, and keep working inside the narrowed list.

func (*Filter) Blur

func (f *Filter) Blur()

Blur releases focus without discarding the query.

func (*Filter) Clear added in v1.14.0

func (f *Filter) Clear()

Clear empties the query and keeps focus. It is what the row's × and the filter-clear command do.

func (*Filter) Cursor added in v1.14.0

func (f *Filter) Cursor() int

Cursor is the caret's rune offset into the query. A surface that caches its rendered row has to key on it: the caret is drawn where it is, so a key that moved only the caret still changed the picture.

func (*Filter) Focus

func (f *Filter) Focus()

Focus enters filtering. `/` is the explicit entry precisely so printable project commands (n, D, p) keep working when it is not focused.

func (*Filter) Focused

func (f *Filter) Focused() bool

func (*Filter) HandleKey

func (f *Filter) HandleKey(msg tea.KeyPressMsg) KeyResult

HandleKey applies one key while the filter has focus. It returns KeyIgnored for anything the list should handle itself.

func (*Filter) HandlePaste added in v1.14.0

func (f *Filter) HandlePaste(msg tea.PasteMsg) KeyResult

HandlePaste puts a bracketed paste into the query.

func (*Filter) Insert

func (f *Filter) Insert(text string)

Insert puts typed or pasted text in at the caret. Pastes go through the same path as keystrokes so a pasted branch name filters exactly like a typed one.

func (*Filter) Query

func (f *Filter) Query() string

func (*Filter) RenderRow

func (f *Filter) RenderRow(width, matched, total int) (string, mouse.Rect)

RenderRow draws the one-line filter affordance both consumers show. It is shared so the project sidebar and the global browser cannot drift on what filtering looks like or on how counts are phrased.

The rect is where the row's × clear control landed, in the row's own coordinates, for the host to register. It is the zero rect when there is nothing to clear, and a host that registers the zero rect registers nothing.

func (*Filter) Reset

func (f *Filter) Reset()

Reset clears both query and focus — used when the underlying list is replaced wholesale (a project switch, a plugin reinit).

func (*Filter) SetQuery

func (f *Filter) SetQuery(query string)

type Group

type Group string

Group is an item's presentation bucket. The buckets are a vertical projection of the shared Kanban semantics — they are assigned by the caller from resolved agentstatus, not derived here, so this package never becomes a second status reducer.

const (
	GroupNeedsAttention Group = "Needs Attention"
	GroupWorking        Group = "Working"
	GroupDone           Group = "Done"
	GroupLive           Group = "Live Shells"
	GroupIdle           Group = "Idle"
	GroupPaused         Group = "Paused"
	GroupNoSession      Group = "No Session"
)

func GroupForLane added in v1.0.0

func GroupForLane(lane string) Group

GroupForLane is the vertical projection of a resolved agent lane, shared by every consumer that groups by activity.

It takes the lane as a string rather than an agentstatus.LaneID so this package keeps its promise not to import a status reducer: it does not decide what "blocked" means, only where a row already resolved as blocked belongs in a list. An unrecognised lane lands in Paused, which is the bucket for "something is here and its state is not legible" — a row this does not recognise is still a row someone has to see.

func Groups

func Groups() []Group

Groups returns the activity group order. Callers render headings in this order so a group that gains its first item never appears in a new place.

type Item

type Item struct {
	ID           string
	Name         string
	NameMeta     []RowField
	Project      string
	ProjectKey   string
	ProjectOrder int
	Branch       string
	Task         string
	Provider     string
	// TmuxName is an identity key, never rendered. It is searchable so two
	// shells sharing a display name inside one project can be told apart.
	TmuxName string
	// Host names the machine this row was collected on. Empty is this machine,
	// which is what every local row is. It is provenance, not status: it earns
	// the row a glyph and a per-host colour, and never touches the gutter
	// marker.
	Host   string
	Status string
	Detail string
	// Kind is a presentation string ("worktree" / "shell"), not a catalog type.
	Kind      string
	Marker    RowMarker
	Group     Group
	ChangedAt time.Time
	Data      any
}

Item is one row's resolved display identity. Every field is presentation input: the component matches, sorts, groups, and renders from these values and reads nothing behind them. Data carries the caller's own record so a selection can be resolved back to its owner without this package knowing the type.

func Filtered

func Filtered(items []Item, query string) []Item

Filtered returns the items matching query, preserving input order.

func Projected added in v1.16.0

func Projected(items []Item, query string, mode Sort, pinnedIDs []string) []Item

Projected applies the shared query, pin order and sort to a catalog. Pins obey the query and retain their configured order; every other matching row follows the selected stable sort. The caller's slices are never changed. Selection and viewport state belong to the consumer, not this projection.

func Sorted

func Sorted(items []Item, mode Sort) []Item

Sorted orders items for presentation. Every mode is stable: equal keys keep the caller's order, so an unchanged poll cannot churn the list.

type KeyResult

type KeyResult = queryfield.KeyResult

KeyResult tells a consumer what a key did to the filter, so the list keeps its own navigation while the filter owns the text. It is the shared query field's vocabulary, aliased here because every existing consumer names it through this package.

type MarkerTone

type MarkerTone string

MarkerTone describes non-semantic row identities and health states. Agent activity should use Lane instead; the caller has already resolved that lane and this renderer only gives the resolved marker its shared visual treatment.

const (
	MarkerMuted   MarkerTone = "muted"
	MarkerLive    MarkerTone = "live"
	MarkerMain    MarkerTone = "main"
	MarkerWarning MarkerTone = "warning"
	MarkerError   MarkerTone = "error"
)

type Model

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

Model is the list state a consumer owns: the catalog projection, the chosen sort, the filter, and the selection/viewport. Selection is by stable ID, so a refresh, a filter keystroke, or a sort change moves the cursor with the item rather than with the row number.

func (*Model) Bottom

func (m *Model) Bottom() bool

func (*Model) ClearFilter added in v1.14.0

func (m *Model) ClearFilter()

ClearFilter empties the query and reprojects, keeping focus where it is. It is what the row's × and the filter-clear command run.

func (*Model) Counts

func (m *Model) Counts() (matched, total int)

func (*Model) CycleSort

func (m *Model) CycleSort()

CycleSort advances `s` through Activity → Project → Recent → Name.

func (*Model) Filter

func (m *Model) Filter() *Filter

func (*Model) FilterKey

func (m *Model) FilterKey(msg tea.KeyPressMsg) KeyResult

FilterKey applies a key while the filter owns focus and reprojects when the query changed.

func (*Model) FilterPaste added in v1.14.0

func (m *Model) FilterPaste(msg tea.PasteMsg) KeyResult

FilterPaste puts a bracketed paste into a focused query and reprojects.

func (*Model) FocusFilter

func (m *Model) FocusFilter()

FocusFilter is the `/` entry point.

func (*Model) IsPinned

func (m *Model) IsPinned(id string) bool

IsPinned reports whether id is in the pin list.

func (*Model) Items

func (m *Model) Items() []Item

func (*Model) Move

func (m *Model) Move(delta int) bool

Move steps the selection, clamping at both ends rather than wrapping.

func (*Model) NeedsPulse added in v1.0.0

func (m *Model) NeedsPulse() bool

NeedsPulse reports whether any currently visible row carries a lane that breathes, so a consumer can keep its animation clock off when nothing on screen would move.

func (*Model) PinnedIDs

func (m *Model) PinnedIDs() []string

PinnedIDs returns the configured pin order, including IDs that are not currently visible.

func (*Model) Render

func (m *Model) Render(opts RenderOptions) Rendered

Render draws the list: header with the active sort, filter row, section headings, rows, and a scrollbar. Headings scroll with their rows so the heading a row sits under is always the heading above it.

func (*Model) Reproject

func (m *Model) Reproject()

Reproject re-runs filter and sort after a caller changed the query directly (a paste, a programmatic clear). Selection is preserved by identity.

func (*Model) Scroll

func (m *Model) Scroll(delta int)

Scroll follows the selected row. It remains as the compatibility entry point for callers that previously moved only the viewport; workspace wheel input must have the same selection-following semantics everywhere.

func (*Model) ScrollAtBoundary added in v1.0.0

func (m *Model) ScrollAtBoundary(delta int) bool

ScrollAtBoundary reports whether moving the selection by delta would leave this list unchanged. Wheel navigation follows selection, so its boundary is the first or last visible item rather than the viewport offset alone.

func (*Model) ScrollOffset

func (m *Model) ScrollOffset() int

ScrollOffset is the first visible row index. Consumers read it to prove the viewport survived a refresh; nothing else depends on it.

func (*Model) SelectID

func (m *Model) SelectID(id string) bool

SelectID moves the cursor to a stable identity when it is visible.

func (*Model) Selected

func (m *Model) Selected() (Item, bool)

func (*Model) SelectedID

func (m *Model) SelectedID() string

func (*Model) SetCreateActions added in v1.0.0

func (m *Model) SetCreateActions(header *SidebarAction, sections map[string]*SidebarAction)

SetCreateActions supplies presentation-only create affordances. Section actions are keyed by Section.Key, which is a stable project identity under Project sort. Nil removes the corresponding affordance and hit region.

func (*Model) SetEmptyState added in v1.3.0

func (m *Model) SetEmptyState(lines []string, actionID string, actionLine int)

SetEmptyState replaces the catalog-empty copy with already-styled lines and an optional pressable row. SetEmptyText is the one-line form.

func (*Model) SetEmptyText

func (m *Model) SetEmptyText(text string)

func (*Model) SetFailures

func (m *Model) SetFailures(failures []string)

SetFailures records per-project unavailability rows. They are presentation only; the list never retries or repairs anything.

func (*Model) SetItems

func (m *Model) SetItems(items []Item)

SetItems replaces the catalog projection, preserving the selected identity.

func (*Model) SetLoading

func (m *Model) SetLoading(loading bool)

SetLoading marks that inventory is still arriving. Rows already collected stay on screen: incremental results are the point.

func (*Model) SetPinned

func (m *Model) SetPinned(ids []string)

SetPinned replaces the pin order. IDs that are not in the current catalog are kept so a later SetItems can restore them; display only includes pins that still have a matching item. The owner prunes against complete inventory.

func (*Model) SetPulseFrame added in v1.0.0

func (m *Model) SetPulseFrame(frame int)

SetPulseFrame advances the working/blocked marker animation. Consumers that never tick leave it at zero and get the steady first frame.

func (*Model) SetScrollViewport added in v1.4.0

func (m *Model) SetScrollViewport(offset int)

SetScrollViewport pins the list's viewport to an offset a scrollbar gesture chose, latching free-scroll mode: renders keep the chosen position even when the selected row sits outside it. Any selection move — keyboard, wheel, or a click on a row — clears the latch, and following resumes.

func (*Model) SetSort

func (m *Model) SetSort(mode Sort)

func (*Model) SetSortNote added in v1.12.0

func (m *Model) SetSortNote(note string)

SetSortNote marks the sort control with state the sort itself does not describe. The global browser uses it for HostHiddenGlyph: a list missing a machine's rows has to say so on the control that can put them back, or the absence reads as the machine having nothing to show.

func (*Model) Sort

func (m *Model) Sort() Sort

func (*Model) TogglePin

func (m *Model) TogglePin(id string) []string

TogglePin pins or unpins id and returns the new pin order. First-pinned first: a new pin is appended.

func (*Model) Top

func (m *Model) Top() bool

func (*Model) Visible

func (m *Model) Visible() []Item

type Region

type Region struct {
	Kind          RegionKind
	ID            string
	X, Y, W, H    int
	VisibleIndex  int
	SectionHeader bool
	Data          any
}

func RegionAt

func RegionAt(regions []Region, x, y int) (Region, bool)

RegionAt resolves a click to the region drawn under it, last registered winning — the same rule the workspace plugin's hit map uses.

type RegionKind

type RegionKind string

RegionKind names a mouse target the list drew. Regions are reported from the same layout that rendered the rows, so a hit test can never disagree with what is on screen.

const (
	RegionRow    RegionKind = "workspacelist-row"
	RegionSort   RegionKind = "workspacelist-sort"
	RegionFilter RegionKind = "workspacelist-filter"
	// RegionFilterClear is the × drawn at the right of a non-empty query row.
	// It is registered only where it is drawn, so the columns it would occupy
	// belong to the filter row itself whenever there is nothing to clear.
	RegionFilterClear RegionKind = "workspacelist-filter-clear"
)
const (
	RegionHeaderAction  RegionKind = "workspacelist-header-action"
	RegionSectionAction RegionKind = "workspacelist-section-action"
	RegionEmptyAction   RegionKind = "workspacelist-empty-action"
)
const (
	RegionScrollbarTrack RegionKind = RegionKind(ui.RegionScrollbarTrack)
	RegionScrollbarThumb RegionKind = RegionKind(ui.RegionScrollbarThumb)
)

The scrollbar's region kinds are the shared core's IDs, so every surface's hit map names a scrollbar identically and the shared gesture contract reads the same everywhere.

type RenderOptions

type RenderOptions struct {
	Width, Height int
	Title         string
	Focused       bool
	Now           time.Time
	// ScrollbarHover / ScrollbarDrag carry the list bar's pointer emphasis
	// from the surface's mouse state into the draw.
	ScrollbarHover bool
	ScrollbarDrag  bool
}

RenderOptions describes the box the list is drawn into.

type Rendered

type Rendered struct {
	View    string
	Regions []Region
	// Scrollbar reports the interactive bar this pass drew, for surfaces
	// answering presses on its thumb/track regions.
	Scrollbar SidebarScrollbar
}

Rendered is the drawn list plus the regions it registered.

type RowField

type RowField struct {
	Text     string
	Rendered string
}

RowField carries both the semantic text used under selection and an optional styled form used on an unselected row. This lets project-only badges remain project-owned without moving their layout into the plugin.

func PlainField

func PlainField(text string) RowField

type RowMarker

type RowMarker struct {
	Icon     string
	Lane     string
	Tone     MarkerTone
	Style    lipgloss.Style
	HasStyle bool
}

RowMarker is a caller-resolved status symbol. Style is reserved for the project sidebar's animated working/blocked frames; ordinary callers provide Lane or Tone and get the same colour vocabulary everywhere.

type RowPresentation

type RowPresentation struct {
	Marker     RowMarker
	Kind       string
	Name       string
	NamePrefix RowField
	Age        string
	NameMeta   []RowField

	BeforeProvider []RowField
	Provider       string
	AfterProvider  []RowField
	Pinned         bool
}

RowPresentation is the neutral two-line workspace row contract shared by the project and global Workspaces surfaces. Callers resolve all state and supply display fields; this package owns layout, marker placement, provider treatment, ANSI-safe fitting, and selection.

Kind is a presentation field, not a status marker. Marker stays the outdented gutter icon (working/live/idle/ambiguous/main).

type ScrollGesture added in v1.4.0

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

ScrollGesture is one surface's in-flight pointer gesture on the shared sidebar bar, following docs/plans/active/mouse-draggable-scrollbars.md: a thumb press grabs where it landed, a track press jumps so the grabbed point becomes the thumb anchor and the same gesture continues from there, and dragging maps the pointer back through the shared inverse mapping — clamped at both ends without ever ending the gesture.

It is state-free about the list itself: the surface owns its offset and applies what Press and DragTo return through its own viewport setter, which is what keeps the math adoptable by a headless caller unchanged.

func (*ScrollGesture) Active added in v1.4.0

func (g *ScrollGesture) Active() bool

Active reports that a gesture is in flight.

func (*ScrollGesture) DragTo added in v1.4.0

func (g *ScrollGesture) DragTo(pointerRow int) int

DragTo maps the pointer's absolute row back onto the dragged offset, preserving where within the thumb the gesture grabbed. OffsetAtRow clamps past both ends of the track without ending anything.

func (*ScrollGesture) End added in v1.4.0

func (g *ScrollGesture) End()

End settles the gesture — on a release anywhere, or on the first button-less motion after a release was lost outside the window. Nothing is persisted; a scroll offset is ephemeral view state.

func (*ScrollGesture) Press added in v1.4.0

func (g *ScrollGesture) Press(bar SidebarScrollbar, trackY, pointerRow int, thumb bool, offset int) int

Press begins a gesture from a press on one of the bar's regions and returns the offset to scroll to now. bar is the last render's snapshot, trackY the absolute screen row of the track top, pointerRow the pressed absolute row, thumb whether the thumb rather than the track was pressed, and offset the view's current scroll offset — the anchor a thumb press grabs at.

type Section

type Section struct {
	Title string
	// Key is the stable grouping identity when a section represents a project.
	// Presentation callers can hang an action from it without decoding Title.
	Key   string
	Group Group
	Items []Item
}

Section is a rendered group of items with its heading. Title is the heading without a count; empty Title means an unheaded run. Group is the Activity bucket when that sort is in play.

func Grouped

func Grouped(items []Item, mode Sort) []Section

Grouped splits sorted items into headed sections. Activity uses the Kanban projection; Project one heading per project; Recent the time buckets; Name stays a single unheaded run.

func GroupedAt

func GroupedAt(items []Item, mode Sort, now time.Time, pinnedIDs []string) []Section

GroupedAt is Grouped with a clock for Recent buckets and an optional pinned identity list. Pinned items that still exist sit in a headed "Pinned" section first and are not re-bucketed below. Gone pin IDs are dropped.

func SectionsAt added in v1.16.0

func SectionsAt(items []Item, mode Sort, now time.Time, pinnedIDs []string) []Section

SectionsAt is the state-free grouping rule with an explicit observation time. Unlike GroupedAt's legacy zero-clock convenience, it never reads the wall clock: the same inputs produce the same sections for a headless caller. Items must already be sorted; pinned rows are separated exactly once.

type SidebarAction

type SidebarAction struct {
	ID      string
	Label   string
	Hovered bool
	// Suffix is a mark the control keeps at every degradation step, appended
	// after whatever is left of Label. It is for state the label does not
	// otherwise say — "some rows are being withheld" — which is precisely the
	// thing that must not vanish when the header runs out of room, since a
	// narrow panel is where a missing row is hardest to explain.
	Suffix string
}

SidebarAction is an optional action painted in a header. Omitting it paints and registers nothing, which lets read-only consumers use the same sidebar without inheriting project workspace mutations.

type SidebarOptions

type SidebarOptions struct {
	Width, Height int
	Title         string
	Focused       bool
	SelectedID    string
	ScrollOffset  int
	HeaderAction  *SidebarAction
	HeaderMeta    *SidebarAction
	PrefixLines   []string
	FilterLine    string
	FilterActive  bool
	// FilterClear is where the filter row drew its × clear control, in the
	// row's own coordinates. The zero rect means the row drew none, and then
	// no region is registered for it.
	FilterClear mouse.Rect
	Sections    []SidebarSection
	EmptyLines  []string
	// EmptyActionID names one of EmptyLines as a pressable control and gives
	// it a hit region. An empty state that offers an action has to be
	// clickable for the same reason its key has to be advertised: the two
	// interaction models say the same thing or neither is trustworthy.
	EmptyActionID   string
	EmptyActionLine int
	FooterLines     []string
	// InteractiveScrollbar opts the bar into the pointer contract: thumb and
	// track Regions are appended after every content region — reverse-scan
	// priority, so a press on the bar is answered by the bar and never by a
	// row beneath its column — and the drawn geometry is reported for hit
	// registration. Nothing is registered when everything fits. Surfaces that
	// have not adopted pointer scrolling leave it false and get exactly the
	// draw-only bar of before.
	InteractiveScrollbar bool
	// FreeScroll reports that ScrollOffset was chosen by a pointer gesture
	// rather than derived from the selection, so the render clamps it without
	// dragging the selected row back into view — a drag past the selection
	// would otherwise be pulled straight back. Any selection move clears it.
	FreeScroll bool
	// ScrollbarHover / ScrollbarDrag feed the bar's pointer emphasis back into
	// the draw, following the divider's HandleState convention. Idle output
	// stays byte-identical to plain RenderScrollbar.
	ScrollbarHover bool
	ScrollbarDrag  bool
}

SidebarOptions contains only resolved presentation state. Collection, selection side effects, preview loading and mutations stay with the caller.

type SidebarRendered

type SidebarRendered struct {
	View         string
	Regions      []Region
	ScrollOffset int
	VisibleRows  int
	// Scrollbar reports the bar this pass drew at the list's right edge, for
	// surfaces answering presses on its regions. Has is false whenever no
	// thumb exists — everything fits, or no body was drawn.
	Scrollbar SidebarScrollbar
}

SidebarRendered is the exact view, geometry and viewport produced by one layout pass. Regions use content-local coordinates; callers add their panel border/padding origin once when registering them.

func RenderSidebar

func RenderSidebar(opts SidebarOptions) SidebarRendered

RenderSidebar is the single row/section/viewport/scrollbar/hit-region renderer used by project and global Workspaces.

type SidebarRow

type SidebarRow struct {
	ID     string
	Data   any
	Render func(width int, selected, focused bool) []string
}

SidebarRow is one caller-owned record projected into the shared list. Data is returned unchanged in the row's Region so consumers never decode display text or a volatile visible index to recover their record.

type SidebarScrollbar added in v1.4.0

type SidebarScrollbar struct {
	Params   ui.ScrollbarParams
	TrackTop int // first row of the track, content-local
	ThumbTop int // thumb's offset within the track, in rows
	ThumbH   int // thumb height in rows
	Has      bool
}

SidebarScrollbar is what one render pass learned about the list's bar: the params it was drawn with and where its track and thumb landed, in content coordinates (the same space as Regions). A bar that was not drawn can never register regions or answer a press.

type SidebarSection

type SidebarSection struct {
	Title string
	// ProjectKey opts a project-group heading into the stable, theme-normalized
	// project hue. Category and time sections leave it empty and stay neutral.
	ProjectKey string
	Count      int
	Action     *SidebarAction
	Rows       []SidebarRow
}

SidebarSection is a headed run of rows. The optional action is commonly the project's create-shell/create-worktree affordance; global sections omit it.

Title is the bare name ("Shells", "Needs Attention") and Count is rendered beside it. They are kept apart rather than pre-joined so a narrow heading can drop the count and still name its rows. An empty Title means an unheaded run.

type Sort

type Sort uint8

Sort is an explicit user-chosen ordering. Sorting is presentation only: it never changes identities, and it never triggers collection.

const (
	SortActivity Sort = iota
	SortProject
	SortRecent
	SortName
	// SortManual is the caller's own order, left exactly as handed in. It is
	// offered only where a durable order actually exists — the project
	// sidebar's fixed Shells/Worktrees structure, and later its drag order.
	// Global inventory does not pretend to own Git or tmux ordering, so it
	// does not offer this.
	SortManual
)

func SortFromAction added in v1.0.0

func SortFromAction(action string, modes []Sort) (Sort, bool)

SortFromAction resolves an action ID back to a mode within the offered set.

func SortFromLabel added in v1.0.0

func SortFromLabel(label string, modes []Sort) (Sort, bool)

SortFromLabel resolves a persisted label back to a mode within the offered set, case-insensitively. Labels are what surfaces persist: they read plainly in a state file and survive the enum being reordered. A label this set does not offer reports false so the caller can fall back to its own default rather than land on an arbitrary mode.

func (Sort) Label

func (s Sort) Label() string

func (Sort) Next

func (s Sort) Next() Sort

Next cycles to the following sort mode.

type Visibility added in v1.16.0

type Visibility struct {
	ShowIdleWorktrees      bool
	Revealed               bool
	RemoteMainWithoutAgent bool
}

Visibility is source-resolved input to the list's visibility rule. The consumer knows whether a remote worktree is a main checkout with no agent; the rule never reads inventory, tmux or the filesystem to decide that fact.

Jump to

Keyboard shortcuts

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