AI chat composer
Shown as Sorrel, a made-up product
An agent for a small ceramics shop. Ask with your catalogue and supplier sheet attached as chips; it plans in timed steps, streams its answer, and proposes one change you apply or undo.
Installation
pnpm dlx shadcn@latest add "https://propui.dev/r/sorrel-agent.json?token=…"Adds the piece to components/propui/02-sorrel-agent/ and installs motion. Needs a free account: sign in and the command includes your token. Fonts load from Prop UI; download the zip to self-host them.
When to use
Reach for it when
- The start screen of an assistant that works on a business's own data: a composer, the sources it will read, and suggested asks.
- Showing an agent's run as it happens: plan steps with timings, a streamed answer, then one result to apply.
- Any agent that proposes a change (a table of fixes, a before and after list) and waits for a person to apply it, with Undo after.
Something else fits when
- A coding agent whose steps you need to inspect and redirect: Run rewind shows each step's code and lets you branch from it.
- A plain chat with no sources and no changes to apply: a message thread is lighter.
- Many runs at once across a team: AI agent runs shows every run and its approval queue.
Usage
Fills a full window: give it a container with a definite height.
import Piece from "@/components/propui/02-sorrel-agent/Section";
export default function Page() {
return (
<main className="h-dvh w-full overflow-hidden">
<Piece />
</main>
);
}Replace SHOP, SOURCES, SUGGESTIONS, PLACEHOLDERS and SCENARIOS in data.ts, and route typed asks in scenarioFor(). To call a real agent, replace send() in Section.tsx, which starts a run from a scenario; the steps, streamed answer and artefact read from it.
Your data
Replace these and everything on screen follows.
SHOP{ name; person; initials }- The business named in the intro line and the Connected sources menu.
SOURCES{ id; kind; name; detail; synced }[]- Context chips, the Add context and Connected sources menus; kind is table, file or channel and sets the icon.
START_SOURCESstring[]- The chips attached when the page opens.
SUGGESTIONS{ id; text; source }[]- The four asks under the composer, ordered by the attached chips.
PLACEHOLDERSstring[]- The example asks the empty composer types once; it rests on the last.
SCENARIOSRecord<ScenarioId, { sources; steps; answer; artefact; apply; applied }>- One run each: plan steps with their timings, the answer, the table or before/after artefact, and the Apply and applied lines.
scenarioFor()(text) => ScenarioId- Picks the run for a typed ask by keyword; anything else gets the general summary.
Interactions
- Type an ask and send it, or pick a suggestion; the heading lifts away and the composer docks at the bottom.
- Add a table, file or channel from the + menu, attach a file from the paperclip, or tick sources on and off in the Connected sources menu.
- Remove a context chip with its ×; hover or focus a chip to see its full name, size and sync time.
- Press the mic to dictate: a waveform runs, and Stop (or a short wait) drops the words into the composer.
- Watch the plan steps tick through and the answer stream in; once done, fold the steps away with the Worked for line.
- Apply the proposed change, then Undo it if needed. New task returns to the start.
Keyboard
- Enter
- In the composer, send.
- Shift+Enter
- In the composer, add a line.
- Esc
- Close the open menu.
- Tab
- Move through chips, tools, suggestions and the result's actions.
Behaviour
Read from the code: roles, motion, breakpoints and what runs.
Accessibility
- The composer has a visually hidden label, and send is disabled until there is text and no run is working.
- Menus use menu, menuitem and menuitemcheckbox roles with aria-checked, and focus their first item when they open.
- A polite live region says when Sorrel is working and when it has finished; the Apply and Undo line is also polite.
- Every icon-only tool has a label, and each chip's remove button names the source it removes.
- Result tables are a focusable region named by their title, with column headers; long file names shorten in the middle so the extension stays visible.
Motion
- The glaze bead breathes and its glaze turns slowly; while a run works a bright rim circles it and the glaze speeds up, eased over 0.7 s so nothing snaps.
- Plan steps fade up in turn and tick with a spring; the answer streams word by word into a layout that is already its full size, so lines never reflow.
- Heights change on one spring measured from the content, so the thread grows without jumps; the composer docks with a layout animation.
- Reduced motion stops the bead, shimmer and waveform, shows the last placeholder at once and lands the whole answer in one step.
Responsive
- The composer and thread are 720px wide and shrink with the screen; the piece fills the window and the thread scrolls inside it.
- Below 720px the side padding and heading size step down.
- Below 480px the composer sits at the bottom once a run starts, suggestions align left, the composer leaves room for a two-line hint, and before/after rows stack.
Performance
- Steps and streaming run on timeouts that stop when the run finishes; the only frame loop is the 0.7 s speed change on the bead.
- The thread follows new content with a ResizeObserver while you are at the bottom, and lets go when you scroll up.
- No canvas or images: three local font files and inline SVG.
Notes for AI
Give your coding assistant the Markdown, not a screenshot.
- Keep runs in SCENARIOS in data.ts; the step count, Worked for time and row counts are computed from them.
- Keep the figures in the data consistent with each other (products, orders, listings, returns).
- Light and dark follow the nearest data-theme attribute above the piece, or the system setting. Keep colours in the tokens at the top of post.css.
/p/sorrel-agent/markdownThe whole library for assistants: llms.txt, or the MCP server in AI tools and MCP.