layoutapply

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: 18 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 layoutapply owns the all-or-nothing layout apply verdict path: resolve descriptors, plan against a trial copy, fit-test floors once, then commit or decline with the first violation and the tree byte-for-byte untouched. Hosts (the project workspace and the global Sessions surface) supply tree access and the create paths their modal already drives.

Index

Constants

View Source
const EscapedGridReason = "" /* 147-byte string literal not displayed */

EscapedGridReason explains a pane that landed in a tree with no grid answer, so an ack never carries a bare empty cell beside a success verdict.

View Source
const MoveNoFocusReason = "no pane is focused on that surface; name the pane by cell instead"

MoveNoFocusReason is --focused with no focused pane to move.

View Source
const MoveNoGridReason = "the current layout does not resolve to grid columns, so no cell can be addressed"

MoveNoGridReason explains a tree with no grid answer, so a move request never reports a bare empty cell beside a verdict.

View Source
const NotOnScreenReason = "the origin shell is not on screen, and layout requests are never queued"

NotOnScreenReason is the decline a layout request earns when its destination is not showing. Layout never queues: a stale answer is worse than a refusal.

View Source
const SessionsNotOnScreenReason = "the Sessions surface is not on screen, and layout requests are never queued"

SessionsNotOnScreenReason is the same rule said for the global Sessions surface: ScopeGlobal + the Sessions tab must be showing.

View Source
const SpecOriginRequired = "a new shell pane needs a Sidecar shell to split beside; run from inside one"

SpecOriginRequired is the decline a new shell pane earns when there is no live session to split beside.

Variables

This section is empty.

Functions

func Apply

func Apply(h Host, req uirequest.Request, payload uirequest.LayoutPayload, root, surface string) tea.Cmd

Apply is the host-side write path: a batch of --pane descriptors, one --spec, or one move, all-or-nothing. Get is the host's to answer; this package does not build reports.

func DeckCellFor

func DeckCellFor(screen *panelayout.Node, cell panelayout.Cell) (panelayout.Cell, string)

DeckCellFor translates a screen cell onto the deck's grid. The deck sees the same layout minus every Shell leaf.

func LandedLeafID

func LandedLeafID(root *panelayout.Node, kind panelayout.Kind) int

LandedLeafID names where a batch's pane of this kind ended up in the final tree: the kind's own leaf for passives, the shell leaf for shells.

func LayoutAcks

func LayoutAcks(h Host, items []ItemPlan, surface string, committed bool) []uirequest.AckItem

LayoutAcks fills the per-pane ack items AFTER the whole batch has run.

func PassivePlanRefusal

func PassivePlanRefusal(deckTrial *panelayout.Node, kind panelayout.Kind) string

PassivePlanRefusal explains a failed deck-side plan with the planner's own vocabulary, worded to stand alone in a toast or an ack.

func PlanPassiveItem

func PlanPassiveItem(screen, deckTrial *panelayout.Node, item ItemPlan, boxes map[int]panelayout.Box) (panelayout.OpenPlan, string)

PlanPassiveItem plans one content pane. Addressing and refusals are stated against the SCREEN grid; the plan itself is resolved against deckTrial.

func PlanShellItem

func PlanShellItem(h Host, trial *panelayout.Node, item ItemPlan) (panelayout.OpenPlan, string)

PlanShellItem plans the batch's shell pane against the SCREEN trial: shells split the pane tree directly, never the deck's.

func RemotePendingKind added in v1.12.0

func RemotePendingKind(kind panelayout.Kind) (contentlink.Kind, bool)

RemotePendingKind maps a pane kind onto the contentlink kind a remote Source resolves it as. Resource is absent: it never reaches the Source.

func ResolveRemoteTargets added in v1.12.0

func ResolveRemoteTargets(kind panelayout.Kind, spec uirequest.LayoutPane, src contentpanes.Source, sourceCtx contentpanes.SourceContext, matchers []terminallink.ResourceMatcher) ([]uirequest.Target, string)

ResolveRemoteTargets is ResolveTargets for a surface bound to another machine: it classifies each target string against the host's content Source rather than this machine's filesystem.

