FlowCanvas
An editable route drawn as a tree: conditions and splits branch downward, and each model's fallback hangs straight under it.
Arrow keys move between steps, Enter selects one, plus and minus zoom, and 0 fits the view.
- fast to x-plan is paid
- x-plan is paid to claude-opus-4-1, Then
- claude-opus-4-1 to Add a fallback to claude-opus-4-1, Fallback
- x-plan is paid to gpt-5-mini, Else
- gpt-5-mini to Add a fallback to gpt-5-mini, Fallback
function Editor() {
const [route, setRoute] = useState<Step>(basic);
const [selected, setSelected] = useState<string | null>("s2");
const add = (edge: string, insert: boolean) => (kind: "model" | "condition" | "split") => setRoute((r) => edit(r, edge, insert, kind));
return (
<Frame>
<FlowCanvas
aria-label="Route of fast"
root={startNode("fast", route)}
selected={selected}
onSelect={setSelected}
onDelete={(id) => setRoute((r) => remove(r, id))}
addMenu={({ edge, insert }) => (
<>
<Menu.Item icon={icons.model} onClick={() => add(edge, insert)("model")}>
Model
</Menu.Item>
<Menu.Item icon={icons.condition} onClick={() => add(edge, insert)("condition")}>
Condition
</Menu.Item>
<Menu.Item icon={icons.split} onClick={() => add(edge, insert)("split")}>
Split
</Menu.Item>
</>
)}
nodeActions={(id) =>
id === "start" ? null : (
<Menu.Item icon={icons.delete} variant="danger" onClick={() => setRoute((r) => remove(r, id))}>
Remove step
</Menu.Item>
)
}
/>
</Frame>
);
}import { FlowCanvas } from "@logicplanes/kaeso-ui/flow-canvas";Props
addMenu((slot: FlowCanvasSlot) => ReactNode)Turns editing on: open slots and a + midway on every connection show, and each opens a menu with these items. Called with the connection's
edgeid andinsert: false for an open slot, true for the + that puts a step before the connection's step. Without it, open slots are not drawn.aria-labelstringThe tree's accessible name: what the route belongs to, such as "Route of fast".
background"plain" | "dots" = dotsA dotted grid that moves with the view, or the plain panel.
busybooleanA request is on its way along
trace: its lines without atonerun as moving dashes, or pulse with reduced motion, and the tree is marked busy. Turn it off once the request answers.nodeActions((id: string) => ReactNode)Menu items for a step, shown in a button on the step and opened with Shift F10 or the context-menu key. Return nothing for a step without actions, such as the start.
onDelete((id: string) => void)Called with a step's id when Delete or Backspace is pressed on it.
onSelect((id: string | null) => void)Called with a step's id when it is clicked or chosen with Enter or Space, and with null when the background is clicked or Escape is pressed.
rootFlowCanvasNodeThe start of the route. Each node has
kind(its tag),title, an optionalsubtitle,leading(such as a provider badge),status(a word and a tone:danger,warningandsuccessalso ring the step),badge(a short word at its top right, such as its try),terminal(a model: its one connection is its fallback, drawn straight under it, with an open slot just below the model) andchildren: connections with anid, alabel, avariant(fallbackdraws a dashed line), atone(success,warningordanger: on a traced path, the line takes that color, such as the status a tried step answered with) and thenodethey lead to; a connection without a node is an open slot.selectedstring | null = nullThe id of the selected step, drawn with the selection ring; the view moves to show it when it changes.
tracereadonly string[]The ids of the steps one request passes, such as from a dry run: they and the lines between them stay strong, and every other step turns quieter: secondary text and a hairline, still readable. When its last step changes, the view moves to show that step. Leave it out to draw the route evenly.