Documentation
¶
Overview ¶
Package contentpanes owns the host-independent lifecycle of Sidecar's passive Document, Issue, 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 ¶
- type AsyncID
- type Config
- type Deck
- func (d *Deck) Apply(result Result) (tea.Cmd, bool)
- func (d *Deck) ApplyBroadcast(payload any) tea.Cmd
- func (d *Deck) CloseActive() bool
- func (d *Deck) CloseTab(leafID, index int) bool
- func (d *Deck) ConfigureViewers(configure func(panelayout.Kind, any))
- func (d *Deck) Context() SurfaceContext
- func (d *Deck) CycleFocus(delta int) int
- func (d *Deck) CycleTab(delta int) tea.Cmd
- func (d *Deck) Encode() State
- func (d *Deck) FocusLeaf(id int) bool
- func (d *Deck) FocusedLeaf() int
- func (d *Deck) Hidden(kind panelayout.Kind) bool
- func (d *Deck) HideFocused() bool
- func (d *Deck) Leaf(kind panelayout.Kind) int
- func (d *Deck) Open(ctx SurfaceContext, ref contentlink.Ref, placement Placement) Outcome
- func (d *Deck) OpenDocumentFile(ctx SurfaceContext, ref contentlink.Ref, placement Placement, file *os.File) Outcome
- func (d *Deck) PlanOpen(ref contentlink.Ref, boxes map[int]panelayout.Box) (panelayout.OpenPlan, bool)
- func (d *Deck) ReplaceActive(ctx SurfaceContext, ref contentlink.Ref) Outcome
- func (d *Deck) SelectTab(leafID, index int) tea.Cmd
- func (d *Deck) SetContext(ctx SurfaceContext)
- func (d *Deck) SetRatio(splitID, ratio int) bool
- func (d *Deck) SetResourceResolver(resolve resourceview.Resolver)
- func (d *Deck) Tabs(leafID int) ([]TabInfo, int)
- func (d *Deck) Tree() *panelayout.Node
- func (d *Deck) Viewer(leafID int) any
- type NodeState
- type Outcome
- type PaneState
- type Placement
- type Refusal
- type Result
- type State
- type Status
- type SurfaceContext
- type TabInfo
- type TabState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncID ¶
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.
func New ¶
func New(ctx SurfaceContext, cfg Config) *Deck
New constructs a primary-only deck without doing I/O.
func (*Deck) Apply ¶
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 ¶
ApplyBroadcast routes an existing viewer-owned broadcast message through every tab. Viewer identities decide whether it applies.
func (*Deck) CloseActive ¶
CloseActive closes the active tab. Closing the last tab forgets the pane and collapses its leaf; unlike HideFocused, no hidden snapshot survives.
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 ¶
CycleFocus walks visible leaves in layout order and wraps.
func (*Deck) FocusedLeaf ¶
FocusedLeaf returns the leaf that owns outer keyboard focus.
func (*Deck) Hidden ¶
func (d *Deck) Hidden(kind panelayout.Kind) bool
Hidden reports whether kind has a remembered, currently collapsed pane.
func (*Deck) HideFocused ¶
HideFocused collapses the focused passive leaf but remembers its tabs. A later Open of the same kind reuses that pane.
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) 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) SetContext ¶
func (d *Deck) SetContext(ctx SurfaceContext)
SetContext changes the deck's async scope without starting work. Results from the old epoch or surface are subsequently stale.
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 ¶
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.
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.
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 Result ¶
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 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.