It is shared by the Sessions preview and the bound project workspace on purpose. The two surfaces are two projections of one model, and the first time this rule lived in both packages the copies drifted within a single commit — a note URI normalized on one surface and passed through raw on the other. There is one remote resolver, and this is it.

A failed resolve is a refusal, not a silent skip: apply is all-or-nothing.

func ResolveTargets

func ResolveTargets(kind panelayout.Kind, spec uirequest.LayoutPane, root string, matchers []terminallink.ResourceMatcher) ([]uirequest.Target, string)

ResolveTargets turns a descriptor's target strings into resolved uirequest targets through ResolveTarget — the exact classification the CLI's `open` argument goes through, here on the host where the workspace root is known.

func SpecLeafJSON added in v1.16.0

func SpecLeafJSON(item *ItemPlan) *state.PaneLayoutJSON

SpecLeafJSON projects validated targets onto the shared persistence shape.

func SplitFileLine added in v1.12.0

func SplitFileLine(raw string) (string, int)

SplitFileLine peels a trailing :N off a document target. The local path gets the same treatment inside uirequest.ResolveTarget; a remote target never reaches that function, so the split has to happen before the Source sees it.

func TargetFromRef added in v1.12.0

func TargetFromRef(ref contentlink.Ref, line int) uirequest.Target

TargetFromRef turns a resolved content reference back into the wire target a layout item carries. An unrecognised ref yields the zero Target, which the caller reports as a kind mismatch rather than opening anything.

func WireKind

func WireKind(kind panelayout.Kind) (uirequest.TargetKind, bool)

func WriteAck

func WriteAck(stateDir, instance string, req uirequest.Request, status uirequest.Status, reason string, items []uirequest.AckItem, layout json.RawMessage)

WriteAck is the shared ActionLayout acknowledgement writer. Hosts pass their instance id; layout carries the get report verbatim and Items on apply.

Types

type Host

type Host interface {
	PaneRoot() *panelayout.Node
	LastBoxes() map[int]panelayout.Box
	PeerBox() (panelayout.Box, bool)
	Floors() panelayout.Floors

	EnsureDeck()
	DeckTree() *panelayout.Node

	TerminalEnabled() bool
	TerminalOffReason() string
	ShellCapMessage() string
	ShellVisible() bool
	SplitOrigin() string
	TermPanelSessionName() string
	LiveShellSessions() map[string]bool

	// FocusedLeaf is the surface's focused pane leaf, or 0 when nothing on it
	// has pane focus. It answers `layout move --focused`.
	FocusedLeaf() int
	// CommitMove installs an accepted MovePlan on the live tree through the
	// host's own path — identity-preserving apply, deck adoption, persistence,
	// and the existing terminal geometry sync — and reports a user-visible
	// reason instead when it cannot. A non-empty reason means nothing changed.
	CommitMove(plan panelayout.MovePlan) (reason string, cmd tea.Cmd)

	ResolveTargets(kind panelayout.Kind, spec uirequest.LayoutPane) ([]uirequest.Target, string)

	CommitPassive(targets []uirequest.Target, plan panelayout.OpenPlan) (verdict, reason string, cmd tea.Cmd)
	CommitShell(spec uirequest.LayoutPane, plan panelayout.OpenPlan) (verdict, reason string, cmd tea.Cmd)

	RestoreSpec(layout *state.PaneLayoutJSON) tea.Cmd
	AdoptSpecShell(spec uirequest.LayoutPane) (verdict, reason string, cmd tea.Cmd)
	AfterSpecCommit()

	LandedLeaf(kind panelayout.Kind) int
	Ack(req uirequest.Request, status uirequest.Status, reason string, items []uirequest.AckItem, layout json.RawMessage)
}

Host is one surface's layout apply adapter. The engine never mutates a tree itself except trial copies; commit goes through the host's create paths.

type ItemPlan

type ItemPlan struct {
	Spec    uirequest.LayoutPane
	Kind    panelayout.Kind
	Targets []uirequest.Target
	Cell    panelayout.Cell
	Plan    panelayout.OpenPlan
	Verdict string
	Reason  string
}

ItemPlan is one requested pane's journey through validation, placement planning, and commit.

Jump to

Keyboard shortcuts

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