contentpanes

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 16 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 contentpanes owns the host-independent lifecycle of Sidecar's passive Document, Issue, Note, Diff, and Resource panes.

A Deck deliberately does not render or persist itself. Hosts provide the available box when opening a leaf, render the returned viewer models, and choose where the reference-only State is stored. All potentially expensive work is returned as tea.Cmd; New, Decode, PlanOpen, and Encode are pure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncID

type AsyncID struct {
	TabID      uint64
	Generation uint64
	Epoch      uint64
	Surface    string
}

AsyncID pins a result to the exact deck tab request that produced it. Tab IDs are never reused; Generation changes whenever that tab starts work.

type Config

type Config struct {
	Renderer         *markdown.Renderer
	ResourceResolver resourceview.Resolver
	// ConfigureViewer attaches host presentation behavior (for example issue
	// navigation handlers or Diff paint state). It must remain free of I/O.
	ConfigureViewer func(kind panelayout.Kind, model any)
}

Config supplies only replaceable viewer dependencies. Constructing a Deck remains free of filesystem, database, git, and provider work.

type Deck

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

Deck is one primary surface plus at most one homogeneous leaf for each passive content kind.

func Decode

func Decode(ctx SurfaceContext, cfg Config, state State) *Deck

Decode restores references in an armed state without starting any load. Unknown kinds and invalid tabs collapse out of the tree. If the surviving state has no primary leaf, Decode returns a safe primary-only deck. Hosts must return Deck.LoadVisible after Decode, or every restored pane stays on its loading placeholder until a later select happens to start work.

func New

func New(ctx SurfaceContext, cfg Config) *Deck

New constructs a primary-only deck without doing I/O.

func (*Deck) Apply

func (d *Deck) Apply(result Result) (tea.Cmd, bool)

Apply routes one load result to the exact live or hidden tab that requested it. It returns an optional, identity-wrapped follow-up command.

func (*Deck) ApplyBroadcast

func (d *Deck) ApplyBroadcast(payload any) tea.Cmd

ApplyBroadcast routes an existing viewer-owned broadcast message through every tab. Viewer identities decide whether it applies.

func (*Deck) CloseActive

func (d *Deck) CloseActive() bool

CloseActive closes the active tab. Closing the last tab forgets the pane and collapses its leaf; unlike HideFocused, no hidden snapshot survives.

func (*Deck) CloseTab

func (d *Deck) CloseTab(leafID, index int) bool

CloseTab closes a specific tab through the same last-tab collapse rule.

func (*Deck) ConfigureViewers

func (d *Deck) ConfigureViewers(configure func(panelayout.Kind, any))

func (*Deck) Context

func (d *Deck) Context() SurfaceContext

Context returns the current resolution identity.

func (*Deck) CycleFocus

func (d *Deck) CycleFocus(delta int) int

CycleFocus walks visible leaves in layout order and wraps.

func (*Deck) CycleTab

func (d *Deck) CycleTab(delta int) tea.Cmd

CycleTab moves the focused homogeneous tab strip and wraps.

func (*Deck) Encode

func (d *Deck) Encode() State

Encode projects the deck to references and view state only.

func (*Deck) FocusLeaf

func (d *Deck) FocusLeaf(id int) bool

FocusLeaf moves focus to a visible leaf.

func (*Deck) FocusedLeaf

func (d *Deck) FocusedLeaf() int

FocusedLeaf returns the leaf that owns outer keyboard focus.

func (*Deck) ForgetLeaf added in v1.3.0

func (d *Deck) ForgetLeaf(leafID int) bool

ForgetLeaf forgets a pane outright, dropping all its tabs and collapsing its leaf. Neither the live leaf nor any hidden snapshot survives.

func (*Deck) Hidden

func (d *Deck) Hidden(kind panelayout.Kind) bool

Hidden reports whether kind has a remembered, currently collapsed pane.

func (*Deck) HideFocused

func (d *Deck) HideFocused() bool

HideFocused collapses the focused passive leaf but remembers its tabs. A later Open of the same kind reuses that pane.

func (*Deck) Leaf

func (d *Deck) Leaf(kind panelayout.Kind) int

func (*Deck) LoadVisible added in v1.3.0

func (d *Deck) LoadVisible() []tea.Cmd

LoadVisible starts a load for the active tab of every visible pane that still needs one. Decode and SetContext arm viewers without I/O; hosts must return these commands or a visible pane sits on its placeholder until something else happens to select it.

func (*Deck) Open

func (d *Deck) Open(ctx SurfaceContext, ref contentlink.Ref, placement Placement) Outcome

Open opens or focuses one homogeneous passive tab. A split is first applied to a clone and laid out against placement; refusal leaves tree, focus, hidden state, and tabs unchanged.

func (*Deck) OpenDocumentFile

func (d *Deck) OpenDocumentFile(ctx SurfaceContext, ref contentlink.Ref, placement Placement, file *os.File) Outcome

OpenDocumentFile opens a validated, already-open file through the ordinary Deck lifecycle. The returned command owns file when accepted.

func (*Deck) PlanOpen

func (d *Deck) PlanOpen(ref contentlink.Ref, boxes map[int]panelayout.Box) (panelayout.OpenPlan, bool)

PlanOpen exposes the shared placement answer without mutating the deck.

func (*Deck) ReloadFocused added in v1.3.0

func (d *Deck) ReloadFocused() tea.Cmd

ReloadFocused force-reloads the focused pane's active tab, including a tab already showing a document. It is the user-facing recovery for a pane stuck on its loading placeholder.

