Skip to content

Canvas Modes

The WorkflowSurface component operates in one of three modes: edit, readonly, and sim (simulation). Each mode configures every panel in the surface — topbar, canvas, inspector, bottom panel, and status bar — through a pure-data contract defined in workflowSurfaceContract.ts. This means mode behavior is declarative: changing a mode flips a set of flags, and every component reads its rules from the contract.

Edit mode is the primary authoring surface. This is the mode you see when you open a workflow from the Flows page.

PanelBehavior
TopbarWorkflow name is editable (click to rename). Save button appears, enabled when there are unsaved changes. Run button visible. No execution metrics.
CanvasNodes are draggable. Connections can be created. Nodes can be deleted (Backspace key). Cost badges show estimated values.
InspectorOpens on double-click. Fields are editable. Tabs: Overview, Prompt, Conditions.
Bottom panelCollapsed by default. Tabs: Logs, Runs.
Status barShows block and edge counts (e.g., “3 blocks, 2 edges”). No execution metrics.
Tab toggleBoth Canvas and YAML tabs are available.

Readonly mode is used when viewing a completed run. Nothing is editable — the surface is a read-only inspection view.

PanelBehavior
TopbarWorkflow name is not editable (links back to the workflow editor). Save button hidden. Fork button visible. Static execution metrics (duration, tokens, cost).
CanvasNodes are not draggable. No connections or deletions. Cost badges show final values.
InspectorOpens on single-click. Fields are read-only. Tabs: Overview, Output, Eval, Error.
Bottom panelExpanded by default. Tabs: Logs, Runs, Regressions.
Status barShows progress format (e.g., “5/5 steps”). Duration and cost metrics visible.
Tab toggleNeither Canvas nor YAML tabs are togglable — the view is fixed.

Sim mode is the surface during a live simulation run. It is read-only but shows live-updating metrics and node statuses.

PanelBehavior
TopbarWorkflow name is not editable. Save button hidden. Cancel button visible (to abort the run). Live execution metrics (elapsed time, running cost).
CanvasNodes are draggable (to rearrange while watching). Connections and deletions are allowed. Cost badges show live values.
InspectorOpens on single-click. Fields are read-only. Tabs: Overview, Results, Conditions.
Bottom panelExpanded by default. Tabs: Logs, Runs.
Status barShows progress format. Elapsed time and cost metrics visible.
Tab toggleCanvas tab only — YAML tab is hidden during simulation.

The mode contract is defined as a pure TypeScript data structure with no React dependencies. Each mode maps to a PanelContract object:

workflowSurfaceContract.ts (simplified)
interface PanelContract {
topbar: {
nameEditable: boolean;
metricsVisible: boolean;
metricsStyle: "live" | "static" | "none";
saveButton: "dirty-dependent" | "disabled" | "hidden";
};
palette: {
visible: boolean;
dimmed: boolean;
searchEditable: boolean;
};
canvas: {
draggable: boolean;
connectionsAllowed: boolean;
deletionAllowed: boolean;
costBadgeStyle: "estimated" | "live" | "final";
};
inspector: {
trigger: "double-click" | "single-click";
fieldsEditable: boolean;
};
bottomPanel: {
defaultState: "collapsed" | "expanded";
};
statusBar: {
stepCountFormat: "steps-and-edges" | "progress";
metricsVisibility: "hidden" | "elapsed-and-cost" | "duration-and-cost";
};
}

Helper functions derive specific UI flags from the mode:

FunctionReturns
isEditable(mode)Whether the mode allows any editing (fields or dragging)
isDraggable(mode)Whether nodes can be repositioned
canCreateConnections(mode)Whether new edges can be drawn
canDeleteNodes(mode)Whether the delete key works
getAvailableTabs(mode, panel)Which tabs appear in the inspector or bottom panel
getActionButton(mode)The primary action: “Save+Run” (edit), “Cancel” (sim), “Fork” (readonly)
getSaveButtonState(mode, isDirty)Save button state: “enabled”, “disabled”, or “hidden”
getCostBadgeStyle(mode)How cost is displayed on nodes
getCanvasYamlToggleVisibility(mode)Which tabs (Canvas, YAML) are available in the topbar

Mode transitions happen through React state in WorkflowSurface:

  • Edit to sim — when a run starts, the mode can switch to sim to show live execution
  • Readonly to edit — the Fork button creates a new workflow from the run’s historical YAML snapshot and navigates to edit mode via handleForkTransition
  • Sim to edit — when a run completes or is cancelled, the mode returns to edit

The fork transition deserves special attention: it reads the YAML from the run’s git commit (not the current workflow file), creates a new disabled workflow, and navigates to its edit surface. This ensures the fork reflects exactly the YAML that executed, not whatever the workflow looks like now.

Each mode defines which tabs are available in the inspector and bottom panel:

ModeInspector tabsBottom panel tabs
EditOverview, Prompt, ConditionsLogs, Runs
SimOverview, Results, ConditionsLogs, Runs
ReadonlyOverview, Output, Eval, ErrorLogs, Runs, Regressions

The Regressions tab only appears in readonly mode, where you can compare a completed run against previous runs to detect quality or cost regressions.