Dock¶
The dock tree and its dockview layout, the persisted UI state it restores from, and the refresh loop each panel runs.
femforge_workbench.dock
¶
The dock tree: panels as tabs in splits and tab groups, its dockview layout JSON, and the rule for restoring a saved arrangement.
Type Aliases:
-
Builder–Makes a panel's component from the shell, the panel id and the title.
-
Layout–A dockview layout document as JSON.
-
Node–A node of the dock tree: a panel, a tab group or a split.
Classes:
-
Orientation–The axis a dockview branch lays its children along.
-
PlacementDirection–Where add_panel puts a panel relative to its reference.
-
Key–The keys of a dockview layout JSON.
-
NodeType–The two node kinds of a dockview grid.
-
Panel–One tab: its title, the builder that makes its component once the shell exists, and its share of the axis.
-
Tabs–Panels sharing one tab group, the first shown.
-
Split–Panels, tab groups or splits sharing one axis by weight; the axis alternates with nesting, horizontal at the root.
-
Placement–Where add_panel puts one panel: beside, below or within the group of a reference panel.
Functions:
-
template_name–The trame template a panel renders through.
-
panels–Every panel under a node, in authored order.
-
panel_ids–The ids of every panel under a node, in authored order.
-
placements–The add_panel sequence that rebuilds the tree group by group: each sibling beside or below the previous one, tabs within the first.
-
layout_json–The dockview serialization of the authored tree: splits alternate orientation from a horizontal root, weights become sizes, each leaf one tab group.
-
restorable–The saved layout when it names exactly the authored panels, with popout and floating groups folded into the first grid group; else None.
Attributes:
-
AXIS–The nominal extent of each axis the weights are shared over; dockview rescales proportionally.
-
CONTENT_COMPONENT–The Dock component that hosts a server template inside a panel, as Dock.tsx names it.
AXIS
module-attribute
¶
The nominal extent of each axis the weights are shared over; dockview rescales proportionally.
CONTENT_COMPONENT
module-attribute
¶
The Dock component that hosts a server template inside a panel, as Dock.tsx names it.
Builder
¶
Builder = Callable[[Workbench, str, str], PanelComponent]
Makes a panel's component from the shell, the panel id and the title.
Orientation
¶
Bases: StrEnum
The axis a dockview branch lays its children along.
Methods:
-
flipped–The other orientation.
flipped
¶
flipped() -> Orientation
Panel
dataclass
¶
One tab: its title, the builder that makes its component once the shell exists, and its share of the axis.
Attributes:
-
name(str) –The tab title, from which the panel id is derived when
idis None. -
build(Builder) –Makes the panel's component from the shell, the panel id and the title, once the shell exists.
-
weight(float) –[-]: The panel's share of its parent's axis, relative to its siblings' weights. -
id(str | None) –The panel id; None derives it from
name. -
panel_id(str) –The id the dock knows the panel by:
idwhen given, elsenamelowercased with dashes.
name
instance-attribute
¶
name: str
The tab title, from which the panel id is derived when id is None.
build
instance-attribute
¶
build: Builder
Makes the panel's component from the shell, the panel id and the title, once the shell exists.
weight
class-attribute
instance-attribute
¶
weight: float = 1
[-]: The panel's share of its parent's axis, relative to its siblings' weights.
Tabs
dataclass
¶
Panels sharing one tab group, the first shown.
Attributes:
Split
dataclass
¶
Panels, tab groups or splits sharing one axis by weight; the axis alternates with nesting, horizontal at the root.
Attributes:
Placement
dataclass
¶
Placement(panel: Panel, reference: str | None, direction: PlacementDirection)
Where add_panel puts one panel: beside, below or within the group of a reference panel.
Methods:
-
add_on–The position add-on for add_panel, empty for the first panel.
template_name
¶
panels
¶
Every panel under a node, in authored order.
Source code in packages/femforge-workbench/src/femforge_workbench/dock.py
panel_ids
¶
placements
¶
The add_panel sequence that rebuilds the tree group by group: each sibling beside or below the previous one, tabs within the first.
Source code in packages/femforge-workbench/src/femforge_workbench/dock.py
layout_json
¶
The dockview serialization of the authored tree: splits alternate orientation from a horizontal root, weights become sizes, each leaf one tab group.
Source code in packages/femforge-workbench/src/femforge_workbench/dock.py
restorable
¶
The saved layout when it names exactly the authored panels, with popout and floating groups folded into the first grid group; else None.
Source code in packages/femforge-workbench/src/femforge_workbench/dock.py
femforge_workbench.persist
¶
UI state persistence: the UiStateStore protocol and a debounced per-user JSON implementation under the user config directory.
Type Aliases:
-
Data–A persisted document: JSON-ready values by key.
-
Scope–The (user_id, workbench_name) a saved document belongs to.
Classes:
-
StateKey–The documents the shell itself persists per workbench.
-
UiStateStore–Where a workbench keeps its UI state per user: layouts, dropdowns, brushes.
-
LocalJsonStore–One JSON file per (user, workbench, key), written at most once per debounce window; a load sees unflushed saves.
Functions:
-
default_user–The OS user, the local stand-in for an authenticated user id.
-
default_root–The per-user config directory the local store writes under.
UiStateStore
¶
Bases: Protocol
Where a workbench keeps its UI state per user: layouts, dropdowns, brushes.
Methods:
-
load–The document saved under
keyinscope, None when there is none. -
save–Saves
dataas the document underkeyinscope. -
flush–Writes every pending save now.
load
¶
save
¶
Saves data as the document under key in scope.
Parameters:
-
scope(Scope) –The user and workbench the document belongs to.
-
key(str) –The document's name within the scope.
-
data(Mapping[str, object]) –The JSON-ready document.
Source code in packages/femforge-workbench/src/femforge_workbench/persist.py
LocalJsonStore
¶
One JSON file per (user, workbench, key), written at most once per debounce window; a load sees unflushed saves.
Methods:
-
path–The JSON file of one document.
-
load–The document: a pending save first, else the file's, None when neither exists.
-
save–Queues the document and restarts the debounce timer that writes it.
-
flush–Writes every pending document now.
Source code in packages/femforge-workbench/src/femforge_workbench/persist.py
path
¶
load
¶
The document: a pending save first, else the file's, None when neither exists.
Source code in packages/femforge-workbench/src/femforge_workbench/persist.py
save
¶
Queues the document and restarts the debounce timer that writes it.
Parameters:
-
scope(Scope) –The user and workbench the document belongs to.
-
key(str) –The document's name within the scope.
-
data(Mapping[str, object]) –The JSON-ready document.
Source code in packages/femforge-workbench/src/femforge_workbench/persist.py
flush
¶
Writes every pending document now.
Source code in packages/femforge-workbench/src/femforge_workbench/persist.py
femforge_workbench.feeds
¶
A panel's refresh loop: one task per panel, polling off the server loop and publishing on it.
Classes:
-
Feed–Runs
pollin a worker thread everyperiodseconds and hands what it returns topublishinside a state context. -
QueueFeed–Drains an asyncio queue another party feeds on the server loop, handing each burst of items to
publishinside a state context.
Feed
¶
Feed(panel: PanelComponent, period: float, poll: Callable[[], T], publish: Callable[[T], None])
Runs poll in a worker thread every period seconds and hands what it returns to publish inside a state context.
Parameters:
-
panel(PanelComponent) –The panel whose state the publish runs in.
-
period(float) –Seconds between polls.
-
poll(Callable[[], T]) –Reads what changed, off the server loop.
-
publish(Callable[[T], None]) –Writes a poll's result into the panel, on the server loop.
Methods:
-
start–Starts the loop unless it already runs; the first poll happens immediately.
-
stop–Cancels the loop, so a hidden panel costs nothing.
-
cycle–Poll, publish, sleep — until the task is cancelled; a failed poll is logged and the loop carries on.
Attributes:
-
polls–How many polls have completed; a panel shows it as its refresh count and the tests wait on it.
-
running(bool) –Whether the loop runs.
Source code in packages/femforge-workbench/src/femforge_workbench/feeds.py
polls
instance-attribute
¶
How many polls have completed; a panel shows it as its refresh count and the tests wait on it.
start
¶
Starts the loop unless it already runs; the first poll happens immediately.
Source code in packages/femforge-workbench/src/femforge_workbench/feeds.py
stop
¶
Cancels the loop, so a hidden panel costs nothing.
Source code in packages/femforge-workbench/src/femforge_workbench/feeds.py
cycle
async
¶
Poll, publish, sleep — until the task is cancelled; a failed poll is logged and the loop carries on.
Source code in packages/femforge-workbench/src/femforge_workbench/feeds.py
QueueFeed
¶
QueueFeed(panel: PanelComponent, subscribe: Callable[[AbstractEventLoop], Queue[T]], unsubscribe: Callable[[Queue[T]], None], publish: Callable[[list[T]], None])
Drains an asyncio queue another party feeds on the server loop, handing each burst of items to publish inside a state context.
Parameters:
-
panel(PanelComponent) –The panel whose state the publish runs in.
-
subscribe(Callable[[AbstractEventLoop], Queue[T]]) –Hands out a queue fed on the given loop.
-
unsubscribe(Callable[[Queue[T]], None]) –Stops feeding a queue
subscribehanded out. -
publish(Callable[[list[T]], None]) –Writes a burst of items into the panel, on the server loop.
Methods:
-
start–Subscribes and starts draining unless it already runs.
-
stop–Cancels the drain and unsubscribes, so a hidden panel is no longer fed.
-
cycle–Wait for an item, take every other one already queued, publish them together — until the task is cancelled.
Attributes:
-
bursts–How many bursts have been published; the tests wait on it.
-
running(bool) –Whether the drain runs.
Source code in packages/femforge-workbench/src/femforge_workbench/feeds.py
start
¶
Subscribes and starts draining unless it already runs.
Source code in packages/femforge-workbench/src/femforge_workbench/feeds.py
stop
¶
Cancels the drain and unsubscribes, so a hidden panel is no longer fed.
Source code in packages/femforge-workbench/src/femforge_workbench/feeds.py
cycle
async
¶
Wait for an item, take every other one already queued, publish them together — until the task is cancelled.