func (*Deck) ReplaceActive

func (d *Deck) ReplaceActive(ctx SurfaceContext, ref contentlink.Ref) Outcome

ReplaceActive retargets the active tab without changing the leaf geometry. Hosts use this for picker-style navigation where Enter replaces the current document while Shift+Enter remains the ordinary append operation.

func (*Deck) SelectTab

func (d *Deck) SelectTab(leafID, index int) tea.Cmd

SelectTab selects a tab and starts a deferred restore load when needed.

func (*Deck) SetContext

func (d *Deck) SetContext(ctx SurfaceContext) []tea.Cmd

SetContext changes the deck's async scope. Tabs are rebound to the new identity so in-flight results from the old context cannot land, and the active tab of every visible pane is asked to load. Hidden panes stay armed until they are shown. Loading visible tabs here is what keeps a sibling document from sitting on "Loading document…" after a split.

func (*Deck) SetRatio

func (d *Deck) SetRatio(splitID, ratio int) bool

func (*Deck) SetResourceResolver

func (d *Deck) SetResourceResolver(resolve resourceview.Resolver)

SetResourceResolver updates existing viewers and the factory used by future Resource tabs created after provider discovery completes.

func (*Deck) Tabs

func (d *Deck) Tabs(leafID int) ([]TabInfo, int)

Tabs returns the strip in display order and its active index. The returned slice is detached; viewer models remain the shared host-independent models.

func (*Deck) Tree

func (d *Deck) Tree() *panelayout.Node

Tree returns a detached layout tree so hosts cannot mutate deck ownership.

func (*Deck) Viewer

func (d *Deck) Viewer(leafID int) any

Viewer returns the active host-independent viewer model for a passive leaf. Its dynamic type is *docview.Model, *issueview.Model, *noteview.Model, *workspacediff.View, or *resourceview.Model.

type NodeState

type NodeState struct {
	Kind  string     `json:"kind,omitempty"`
	Axis  string     `json:"axis,omitempty"`
	Ratio int        `json:"ratio,omitempty"`
	A     *NodeState `json:"a,omitempty"`
	B     *NodeState `json:"b,omitempty"`
	Pane  *PaneState `json:"pane,omitempty"`
}

NodeState is a pane tree. Leaf Pane is omitted for the primary surface.

type Outcome

type Outcome struct {
	Status      Status
	Refusal     Refusal
	Ref         contentlink.Ref
	Kind        panelayout.Kind
	LeafID      int
	TabID       uint64
	CreatedLeaf bool
	CreatedTab  bool
	Command     tea.Cmd
}

Outcome describes exactly what Open did. Command, when non-nil, performs the viewer load and returns a Result for Apply.

func (Outcome) Accepted

func (o Outcome) Accepted() bool

Accepted reports whether the deck accepted the target or delegated a valid action to the host.

type PaneState

type PaneState struct {
	Kind   string     `json:"kind"`
	Active int        `json:"active,omitempty"`
	Tabs   []TabState `json:"tabs"`
}

PaneState is one homogeneous passive tab strip.

type Placement

type Placement struct {
	Box    panelayout.Box
	Boxes  map[int]panelayout.Box
	Floors panelayout.Floors
	Split  string
}

Placement is the geometry against which a new split is trialled. Boxes are the last boxes by leaf ID and let panelayout choose the largest content leaf.

type Refusal

type Refusal string

Refusal is why Open made no change.

const (
	RefusalNone        Refusal = ""
	RefusalInvalid     Refusal = "invalid-reference"
	RefusalUnsupported Refusal = "unsupported-kind"
	RefusalPlacement   Refusal = "no-placement"
	RefusalFit         Refusal = "does-not-fit"
)

type Result

type Result struct {
	ID      AsyncID
	Payload any
}

Result is the only asynchronous message a Deck consumes. Payload remains a viewer-owned type such as docview.LoadedMsg or resourceview.ResolvedMsg.

type State

type State struct {
	Version   int         `json:"version"`
	Root      *NodeState  `json:"root,omitempty"`
	FocusKind string      `json:"focusKind,omitempty"`
	Hidden    []PaneState `json:"hidden,omitempty"`
}

State is the reference-only persistence boundary for a Deck. It contains no loaded document, issue, diff, provider response, error, or rendered bytes.

type Status

type Status uint8

Status is the typed result of Open.

const (
	StatusRefused Status = iota
	StatusOpened
	StatusFocused
	// StatusAction means the reference is valid but is not a passive leaf.
	// URL and Internal refs are returned to the host for activation.
	StatusAction
)

type SurfaceContext

type SurfaceContext struct {
	Root        string
	DiffRoot    string
	Surface     string
	DiffSurface string
	BaseRef     string
	Epoch       uint64
}

SurfaceContext is the stable identity and resolution context for one deck. BaseRef is used only by working-tree Diff viewers.

type TabInfo

type TabInfo struct {
	ID     uint64
	Ref    contentlink.Ref
	Viewer any
}

TabInfo is one tab as a host needs to render it. Viewer is intentionally the existing shared model rather than a second rendering interface.

type TabState

type TabState struct {
	Ref      contentlink.Ref `json:"ref"`
	Scroll   int             `json:"scroll,omitempty"`
	Wrap     bool            `json:"wrap,omitempty"`
	Rendered bool            `json:"rendered,omitempty"`
	Scope    string          `json:"scope,omitempty"`
	Mode     string          `json:"mode,omitempty"`
	Path     string          `json:"path,omitempty"`
}

TabState contains target identity and user-owned view position only.

Jump to

Keyboard shortcuts

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