termpanes

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 11 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 termpanes owns the host-independent state and lifecycle of Sidecar's live terminal leaves.

A Deck deliberately does not render or persist itself. Hosts own their pane trees and target policy; the deck only keys terminal state by tree leaf ID. Potentially expensive terminal operations are returned as tea.Cmd.

Index

Constants

View Source
const (
	CapMessage        = "Two live terminals at a time; close one first"
	CapDisabledReason = "Two terminals are already on screen — close one first"
)
View Source
const SessionPrefix = "sidecar-tp-"

Variables

This section is empty.

Functions

func CloseNeedsConfirm

func CloseNeedsConfirm(currentCommand, shellCommand string) bool

CloseNeedsConfirm reports whether a split close must ask about a running process rather than closing its login shell directly.

func EnsureSession

func EnsureSession(session, workDir string) (string, error)

EnsureSession reuses a split session when it exists, otherwise creates it.

func KillSession

func KillSession(session string) tea.Cmd

KillSession ends only a session created for a terminal split.

func SessionName

func SessionName(selector string) string

SessionName derives the stable tmux name used by a terminal split on every host. selector is the owning workspace or shell's durable tmux identity.

Types

type CloseEvidence

type CloseEvidence struct {
	CurrentCommand string
	ShellCommand   string
}

CloseEvidence is the minimum tmux state needed to decide whether a terminal split may close immediately or needs a running-process confirmation.

func ProbeClose

func ProbeClose(session string) (CloseEvidence, error)

ProbeClose asks only the owned split session what is currently running.

type CloseMode

type CloseMode uint8
const (
	CloseHide CloseMode = iota
	CloseExplicit
	CloseSessionEnded
)

type Deck

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

Deck is the keyed collection of live leaf state for one pane tree.

func New

func New() *Deck

New constructs an empty collection without I/O.

func (*Deck) Attach

func (d *Deck) Attach(leaf *Leaf) bool

Attach installs leaf state at its pane-tree ID.

func (*Deck) Leaf

func (d *Deck) Leaf(id int) *Leaf

Leaf returns state for a pane-tree leaf ID.

func (*Deck) LiveLeafCount

func (d *Deck) LiveLeafCount(root *panelayout.Node) int

LiveLeafCount answers the cap from the pane tree, which remains the source of truth for which leaves are live.

func (*Deck) Range

func (d *Deck) Range(visit func(int, *Leaf) bool)

Range visits attached leaves until visit returns false.

func (*Deck) Rekey

func (d *Deck) Rekey(from, to int) *Leaf

Rekey moves detached state onto the pane-tree ID that made it live.

func (*Deck) Release

func (d *Deck) Release(id int) *Leaf

Release removes and closes a leaf.

type Leaf

type Leaf struct {
	ID int
	// Requested is host reconciliation policy: the keyed state should have a
	// live tree leaf. It is distinct from merely preparing detached state.
	Requested bool

	Terminal  *tty.Model
	Target    Target
	Buffer    *tty.OutputBuffer
	Scroll    int
	Freeze    tty.WindowFreeze
	FreezeDoc bool
	History   tty.HistoryReach

	LinkState   termpreview.LinkState
	LinkContext any
	RowAnalyzer *termpreview.RowAnalyzer

	// Interaction state belongs to the leaf where the gesture or input mode
	// began. HostState retains host-specific adapters without teaching this
	// presentation-neutral collection either host's private interface.
	Selection   ui.SelectionState
	Pointer     tty.Pointer
	Wheel       tty.WheelBurst
	Interactive bool
	HostState   any

	Session string
	PaneID  string
	Name    string
}

Leaf is all mutable state belonging to one live terminal leaf.

func Decode

func Decode(id int, session, paneID string, terminal *tty.Model) *Leaf

Decode reconstructs detached state without opening a terminal.

func NewLeaf

func NewLeaf(id int, terminal *tty.Model) *Leaf

NewLeaf constructs detached leaf state without I/O.

func (*Leaf) Close

func (l *Leaf) Close()

Close releases the model synchronously and clears its target.

func (*Leaf) Open

func (l *Leaf) Open(target Target) tea.Cmd

Open attaches the terminal model to target asynchronously.

func (*Leaf) ReadHistory

func (l *Leaf) ReadHistory(read func() tea.Msg) tea.Cmd

ReadHistory performs a caller-supplied history read as a command. The deck owns the reach state while the host owns target resolution and result policy.

func (*Leaf) Resize

func (l *Leaf) Resize(width, height int) tea.Cmd

Resize asks the attached model to adopt a new geometry.

type Target

type Target struct {
	Session string
	Pane    string
	// Host names the machine the session lives on; empty is this machine. It
	// is stored rather than derived because the surface compares its stored
	// target against a desired one to decide "am I already showing this?" —
	// and a comparison that always dropped Host could never answer yes for a
	// remote pane, so every poll tore down its ssh connection and reseeded.
	Host     string
	Width    int
	Height   int
	Source   string
	SourceID string
}

Target is the currently attached terminal identity and geometry. Source and SourceID are host vocabulary used to distinguish projections of the same tmux target without coupling the deck to a particular surface.

Jump to

Keyboard shortcuts

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