Skip to content
Talk to an engineer

Canvas

Custom canvas

A plain starting point for a canvas no typed one fits: a plan, a brief or a runbook built from headings, text, key values, checklists and callouts. The user and the agent edit the same blocks, the agent’s changes are marked, and your footer buttons act on the result.

KindCanvas · OTHER · EDIT_MODEAgent waitsNoAgent rulesYour action's promptMobileNo canvas: a summary card

Use it when: None of the typed canvases fits: a plan, a brief, a runbook or a review the user and the agent shape together from headings, text, key values, checklists and callouts. The SDK adds no rule for OTHER, so your action’s own prompt must say what the agent may change and what it must leave alone.

Use something else when: The content is a form, a table, a document, code or a report: use that canvas, whose type tells the agent how to behave. A one-off answer (a chat card). Mobile: the canvas isn’t available; use the card (mountMobile).

The template callsThe agent getsWhen
canvas.setState({ blocks })Canvas state600 ms after the user stops editing, and when a field loses focus. The agent edits the same blocks by id.
actions.onAction(id, state)Your appA footer button. The patch it returns (a new status, say) is drawn and shared.
displayed()FUNCTION_TOOL_DISPLAYEDMobile card: as soon as it shows.

Besides its data, the template draws these as itself, with mountState(). Pick one on the preview with State.

StateWhen it shows
LoadingWhile execute reads what the plan starts from. The skeleton has the canvas’s shape: a title, key values, text and a checklist.
EmptyThere’s nothing to build the canvas from, for example a workspace that’s already in the target region. Say why, and what the user can do.
Errorexecute couldn’t read what the canvas needs. Nothing changed; Try again loads it in place.
mountState({ root, head, title: "…", state: { kind: "error", text: "…", retry } });

The hosted action and the in-page handler below show each case. The state types are LoadingState, EmptyState and ErrorState in fs-kit.

FieldTypeNotes
canvasTitle (optional)stringThe canvas header (setTitle, up to 80 characters). Default: title.
eyebrow (optional)stringA small label above the title, e.g. “Migration plan”.
titlestring
subtitle (optional)stringOne or two lines under the title.
status (optional)CustomCanvasStatusA status pill beside the eyebrow.
blocksCustomCanvasBlock[]The body, top to bottom. Each block keeps its id when the agent edits it, so the canvas can mark the change.
buttons (optional)CustomCanvasButton[]Footer buttons. Their clicks go to actions.onAction(id); the last primary one is the main action.
footnote (optional)stringA line in the footer, e.g. who decides what.
FieldTypeNotes
idstringStable id.
type"heading" | "text" | "keyValue" | "checklist" | "callout"heading, text (paragraphs), keyValue (label and value rows), checklist (items the user ticks), callout (a note with a tone).
text (optional)stringheading, text and callout: the text. A blank line starts a paragraph.
items (optional)CustomCanvasItem[]keyValue and checklist: the rows.
tone (optional)"info" | "success" | "warning" | "error"callout: info (default), success, warning or error.
editable (optional)booleantext and keyValue: the user can edit it in place. Checklists are always tickable.
FieldTypeNotes
idstringStable id.
labelstring
value (optional)stringkeyValue: the value.
done (optional)booleanchecklist: ticked.
hint (optional)stringA muted line under the label or value.
FieldTypeNotes
idstringWhat actions.onAction receives.
labelstring
primary (optional)booleanThe filled button. Default: outlined.
FieldTypeNotes
onAction() (optional)(id: string, state: CustomCanvasState) => Promise<Partial<CustomCanvasState> | void> | Partial<CustomCanvasState> | voidA footer button was clicked. Return a state patch to apply and share (e.g. a new status). Throw to show why it failed.
onChange() (optional)(state: CustomCanvasState) => voidCalled each time the state is shared with the agent (debounced).

Copy the template and the shared kit into your code: agent/ui/ in an agent repo, or anywhere in your app. The template imports only ./fs-kit.js. Then wire it up from the hosted action or the in-page handler.

The hosted action needs an agent repo with one folder per action (agent/actions/<action_key>/index.ts). If your repo keeps its actions in agent/actions/index.ts, use the in-page handler: it runs the same template in your app.

All templates in machine-readable form: /ui-catalog/catalog.json.