Edit a dashboard
Change a saved dashboard in place with dashboards.edit.
dashboards.edit() changes a saved dashboard from a prompt that describes the change. It patches only the parts the prompt describes, and the rest of the dashboard stays as it is.
import { dashboards } from "@/lib/openui";
const response = await dashboards.edit(
{
id: dashboardId,
prompt: "Add a pie chart of revenue by payment method next to the line chart.",
},
{ userId: session.user.id },
{ signal: request.signal },
);| Parameter | Description |
|---|---|
id | The dashboard's id. |
prompt | The change to make, and any data it needs. |
Only the dashboard's owner can edit it: context.userId must match the user who created it.
edit resolves with a response, like create. Return it as the tool result, or pass it to the renderer.
Get the id
The id comes from one of two places:
- The tool result: In a chat, the model reads the id from the earlier
create_dashboardresult and passes it toedit_dashboard. See Add to your agent. - The list: Each item from
useArtifactListhas anid.
Write the prompt
The model applies the change to the saved dashboard, so describe only what changes:
- "Add a table of failed payments below the chart."
- "Switch the revenue chart to weekly totals."
- "Remove the refunds section."
What the user sees
- The open dashboard stays on screen.
- When the new version is ready, every renderer showing the dashboard switches to it, including renderers opened from the list.
- The dashboard loads its data again for the new version.