Workflow Canvas

Lay out an automation's trigger and steps, and connect them.

9 steps · 2 need setup

  1. ↻ For each item

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/canvas

Usage

import { type CanvasStep, WorkflowCanvas } from "./ui/uicontext/components/kit/Canvas.ts"
const Message = UiSchema.TaggedEnum({	SelectedStep: { step: Schema.String },	AddedStep: { path: Schema.String, index: Schema.Number },	MovedStep: { path: Schema.String, from: Schema.Number, to: Schema.Number },	RemovedStep: { step: Schema.String },})export const Steps = (h: Html.H<typeof Message.Type>, steps: ReadonlyArray<CanvasStep>, selected: string | null) =>	WorkflowCanvas(h, {		props: { id: "lead-intake", label: "New lead intake", steps, selected, can: ["add", "move", "remove"] },		onEmit: {			RequestedSelect: ({ step }) => Message.SelectedStep({ step }),			RequestedAdd: ({ path, index }) => Message.AddedStep({ path, index }),			RequestedMove: ({ path, from, to }) => Message.MovedStep({ path, from, to }),			RequestedRemove: ({ step }) => Message.RemovedStep({ step }),			RequestedSelectPath: () => undefined,			RequestedAddPath: () => undefined,			RequestedDuplicate: () => undefined,			RequestedDisable: () => undefined,			RequestedEdit: () => undefined,		},	})

Examples

A published version

Read-only, with no add, move or menu controls, until the person opens it for editing.

You’re viewing version 3, which is live.

6 steps · 2 need setup

A new workflow

With no steps yet, the board asks for the trigger first.

API reference

Props

WorkflowCanvas props
NameTypeDefaultDescription
idrequiredstring—The workflow's id, which names it to agents
labelrequiredstring—The workflow's name, read by screen readers and agents
stepsrequiredCanvasStep[]—The trigger first, then the steps; a paths step carries its branches
status"loading" | "ready"—loading shows placeholder steps while the workflow loads
selectedstring | null—The id of the step or path whose setup is open
canrequired("add" | "move" | "remove" | "duplicate" | "disable")[]—What the viewer may do to the steps: add, move, remove, duplicate or turn them off
maxStepsnumber—At most this many steps in all
readOnly{ notice, editLabel }—Why it can't be changed, with an action that opens it for editing: "Edit workflow"
outcomeOutcome | null—The app's answer to the request in flight; the request id is the action ("add", "move", "remove")
agentIdstringcanvas:<id>The id agents know this canvas by; canvas:<id> by default

Events

WorkflowCanvas events
EventPayloadDescription
RequestedSelect{ step: string }A step was clicked: open its setup
RequestedSelectPath{ path: string }A path's label was clicked: open its conditions
RequestedAdd{ path: string; index: number }Add a step in path ("root" for the main column) at index
RequestedAddPath{ step: string }Add another path to a paths step
RequestedMove{ path: string; from: number; to: number }Move the step at from in path to to (in "root", indices count the trigger)
RequestedDuplicate{ step: string }Copy a step, with its setup, right after it
RequestedDisable{ step: string; disabled: boolean }Turn a step off (runs pass over it) or back on
RequestedRemove{ step: string }Remove a step, after the person confirmed
RequestedEdit{}The workflow is read-only: open it for editing

Agent actions

What agents can do with WorkflowCanvas
ActionDescription
ClickedStepSelect a step by id to open its setup
ClickedPathOpen a path's conditions by path id
ClickedNextProblemOpen the next step that needs setup
ClickedAddAdd a step in a sequence ("root" or a path id) at an index
ClickedAddPathAdd another path to a paths step
MovedStepMove a step within its sequence ("root" or a path id), from one index to another
ClickedDuplicateCopy a step, with its setup, right after it
ClickedDisableTurn a step off (runs pass over it) or back on
ClickedRemoveAsk to remove a step by id (opens the confirmation)
ConfirmedRemoveasks firstRemove the step being confirmed. Name it as your target.
ClickedEditOpen the read-only workflow for editing

Accessibility

  • Each step is a button that says its number, kind and title, and whether its setup is open (aria-pressed).
  • A step moves from its handle without a pointer: press the handle to pick it up, the arrow keys move it, the handle again drops it and Escape cancels. Each move is announced.
  • Removing a step asks first, and every add button names the step it adds after.
  • The up and down arrows move between steps, and each step's menu duplicates, turns off, moves or deletes it without a pointer.
  • The bar above the board announces how many steps need setup, and its button opens the next one.

Source