panesize

package
v0.17.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinColumns = 40
	MaxColumns = 240
	MinRows    = 10
	MaxRows    = 120
	// LeaseTTL must ride out hidden-tab timer clamping: desktop Safari
	// reports an occluded window as hidden and degrades its timers to a
	// measured ~60-65s cadence within two minutes, so a 30s TTL lapsed the
	// lease — and resized the shared pane — during every longer glance away,
	// even though renewals were still arriving. Twice the measured clamp
	// keeps a renewing-but-hidden page leased; a frozen or vanished client
	// gives the pane back within two minutes instead of half a minute, and a
	// closing client is still released immediately through ReleaseClient.
	LeaseTTL = 120 * time.Second
	// ReleaseGrace keeps a released width in place for a moment. Leaving a
	// terminal on the phone and stepping back into it is a few seconds apart,
	// and restoring the pane in between resizes it twice: the agent re-renders
	// on both SIGWINCHs, so its output looks stalled for as long as it repaints.
	// The pane keeping the phone's width this much longer is the cheaper trade.
	ReleaseGrace = 10 * time.Second
)

Variables

View Source
var (
	ErrClosed             = errors.New("Pane size leasing is shut down")
	ErrInvalidColumns     = errors.New("Columns must be between 40 and 240")
	ErrInvalidRows        = errors.New("Rows must be between 10 and 120")
	ErrInvalidLease       = errors.New("Pane and lease owner are required")
	ErrLeaseOwnerGone     = errors.New("Pane size lease owner is disconnected")
	ErrProcessUnavailable = errors.New("Pane foreground process information is unavailable")
	ErrTTYUnavailable     = errors.New("Pane foreground process does not have a TTY")
	ErrSizeUnavailable    = errors.New("Pane terminal size is unavailable")
	ErrResizeFailed       = errors.New("Pane terminal size could not be changed")
	ErrUnsupportedOS      = errors.New("Pane size leasing is unsupported on this platform")
)

Functions

This section is empty.

Types

type Lease

type Lease struct {
	Columns int
	// Rows is zero when the client leases only the width: the pane keeps
	// its own height and old clients stay valid without sending rows.
	Rows      int
	ExpiresAt time.Time
}

type Manager

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

func NewManager

func NewManager(provider ProcessInfoProvider, logger *slog.Logger) *Manager

func (*Manager) Acquire

func (m *Manager) Acquire(
	ctx context.Context,
	clientID, paneID string,
	columns, rows int,
) (int, int, error)

func (*Manager) ActiveColumns added in v0.14.2

func (m *Manager) ActiveColumns(paneID string) (int, bool)

ActiveColumns reports the narrowest unexpired lease for a pane.

func (*Manager) ActiveRows added in v0.14.8

func (m *Manager) ActiveRows(paneID string) (int, bool)

ActiveRows reports the effective terminal height for an actively leased pane: the smallest unexpired row lease, or the pane's baseline height when no client leases rows.

func (*Manager) Release

func (m *Manager) Release(ctx context.Context, clientID, paneID string) error

Release lapses the lease instead of restoring the pane immediately. A phone that returns to the terminal within ReleaseGrace re-acquires the width it already has, so nothing is resized and the agent does not re-render; the expiry sweep restores the pane once the grace elapses. A disconnecting client keeps the immediate path through ReleaseClient.

func (*Manager) ReleaseClient

func (m *Manager) ReleaseClient(ctx context.Context, clientID string) error

func (*Manager) ResizedWithin added in v0.15.7

func (m *Manager) ResizedWithin(paneID string, window time.Duration) bool

ResizedWithin reports whether a lease actually changed the pane's terminal width within the given window. Renewals that keep the same columns do not count: they do not signal the application, so it does not re-render.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

func (*Manager) Shutdown

func (m *Manager) Shutdown(ctx context.Context) error

func (*Manager) SweepExpired

func (m *Manager) SweepExpired(ctx context.Context) error

type ProcessInfoProvider

type ProcessInfoProvider interface {
	PaneProcessInfo(context.Context, string) (*herdr.PaneProcessInfo, error)
}

Jump to

Keyboard shortcuts

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