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 ¶
- type AsyncID
- type Config
- type Deck
- func (d *Deck) AdoptLayout(candidate *panelayout.Node) bool
- func (d *Deck) Apply(result Result) (tea.Cmd, bool)
- func (d *Deck) ApplyBroadcast(payload any) tea.Cmd
- func (d *Deck) CanAdoptLayout(candidate *panelayout.Node) bool
- 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) ForgetLeaf(leafID int) bool
- func (d *Deck) Hidden(kind panelayout.Kind) bool
- func (d *Deck) HideFocused() bool
- func (d *Deck) Leaf(kind panelayout.Kind) int
- func (d *Deck) LoadVisible() []tea.Cmd
- func (d *Deck) LoadVisibleKind(kind panelayout.Kind) []tea.Cmd
- 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) ReloadFocused() tea.Cmd
- 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) []tea.Cmd
- 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. 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) AdoptLayout ¶ added in v1.11.0
func (d *Deck) AdoptLayout(candidate *panelayout.Node) bool
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) CanAdoptLayout ¶ added in v1.11.0
func (d *Deck) CanAdoptLayout(candidate *panelayout.Node) bool
CanAdoptLayout validates a host-composed candidate without changing the deck. Modal hosts use it before touching their live tree, so adopting the passive projection cannot become a late partial-commit failure.
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) ForgetLeaf ¶ added in v1.3.0
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 ¶
HideFocused collapses the focused passive leaf but remembers its tabs. A later Open of the same kind reuses that pane.
func (*Deck) LoadVisible ¶ added in v1.3.0
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) LoadVisibleKind ¶ added in v1.6.0
func (d *Deck) LoadVisibleKind(kind panelayout.Kind) []tea.Cmd
LoadVisibleKind is LoadVisible narrowed to one kind, for the moments when only one viewer's dependency has changed — a resource resolver arriving after startup — and re-focusing every other visible pane would be work the change did not ask for.
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
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) 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) 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.
Rebinding starts nothing. A deck that is on screen follows this with LoadVisibleKind(panelayout.Resource) and returns the commands, which is what finally resolves tabs armed before any provider was ready; a deck the host is only holding does not, because a load whose command is dropped would leave the tab loading forever.
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
Plan *panelayout.OpenPlan
}
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. Plan, when set, IS that choice: the open applies the caller's plan verbatim instead of re-running PlanOpen, so a host that validated a composed layout commits exactly the tree it fit-tested. A planned retarget must still name an existing pane of the kind, or the open refuses.
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"`
// OwnerName and OwnerRoot identify a cross-project issue tab's owning
// store. Empty on a local issue. Restore reinstates the adoption before
// the first load so the card does not re-run the search.
OwnerName string `json:"ownerName,omitempty"`
OwnerRoot string `json:"ownerRoot,omitempty"`
}
TabState contains target identity and user-owned view position only.