Flow Editor
Framework-layer visual editor and viewer for softa flow-starter definitions, built on @xyflow/react v12. It renders the design-time graph (DesignFlowDefinition), drives the full draft lifecycle (autosave with optimistic locking, validation diagnostics, publish/versioning, test runs), and exposes a read-only canvas for instance monitoring. The authoritative backend contract is the Flow docs’ API & Data page (the design APIs, the node descriptor contract, frontend graph compatibility); this component implements it verbatim.
Quick start
// Editor page (always the SSR-safe lazy entry — xyflow measures the DOM):
import { FlowDesignerLazy } from "@/components/flow/flow-designer-lazy";
<FlowDesignerLazy flowId={flowId} toolbarStart={<BackButton />} />
// Read-only render of a published snapshot with a run-state overlay:
import { FlowViewer, useInstanceOverlay } from "@/components/flow";
const { overlay, trace } = useInstanceOverlay(instanceId);
<FlowViewer definition={bundleDetail.design!} overlay={overlay} />Public API
| Export | Purpose |
|---|---|
FlowDesigner / FlowDesignerLazy | Self-contained designer: palette, canvas, property panel, toolbar, autosave, 470 conflict dialog, validation diagnostics, publish dialog, version history, test runs. FlowDesignerProps = { flowId, readOnly?, toolbarStart?, requestFormView?, className? } (toolbarStart: page controls before the flow name, such as a Back button; requestFormView(modelName): the form an approval flow’s test run fills in — see Test runs & overlays). Always mount the lazy entry from Next.js pages. |
FlowViewer | Read-only canvas: { definition, overlay?, onNodeClick?, fitView?, className? }. Render history from the bundle’s ?include=design snapshot and an instance from GET /flow/instances/{instanceId}/design, the same snapshot read through the instance — the compiled graph drops width/height/data/label and cannot repaint faithfully. It keeps its own xyflow store (its own ReactFlowProvider), so it can sit inside the designer — the revision preview does — without touching the designer’s canvas. Node icons come from GET /flow/nodeDescriptors, a read no instance admits: a page that shows a canvas grants FLOW_CANVAS_READS (flow-endpoints.ts) in one of its own permissions. Left out, the canvas still draws, every node with the fallback icon, and the refused read raises the global no-access toast. |
FlowInstanceDiagram / FlowInstanceDiagramLazy | One instance’s read-only canvas from its id alone: the design it runs (GET /flow/instances/{instanceId}/design) painted with the overlay, read once and again from the Refresh button in its corner — not polled: an approval moves when someone acts on it. A caller the instance refuses sees “You don’t have access to this approval’s diagram” in place, without a toast. For showing an instance away from the monitor pages (a record’s approval panel); the lazy entry keeps xyflow out of the page until it renders. Both reads go through the instance and admit its submitter and task holders, and anyone else whose permissions reach the instance — or, for a record’s approval, the record — and, on a record’s submission, whoever sees that record’s approval (see A record’s approval and its steps); a participant holds no permission on the bundle itself. A record’s approval panel offers its Flow button on every submission: whoever sees the record’s approval opens the diagram of each submission of it. |
useInstanceOverlay(instanceId, { enabled?, meta? }) | An instance’s run-state overlay and trace, read once and again on refresh() — an instance waiting on people changes only when someone acts, so nothing polls. The trace accumulates through sinceSequence: each read continues from the last one’s cursor, and a refresh asked for while a read is out runs after it. meta goes with both reads: a page that explains a refusal itself (the instance detail page’s “no access”) passes suppressErrorToast: [403], rather than have each read toast it too; pass a stable object (a module constant), since a new one pulls the trace again. |
TraceList | An instance’s trace, oldest first, scrolled to the newest as more arrive: { trace, nodeLabels?, className? }. Each event shows its time, its type as the FlowTraceEventType option set labels it (humanized until the set loads), the step it happened at by its label — nodeLabels, the design’s labels by node id, which the instance page passes; a node they do not name shows its id — and its message in full; a FlowFailed event reads in red. |
registerConfigControl(type, component) | App-level extension seam for the property-panel control registry (see below). |
FlowPickerModelsProvider / DEFAULT_PICKER_MODELS | Overrides the models behind rolePicker/positionPicker (defaults: Role/JobPosition), keeping the package model-agnostic. userPicker/deptPicker have no model to override: they pick from flow-starter’s directory (/flow/directory/**, granted by the pages whose pickers read it in their own permissions — see src/components/directory/directory-endpoints.ts) through the shared PeoplePicker/DepartmentPicker (src/components/directory/). |
toReactFlow / fromReactFlow | The pure adapter between backend FlowGraphDocument and xyflow state (see mapping rules). |
@/components/flow/types | Full TS mirror of the backend DTO surface (wire enums are PascalCase string unions). |
Backend contract mapping
Backend nodes carry label/config/width/height as top-level fields; xyflow keeps custom payload in node.data. toReactFlow hoists them into data on load, fromReactFlow extracts them back on save; everything else in node.data / graph.metadata / definition.metadata is compiler-ignored passthrough and survives the round trip untouched. Conditions live on EDGES, one of two kinds: condition (a rule, the platform Filters JSON) and conditionExpression (AviatorScript); each maps to the same key in edge.data, and an empty one is dropped on save. Node/edge ids are frontend-generated stable strings (approval_k3x9q2 / edge_p0m2aa) — the server never mints or rewrites them. Rendered measured dimensions are persisted so historical snapshots repaint fully; on load they seed only a node’s first paint (initialWidth/initialHeight) — as xyflow’s width/height they would hold the node at the saved size, so one renamed since could never take its own. Those sizes also tell whose the positions are: a graph whose nodes carry no size was never saved from the canvas — seed data, a design written through the API, a new flow’s Start — so nobody chose its positions, and it opens laid out as the toolbar’s Auto layout lays it out, then fitted (hooks/use-auto-arrange.ts). Centering nodes takes their rendered sizes, so the layout runs once every node is measured and again whenever a measured size changes (nodes resize as the descriptors arrive). In the designer it is display only and holds until the first edit, which saves it with everything else; opening a flow saves nothing. A graph saved from the canvas keeps its positions, tidy or not; Auto layout tidies one saved untidy. FlowViewer lays out the same way, so the history preview and instance diagrams match what the designer shows. Positions/viewport round to 2 decimals to kill float drag noise.
Save / version / publish semantics
Structural changes bump a mutation counter (dirty = counter > savedCounter — no deep diffs); autosave debounces 2s, is single-flight with a watermark re-queue, and flushes on tab hide/unload. Every successful save adopts the returned draft version (optimistic lock). A 470 opens a blocking conflict dialog: Reload (adopt remote, drop local) or Overwrite (re-save local over the remote version) — no three-way merge. Publishing flush-saves, validates (errors block, warnings advise), then POST /{id}/publish; publish bumps the draft version, so the draft is reloaded afterwards. A refused publish (400) that carries compile diagnostics puts them on the canvas; one that carries none — refused for a reason outside the canvas, such as another flow that would take the same records — shows the server’s reason in the dialog, in place of “Validation passed”. The History sheet lists bundles — each keyed by its bundleId (a bundle summary carries no id), dated by publishedAt, marked by active and showing its changeDescription; Activate (POST /flow/bundles/{bundleId}/activate) switches the runtime revision without touching the draft, Restore (POST /{id}/restore?bundleId=) overwrites the draft canvas with a snapshot, and View opens the revision’s ?include=design snapshot. The menu beside Publish disables or enables the flow (canvas/toolbar/flow-enablement-menu.tsx, disabling asks first), and the toolbar then shows a Disabled badge; the switch is independent of publishing and of the effective revision, and reaches the editor state as enabled from GET /{id}/status. Switching also moves the draft version on, so the menu does what publishing does: it flushes unsaved edits first (and switches nothing when they fail to save), then reloads the draft, so the next autosave does not hit a version conflict. The disable confirmation says that a flow with instances still in progress, or one an enabled flow calls as a subflow, can’t be disabled; the server’s refusal is shown once by the global error toast. The Flow Designs list has a Status column (Disabled / Not published / Enabled) and Disable / Enable row actions; a row opens its flow in the designer, for whoever holds Open Designer — there is no separate button for it.
Toolbar
The toolbar (canvas/toolbar/flow-toolbar.tsx) starts with a part as wide as the palette below it (PALETTE_WIDTH_CLASS in lib/designer-layout.ts, which the palette reads too), so its right border continues the palette’s — the toolbar’s one line; its other groups are set apart by space. That part holds the page’s toolbarStart controls (the edit page’s Back arrow) and the name, a read-only title — past that part’s width it ends in an ellipsis, the whole of it in the tooltip — that opens Flow settings with their Name field focused when clicked: the name is edited there, with the other flow-level settings, where a flow-level diagnostic such as a missing name leads. Over the canvas follow the publish badges, the save status (“Saved”, without the draft’s version: that is the optimistic lock’s counter, one more at every save, and beside the published “v3” it read as a second version of the flow), then undo, redo and Auto layout; at the right, what happens to the flow: History and Test run (an approval flow’s only), then Settings, plain like them (the panel’s header says when it shows the flow’s settings) and sitting above the panel it switches, and Publish, one split button with its on/off menu. The scenario has no badge there: fixed when the flow is created, it is shown under the Flow settings panel’s title and in the flow list. There is no Save button: the designer saves 2s after an edit, and while there is something to save — unsaved changes, or a save that failed — the save status itself saves now when clicked. There is no Validate button either: the flow is validated each time it loads (opened or reloaded) and 2s after each edit, and the diagnostics bar under the canvas says what it found, “No issues” when clean.
Validation diagnostics
Three layers per the contract: local (RHF required/min, descriptor-port connection rules, local cycle detection — a connection they refuse is not drawn, and releasing it over the refused handle toasts the reason) → debounced 2s server validation of the in-memory document → mandatory all-green gate before publish. CompileDiagnostics anchor to nodes (a ring — red for an error, amber for a warning, outranked by the selection ring — plus a count badge), edges (the stroke in the same tones), or panel fields — a diagnostic about a connection marks both its edge and the node it leaves, and the trigger’s mark the Start node, where the trigger is edited. The bottom diagnostics drawer shows each message in full, with where it points as people read it (Step Direct Manager · Approvers, Connection Manager → HR, Trigger · Start, Flow settings; the code and ids in the tooltip), and a row selects and centers its anchor — a connection first, its edge form opening; a flow-level one opens Flow settings. The drawer opens when a decision meets errors: the flow loading (each load is validated once: opening it, and the reloads after Publish, a switch on or off, a restore or a conflict) and Publish — the dialog lists the blocking errors themselves, each closing it and leading to what it is about, and a publish the compiler refuses opens the drawer too; while editing, the 2s server validation only turns the header line red. Once the flow has been checked the bar stays under the canvas — “No issues” when clean — so validation needs no button (the diagnostics context’s checked tells a flow not yet checked from a clean one). The property panel does not repeat them — the drawer lists every message and the canvas marks the node or connection — but a step’s errors on a config field (config.<path>) stand on that field until the next validation. A node the Start cannot reach is an error (UNREACHABLE_NODE): it would never run, and a parallel join it feeds would wait for it forever — the draft still saves, only publishing is blocked. So is a node without a label (MISSING_NODE_LABEL): the label is the step’s name people see in the approval center and the audit trail. The panel’s Label field is marked required; emptied, it says “Label is required.” and is not committed — the node keeps its last label — and a node loaded without one shows the same error. New nodes start with their type’s name. The server names what a diagnostic is about as people see it: a node by its label, an edge by its label or else as source → target; each raw node / edge id stays in each drawer row’s tooltip, which tells two nodes of the same name apart. Contract behavior worth knowing: while structural errors exist the server suppresses semantic checks — fix structure first, then semantic diagnostics appear.
Inserting nodes
Hovering or selecting a connection shows a + at its middle (beside its chip when it has one); it opens the node types that can go into a connection — the palette’s groups without the Start and End (canvas/palette/node-type-picker.tsx) — and inserts the one picked (insertNodeOnEdge). The connection keeps its id, label and condition and now ends at the new node, because a condition belongs to the branch leaving the source and a gateway’s routing config names its outgoing edges by id; a fresh, unconditioned edge carries on to the old target (lib/node-insertion.ts splitEdge). The node takes the column of the branch it joins — the target’s under a split, the source’s above a merge — with a rank gap on each side; when the target sits too close, it and everything downstream of it move down and nothing else does (placeInsertedNode). A palette node dropped on a connection is inserted the same way, the connection highlighted while the drag is over it. A connection dragged from an output and released on empty canvas opens the same menu, End included, and creates the picked node there, already connected, its input at the release point (addConnectedNode); an output that takes no more connections says why instead. Each is one undo step and selects the new node. The + and the drop highlight come from store/canvas-editing-context.tsx, which only the editable canvas supplies, so the read-only viewer shows neither.
Deleting nodes
Hovering or selecting a node shows a × at its top-left — opposite its diagnostic count — that deletes it with its connections, as Delete / Backspace does with the selection. Both go through onBeforeDelete (canvas/flow-canvas.tsx), which keeps the Start node: it carries the trigger, so it has no ×. A deletion is one undo step, its connections included. Like the connection’s +, the × comes from store/canvas-editing-context.tsx (deleteNode), which only the editable canvas supplies, so the read-only viewer and a canvas a test run locks show none.
Property panel & control registry
What a field means or does sits behind a help icon after its label (panel/field-help.tsx — FieldHelp, and FieldLabelRow for a label with its help; ConfigFieldShell takes help), shown on hover or keyboard focus, as a model form’s field description is — not as a caption under the field, which in a 320px panel took more room than the fields: the flow settings, the trigger’s fields, a condition’s note per kind, an enum’s hintBy and optionDescriptions, field permissions. The icon sits beside the label, never inside it, so the control’s accessible name stays the label. Text that stands in for a control stays in place: “Select a model first”, the default edge’s “Other”, a Subflow trigger’s note.
The panel is descriptor-driven: GET /flow/nodeDescriptors supplies configSchema per node type (deployment-dependent — never hardcoded), rendered through a control registry keyed by the contract’s control-type vocabulary: string number boolean enum expression template cron stringList json keyValueMap fieldMapping filters orders model variableRef recordField userPicker deptPicker rolePicker positionPicker recordPicker flowPicker nodeId approverSources fieldPermissionMap. depends gives strict-equality conditional visibility (hidden fields keep their values); a number left empty shows its default as <value> (default); an enum left unset shows its default as <label> (default), says behind its help icon what the chosen (or default) value does from optionDescriptions, each group of an approverSources hides sources marked deprecated unless the config already holds one, and hintBy adds to that help by another field’s value (an approval step’s “If nobody is found” says when it applies by the source of its one group of approvers; with several, that it applies when none of them finds anyone); sourceField feeds model-driven controls (fieldMapping/filters/orders read the sibling model). filters/orders reuse the framework FilterBuilder/OrderBuilder via a synthesized MetaField; a data node’s filters run as a query of its model, so they also open its to-one relations one level (a ModelFieldSourceProvider with cascade), as every list filter does. approverSources is who approves a step (ApproverSourcesControl in controls/approval-controls.tsx): one or more groups, everyone they find approving together, the vote threshold counting over them all — the Approvers label’s help says so. Each group is one select over the sources the descriptor offers, in its order — “Specific people” (Users, its userIds a user picker) first, then one person found (supervisor, department leader, department HRBP, and “Person on the record” — RecordField, whoever a field of the record names) and the groups’ (role, position, department members); none takes its people from a variable typed in — each recursing into the registry for its nested fields (paths such as approverSources.1.userIds); switching sources resets the group to just its type. Add approvers adds a group on the first option; with several, each group’s select is “Approvers, group N”, with a button beside it that removes it, down to one. A new step starts with one group on Specific people (the Approval descriptor’s defaultConfig). A CC rule’s recipients are one group (ApproverSourceControl), from the same sources. An approval step’s setting that applies only to some steps carries appliesWhen, which the field list judges from the step’s groups (isFieldVisible / fieldApplies in lib/config-zod.ts), showing it only where it applies — the backend ignores it elsewhere: severalApprovers (the vote threshold and its count and percentage: several groups, or one naming several people or of a source not marked findsOne), approversFoundByRule (“If nobody is found” and its roles: a group of a source with a type that names no people). recordField (RecordFieldControl in controls/reference-controls.tsx) picks a field of the record the flow approves by its label, from the trigger variables whose modelName is one of the schema’s targets (recordFieldOptions in lib/record-fields.ts): a person on the record from a field onto Employee or UserAccount (hinted with the model it points at), a department-based source’s “Department in a field of the record” (deptScope: VARIABLE_DEPT, its deptVariable) from one onto Department; only the record’s own fields, nothing typed in, and nothing offered when the flow approves no record — publishing refuses any other field. The source options’ names (the field specific people are named in, userIds) and findsOne (the source finds one person at most: a supervisor, a department leader or HRBP, a person on the record) come from the descriptor; the editor hardcodes no source type. Unknown control types render a visible non-crashing fallback. Expression controls use CodeMirror with variable autocompletion from GET /{id}/availableVariables plus a debounced GET /toolkit/validateExpression syntax check. A Cron trigger’s Schedule is panel/cron-input.tsx, the shared cron editor (CronEditor, see Widgets): a button that says what the schedule means, opening a panel to pick a common schedule (every few minutes, every hour, day, weekday, week or month), set the fields one by one, or type the expression — always Quartz with a single second: a flow has one cron language, the scheduler’s Quartz, and runs at most once a minute. It asks GET /flow/cron/preview how publishing would judge the expression — the scheduler’s rules, and at most once a minute — and shows why it would be refused, or what it means and its next runs in the server’s zone; Apply stays off while it is refused. The template control (controls/template-control.tsx) edits text interpolated as the node runs: its {x} menu inserts a variable the node sees as {{ name }} at the cursor, and what publishing would refuse — a placeholder left open, empty, or not compiling — is said under it. Expressions and templates both carry Try it (controls/try-it.tsx): a sample value for each variable they read (JSON where it parses), sent to POST /flow/expressions/preview, which answers with the result and its type or why it does not run. stringList is a tag input (panel/tag-input.tsx); json is parsed and stored as the field is left, text that does not parse staying in the field, said so; recordPicker picks a record of the schema’s model; flowPicker (a Subflow node’s target) offers only the flows a Subflow node can call — the enabled Automation flows whose effective revision has a Subflow trigger (GET /flow/designs?subflowTargets=true), never one that would fail the node at run time; model and the record pickers (rolePicker/positionPicker/recordPicker) read their candidates 20 at a time, the next page as the list is scrolled to its end, up to 200, after which the list says to type to narrow down; a keyValueMap edits its values as expressions or templates by valueType, and keeps its rows locally, so a row added stays on screen until its key is written. In these map controls a key written on two rows is saved from the first only, and the later row says “Already listed above” instead of replacing the first one unseen. fieldPermissionMap (an approval step’s field permissions) picks its fields from the model of the record the flow starts on — the trigger names it — and leaves the fields already listed out of the list; a flow that starts on no record still names its fields by hand. A row it adds starts as Readonly, so none is saved without a permission; a row an older draft saved without one is flagged in the panel and refused by validation and publishing. A record picker names what is selected with the label picked with it, else by asking for it (searchName with [valueField ?? "id", "IN", values]), so a pick never turns into its id when the search moves on or the panel reopens; userPicker and deptPicker are the shared directory pickers (PeoplePicker / DepartmentPicker in src/components/directory/), showing 20 more as the list is scrolled to its end, up to 200, whose reads the designer’s Open Designer permission carries, and which name saved values the same way through GET /flow/directory/people/all/by-ids / GET /flow/directory/departments/by-ids — the user picker (the specific people of a step or a CC rule) searches the whole directory (everyone, GET /flow/directory/people/all): people who can sign in and act, each with their employee code, department and position beside the name, and the accounts without an employee record (a tenant’s administrators, hinted “Account”); a saved person who can no longer act keeps their name, marked inactive, and validation warns about it; the department picker shows each department’s code and parent.
A connection’s form edits its label and its condition, as a Rule or an Expression (panel/condition-editor.tsx, which a data-change trigger’s condition uses too). A rule is built with the framework’s FilterBuilder over the model of the record the flow starts on (a Submit / Entity Change trigger), offered only the record fields the backend lists for the edge (Trigger variables of availableVariables?nodeId=<source>&afterNode=true, to-many relations left out) and, up to two levels on through the record’s relations, the fields the backend lists for each relation (ruleFields on its variable: employeeId.departmentId reads as Employee › Department, employeeId.departmentId.costCentreId as Employee › Department › Cost Centre) — ruleFieldNames(variables, throughRelations) turns them into the builder’s allowedFields, whose paths open just those relations, a second-level one inside the first; the backend judges the rule like a field condition. The engine reads a path’s value from the related record when the flow starts — at submission for an Approval flow, again after an approver’s edits — and keeps it with the record’s own, so every route decides on what it was then. An edge’s rule and an Approval flow’s trigger condition read through relations (ConditionEditor’s throughRelations); a data-change trigger’s condition, decided on the change itself before any run starts, reads the changed record’s own fields only. The builder’s dialog says which, under its title (the Filters widget’s dialogDescription). An expression is the CodeMirror editor with the variables the edge sees, the source node’s own outputs included. An edge holds one kind: switching with a condition in place asks first, then clears it. Most conditions are rules, so the condition editor shows the rule builder and keeps the expression behind a quiet switch at the end of the “Condition” label row (“Use expression”, and “Use rule” back): a condition held as an expression opens on the expression, a flow that starts on no record — no rule to switch to — shows only the expression, and a read-only condition has no switch. The condition’s help says how the edge’s source chooses: from an inclusive gateway every edge whose condition holds is taken, and an edge without a condition is the default — taken only when no other edge’s condition holds, at most one per gateway; from any other node the first edge, in order, whose condition holds is taken, and an edge without a condition is the default, at most one per node. Such a node tries its conditional edges in order (priority, 1 first; edges without one after, in drawing order; the default last — lib/edge-priority.ts, as the engine orders them): with two or more edges, the canvas leads each edge’s chip with its place (“1”, “2”… and “Other” on the default; an inclusive gateway, which takes every edge that holds, gives no places but still marks its default; and while a node has more than one edge without a condition, each of them reads “Add condition” on a dashed chip, since all but one need one — edgeOrderLabels, served through store/edge-order-context.tsx to the editor and the read-only viewer, never written into edge data), and the form shows “Tried n of m” with buttons that move a conditional edge earlier or later (moveEdge, which numbers all of the node’s conditional edges from 1). The default’s priority is never saved. On the editable canvas the chip is the way to the condition: it takes a pointer cursor and a hover border, and a click on it selects the connection, opening this form — React carries the click from the label layer’s portal to xyflow’s edge, so the chip needs no handler of its own. An edge leaving a parallel fork has no condition: the fork takes all of its edges and never reads their conditions, so the form says so in place of the condition editor, and the chip shows no place. On the canvas a rule reads in the model’s terms — field labels, a path by its labels (Department › Cost Centre), option labels, record names — through the list filter’s preview, and in its stored terms until the metadata arrives.
With nothing selected on the canvas the panel shows Flow Settings, as the toolbar’s Settings button does — on the right, above the panel it switches. Flow Settings holds the flow’s name — required as a node’s label is: emptied, it says “Name is required.” and is not committed — and the settings its scenario takes (lib/scenario-rules.ts, mirroring the backend compile rules — a setting outside the scenario is neither shown nor saved). The scenario is set when the flow is created and never changes, so it is no field of the form: it heads the panel, under its title (“Flow settings / Approval”, as a node’s header names its type), with the scenario’s one-line description in the header’s description line (an approval flow’s is “Approves a submitted record and writes the outcome back to it: its steps are people and routes.”). The node palette is filtered by the backend (GET /flow/nodeDescriptors?scenario=), so an approval flow’s palette offers people and routes only: Start, End, Approval and the gateways. An Approval flow’s settings come in three sections by whom they are about, each a section named by its heading: Submitter (May withdraw; May urge; Urge interval (hours), urgeIntervalHours — hours, as the reminders are), Approvers (May return to the submitter; Remind after (hours); When the submitter is an approver, selfApproval, which covers the submitter only; When an approver approved an earlier step, approverDedup — Global approves for them, Contiguous only when it was the step just before, None asks them again) and Notifications (Send email notifications; CC). An Automation flow’s two settings (Synchronous execution, Rollback on failure — sync / rollbackOnFail) follow the name with no heading. A switch is named by its label. The trigger is configured on the Start node (panel/trigger-editor.tsx), whose card shows its summary (“Submit · ExpenseClaim”); a flow without a trigger opens with its Start node selected, one with a trigger on Flow Settings. An approval flow’s Start node shows “Submitted for approval: availableVariables without a nodeId: the record’s fields and _triggerType and its kin); a schedule is edited and previewed by the same cron editor (CronInput). The New Flow dialog (app/flow/flow-design/components/new-flow-dialog.tsx) offers the Approval and Automation scenarios only: an approval flow picks its document (GET /flow/approvalModels, every approvable document, those with approval flows marked ”— has N approval flow(s)”), an automation flow its trigger and, for a data-change trigger, its model; once created, only the scenario and an approval flow’s document are fixed. Approval flows can be duplicated too: the copy is an unpublished draft with the same document and condition, and the duplicate dialog and toast say to change the condition before publishing. An approval flow sets its CC in Flow Settings (panel/cc-rules-editor.tsx): each rule’s timing — on submit, approved, rejected — and its recipients, recipientSource, one group, chosen in the same select as each group of a step’s approvers — the sources of the Approval descriptor’s own approverSources, so every source a step offers is offered here, a new rule starting on its first option, specific people; several groups at one timing are several rules; approval nodes carry no CC of their own. The rows live in a local form, commit to the editor state as they change, and remount on every (re)load (loadGeneration).
Test runs & overlays
Test run is an approval flow’s only (the toolbar shows the button when the flow’s trigger is Submit): what submitting a request would do under the draft, worked out and never run — nothing is started, saved or sent.
- The dialog (
test-run/test-run-dialog.tsx) asks who submits (“Submitted by”, the directory’sPeoplePickerwitheveryone, the current user to begin with) and for the request, on the formFlowDesignerProps.requestFormView(modelName)gives — the HCM page passes the approval center’s view of that model without its blocks (testRunRequestView); without one the request goes with its employee alone. The form is aDialogFormin create mode with no schema: no field is required, only those the flow reads matter, and the employee left empty is the submitter’s own. - Preview saves the canvas, then posts the form’s save payload to
POST /flow/designs/{id}/preview— ids and dates as text, a table as the rows it creates, which the server types by the model’s fields; a draft that does not compile closes the dialog and lists its diagnostics, as Publish does, and any other 400 (a value a field cannot take, say) is said as the server words it, the dialog left open and the diagnostics as they were (testRunRefusal; the request layer leaves the preview’s 400 to the dialog). A value the server works out is never read from the form: an expense claim’s test run routes on the sum of the lines filled in. - The result (
FlowDesignPreview) locks the canvas read-only and marks the route on it (test-run/test-run-marks.tsthroughstore/test-run-context.tsx): every node it passes gets a chip and ring — passed, waits for approvers, known only once it runs, stops here — an approval step says under its name whom it waits for or why it passes on its own, and nodes and edges off the route are faded. Below the canvas, in the diagnostics bar’s place, the steps read as the record page’s “If submitted now”ApprovalPreviewCardreads them (onApprovalSteps, every step drawn as one not reached yet, see Approval panel), the submitter named rather than “you”, after a warning when the flow’s submit condition would not take the request. A bar over the canvas names the submitter and has Change request (the dialog again, filled in as it was) and Exit test run.
Run-state overlays are FlowViewer’s, for instance pages: nodes paint their run state (Completed / WaitingApproval / WaitingAsync / Failed) from store/overlay-context.tsx.
Undo / redo
Graph-only snapshot history (cap 50): node/edge add/remove/move, inserts, connects, label/config/edge edits, and auto-layout are undoable via toolbar or Cmd/Ctrl+Z (Shift for redo); flow-level settings (name, trigger, flags) are deliberately excluded. A config commit that changes nothing — the panel’s form re-committing as a node opens in it — is no edit: it takes no step and leaves the draft clean. The layout a graph nobody arranged opens with is no step either. History resets on load/reload/restore.
Theming & density
styles/flow-theme.css maps xyflow’s --xy-* variables onto the project palette (only theme variables, no literal colors — dark mode flips automatically). Node/edge/panel visuals use density tokens (--ds-*/--ui-*); category accents map to chart-* palette slots. Every node is drawn one fixed width whatever its label (lib/node-size.ts: 240px, an End 160px): the canvas stores a node’s top-left corner, so a node sized by its text would grow to the right when renamed and pull its handles off the line its edges run on; text that does not fit is cut short, whole in its title. Start and End are round pills on solid discs of their own — Start green with a play, End grey with a stop — told apart by their ports rather than their shared Control category (nodeStyle in lib/category-styles.ts, NodeIcon in lib/icon-registry.tsx), so the canvas card, panel header, palette and type picker agree; every other node takes its category’s tint and its descriptor’s icon. The icon registry maps every icon name the built-in descriptors send; an unknown one (a custom executor’s) draws as a puzzle piece. Every edge ends in an arrowhead that FlowEdge draws as its own marker rather than through xyflow’s markerEnd, whose markers are one fixed color shared by all edges; the theme colors it with its line — default, diagnostic (the edge overrides --xy-edge-stroke), selected or focused.
Known limitations
availableVariables reads the last saved draft, so new upstream variables appear in autocompletion after one autosave tick. Undo covers the graph only. No collaborative editing — 470 offers reload/overwrite, not merge.
Testing
Pure logic is unit-tested in tests/flow-*.test.ts: graph adapter round-trips, id generation, connection rules (ports + cycles), node insertion (edge split, placement), configSchema→zod, dagre coordinate conversion, telling a graph nobody arranged from one saved from the canvas, and diagnostics normalization. Interactive flows are covered by the flow module’s Playwright smokes.