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
- func Apply(h Host, req uirequest.Request, payload uirequest.LayoutPayload, ...) tea.Cmd
- func DeckCellFor(screen *panelayout.Node, cell panelayout.Cell) (panelayout.Cell, string)
- func LandedLeafID(root *panelayout.Node, kind panelayout.Kind) int
- func LayoutAcks(h Host, items []ItemPlan, surface string, committed bool) []uirequest.AckItem
- func PassivePlanRefusal(deckTrial *panelayout.Node, kind panelayout.Kind) string
- func PlanPassiveItem(screen, deckTrial *panelayout.Node, item ItemPlan, ...) (panelayout.OpenPlan, string)
- func PlanShellItem(h Host, trial *panelayout.Node, item ItemPlan) (panelayout.OpenPlan, string)
- func RemotePendingKind(kind panelayout.Kind) (contentlink.Kind, bool)
- func ResolveRemoteTargets(kind panelayout.Kind, spec uirequest.LayoutPane, src contentpanes.Source, ...) ([]uirequest.Target, string)
- func ResolveTargets(kind panelayout.Kind, spec uirequest.LayoutPane, root string, ...) ([]uirequest.Target, string)
- func SplitFileLine(raw string) (string, int)
- func TargetFromRef(ref contentlink.Ref, line int) uirequest.Target
- func WireKind(kind panelayout.Kind) (uirequest.TargetKind, bool)
- func WriteAck(stateDir, instance string, req uirequest.Request, status uirequest.Status, ...)
- type Host
- type ItemPlan
Constants ¶
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.
const MoveNoFocusReason = "no pane is focused on that surface; name the pane by cell instead"
MoveNoFocusReason is --focused with no focused pane to move.
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.
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.
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.
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 ¶
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 SplitFileLine ¶ added in v1.12.0
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.