The shared stream shapes every agent piece reads from
pnpm dlx shadcn@latest add https://notchset.dev/r/stream-adapters.jsonThe install contract: the shapes and state names every agentic piece reads.
Every shadcn style · one file
Import it and pass your content. The props that matter most are listed next.
"use client";
import * as React from "react";
import { Card } from "@/components/ui/notchset/card";
import { LiveLabel } from "@/components/ui/notchset/live-label";
import { StatusGlyphRun } from "@/components/ui/notchset/status-glyph-run";
import { RUN_STATUS_WORDS, RunAnnouncer, runOf, runStatusFrom, type RunStatus, type UIMessage } from "@/components/ui/notchset/stream-adapters";
import { useLessMotion } from "@/lib/notchset/motion";
import { useSelfPlay } from "./self-play";
/*
* One run, fed by a format switch: the same scripted run (an agent fixing a GitHub build, asking before it pushes)
* arrives as AI SDK messages, AG-UI events or A2A task states. Each goes through the contract's one reader and the
* same two pieces react, the glyph and the live label, the same way whichever format it came in; under them, the
* word the format itself sent. The run plays once on view and rests at its end (less motion shows the end); the
* first touch makes it yours; choosing a format (the stage's switch) plays the run again in it.
*/
type Format = "ai-sdk" | "ag-ui" | "a2a";
const ask: UIMessage = { id: "u1", role: "user", parts: [{ type: "text", text: "Fix the failing GitHub build" }] };
const reply = (parts: UIMessage["parts"]): UIMessage[] => [ask, { id: "a1", role: "assistant", parts }];
const reading = { type: "tool-read_log", toolCallId: "t1", state: "output-available", output: "3 failures" } as const;
const push = (state: "approval-requested" | "approval-responded") => ({ type: "tool-git_push", toolCallId: "t2", state, approval: { id: "ap1", approved: state === "approval-responded" || undefined } }) as const;
/* each beat of the run, as each format says it */
const BEATS: { present: string; past: string; outcome?: string; ai: { status: string; parts: UIMessage["parts"] }; agUi: string | null; a2a: string }[] = [
{ present: "Fixing the GitHub build", past: "Queued behind one run", ai: { status: "submitted", parts: [] }, agUi: null, a2a: "submitted" },
{ present: "Reading the failing job's log", past: "Read the failing job's log", ai: { status: "streaming", parts: [{ ...reading, state: "input-available" }] }, agUi: "RUN_STARTED", a2a: "working" },
{ present: "Pushing the fix to main", past: "Asked to push the fix to main", ai: { status: "streaming", parts: [reading, push("approval-requested")] }, agUi: "RUN_FINISHED:interrupt", a2a: "input-required" },
{ present: "Pushing the fix to main", past: "Pushed the fix to main", ai: { status: "streaming", parts: [reading, push("approval-responded")] }, agUi: "STEP_STARTED", a2a: "working" },
{ present: "Fixing the GitHub build", past: "Fixed the GitHub build", outcome: "3 files", ai: { status: "ready", parts: [reading, push("approval-responded")] }, agUi: "RUN_FINISHED:success", a2a: "completed" },
];
const BEAT = 1600;
const TAKES = BEATS.map(() => BEAT);
/* the contract's one reader per format: whichever came in, a RunStatus comes out */
function statusOf(format: Format, b: (typeof BEATS)[number]): RunStatus {
if (format === "ai-sdk") return runOf(reply(b.ai.parts), { status: b.ai.status })?.status ?? "queued";
return runStatusFrom(format, format === "ag-ui" ? b.agUi : b.a2a) ?? "running";
}
const sent = (format: Format, b: (typeof BEATS)[number]) =>
format === "ai-sdk" ? `status "${b.ai.status}"${b.ai.parts.some((p) => "state" in p && p.state === "approval-requested") ? ", a tool in approval-requested" : ""}` : format === "ag-ui" ? (b.agUi ?? "before RUN_STARTED") : `TaskState "${b.a2a}"`;
export default function StreamAdaptersDemo() {
const knob = "ai-sdk" as Format;
const [format, setFormat] = React.useState<Format>(knob);
/* the knob's morph row sets the format too */
const [knobWas, setKnobWas] = React.useState(knob);
/* a new format plays the run again from its first beat, so the same pieces are seen reacting to it */
const [replay, setReplay] = React.useState<number | null>(null);
if (knob !== knobWas) {
setKnobWas(knob);
setFormat(knob);
setReplay(0);
}
const less = useLessMotion();
const root = React.useRef<HTMLDivElement>(null);
const play = useSelfPlay(root, { beats: TAKES, off: less });
React.useEffect(() => {
if (replay === null || replay >= BEATS.length - 1) return;
const id = window.setTimeout(() => setReplay((r) => (r ?? 0) + 1), BEAT);
return () => window.clearTimeout(id);
}, [replay]);
const step = replay ?? (less ? BEATS.length - 1 : Math.max(0, play.step));
const b = BEATS[step]!;
const status = statusOf(format, b);
const label = status === "running" ? "running" : status === "failed" ? "failed" : "done";
return (
<div ref={root} data-slot="stream-adapters-demo" onPointerDownCapture={play.handOver} onKeyDownCapture={play.handOver} onFocusCapture={play.handOver} className="flex w-[min(100%,var(--ns-width-md))] flex-col items-start gap-3">
<Card inset className="w-full">
<div className="flex flex-col gap-1.5">
<div className="flex min-h-[var(--ns-row)] min-w-0 items-center gap-2.5 text-[length:var(--ns-text-body)]">
<StatusGlyphRun state={status} label={b.present} />
<LiveLabel state={label} present={b.present} past={b.past} outcome={b.outcome} />
<span className="ms-auto shrink-0 text-[length:var(--ns-text-small)] text-[var(--ns-ink-3)]">{RUN_STATUS_WORDS[status]}</span>
</div>
<RunAnnouncer status={status} label={b.present} />
<code className="inline-block max-w-full min-w-0 self-start truncate font-[family-name:var(--ns-font-mono)] text-[length:var(--ns-text-meta)] text-[var(--ns-ink-3)]">
{`${sent(format, b)} → ${status}`}
</code>
</div>
</Card>
</div>
);
}"use client";
import * as React from "react";
import { Card } from "@/components/ui/notchset/card";
import { LiveLabel } from "@/components/ui/notchset/live-label";
import { StatusGlyphRun } from "@/components/ui/notchset/status-glyph-run";
import { RUN_STATUS_WORDS, RunAnnouncer, runOf, runStatusFrom, type RunStatus, type UIMessage } from "@/components/ui/notchset/stream-adapters";
import { useLessMotion } from "@/lib/notchset/motion";
import { useSelfPlay } from "./self-play";
/*
* One run, fed by a format switch: the same scripted run (an agent fixing a GitHub build, asking before it pushes)
* arrives as AI SDK messages, AG-UI events or A2A task states. Each goes through the contract's one reader and the
* same two pieces react, the glyph and the live label, the same way whichever format it came in; under them, the
* word the format itself sent. The run plays once on view and rests at its end (less motion shows the end); the
* first touch makes it yours; choosing a format (the stage's switch) plays the run again in it.
*/
type Format = "ai-sdk" | "ag-ui" | "a2a";
const ask: UIMessage = { id: "u1", role: "user", parts: [{ type: "text", text: "Fix the failing GitHub build" }] };
const reply = (parts: UIMessage["parts"]): UIMessage[] => [ask, { id: "a1", role: "assistant", parts }];
const reading = { type: "tool-read_log", toolCallId: "t1", state: "output-available", output: "3 failures" } as const;
const push = (state: "approval-requested" | "approval-responded") => ({ type: "tool-git_push", toolCallId: "t2", state, approval: { id: "ap1", approved: state === "approval-responded" || undefined } }) as const;
/* each beat of the run, as each format says it */
const BEATS: { present: string; past: string; outcome?: string; ai: { status: string; parts: UIMessage["parts"] }; agUi: string | null; a2a: string }[] = [
{ present: "Fixing the GitHub build", past: "Queued behind one run", ai: { status: "submitted", parts: [] }, agUi: null, a2a: "submitted" },
{ present: "Reading the failing job's log", past: "Read the failing job's log", ai: { status: "streaming", parts: [{ ...reading, state: "input-available" }] }, agUi: "RUN_STARTED", a2a: "working" },
{ present: "Pushing the fix to main", past: "Asked to push the fix to main", ai: { status: "streaming", parts: [reading, push("approval-requested")] }, agUi: "RUN_FINISHED:interrupt", a2a: "input-required" },
{ present: "Pushing the fix to main", past: "Pushed the fix to main", ai: { status: "streaming", parts: [reading, push("approval-responded")] }, agUi: "STEP_STARTED", a2a: "working" },
{ present: "Fixing the GitHub build", past: "Fixed the GitHub build", outcome: "3 files", ai: { status: "ready", parts: [reading, push("approval-responded")] }, agUi: "RUN_FINISHED:success", a2a: "completed" },
];
const BEAT = 1600;
const TAKES = BEATS.map(() => BEAT);
/* the contract's one reader per format: whichever came in, a RunStatus comes out */
function statusOf(format: Format, b: (typeof BEATS)[number]): RunStatus {
if (format === "ai-sdk") return runOf(reply(b.ai.parts), { status: b.ai.status })?.status ?? "queued";
return runStatusFrom(format, format === "ag-ui" ? b.agUi : b.a2a) ?? "running";
}
const sent = (format: Format, b: (typeof BEATS)[number]) =>
format === "ai-sdk" ? `status "${b.ai.status}"${b.ai.parts.some((p) => "state" in p && p.state === "approval-requested") ? ", a tool in approval-requested" : ""}` : format === "ag-ui" ? (b.agUi ?? "before RUN_STARTED") : `TaskState "${b.a2a}"`;
export default function StreamAdaptersDemo() {
const knob = "ai-sdk" as Format;
const [format, setFormat] = React.useState<Format>(knob);
/* the knob's morph row sets the format too */
const [knobWas, setKnobWas] = React.useState(knob);
/* a new format plays the run again from its first beat, so the same pieces are seen reacting to it */
const [replay, setReplay] = React.useState<number | null>(null);
if (knob !== knobWas) {
setKnobWas(knob);
setFormat(knob);
setReplay(0);
}
const less = useLessMotion();
const root = React.useRef<HTMLDivElement>(null);
const play = useSelfPlay(root, { beats: TAKES, off: less });
React.useEffect(() => {
if (replay === null || replay >= BEATS.length - 1) return;
const id = window.setTimeout(() => setReplay((r) => (r ?? 0) + 1), BEAT);
return () => window.clearTimeout(id);
}, [replay]);
const step = replay ?? (less ? BEATS.length - 1 : Math.max(0, play.step));
const b = BEATS[step]!;
const status = statusOf(format, b);
const label = status === "running" ? "running" : status === "failed" ? "failed" : "done";
return (
<div ref={root} data-slot="stream-adapters-demo" onPointerDownCapture={play.handOver} onKeyDownCapture={play.handOver} onFocusCapture={play.handOver} className="flex w-[min(100%,var(--ns-width-md))] flex-col items-start gap-3">
<Card inset className="w-full">
<div className="flex flex-col gap-1.5">
<div className="flex min-h-[var(--ns-row)] min-w-0 items-center gap-2.5 text-[length:var(--ns-text-body)]">
<StatusGlyphRun state={status} label={b.present} />
<LiveLabel state={label} present={b.present} past={b.past} outcome={b.outcome} />
<span className="ms-auto shrink-0 text-[length:var(--ns-text-small)] text-[var(--ns-ink-3)]">{RUN_STATUS_WORDS[status]}</span>
</div>
<RunAnnouncer status={status} label={b.present} />
<code className="inline-block max-w-full min-w-0 self-start truncate font-[family-name:var(--ns-font-mono)] text-[length:var(--ns-text-meta)] text-[var(--ns-ink-3)]">
{`${sent(format, b)} → ${status}`}
</code>
</div>
</Card>
</div>
);
}"use client";
import * as React from "react";
/*
* A demo that plays itself until the first touch: the script lives in the demo, never in the piece, which only gets
* the props a person would give it. It moves 0.4 s after the piece is first seen, then takes each step on its beat;
* off screen or paused it waits. The first press, key or focus on the piece (bind `handOver` to it; a scroll over it never counts) makes it the
* visitor's for good and drops every queued step; with less motion (`off`) it never plays and rests in its first frame.
* A host can hand it over from outside the piece too (a settings panel beside it the visitor has used): under
* <HandedOver value>, it never plays, a remount included.
*
* const play = useSelfPlay(root, { beats: [2800, 2800], loop: true, off: less });
* <div ref={root} onPointerDownCapture={play.handOver} onKeyDownCapture={play.handOver} onFocusCapture={play.handOver}>
* play.step // the step it is at, -1 before its first
* play.control // "pause" while it plays, "play" once paused (a new take), "replay" once it is over or yours
*
* Each step presses the piece's own controls (pressIn), so the script shows exactly what a hand can do.
*
* A host that shows the piece once (<PlayOnce value={{ settle }}>) changes three things: the script starts when the
* piece is first half in view and never again on coming back, it never loops, and with less motion (or `settle`) it
* takes every step at once, so the piece rests on the END of its moment. `hold` is a reason not to play at all that is
* not motion (a mode with nothing to show): it holds in every host. Under <PlayOnce value={{ active: false }}> (a look
* that is mounted but not shown) it waits until it is shown.
*/
type SelfPlayOptions = {
/** how long each step waits after the one before it, in ms; the first step waits 0.4 s after the piece is seen */
beats: readonly number[];
/** starts over after the last step; without it the script plays once and rests */
loop?: boolean | undefined;
/** no self-play at all (less motion): the piece is the visitor's from the start */
off: boolean;
/** no self-play for a reason other than motion (a mode with nothing to show), in every host */
hold?: boolean | undefined;
};
/** How a host shows the piece: once on arrival (see useSelfPlay). */
type PlayOnceHost = {
/** rest on the end at once, without playing (less motion, or a reset) */
settle?: boolean | undefined;
/** false while the piece is mounted but not shown: it waits */
active?: boolean | undefined;
};
const START = 400;
/**
* Whether a demo plays itself at all. Off: every piece rests in its first frame and is
* the visitor's from the start; nothing presses its controls for them.
*/
const SELF_PLAY: boolean = false;
/** True where the visitor has already taken the piece from outside it: nothing under it plays itself. */
const HandedOver = React.createContext(false);
/** A host that shows the piece once: play once on arrival, rest on the end (null: play as the demo asks). */
const PlayOnce = React.createContext<PlayOnceHost | null>(null);
function useSelfPlay(root: React.RefObject<Element | null>, { beats, loop: looped = false, off: still, hold = false }: SelfPlayOptions) {
const once = React.useContext(PlayOnce);
const active = once?.active !== false;
/* shown once: less motion (or a settled host) takes every step at once and rests on the end */
const quick = once != null && (still || Boolean(once.settle));
const loop = once == null && looped;
/* the first touch hands it over for good */
const [mine, setMine] = React.useState(false);
const handOver = React.useCallback(() => setMine(true), []);
const handedOver = React.useContext(HandedOver);
const off = !SELF_PLAY || hold || (quick ? false : still) || mine || (handedOver && !quick);
const [seen, setSeen] = React.useState(false);
const [paused, setPaused] = React.useState(false);
const [taken, setTaken] = React.useState(0);
const n = Math.max(1, beats.length);
const done = !loop && taken >= n;
React.useEffect(() => {
const el = root.current;
if (!active) return;
/* without an observer (an old browser, a test) it counts as seen */
if (!el || typeof IntersectionObserver === "undefined" || quick) {
const t = window.setTimeout(() => setSeen(true));
return () => window.clearTimeout(t);
}
/* shown once: first half in view starts it, and leaving never stops or restarts it */
const io = once
? new IntersectionObserver((es) => {
if (es.some((e) => e.isIntersecting && e.intersectionRatio >= 0.5)) {
setSeen(true);
io.disconnect();
}
}, { threshold: 0.5 })
: new IntersectionObserver((es) => setSeen(es.some((e) => e.isIntersecting)));
io.observe(el);
return () => io.disconnect();
}, [root, active, once, quick]);
const playing = !off && seen && active && !paused && !done;
const delay = quick ? 0 : taken === 0 ? START : (beats[taken % n] ?? START);
React.useEffect(() => {
if (!playing) return;
const t = window.setTimeout(() => setTaken((k) => k + 1), delay);
return () => window.clearTimeout(t);
}, [playing, taken, delay]);
/* one control in one place: Pause while it plays, Play (a new take) once paused, Replay once it is over or yours */
/* self-play off: never "over", so a demo rests in its FIRST frame, not its end frame */
const control: "pause" | "play" | "replay" = paused || !SELF_PLAY ? "play" : off || done ? "replay" : "pause";
return { step: taken === 0 ? -1 : (taken - 1) % n, taken, playing, control, mine, handOver, pause: () => setPaused(true) };
}
/**
* Presses a real control inside `root`, as the visitor would: the first match of `selector`, or the one whose text is
* `text`. A click only, so it never counts as the visitor's touch.
*/
function pressIn(root: Element | null, selector: string, text?: string) {
const all = [...(root?.querySelectorAll<HTMLElement>(selector) ?? [])];
(text == null ? all[0] : all.find((el) => el.textContent?.trim() === text))?.click();
}
export { HandedOver, PlayOnce, pressIn, useSelfPlay, type PlayOnceHost, type SelfPlayOptions };This example also uses Card, Live label, Status glyph, run states. This command installs them with it, so the example pastes as it is:
pnpm dlx shadcn@latest add https://notchset.dev/r/stream-adapters.json https://notchset.dev/r/card.json https://notchset.dev/r/live-label.json https://notchset.dev/r/status-glyph-run.jsoncomponents/ui/notchset/stream-adapters.tsx
LevelAtom: uses no other piece.
Made ofNothing else from the library: the foundation alone.
Free, no account or key. One command for every shadcn style. With the @notchset registry added, @notchset/<name> works too.
Works with React 18.3 or 19 on Tailwind CSS v4, in any shadcn project. What's tested
The CLI adds the styles to the CSS file named in components.json (tailwind.css). Check that it points at your global stylesheet, that the project uses Tailwind CSS v4, and that the file is imported in your root layout. Installed by hand: paste styles.css into that file.
RunAnnouncer.status–
RunStatuswhere the run stands
RunAnnouncer.label–
stringwhat the run is doing, said with its phase: "Fixing the GitHub build"
RunAnnouncer.labels–
RunAnnouncerLabelsthe states' words and the sentence, over the English defaults ("Running" is said "Started")
Three usesan assistant's chat on the AI SDK · a coding agent's runs over AG-UI · a support desk's agent tasks over A2A
Give your coding assistant the Markdown guide instead of screenshots.
https://notchset.dev/api/mcp (setup)v1.0.0 · 2026-11-09
Released free with the Notchset system.