WorkbenchLayoutState class
A serializable snapshot of a workbench's view-container arrangement (§spec:layout-state-persistence). Bundles the four controlled-seam concerns as container-keyed maps — pane sizes, pane order, pane expanded, and view hidden visibility — that a host reads once, hands to its own storage, and hands back at startup. A host that persists and rehydrates this one value restores a user's sidebar arrangement across restarts without deriving any map shape or writing reconcile/reorder logic of its own.
The maps mirror the shell's existing seam vocabulary exactly (§spec:view-stack order and expansion, §spec:view-container-title visibility, §spec:resize-geometry sizing), so the state is a faithful snapshot of what those seams already control, not a second model to keep in sync.
Serialization is the host's mechanism; the shape is the shell's contract. toJson/WorkbenchLayoutState.fromJson convert to and from a JSON-encodable primitive map — not bytes. The shell never encodes a string, names a storage key, or writes to disk; the host owns the codec and the bytes (§spec:capability-boundary). Deserialization is tolerant: it defaults absent concerns and ignores unrecognized ones, so a value written by an older or newer shell rehydrates without the host guarding versions.
Reconciliation is distinct from deserialization. fromJson is a dumb structural round-trip. reconcile resolves the state against the container's current view descriptors — which do not exist at deserialize time — dropping arrangement for ids the host no longer declares, admitting newly declared views at their descriptor defaults, and clamping persisted sizes to the current geometry.
Constructors
-
WorkbenchLayoutState({Map<
String, Map< sizes = const {}, Map<String, double> >String, List< order = const {}, Map<String> >String, Map< expanded = const {}, })String, bool> > -
const
-
WorkbenchLayoutState.fromJson(Map<
String, dynamic> json) -
Rebuild from a JSON-decoded map, tolerantly (§spec:layout-state-persistence):
absent concerns default to empty, unrecognized concerns are ignored, and
malformed entries are dropped rather than throwing. A value written by a
different shell version rehydrates without the host guarding versions.
factory
Properties
-
expanded
→ Map<
String, Map< String, bool> > -
Per-container pane expansion: container id → (view id → expanded)
(§spec:view-stack, §spec:section-disclosure).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
Per-container view visibility store: container id → the set of hidden
view ids (§spec:view-container-title, the port of VS Code's
ViewContainerModel). Serialized as a list; fromJson dedupes back into a set.final -
order
→ Map<
String, List< String> > -
Per-container pane order: container id → the full ordered view ids
including hidden panes (§spec:view-stack). Hidden views keep their slot
so re-showing restores their position (§spec:view-container-title).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sizes
→ Map<
String, Map< String, double> > -
Per-container pane body sizes: container id → (view id → body height in
pixels), the seed-plus-commit sizing of §spec:resize-geometry.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reconcile(
Map< String, List< live) → WorkbenchLayoutStateWorkbenchViewDescriptor> > -
Resolve this persisted state against the container's current descriptors
(§spec:layout-state-persistence). For each container in
live: drops arrangement for view ids the descriptors no longer declare, admits newly declared views at their descriptor defaults, and clamps persisted sizes to each pane's geometry ([minBody, maximumBodySize]). Containers absent fromliveare dropped entirely. Controlled visibility views (a descriptor withonVisibleChanged) are excluded from hidden — the host owns their visibility, not the shell store. -
toJson(
) → Map< String, dynamic> - A JSON-encodable primitive map (§spec:layout-state-persistence). Sets serialize as lists so the result contains only JSON primitives; the host owns the codec (JSON, binary, a key–value store).
-
toString(
) → String -
A string representation of this object.
inherited
-
withContainer(
String containerId, {required List< String> order, required Map<String, bool> expanded, required Map<String, double> sizes}) → WorkbenchLayoutState -
Return a copy with one container's
order,expanded, andsizesreplaced. Used by the layout to fold a container's reported arrangement into the aggregate snapshot. -
withHidden(
String containerId, ) → WorkbenchLayoutState - Return a copy with one container's hidden view set replaced.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
applyReorder(
List< String> fullOrder, int fromVisible, int toVisible) → List<String> -
Splice a reorder expressed in visible-pane indices back into the full
fullOrderthat still includes hidden panes (§spec:view-container-title). A header drag reports indices among the visible panes; this maps the drag from indexfromVisibletotoVisibleonto the full order without disturbing hidden views' slots. -
reconcileOrder(
Iterable< String> persisted, Iterable<String> liveIds) → List<String> -
Reconcile a
persistedpane order against theliveIdscurrently declared: keep persisted ids still live, in persisted sequence, then append newly declared ids in live order. The drop/append rule (§spec:view-stack) has one owner — reconcile resolves the persisted blob with it, andWorkbenchViewContainerapplies it to its live order at build.