Flow Studio
Store State Shape
workflowStore holds six top-level state fields: nodes, edges, viewport, selectedNodes, selectedEdges, and processId. Understanding the shape of each field is fundamental to writing correct components and selectors.
State Fields
| Field | Type | Purpose |
|---|---|---|
nodes | WorkflowNode[] | All nodes on the canvas |
edges | WorkflowEdge[] | All connections between nodes |
viewport | Viewport | Camera position: x, y, zoom |
selectedNodes | string[] | IDs of currently selected nodes |
selectedEdges | string[] | IDs of currently selected edges |
processId | string | null | The workflow definition ID being edited |
WorkflowNode Type
// workflow.types.ts
export interface WorkflowNode {
id : string; // Unique node ID (GUID)
type : string; // TypeCode — matches the executor's NodeType
position : XYPosition; // { x: number, y: number } — top-left corner on canvas
data : WorkflowNodeData; // Config + port definitions
}
export interface WorkflowNodeData {
label : string; // Display name on canvas
config : Record<string, unknown>; // Node-specific settings
inputPorts : NodePortDefinition[]; // Declared input handles
outputPorts : NodePortDefinition[]; // Declared output handles
}
export interface NodePortDefinition {
id : string;
label : string;
isTimeoutPort?: boolean; // True for HIL timeout ports
}
WorkflowEdge Type
export interface WorkflowEdge {
id : string; // Unique edge ID
source : string; // Source node ID
sourceHandle : string; // Source port ID (output port)
target : string; // Target node ID
targetHandle : string; // Target port ID (input port)
data? : WorkflowEdgeData;
}
export interface WorkflowEdgeData {
label?: string; // Optional edge label (e.g., condition name)
}
Viewport Type
export interface Viewport {
x : number; // Horizontal pan offset (pixels)
y : number; // Vertical pan offset (pixels)
zoom : number; // Zoom level (1.0 = 100%)
}
Example State Snapshot
{
"processId" : "proc-001",
"selectedNodes": ["node-abc"],
"selectedEdges": [],
"viewport" : { "x": -120, "y": 80, "zoom": 0.85 },
"nodes": [
{
"id" : "node-abc",
"type" : "ApprovalNode",
"position": { "x": 400, "y": 200 },
"data": {
"label" : "Manager Approval",
"config" : { "actorId": "{{$context.managerId}}", "timeoutDuration": "P1D" },
"inputPorts" : [{ "id": "in", "label": "In" }],
"outputPorts": [
{ "id": "approved", "label": "Approved" },
{ "id": "rejected", "label": "Rejected" },
{ "id": "timeout", "label": "Timeout", "isTimeoutPort": true }
]
}
}
],
"edges": [
{
"id": "edge-001", "source": "node-trigger", "sourceHandle": "out",
"target": "node-abc", "targetHandle": "in"
}
]
}
processId is the workflow definition ID — not the execution ID. It identifies which workflow blueprint is being edited. The execution ID lives in
executionStore and is only present during an active or past run.