Chat cards
Progress
A job the agent started (import, export, sync, bulk update) as it runs: overall progress, each step, elapsed and estimated time. The user can stop it, and when it ends, open the result, download the error report or retry what failed. The agent doesn’t wait for it.
When to use it
Section titled “When to use it”Use it when: The agent started a job that takes more than a few seconds and runs on its own: an import, an export, a sync, a bulk update. The user wants to see it move, stop it, and act on what failed.
Use something else when: A change that finishes in a second or two (do it, then show the result). A yes or no before the job starts (confirm card first). Setup steps the user does by hand (onboarding guide). A job whose result the agent must read before it answers (wait in execute instead).
What the agent receives
Section titled “What the agent receives”| The template calls | The agent gets | When |
|---|---|---|
displayed() | FUNCTION_TOOL_DISPLAYED | As soon as the card shows. The agent goes on and isn’t told when the job ends: the user sees the outcome here, and the agent learns it on a later turn (a status action that reads the job) or from your app. |
States
Section titled “States”Besides its data, the template draws these as itself, with mountState(). Pick one on the preview with State.
| State | When it shows |
|---|---|
| Loading | While the card starts the job again in place, for example after Try again. While execute runs, the SDK shows its own loader. |
| Empty | execute found nothing to run, here a file with no rows. Nothing started, and the card says why. |
| Error | The job didn’t start, and execute returned the failure as data, so the agent can explain it. Try again starts 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.
ProgressData
Section titled “ProgressData”| Field | Type | Notes |
|---|---|---|
title | string | Name the job as it runs, “Importing contacts”; send a new title when it ends, “Contacts imported”. |
subtitle (optional) | string | |
icon (optional) | IconName | |
status | JobStatus | |
done | number | Items handled so far. |
total | number | |
unit (optional) | string | What’s counted, plural: “rows”, “files”. Default “items”. |
failed (optional) | number | Items that failed. With status “partial” they’re what Retry sends again. |
steps | ProgressStep[] | |
startedAt (optional) | string | number | When the job started (ISO string or ms). Default: when the card mounted. Elapsed time counts from it. |
finishedAt (optional) | string | number | When it ended. Default: when the card saw it end. Freezes elapsed time. |
etaSeconds (optional) | number | Seconds left, when your job knows. Otherwise the card estimates it from the rate so far. |
summary (optional) | string | The outcome in a sentence, under the result title: what happened, what failed and why. |
link (optional) | { label: string; href: string } | Where the result lives, e.g. “Open contacts”. Shown when the job is done or partly done. |
reportHref (optional) | string | A file of the failed items and why (CSV). Shows “Download error report”. |
error (optional) | string | status “failed”: what went wrong, in the user’s words, and whether anything changed. |
notice (optional) | string | A passing problem while it runs, e.g. “Can’t reach the import service. Retrying…”. An empty string clears it. |
cancelable (optional) | boolean | Show Cancel while running. Default: when actions.cancel is set. |
jobNoun (optional) | string | The noun in buttons and the stop question, e.g. “import”. Default “job”. |
ProgressStep
Section titled “ProgressStep”| Field | Type | Notes |
|---|---|---|
id | string | |
label | string | |
status | StepStatus | |
detail (optional) | string | One short line under the label: “214 merged”, or why it failed or was skipped. |
failed (optional) | number | Items this step couldn’t handle. A done step with failures shows a warning mark and “12 failed”. |
ProgressActions
Section titled “ProgressActions”| Field | Type | Notes |
|---|---|---|
subscribe() (optional) | (onChange: (patch: ProgressPatch) => void) => () => void | Your job’s updates (app events, polling). Call onChange with each change; the card redraws and announces step changes. Return the unsubscribe. |
cancel() (optional) | () => Promise<unknown> | Stops the job. Throw to keep it running and show why. Without it, there’s no Cancel. |
retry() (optional) | () => Promise<unknown> | Runs again what failed: the failed items for “partial”, the job for “failed”. New progress arrives through subscribe. |
download() (optional) | (href: string) => void | Downloads the error report. Hosted actions pass ctx.ui.download (the sandbox blocks native downloads). Without it, a download link. |
Install
Section titled “Install”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.
- Hosted action: TypeScript, JavaScript
- In-page handler: TypeScript, JavaScript
- progress: TypeScript, JavaScript
- fs-kit: TypeScript, JavaScript
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.