/ceh-ag-ui:add-live-state-panelfrom ceh-ag-ui
Load this skill when adding a live panel to an AG-UI canvas: one fixed area the agent keeps updating while it works, wired from STATE_SNAPSHOT and STATE_DELTA. Trigger on "show the agent's progress live", "shared state", "sync state with the agent".
Ships in ceh-ag-ui. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Catalogue components are snapshots: once placed, a component never changes. Shared state is for the opposite case, a value that changes while the user watches. A progress tracker ticks, a plan gets rewritten, a counter climbs. The agent owns the value and streams its changes, and one fixed panel on the canvas renders it. The work is done when the three checks in step 5 pass.
progress,
plan) or the UI (filters, selection). Two writers on the same key race, because each run
sends the UI's copy and the agent answers with its own.RunAgentInput.state),
and the agent may snapshot it at any time.STATE_SNAPSHOT { snapshot } replaces the whole state. Send one when a value first appears,
and whenever you are unsure what the client holds (a new run, a reconnect).STATE_DELTA { delta } is an RFC 6902 JSON Patch applied to the client's current state. Paths
must exist, except for add. A patch against a path the client never received fails on the
client, so when in doubt, snapshot.Mock-agent handler (agent/main.py; import StateSnapshotEvent and StateDeltaEvent from
ag_ui.core, and call it from respond when the text mentions "progress"):
def progress() -> list[BaseEvent]:
steps = ["Collect data", "Analyse", "Write summary"]
snapshot = {"progress": {"title": "Preparing report", "steps": steps, "done": 0}}
deltas = [
[{"op": "replace", "path": "/progress/done", "value": i}]
for i in range(1, len(steps) + 1)
]
return [
StateSnapshotEvent(snapshot=snapshot),
*(StateDeltaEvent(delta=d) for d in deltas),
*say("Report ready."),
]
With a real model (the ceh-ag-ui:build-ag-ui-agent server), give the model a backend tool
such as update_progress whose handler validates the input and updates the thread's state. The
loop then yields a STATE_DELTA for the change before continuing, and the model never writes the
patch itself. To make the loop yield state events from a handler, have handlers return the events
to emit alongside the tool result. Keep the thread's state next to its transcript and send a
STATE_SNAPSHOT at the start of each run.
In useAgent.ts, mirror the client's state. The client applies snapshots and patches itself:
const [state, setState] = useState<Record<string, unknown>>({});
// inside the existing agent.subscribe({...}):
onStateChanged: ({ state }) => setState({ ...state }),
// and return `state` from the hook
Render each agent-owned key with one fixed panel, validated like tool arguments. State is agent output, so the styling lock applies in the same way:
// src/state/progress.tsx
import {
Progress,
ProgressTrack,
ProgressIndicator,
} from "@ui-sdk/react/progress";
import { z } from "zod";
import { card, cardTitle, eyebrow } from "../ui";
const progressSchema = z.object({
title: z.string(),
steps: z.array(z.string()).min(1),
done: z.number().int().nonnegative(),
});
export function ProgressPanel({ value }: { value: unknown }) {
const parsed = progressSchema.safeParse(value);
if (!parsed.success) return null;
const { title, steps, done } = parsed.data;
return (
<section className={card} aria-label={title}>
<p className={eyebrow}>In progress</p>
<h2 className={cardTitle}>{title}</h2>
{/* UI SDK's Progress is the progressbar and sets aria-valuenow and the indicator's width. */}
<Progress
value={Math.min(done, steps.length)}
max={steps.length}
aria-label={title}
>
<ProgressTrack className="h-1 w-full overflow-hidden rounded-full bg-muted">
<ProgressIndicator className="h-full bg-primary transition-all motion-reduce:transition-none" />
</ProgressTrack>
</Progress>
<ol className="flex flex-col gap-1">
{steps.map((step, i) => (
<li
key={step}
className={i < done ? "text-muted-foreground" : undefined}
>
{step}
{i < done && <span className="sr-only"> (done)</span>}
</li>
))}
</ol>
</section>
);
}
In App.tsx, pin the panel above the placed components, and keep the empty state only while there
is neither:
{state.progress !== undefined && <ProgressPanel value={state.progress} />}
{blocks.length === 0 && state.progress === undefined ? (/* empty state */) : (/* blocks */)}
For keys the UI writes, call agent.setState({ ...agent.state, filters }) before the next
runAgent. The state goes out in RunAgentInput.state. On the server, read it from run.state
and pass the relevant part to the model as text in the new user turn. Do not put it in the system
prompt: rewriting the prompt on every run breaks the prompt cache and the append-only transcript.
aria-valuenow ends at the step count, and the chat says
"Report ready."done as a string, renders no panel and does not crash.theme.css.state. A copy goes stale on
the next delta.role="progressbar" with aria-valuenow
reports the value when asked. Keep a fast-changing panel outside any aria-live region.ceh-ag-ui:add-canvas-component.ceh-ag-ui:add-human-approval.ceh-ag-ui:build-ag-ui.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub cheneeheng/ceh-claude-code-library --plugin ceh-ag-ui5 skills in this plugin
/add-canvas-componentLoad this skill when adding or changing a component in an AG-UI canvas catalogue: a card, chart, or form the agent can place on screen. Trigger on "add a component the agent can show", "let the agent render a <thing>", or an edit under `catalogue/`./add-human-approvalLoad this skill when an AG-UI agent must stop for the user's decision before an irreversible or costly step (a delete, a payment, a send), using AG-UI 1.0 interrupts and resume. Trigger on "ask the user before", "human in the loop", "approval step"./build-ag-uiLoad this skill when starting a generative-UI frontend for an AG-UI agent: a canvas where the agent answers by placing components from a catalogue. Trigger on "build a UI with AG-UI", "generative UI for my agent", or @ag-ui/client with no canvas yet./build-ag-ui-agentLoad this skill when building or fixing the agent server behind an AG-UI canvas: an endpoint that calls an LLM with the canvas's frontend tools and streams AG-UI events over SSE. Trigger on "build the AG-UI server", "connect Claude to my canvas", "replace the mock agent".