Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(quill): add chat primitives for agent surfaces (#71808)

Adam Leithe3280fcdcf25
diff --git a/frontend/bin/check-toolbar-graph.mjs b/frontend/bin/check-toolbar-graph.mjs
index 00eb719ae88a..19dc127d6812 100644
--- a/frontend/bin/check-toolbar-graph.mjs
+++ b/frontend/bin/check-toolbar-graph.mjs
@@ -41,7 +41,7 @@ const FORBIDDEN_PACKAGES = [
// Ratchet policy: when an edge is cut, lower the budget to lock it in; raise it only as a
// conscious, reviewed decision in the PR that needs it. There is headroom for churn, but any
// reintroduced leak jumps the graph back toward ~100 MiB and fails loudly.
-const TOTAL_INPUT_BYTES_BUDGET = 14_415_000
+const TOTAL_INPUT_BYTES_BUDGET = 14_436_000
function fail(message) {
console.error(`\n❌ ${message}`)
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index d0bd7e6a0136..ad7cb1fd4847 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -2573,7 +2573,7 @@ snapshots:
filters-taxonomic-filter--three-groups-default-layout--light:
hash: v1.k794b7964.b0d92a623d942f1378fd21f5d854d4e7764713ad759b5a74201e6d9806d46b48._przGLIsFcasVn8JIVDPIVC1JAnnqtA7Yn2v18iUbi0
filters-taxonomic-filter-menu-rebuild--data-warehouse-config--dark:
- hash: v1.k794b7964.75a7dc4221b22571369d6b3a1253e2f91d5caddccf58d022c4f0c3e5764bed33.ozhnlesjhew_maunSC-4TAGhNFiLtWf_QnkDQnpiVaY
+ hash: v1.k794b7964.695594eab6753acf560cbd54ecd1fa59157d0844e11c1ace7fe5e0637d60a570.84QX-AsU_pJxzLcbc1edVoTr4rn-EnEY25SbyuXe7Ys
filters-taxonomic-filter-menu-rebuild--data-warehouse-config--light:
hash: v1.k794b7964.48d96bddd32a3aab5e42c6b74c8404452559526a6a7f50931e037ce2d19b95b2.2K6X_AFjB8Yjo5SjwZvHlU0La7Kp79G-BSqYjMUoB9Q
filters-taxonomic-filter-menu-rebuild--events-and-actions--dark:
diff --git a/packages/quill/packages/primitives/AGENTS.md b/packages/quill/packages/primitives/AGENTS.md
index 6bf7e227f103..6bfe1000fb5b 100644
--- a/packages/quill/packages/primitives/AGENTS.md
+++ b/packages/quill/packages/primitives/AGENTS.md
@@ -143,6 +143,7 @@ Don't hand-roll `<p className="text-xs text-muted-foreground">` when `<Text size
| Progress | — | — | value: 0-100 |
| Slider | — | — | value, min, max |
| Avatar | — | lg, default, sm, xs | Compose `Avatar > AvatarImage + AvatarFallback`; image errors fall back to initials/icon |
+| ChatGlobe | — | — | Sweeping globe for "browsing the web"; sizes from its container. Still globe under reduced motion |
| AvatarGroup | — | default, sm, xs | Row of Avatars; `stacked` overlaps + spreads on hover (no reflow), `reverse` spreads left; `size` forwards to children |
---
@@ -768,6 +769,116 @@ A feed-style message row — Slack-like channel surfaces where every message ali
</ThreadItemGroup>
```
+### Chat disclosures — Marker and TaskList
+
+Two primitives share a row, a rail, a chevron, and a shimmer (`chat/lib/disclosure.css`), plus a status bullet (`chat/lib/status.css`):
+
+| Primitive | Use when |
+| -------------- | --------------------------------------------------------------------------------- |
+| `ChatMarker` | Anything an agent did — a note, one tool call, or a group of them |
+| `ChatTaskList` | A plan worked through — many steps, an aggregate count, each with its own outcome |
+
+Two shared classes carry the state vocabulary, and both handle `prefers-reduced-motion`:
+
+- `quill-shimmer` — "this is live". A cross-cutting utility, not a chat class; see Utilities below. `ChatMarkerContent` applies it from `status`, and an active `ChatTask` applies it too.
+- `quill-chat-bullet` — the leading status icon on `ChatSource` and `ChatTask`. Put `data-status` **on the bullet itself**; `done` tints `--success-foreground`, `failed`/`error` tint `--destructive-foreground`.
+- `quill-chat-swap` — a leading slot showing a state icon at rest and a chevron on hover/focus (`ChatTaskList`'s header). Compose `quill-chat-swap` > `quill-chat-swap__icon` + `quill-chat-swap__chevron`; the row supplies `quill-chat-row--interactive` for the hover scope. Cross-fades rather than `display`-swapping, so an icon carrying the bullet's reveal animation doesn't replay it on every hover-out.
+
+**Status tokens are fill/ink pairs, not shades.** `--success`/`--destructive` are backgrounds; the ink that reads on a surface is the `-foreground` half. Tinting an icon `--success` gives you pale-green-on-white.
+
+**Never style a chat row's descendants from the row.** These nest — a group's body holds markers, sources, whole lists — so `.block[data-status] .thing` and `.block a` reach straight into children that own their own state. This has caused real bugs: an errored group painted its succeeded rows' bullets red, and the marker's bare `svg` rule outranked `ChatSource`'s smaller out-arrow. Scope to the row's own slots (`__content`, `__icon`) or put the attribute on the element being styled.
+
+**Base UI triggers are never natively `disabled`** — an inert trigger gets `aria-disabled="true"` and keeps its tab stop, so it stays reachable by screen readers. CSS must gate on `:not([aria-disabled='true'])`, never `:not(:disabled)`, which matches everything and silently does nothing.
+
+### Chat marker (everything an agent did)
+
+One row at three fill levels. Resist splitting them apart again — they were separate primitives once and the seams cost more than they bought.
+
+- A **note** is the flat row: icon + text, nothing to open.
+- A **tool call** adds `status` (`running` shimmers the content, `error` turns the row destructive, `done` keeps the value) and usually a `ChatMarkerValue` for the argument it acted on. The value is quoted by CSS, so it can't ship without its quotes.
+- A **group** passes `body` and drops the icon: the row is the joined-up summary, and the calls behind it are markers of their own inside. No single icon is honest about several tools at once, which is why the icon is a slot you fill rather than a fixture.
+
+With a body the row becomes a Collapsible trigger — the chevron hugs the end of the text and only shows on hover/focus or when open, so a transcript of these doesn't read as a wall of controls. `defaultOpen` is the app's grouping decision; `open`/`onOpenChange` are there for the rare case the app drives it.
+
+**A group's status is its own, not its children's.** An errored group tints only its row; the rows inside keep their outcomes, so the call that succeeded still reads as a success.
+
+```tsx
+<ChatMarker
+ status="done"
+ defaultOpen
+ body={
+ <>
+ <ChatMarker>
+ <ChatMarkerIcon>
+ <FileIcon />
+ </ChatMarkerIcon>
+ <ChatMarkerContent>Read auth/middleware.ts</ChatMarkerContent>
+ </ChatMarker>
+ {/* …one marker per call */}
+ </>
+ }
+>
+ <ChatMarkerContent>Read 2 files · Edited 1 file · Ran 1 command</ChatMarkerContent>
+</ChatMarker>
+```
+
+When the tool returned pages, fill the body with `ChatSourceList` > `ChatSource` instead of markers. `status` walks a row through the fetch — `pending` (dashed ring) → `loading` (`ChatGlobe`) → `done` (green check). The app owns when each row moves. An `href` makes the row a link with a hover out-arrow; without one it's static text.
+
+```tsx
+<ChatMarker
+ status={running ? 'running' : 'done'}
+ defaultOpen
+ body={
+ <ChatSourceList>
+ {sites.map((site) => (
+ <ChatSource key={site.url} status={site.status} href={`https://${site.url}`}>
+ <ChatSourceTitle>{site.title}</ChatSourceTitle>
+ <ChatSourceUrl>{site.url}</ChatSourceUrl>
+ </ChatSource>
+ ))}
+ </ChatSourceList>
+ }
+>
+ <ChatMarkerContent>
+ {running ? 'Searching' : `Searched ${sites.length} sources`}
+ <ChatMarkerValue>{query}</ChatMarkerValue>
+ </ChatMarkerContent>
+</ChatMarker>
+```
+
+`ChatGlobe` is exported on its own: a globe whose meridians sweep, for when you can say _what_ is loading rather than only that something is (`Spinner` covers the rest). It sizes and tints from its container like any icon. It animates with SMIL, which **CSS cannot disable** — it reads `useReducedMotion()` and renders a still globe instead. Reach for that hook only where a media query can't reach; CSS is the right place for everything else.
+
+### Chat task list (a plan, worked through)
+
+The checklist an agent is following. The header shows where it's up to at a glance — a list icon before anything starts, a ring that fills as steps land, a check once they all have — beside a `2/5` count whose digits roll. It doubles as the disclosure affordance: hovering swaps it for a chevron. `ChatTask` carries its own `status`: `pending` (dashed), `active` (arrow, label shimmers), `done` (green check), `failed` (red X, destructive label). `ChatTaskDetail` is what the step produced — a duration, an exit code, the line explaining a failure.
+
+Steps **wrap** by default: a step's text is the point of the row, so clipping it is the caller's call, not the primitive's. Pass `truncate` to clamp one to a single line — the label and its detail clip together, so the ellipsis lands wherever the room runs out. Either way the bullet stays on the first line rather than floating into the middle of a wrapped paragraph.
+
+The list holds no state: `value`/`total` are the app's count, and nothing is inferred from the children, because only the app knows which step is running or why one broke. The header can't drift from the count beside it — both read the same context.
+
+**Setting up a sandbox is this primitive, not a variant of it.** A checklist is a checklist; the sandbox is its own copy plus `ChatTaskDetail` and a `failed` step. Don't add a `variant` prop for a product's wording.
+
+```tsx
+<ChatTaskList value={2} total={5} defaultOpen>
+ <ChatTaskListTrigger>
+ <ChatTaskListProgress />
+ <ChatTaskListLabel>Setting up sandbox</ChatTaskListLabel>
+ <ChatTaskListCount />
+ </ChatTaskListTrigger>
+ <ChatTaskListContent>
+ <ChatTask status="done">
+ Pull image
+ <ChatTaskDetail>node:22 · 1.2s</ChatTaskDetail>
+ </ChatTask>
+ <ChatTask status="failed">
+ Start services
+ <ChatTaskDetail>exit 1: port 8000 already in use</ChatTaskDetail>
+ </ChatTask>
+ <ChatTask status="pending">Run migrations</ChatTask>
+ </ChatTaskListContent>
+</ChatTaskList>
+```
+
### Keyboard Shortcuts
```tsx
@@ -980,6 +1091,27 @@ Sanctioned escape hatches (the only padding overrides the stories use):
---
+## Utilities
+
+Cross-cutting classes that aren't any component's. They ship with the package (`styles/utilities.css`, loaded from `index.ts`), so they're available to any element in a quill app.
+
+### `quill-shimmer`
+
+Live text: a highlight sweeping a line to say work is still in flight. Put it on any text — a `Text`, a bare `<span>`, a component's label.
+
+```tsx
+<Text size="sm" className="quill-shimmer">
+ Deploying…
+</Text>
+```
+
+- **It owns `color`.** The gradient is clipped to the glyphs, so the text must be transparent for the sweep to show. That's also why the rule is **unlayered** — inside `@layer components` any `text-*` utility beat it and silently painted over the animation. Unlayered beats every layer, so it now composes with utility colors; don't reintroduce a `color` on the same element expecting it to win.
+- **Text only.** `background-clip: text` can't reach an SVG stroke, so an icon needs its own treatment.
+- **Retune** with `--quill-shimmer-base` / `--quill-shimmer-highlight`; defaults read as muted brightening to full.
+- Reduced motion hands the color back rather than just stopping — otherwise the text would stay invisible.
+
+---
+
## Icons
Primitives size and lay out their own icons — drop a bare lucide icon in as a child and it just works:
diff --git a/packages/quill/packages/primitives/src/chat/chat-globe.tsx b/packages/quill/packages/primitives/src/chat/chat-globe.tsx
new file mode 100644
index 000000000000..2314dcd07e20
--- /dev/null
+++ b/packages/quill/packages/primitives/src/chat/chat-globe.tsx
@@ -0,0 +1,104 @@
+import * as React from 'react'
+
+import { cn } from '../lib/utils'
+import { useReducedMotion } from '../lib/use-reduced-motion'
+
+/**
+ * A globe whose meridians sweep, reading as "browsing the web". Vendored from the aicss web-search
+ * pattern. Where {@link ../spinner#Spinner} says only that something is loading, this says what — so
+ * use it for fetching a page or a source, and the Spinner for everything else.
+ *
+ * Sizes and tints itself from its container like any other icon (see the Icons section of
+ * AGENTS.md), so drop it in bare.
+ */
+
+// Four meridian shapes, left-most to right-most. Tweening between them in order sweeps a line across
+// the face; six copies at staggered offsets read as one rotating globe.
+const MERIDIANS = {
+ left: 'M6.057 11.565 C2.081 11.565 0.371 8.159 0.371 5.964 C0.371 3.642 2.152 0.329 6.05 0.329',
+ midLeft: 'M6.012 11.55 C4.575 10.496 3.333 8.116 3.321 5.964 C3.307 3.399 4.974 0.977 6.012 0.329',
+ midRight: 'M6.012 11.55 C7.211 10.781 8.715 8.287 8.715 5.964 C8.715 3.399 7.24 1.233 6.012 0.329',
+ right: 'M6.012 11.55 C9.677 11.55 11.65 8.487 11.65 5.964 C11.65 3.499 9.748 0.329 6.012 0.329',
+} as const
+
+const SWEEP = [MERIDIANS.left, MERIDIANS.midLeft, MERIDIANS.midRight, MERIDIANS.right, MERIDIANS.left].join(';')
+
+/*
+ * The paths are drawn to fill a 12-unit box edge to edge, but lucide keeps its art at 20 of 24 units
+ * — 91.7% of the box once the stroke is counted — and pads the rest. Sized to the same 0.875rem as
+ * its neighbours, an unpadded globe therefore renders ~14% wider than the circles beside it.
+ *
+ * So pad the viewBox instead of touching the geometry: widen the box until the globe's outer edge
+ * lands on lucide's 91.7%, and scale the stroke with it so the line keeps the weight it renders at
+ * today. Solving both together for r=5.7: box 13.48, stroke 0.95.
+ */
+const VIEW_BOX_SIZE = 13.48
+// Rounded, or binary float leaves `-0.7400000000000002` sitting in the markup.
+const VIEW_BOX_PAD = Math.round(((VIEW_BOX_SIZE - 12) / 2) * 100) / 100
+const VIEW_BOX = `${-VIEW_BOX_PAD} ${-VIEW_BOX_PAD} ${VIEW_BOX_SIZE} ${VIEW_BOX_SIZE}`
+const STROKE_WIDTH = 0.95
+
+const DURATION = '7.2s'
+// One full sweep split six ways, so a meridian crosses the face at an even cadence.
+const STARTS = ['0s', '-1.2s', '-2.4s', '-3.6s', '-4.8s', '-6s']
+const EASE_IN_OUT = '0.42 0 0.58 1'
+
+function ChatGlobe({ className, ...props }: React.ComponentProps<'svg'>): React.ReactElement {
+ const reducedMotion = useReducedMotion()
+
+ return (
+ <svg
+ data-quill
+ data-slot="globe"
+ viewBox={VIEW_BOX}
+ // Fallback only: containers size their bare icons in CSS, which beats these attributes.
+ width="14"
+ height="14"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth={STROKE_WIDTH}
+ strokeLinecap="round"
+ aria-hidden="true"
+ className={cn('quill-chat-globe', className)}
+ {...props}
+ >
+ <circle cx="6" cy="6" r="5.7" opacity="0.9" />
+ <line x1="0.3" y1="6" x2="11.7" y2="6" opacity="0.9" />
+ {reducedMotion ? (
+ // Still globe: two fixed meridians read as a sphere without anything moving. SMIL
+ // ignores `prefers-reduced-motion`, so the only way to honour it is to not render it.
+ <>
+ <path d={MERIDIANS.midLeft} opacity="0.9" />
+ <path d={MERIDIANS.midRight} opacity="0.9" />
+ </>
+ ) : (
+ STARTS.map((begin) => (
+ <path key={begin} d={MERIDIANS.left} opacity="0">
+ <animate
+ attributeName="d"
+ dur={DURATION}
+ begin={begin}
+ repeatCount="indefinite"
+ calcMode="spline"
+ keyTimes="0;0.25;0.5;0.75;1"
+ keySplines={[EASE_IN_OUT, EASE_IN_OUT, EASE_IN_OUT, EASE_IN_OUT].join(';')}
+ values={SWEEP}
+ />
+ {/* Fade in at the left limb and out at the right, so meridians don't pop. */}
+ <animate
+ attributeName="opacity"
+ dur={DURATION}
+ begin={begin}
+ repeatCount="indefinite"
+ calcMode="linear"
+ keyTimes="0;0.05;0.7;0.75;1"
+ values="0;0.9;0.9;0;0"
+ />
+ </path>
+ ))
+ )}
+ </svg>
+ )
+}
+
+export { ChatGlobe }
diff --git a/packages/quill/packages/primitives/src/chat/chat-marker.css b/packages/quill/packages/primitives/src/chat/chat-marker.css
index 7160299f6f21..6945056530f6 100644
--- a/packages/quill/packages/primitives/src/chat/chat-marker.css
+++ b/packages/quill/packages/primitives/src/chat/chat-marker.css
@@ -1,44 +1,41 @@
@layer components {
/*
- * Inline status / system-note / separator row, plus the quill collapsible extension.
+ * Note, tool call, and tool group — one row at three fill levels, plus the quill collapsible
+ * extension.
*
- * `quill-chat-marker` is the block. A flat marker is that block, rendered as a horizontal row.
- * A collapsible marker is the block + `--collapsible`, which flips it to a column wrapper that
- * stacks `__trigger` (a row sharing the block's appearance) above `__panel` — mirroring how
- * `quill-accordion` nests `__trigger` + `__panel` under its block.
+ * The row, trigger affordance, chevron, and rail come from `lib/disclosure.css` — this file only
+ * holds what's the marker's own. A flat marker is `quill-chat-row` + this block. A collapsible
+ * marker adds `--collapsible`, which flips the block to a column wrapper stacking `__trigger`
+ * (itself a row) above `__panel` — mirroring how `quill-accordion` nests trigger + panel.
*/
- .quill-chat-marker,
- .quill-chat-marker__trigger {
- position: relative;
- display: flex;
- gap: 0.5rem;
- align-items: center;
- width: 100%;
- min-height: 1rem;
- font-size: var(--text-xs, 0.75rem);
- line-height: 1.625;
- color: var(--muted-foreground);
- text-align: left;
- }
/* Collapsible form: the block becomes the column wrapper; the trigger is the row. */
.quill-chat-marker--collapsible {
+ display: flex;
flex-direction: column;
gap: 0;
align-items: stretch;
+ width: 100%;
}
- .quill-chat-marker svg:not([class*='size-']) {
+ /*
+ * Scoped to the row's own slots, never `.quill-chat-marker *`. A marker's body holds other
+ * components now — nested markers, a `ChatSourceList` — and a descendant rule reaches straight
+ * into them: the bare `svg` rule outranked `ChatSource`'s smaller out-arrow (0,1,1 beats 0,1,0)
+ * and the bare `a` rule underlined every source link.
+ */
+ .quill-chat-marker__icon svg:not([class*='size-']),
+ .quill-chat-marker__content svg:not([class*='size-']) {
width: 0.875rem;
height: 0.875rem;
}
- .quill-chat-marker a {
+ .quill-chat-marker__content a {
text-decoration: underline;
text-underline-offset: 3px;
}
- .quill-chat-marker a:hover {
+ .quill-chat-marker__content a:hover {
color: var(--foreground);
}
@@ -82,71 +79,51 @@
text-align: center;
}
- /* Collapsible extension */
- .quill-chat-marker__trigger {
- padding-inline: 0.25rem;
- margin-inline: -0.25rem;
- cursor: pointer;
- border-radius: 0.375rem;
+ /*
+ * The argument the call acted on. Quoted here rather than in the markup so a value can't ship
+ * without its quotes, and so they disappear with it.
+ */
+ .quill-chat-marker__value::before {
+ content: '\201C';
}
- .quill-chat-marker__trigger:hover {
- background-color: var(--fill-hover);
+ .quill-chat-marker__value::after {
+ content: '\201D';
}
- /* Keyboard focus needs a real ring, not just the hover fill (WCAG 2.4.7). */
- .quill-chat-marker__trigger:focus-visible {
- background-color: var(--fill-hover);
- outline: none;
- box-shadow: 0 0 0 2px color-mix(in oklab, var(--ring) 50%, transparent);
+ .quill-chat-marker__value {
+ margin-inline-start: 0.25rem;
}
- .quill-chat-marker__chevron {
- flex-shrink: 0;
- width: 0.875rem;
- height: 0.875rem;
- margin-inline-start: auto;
- color: var(--muted-foreground);
- opacity: 0;
- transition:
- opacity 150ms ease,
- rotate 150ms ease;
- }
-
- .quill-chat-marker__trigger:hover .quill-chat-marker__chevron,
- .quill-chat-marker__trigger[data-panel-open] .quill-chat-marker__chevron {
- opacity: 1;
+ /*
+ * Settled: the verb stays muted, the value it acted on reads as the fact worth keeping. Routed
+ * through `__content` so a group's status can't reach a nested marker's value — the body lives in
+ * `__panel`, never in `__content`, so this can't cross into a child row.
+ */
+ .quill-chat-marker[data-status='done'] > .quill-chat-marker__content .quill-chat-marker__value,
+ .quill-chat-marker[data-status='done']
+ > .quill-chat-marker__trigger
+ > .quill-chat-marker__content
+ .quill-chat-marker__value {
+ color: var(--foreground);
}
- .quill-chat-marker__trigger[data-panel-open] .quill-chat-marker__chevron {
- rotate: 90deg;
+ /*
+ * Failed: the whole row goes destructive, verb included — "Searched" is no longer true, so it
+ * shouldn't read as neutral history. Scoped to this marker's own row: `__content` and `__icon`
+ * belong to it, while a nested marker in the body carries its own status and tints itself.
+ */
+ .quill-chat-marker[data-status='error'] > .quill-chat-marker__icon,
+ .quill-chat-marker[data-status='error'] > .quill-chat-marker__content,
+ .quill-chat-marker[data-status='error'] > .quill-chat-marker__trigger > .quill-chat-marker__icon,
+ .quill-chat-marker[data-status='error'] > .quill-chat-marker__trigger > .quill-chat-marker__content {
+ color: var(--destructive-foreground);
}
- /* Collapsible panel: indent children + animate height. */
+ /* Collapsible panel: stack the disclosed children. */
.quill-chat-marker__panel {
display: flex;
flex-direction: column;
gap: 0.25rem;
- padding-inline-start: 0.875rem;
- margin-inline-start: 0.375rem;
- overflow: hidden;
- border-inline-start: 1px solid var(--border);
- transition: height 150ms ease;
- }
-
- .quill-chat-marker__panel[data-starting-style],
- .quill-chat-marker__panel[data-ending-style] {
- height: 0;
- }
-
- .quill-chat-marker__panel[data-open] {
- height: var(--collapsible-panel-height);
- }
-
- @media (prefers-reduced-motion: reduce) {
- .quill-chat-marker__chevron,
- .quill-chat-marker__panel {
- transition: none;
- }
}
}
diff --git a/packages/quill/packages/primitives/src/chat/chat-marker.stories.tsx b/packages/quill/packages/primitives/src/chat/chat-marker.stories.tsx
index 49f313e8ff90..47e8556ae2d2 100644
--- a/packages/quill/packages/primitives/src/chat/chat-marker.stories.tsx
+++ b/packages/quill/packages/primitives/src/chat/chat-marker.stories.tsx
@@ -1,8 +1,11 @@
import type { Meta, StoryObj } from '@storybook/react'
import { CheckIcon, FileIcon, PencilIcon, SearchIcon, TerminalIcon } from 'lucide-react'
+import * as React from 'react'
-import { ChatMarker, ChatMarkerContent, ChatMarkerIcon } from './chat-marker'
+import { ChatMarker, ChatMarkerContent, ChatMarkerIcon, ChatMarkerValue } from './chat-marker'
+import { ChatSource, ChatSourceList, ChatSourceTitle, ChatSourceUrl, type ChatSourceStatus } from './chat-source'
+import { Button } from '../button'
import { Spinner } from '../spinner'
const meta = {
@@ -14,7 +17,21 @@ const meta = {
export default meta
type Story = StoryObj<typeof meta>
-/** The three flat variants — no body, no collapse (stock shadcn Marker). */
+const QUERY = 'JWT auth vulnerabilities and middleware security best practices'
+
+const SITES = [
+ { title: 'JWT verification best practices', url: 'auth0.com/blog/jwt-security-best-practices' },
+ { title: 'Node.js authentication security guide', url: 'owasp.org/www-project-nodejs-goat' },
+ { title: 'JWT attacks · Web Security Academy', url: 'portswigger.net/web-security/jwt' },
+]
+
+const TIMELINE = [
+ { discover: 600, finish: 2400 },
+ { discover: 1600, finish: 4000 },
+ { discover: 2800, finish: 5600 },
+]
+
+/** The three flat variants — a settled note, no body, nothing to open. */
export const Variants = {
render: () => (
<div className="flex w-[420px] flex-col gap-4">
@@ -37,61 +54,104 @@ export const Variants = {
),
} satisfies Story
-/** Live state: Spinner + shimmer text while a tool runs. */
+/** `status="running"` shimmers the content. Pair it with a Spinner for the icon. */
export const Live = {
render: () => (
<div className="w-[420px]">
- <ChatMarker>
+ <ChatMarker status="running">
<ChatMarkerIcon>
<Spinner />
</ChatMarkerIcon>
- <ChatMarkerContent className="shimmer">Editing components/thread.tsx…</ChatMarkerContent>
+ <ChatMarkerContent>Editing components/thread.tsx…</ChatMarkerContent>
</ChatMarker>
</div>
),
} satisfies Story
/**
- * Collapsible: pass `body` and the row gains a hover chevron + `bg-fill-hover`; click toggles.
- * This is the tool-group summary → per-tool children pattern. `defaultOpen` is the app's
- * grouping-mode decision (compact → false).
+ * One tool call: `status` plus the argument it acted on. The value is quoted by CSS, and goes
+ * foreground once the call settles — that's the fact worth keeping.
*/
-export const Collapsible = {
+export const ToolCall = {
+ render: () => (
+ <div className="flex w-[420px] flex-col gap-4">
+ <ChatMarker status="running">
+ <ChatMarkerIcon>
+ <SearchIcon />
+ </ChatMarkerIcon>
+ <ChatMarkerContent>
+ Searching
+ <ChatMarkerValue>{QUERY}</ChatMarkerValue>
+ </ChatMarkerContent>
+ </ChatMarker>
+ <ChatMarker status="done">
+ <ChatMarkerIcon>
+ <TerminalIcon />
+ </ChatMarkerIcon>
+ <ChatMarkerContent>
+ Ran
+ <ChatMarkerValue>pnpm build</ChatMarkerValue>
+ </ChatMarkerContent>
+ </ChatMarker>
+ <ChatMarker status="error">
+ <ChatMarkerIcon>
+ <TerminalIcon />
+ </ChatMarkerIcon>
+ <ChatMarkerContent>
+ Couldn’t run
+ <ChatMarkerValue>pnpm test</ChatMarkerValue>
+ </ChatMarkerContent>
+ </ChatMarker>
+ </div>
+ ),
+} satisfies Story
+
+/**
+ * A group: pass `body` and drop the icon. The row is the joined-up summary and the calls behind it
+ * are markers of their own — no single icon is honest about several tools at once. The chevron hugs
+ * the summary and only shows on hover, so a transcript of these isn't a wall of controls.
+ */
+export const Group = {
render: () => (
<div className="flex w-[420px] flex-col gap-4">
<ChatMarker
- defaultOpen={false}
+ defaultOpen
+ status="done"
body={
<>
<ChatMarker>
<ChatMarkerIcon>
<FileIcon />
</ChatMarkerIcon>
- <ChatMarkerContent>Read store.ts</ChatMarkerContent>
+ <ChatMarkerContent>Read auth/middleware.ts</ChatMarkerContent>
</ChatMarker>
<ChatMarker>
<ChatMarkerIcon>
<FileIcon />
</ChatMarkerIcon>
- <ChatMarkerContent>Read view.tsx</ChatMarkerContent>
+ <ChatMarkerContent>Read auth/verify.test.ts</ChatMarkerContent>
</ChatMarker>
<ChatMarker>
<ChatMarkerIcon>
<PencilIcon />
</ChatMarkerIcon>
- <ChatMarkerContent>Edited view.tsx</ChatMarkerContent>
+ <ChatMarkerContent>Edited auth/middleware.ts</ChatMarkerContent>
+ </ChatMarker>
+ <ChatMarker>
+ <ChatMarkerIcon>
+ <TerminalIcon />
+ </ChatMarkerIcon>
+ <ChatMarkerContent>pnpm test — 12 passed</ChatMarkerContent>
</ChatMarker>
</>
}
>
- <ChatMarkerIcon>
- <CheckIcon />
- </ChatMarkerIcon>
- <ChatMarkerContent>Read 2 files · Edited 1 file</ChatMarkerContent>
+ <ChatMarkerContent>Read 2 files · Edited 1 file · Ran 1 command</ChatMarkerContent>
</ChatMarker>
<ChatMarker
- defaultOpen
+ defaultOpen={false}
+ status="done"
body={
<ChatMarker>
<ChatMarkerIcon>
@@ -101,11 +161,139 @@ export const Collapsible = {
</ChatMarker>
}
>
- <ChatMarkerIcon>
- <TerminalIcon />
- </ChatMarkerIcon>
- <ChatMarkerContent>Ran 1 command (expanded by default)</ChatMarkerContent>
+ <ChatMarkerContent>Ran 1 command (collapsed by default)</ChatMarkerContent>
+ </ChatMarker>
+ </div>
+ ),
+} satisfies Story
+
+function WebSearch({ statuses, running }: { statuses: ChatSourceStatus[]; running: boolean }): React.ReactElement {
+ return (
+ <ChatMarker
+ defaultOpen
+ status={running ? 'running' : 'done'}
+ body={
+ <ChatSourceList>
+ {SITES.map((site, index) => (
+ <ChatSource key={site.url} status={statuses[index]} href={`https://${site.url}`}>
+ <ChatSourceTitle>{site.title}</ChatSourceTitle>
+ <ChatSourceUrl>{site.url}</ChatSourceUrl>
+ </ChatSource>
+ ))}
+ </ChatSourceList>
+ }
+ >
+ <ChatMarkerContent>
+ {running ? 'Searching' : `Searched ${SITES.length} sources`}
+ <ChatMarkerValue>{QUERY}</ChatMarkerValue>
+ </ChatMarkerContent>
+ </ChatMarker>
+ )
+}
+
+/**
+ * A tool that returned pages: fill the body with `ChatSourceList` instead of markers. Each row walks
+ * its own fetch — dashed ring → globe → green check — and the app owns when it moves.
+ */
+export const WebSearchSources = {
+ render: () => (
+ <div className="w-[460px]">
+ <WebSearch statuses={['pending', 'loading', 'done']} running />
+ </div>
+ ),
+} satisfies Story
+
+/**
+ * An errored group tints its own row only. The rows inside keep their own outcomes — the one that
+ * succeeded still reads as a success, because a group's status is not its children's.
+ */
+export const GroupError = {
+ render: () => (
+ <div className="w-[460px]">
+ <ChatMarker
+ defaultOpen
+ status="error"
+ body={
+ <ChatSourceList>
+ <ChatSource status="done" href={`https://${SITES[0].url}`}>
+ <ChatSourceTitle>{SITES[0].title}</ChatSourceTitle>
+ <ChatSourceUrl>{SITES[0].url}</ChatSourceUrl>
+ </ChatSource>
+ <ChatSource status="pending">
+ <ChatSourceTitle>Rate limited after 1 result</ChatSourceTitle>
+ <ChatSourceUrl>retry in 30s</ChatSourceUrl>
+ </ChatSource>
+ </ChatSourceList>
+ }
+ >
+ <ChatMarkerContent>
+ Couldn’t search
+ <ChatMarkerValue>{QUERY}</ChatMarkerValue>
+ </ChatMarkerContent>
</ChatMarker>
</div>
),
} satisfies Story
+
+/** A source row without an href is static text — no hover fill, no out-arrow. */
+export const SourcesWithoutLinks = {
+ render: () => (
+ <div className="w-[460px]">
+ <ChatMarker
+ defaultOpen
+ status="done"
+ body={
+ <ChatSourceList>
+ <ChatSource status="done">
+ <ChatSourceTitle>Internal runbook</ChatSourceTitle>
+ <ChatSourceUrl>indexed 2 days ago</ChatSourceUrl>
+ </ChatSource>
+ </ChatSourceList>
+ }
+ >
+ <ChatMarkerContent>
+ Searched the knowledge base
+ <ChatMarkerValue>onboarding</ChatMarkerValue>
+ </ChatMarkerContent>
+ </ChatMarker>
+ </div>
+ ),
+} satisfies Story
+
+function LiveSearch(): React.ReactElement {
+ const [runId, setRunId] = React.useState(0)
+ const [statuses, setStatuses] = React.useState<ChatSourceStatus[]>(() => SITES.map(() => 'pending'))
+ const [running, setRunning] = React.useState(true)
+
+ React.useEffect(() => {
+ setStatuses(SITES.map(() => 'pending'))
+ setRunning(true)
+ const setAt = (index: number, status: ChatSourceStatus): void =>
+ setStatuses((prev) => prev.map((value, i) => (i === index ? status : value)))
+ const timers = TIMELINE.flatMap(({ discover, finish }, index) => [
+ setTimeout(() => setAt(index, 'loading'), discover),
+ setTimeout(() => setAt(index, 'done'), finish),
+ ])
+ const last = Math.max(...TIMELINE.map((t) => t.finish))
+ timers.push(setTimeout(() => setRunning(false), last + 800))
+ return () => timers.forEach(clearTimeout)
+ }, [runId])
+
+ return (
+ <div className="flex w-[460px] flex-col gap-4">
+ <WebSearch statuses={statuses} running={running} />
+ <Button variant="outline" size="sm" className="self-start" onClick={() => setRunId((id) => id + 1)}>
+ Replay
+ </Button>
+ </div>
+ )
+}
+
+/**
+ * The whole arc: sources are discovered, fetched, and land one by one, then the call settles and the
+ * shimmer stops. The app owns the timing — the primitive never infers it.
+ */
+export const Live_Search = {
+ name: 'Live search',
+ render: () => <LiveSearch />,
+} satisfies Story
diff --git a/packages/quill/packages/primitives/src/chat/chat-marker.tsx b/packages/quill/packages/primitives/src/chat/chat-marker.tsx
index 103c6d4fbdb1..db9c5826bae0 100644
--- a/packages/quill/packages/primitives/src/chat/chat-marker.tsx
+++ b/packages/quill/packages/primitives/src/chat/chat-marker.tsx
@@ -6,19 +6,31 @@ import { ChevronRightIcon } from 'lucide-react'
import * as React from 'react'
import './chat-marker.css'
+import './lib/disclosure.css'
import { cn } from '../lib/utils'
/**
- * Inline status / system-note / separator row — vendored from the shadcn `base-mira` registry
- * and renamed `ChatX`. Styling lives in `chat-marker.css` (quill convention).
+ * Everything an agent did, at every fill level — vendored from the shadcn `base-mira` registry and
+ * renamed `ChatX`. Styling lives in `chat-marker.css` (quill convention).
*
- * Quill divergence from stock shadcn Marker: pass `body` to make it collapsible. With a body the
- * row becomes a Base-UI Collapsible trigger (hover reveals a chevron + `bg-fill-hover`, click
- * toggles, the body renders below). Without a body it's the flat shadcn marker. This is how a
- * single tool, a tool-group summary, and a status note are all the same primitive at different
- * fill levels. Collapse state is uncontrolled via `defaultOpen`; `open`/`onOpenChange` are there
+ * The fill levels are one primitive, not three. Resist splitting them back apart:
+ *
+ * - A **note** is the flat row: icon + text, nothing to open.
+ * - A **tool call** adds `status` — it shimmers while `running` and goes destructive on `error` —
+ * and usually a `ChatMarkerValue` for the argument it acted on.
+ * - A **group** passes `body` and drops the icon: the row becomes the joined-up summary ("Read 2
+ * files · Edited 1 file") and the calls behind it are markers of their own inside. No single icon
+ * is honest about several tools at once, which is why the icon is a slot you fill, not a fixture.
+ *
+ * Quill divergence from stock shadcn Marker: pass `body` to make it collapsible. The row becomes a
+ * Base-UI Collapsible trigger (hover reveals a chevron + `bg-fill-hover`, click toggles, the body
+ * renders below). Collapse state is uncontrolled via `defaultOpen`; `open`/`onOpenChange` are there
* for the rare case the app drives it (e.g. auto-expand the running tool).
+ *
+ * Fill the body with more markers, or with `ChatSourceList` when the tool returned pages.
*/
+type ChatMarkerStatus = 'running' | 'done' | 'error'
+
const markerVariants = cva('quill-chat-marker', {
variants: {
variant: {
@@ -32,8 +44,15 @@ const markerVariants = cva('quill-chat-marker', {
},
})
+const ChatMarkerContext = React.createContext<ChatMarkerStatus | undefined>(undefined)
+
type ChatMarkerProps = useRender.ComponentProps<'div'> &
VariantProps<typeof markerVariants> & {
+ /**
+ * Omit for a settled note. `running` shimmers the content, `error` turns the row destructive,
+ * `done` keeps the value it acted on. The app flips it; the primitive never infers it.
+ */
+ status?: ChatMarkerStatus
/** Renders the marker as a collapsible: this becomes the expandable panel below the row. */
body?: React.ReactNode
/** Uncontrolled initial open state (only meaningful with `body`). */
@@ -43,12 +62,17 @@ type ChatMarkerProps = useRender.ComponentProps<'div'> &
}
function ChatMarker({ body, ...props }: ChatMarkerProps): React.ReactElement {
- return body == null ? <ChatMarkerFlat {...props} /> : <ChatMarkerCollapsible body={body} {...props} />
+ // Every value React renders as nothing means there's nothing to disclose. `body == null` alone
+ // would miss `body={items.length > 0 && <List />}`, the usual way to pass one conditionally, and
+ // give the row a chevron that opens onto an empty panel.
+ const hasBody = body != null && body !== false && body !== ''
+ return hasBody ? <ChatMarkerCollapsible body={body} {...props} /> : <ChatMarkerFlat {...props} />
}
function ChatMarkerFlat({
className,
variant = 'default',
+ status,
render,
// `body`/collapse props are accepted by ChatMarker but inert in the flat path.
defaultOpen: _defaultOpen,
@@ -56,14 +80,15 @@ function ChatMarkerFlat({
onOpenChange: _onOpenChange,
...props
}: ChatMarkerProps): React.ReactElement {
- return useRender({
+ const row = useRender({
defaultTagName: 'div',
props: mergeProps<'div'>(
{
'data-quill': '',
'data-slot': 'marker',
'data-variant': variant,
- className: cn(markerVariants({ variant, className })),
+ 'data-status': status,
+ className: cn('quill-chat-row', markerVariants({ variant, className })),
} as Omit<React.ComponentProps<'div'>, 'ref'>,
props
),
@@ -71,13 +96,17 @@ function ChatMarkerFlat({
state: {
slot: 'marker',
variant,
+ status,
},
})
+
+ return <ChatMarkerContext.Provider value={status}>{row}</ChatMarkerContext.Provider>
}
function ChatMarkerCollapsible({
className,
variant = 'default',
+ status,
body,
defaultOpen,
open,
@@ -87,36 +116,69 @@ function ChatMarkerCollapsible({
...props
}: ChatMarkerProps): React.ReactElement {
return (
- <CollapsiblePrimitive.Root
- data-quill
- data-slot="marker"
- data-variant={variant}
- defaultOpen={defaultOpen}
- open={open}
- onOpenChange={onOpenChange}
- className={cn(markerVariants({ variant }), 'quill-chat-marker--collapsible')}
- >
- <CollapsiblePrimitive.Trigger
- className={cn('quill-chat-marker__trigger', className)}
- render={render}
- {...(props as React.ComponentProps<typeof CollapsiblePrimitive.Trigger>)}
+ <ChatMarkerContext.Provider value={status}>
+ <CollapsiblePrimitive.Root
+ data-quill
+ data-slot="marker"
+ data-variant={variant}
+ data-status={status}
+ defaultOpen={defaultOpen}
+ open={open}
+ onOpenChange={onOpenChange}
+ className={cn(markerVariants({ variant }), 'quill-chat-marker--collapsible')}
>
- {children}
- <ChevronRightIcon aria-hidden="true" className="quill-chat-marker__chevron" />
- </CollapsiblePrimitive.Trigger>
- <CollapsiblePrimitive.Panel data-slot="marker-panel" className="quill-chat-marker__panel">
- {body}
- </CollapsiblePrimitive.Panel>
- </CollapsiblePrimitive.Root>
+ <CollapsiblePrimitive.Trigger
+ className={cn(
+ 'quill-chat-row',
+ 'quill-chat-row--interactive',
+ 'quill-chat-marker__trigger',
+ className
+ )}
+ render={render}
+ {...(props as React.ComponentProps<typeof CollapsiblePrimitive.Trigger>)}
+ >
+ {children}
+ <ChevronRightIcon
+ aria-hidden="true"
+ className={cn('quill-chat-chevron', 'quill-chat-chevron--reveal')}
+ />
+ </CollapsiblePrimitive.Trigger>
+ <CollapsiblePrimitive.Panel
+ data-slot="marker-panel"
+ className={cn('quill-chat-collapse', 'quill-chat-rail', 'quill-chat-marker__panel')}
+ >
+ {body}
+ </CollapsiblePrimitive.Panel>
+ </CollapsiblePrimitive.Root>
+ </ChatMarkerContext.Provider>
)
}
function ChatMarkerIcon({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return <span data-slot="marker-icon" aria-hidden="true" className={cn('quill-chat-marker__icon', className)} {...props} />
+ return (
+ <span
+ data-slot="marker-icon"
+ aria-hidden="true"
+ className={cn('quill-chat-marker__icon', className)}
+ {...props}
+ />
+ )
}
function ChatMarkerContent({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
- return <span data-slot="marker-content" className={cn('quill-chat-marker__content', className)} {...props} />
+ const status = React.useContext(ChatMarkerContext)
+ return (
+ <span
+ data-slot="marker-content"
+ className={cn('quill-chat-marker__content', status === 'running' && 'quill-shimmer', className)}
+ {...props}
+ />
+ )
+}
+
+/** The argument a call acted on — a query, a path, a command. Quoted, and kept once it settles. */
+function ChatMarkerValue({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+ return <span data-slot="marker-value" className={cn('quill-chat-marker__value', className)} {...props} />
}
-export { ChatMarker, ChatMarkerIcon, ChatMarkerContent, markerVariants }
+export { ChatMarker, ChatMarkerIcon, ChatMarkerContent, ChatMarkerValue, markerVariants, type ChatMarkerStatus }
diff --git a/packages/quill/packages/primitives/src/chat/chat-message-scroller.stories.tsx b/packages/quill/packages/primitives/src/chat/chat-message-scroller.stories.tsx
index c0021033ef45..03489cc769f6 100644
--- a/packages/quill/packages/primitives/src/chat/chat-message-scroller.stories.tsx
+++ b/packages/quill/packages/primitives/src/chat/chat-message-scroller.stories.tsx
@@ -110,7 +110,7 @@ export const Default = {
<ChatMarkerIcon>
<Spinner />
</ChatMarkerIcon>
- <ChatMarkerContent className="shimmer">Reading large-file.ts…</ChatMarkerContent>
+ <ChatMarkerContent className="quill-shimmer">Reading large-file.ts…</ChatMarkerContent>
</ChatMarker>
</ChatMessageContent>
</ChatMessage>
diff --git a/packages/quill/packages/primitives/src/chat/chat-source.css b/packages/quill/packages/primitives/src/chat/chat-source.css
new file mode 100644
index 000000000000..9113bc23319e
--- /dev/null
+++ b/packages/quill/packages/primitives/src/chat/chat-source.css
@@ -0,0 +1,101 @@
+@layer components {
+ /*
+ * A found page: bullet · title · url · out-arrow, on one dense line. The bullet carries the
+ * fetch state; the title is what the reader scans, so it holds the foreground while the url
+ * stays muted behind it.
+ */
+
+ /*
+ * Rows bleed 0.25rem past their text on both sides so the hover fill isn't cramped against it.
+ * On the start side that bleed lands in the rail's padding; on the end side there's nothing to
+ * land in, so the list reserves it here. Without this the row overhangs the component's right
+ * edge, which becomes a horizontal scrollbar the moment a parent is tight or clips.
+ */
+ .quill-chat-source-list {
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+ padding-inline-end: 0.25rem;
+ margin: 0;
+ list-style: none;
+ }
+
+ .quill-chat-source {
+ display: flex;
+ gap: 0.375rem;
+ align-items: center;
+ min-width: 0;
+ padding-inline: 0.25rem;
+ margin-inline: -0.25rem;
+ font-size: var(--text-xs, 0.75rem);
+ line-height: 1.625;
+ color: var(--muted-foreground);
+ text-decoration: none;
+ border-radius: 0.375rem;
+ }
+
+ a.quill-chat-source:hover {
+ background-color: var(--fill-hover);
+ }
+
+ a.quill-chat-source:focus-visible {
+ background-color: var(--fill-hover);
+ outline: none;
+ box-shadow: 0 0 0 2px color-mix(in oklab, var(--ring) 50%, transparent);
+ }
+
+ /*
+ * The line the reader is actually here for, so it shrinks last — but it does shrink. A
+ * `flex-shrink: 0` title lets its box run past the row, where it clips against an edge nobody
+ * can see and the ellipsis never appears.
+ */
+ .quill-chat-source__title {
+ min-width: 0;
+ overflow: hidden;
+ color: var(--foreground);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .quill-chat-source-item[data-status='pending'] .quill-chat-source__title {
+ color: var(--muted-foreground);
+ }
+
+ /*
+ * Supporting detail, so it's the first thing to give up room — the outsized shrink factor is
+ * what makes it yield almost entirely before the title gives up a pixel. The separator lives
+ * here rather than in the markup: it belongs to the url, and it should disappear with it.
+ */
+ .quill-chat-source__url {
+ flex-shrink: 9999;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .quill-chat-source__url::before {
+ margin-inline-end: 0.375rem;
+ content: '·';
+ }
+
+ .quill-chat-source__arrow {
+ flex-shrink: 0;
+ width: 0.75rem;
+ height: 0.75rem;
+ margin-inline-start: auto;
+ opacity: 0;
+ transition: opacity 150ms ease;
+ }
+
+ a.quill-chat-source:hover .quill-chat-source__arrow,
+ a.quill-chat-source:focus-visible .quill-chat-source__arrow {
+ opacity: 1;
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .quill-chat-source__arrow {
+ transition: none;
+ }
+ }
+}
diff --git a/packages/quill/packages/primitives/src/chat/chat-source.tsx b/packages/quill/packages/primitives/src/chat/chat-source.tsx
new file mode 100644
index 000000000000..6fe3e6e5512f
--- /dev/null
+++ b/packages/quill/packages/primitives/src/chat/chat-source.tsx
@@ -0,0 +1,86 @@
+import { mergeProps } from '@base-ui/react/merge-props'
+import { useRender } from '@base-ui/react/use-render'
+import { ArrowUpRightIcon, CircleCheckIcon, CircleDashedIcon } from 'lucide-react'
+import * as React from 'react'
+
+import './chat-source.css'
+import './lib/status.css'
+import { cn } from '../lib/utils'
+import { ChatGlobe } from './chat-globe'
+
+/**
+ * A page an agent found and read — the rows a web search discloses. Vendored from the aicss
+ * web-search pattern and renamed `ChatSource`. Drop a `ChatSourceList` into a `ChatMarker`'s `body`.
+ *
+ * `status` walks a row through the fetch: `pending` (found, not opened) shows a dashed ring,
+ * `loading` swaps in a sweeping {@link ./chat-globe#ChatGlobe}, `done` lands on a check. The app owns
+ * when each row moves — same contract as the rest of the family, since only the app knows what the
+ * agent is actually doing.
+ *
+ * Give a row an `href` and it becomes a link with an out-arrow; without one it's static text.
+ */
+type ChatSourceStatus = 'pending' | 'loading' | 'done'
+
+const STATUS_ICON: Record<ChatSourceStatus, React.ReactElement> = {
+ pending: <CircleDashedIcon />,
+ loading: <ChatGlobe />,
+ done: <CircleCheckIcon />,
+}
+
+function ChatSourceList({ className, ...props }: React.ComponentProps<'ul'>): React.ReactElement {
+ return <ul data-quill data-slot="source-list" className={cn('quill-chat-source-list', className)} {...props} />
+}
+
+type ChatSourceProps = useRender.ComponentProps<'a'> & {
+ status?: ChatSourceStatus
+ href?: string
+}
+
+function ChatSource({
+ status = 'pending',
+ className,
+ children,
+ href,
+ render,
+ ...props
+}: ChatSourceProps): React.ReactElement {
+ const row = useRender({
+ defaultTagName: href == null ? 'span' : 'a',
+ props: mergeProps<'a'>(
+ {
+ 'data-slot': 'source',
+ href,
+ className: cn('quill-chat-source', className),
+ children: (
+ <>
+ <span data-slot="source-bullet" data-status={status} className="quill-chat-bullet">
+ {/* Keyed so a status change mounts a fresh icon, which replays the reveal. */}
+ <React.Fragment key={status}>{STATUS_ICON[status]}</React.Fragment>
+ </span>
+ {children}
+ {href != null && <ArrowUpRightIcon aria-hidden="true" className="quill-chat-source__arrow" />}
+ </>
+ ),
+ } as Omit<React.ComponentProps<'a'>, 'ref'>,
+ props
+ ),
+ render,
+ state: { slot: 'source', status },
+ })
+
+ return (
+ <li data-status={status} className="quill-chat-source-item">
+ {row}
+ </li>
+ )
+}
+
+function ChatSourceTitle({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+ return <span data-slot="source-title" className={cn('quill-chat-source__title', className)} {...props} />
+}
+
+function ChatSourceUrl({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+ return <span data-slot="source-url" className={cn('quill-chat-source__url', className)} {...props} />
+}
+
+export { ChatSourceList, ChatSource, ChatSourceTitle, ChatSourceUrl, type ChatSourceStatus }
diff --git a/packages/quill/packages/primitives/src/chat/chat-stream.css b/packages/quill/packages/primitives/src/chat/chat-stream.css
new file mode 100644
index 000000000000..d56c2e6414e6
--- /dev/null
+++ b/packages/quill/packages/primitives/src/chat/chat-stream.css
@@ -0,0 +1,89 @@
+@layer components {
+ /*
+ * A window onto output that's still arriving. `quill-chat-stream` is the window (height cap +
+ * edge fades); `__lines` is the content it slides; `__line` is one line of it.
+ *
+ * No rail and no chrome here on purpose — a stream is framed by whatever it's dropped into.
+ */
+ .quill-chat-stream {
+ --quill-chat-stream-fade-top: 0px;
+ --quill-chat-stream-fade-bottom: 0px;
+
+ max-height: var(--quill-chat-stream-max-height, 11.25rem);
+ overflow-y: auto;
+
+ /*
+ * The mask softens whichever edge has content beyond it; the fade inset collapses to 0 on an
+ * edge that's already flush, so a short stream renders with no fade at all.
+ */
+ mask-image: linear-gradient(
+ to bottom,
+ transparent 0,
+ #000 var(--quill-chat-stream-fade-top),
+ #000 calc(100% - var(--quill-chat-stream-fade-bottom)),
+ transparent 100%
+ );
+ }
+
+ /* Pinned, the window drives itself to the newest line — the reader doesn't. */
+ .quill-chat-stream[data-pinned] {
+ overflow-y: hidden;
+ }
+
+ .quill-chat-stream[data-fade-top] {
+ --quill-chat-stream-fade-top: 1rem;
+ }
+
+ .quill-chat-stream[data-fade-bottom] {
+ --quill-chat-stream-fade-bottom: 1rem;
+ }
+
+ /*
+ * The stream slides up as it outgrows the window, carrying older lines off the top edge. It's
+ * on-screen content moving rather than entering, so it eases in and out (a car pulling away and
+ * braking) instead of the ease-out an entrance would take. About a line of travel, so it sits at
+ * the short end of the UI range.
+ */
+ .quill-chat-stream__lines {
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+ transition: translate 250ms cubic-bezier(0.645, 0.045, 0.355, 1);
+ translate: 0 var(--quill-chat-stream-offset, 0);
+ will-change: transform;
+ }
+
+ .quill-chat-stream__line {
+ font-size: var(--text-xs, 0.75rem);
+ line-height: 1.625;
+ color: var(--muted-foreground);
+ text-wrap: pretty;
+ }
+
+ /* A line's reveal and the slide that makes room for it are one event, so they share a curve. */
+ .quill-chat-stream[data-pinned] .quill-chat-stream__line {
+ animation: quill-chat-stream__line-in 200ms cubic-bezier(0.215, 0.61, 0.355, 1);
+ }
+
+ @keyframes quill-chat-stream__line-in {
+ from {
+ opacity: 0;
+ translate: 0 0.25rem;
+ }
+
+ to {
+ opacity: 1;
+ translate: 0 0;
+ }
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .quill-chat-stream__lines {
+ transition: none;
+ }
+
+ .quill-chat-stream[data-pinned] .quill-chat-stream__line {
+ animation: none;
+ }
+ }
+}
diff --git a/packages/quill/packages/primitives/src/chat/chat-stream.stories.tsx b/packages/quill/packages/primitives/src/chat/chat-stream.stories.tsx
new file mode 100644
index 000000000000..7cea89121501
--- /dev/null
+++ b/packages/quill/packages/primitives/src/chat/chat-stream.stories.tsx
@@ -0,0 +1,177 @@
+import type { Meta, StoryObj } from '@storybook/react'
+
+import * as React from 'react'
+
+import { ChatMarker, ChatMarkerContent } from './chat-marker'
+import { ChatStream, ChatStreamLine } from './chat-stream'
+import {
+ ThreadItem,
+ ThreadItemAuthor,
+ ThreadItemBody,
+ ThreadItemContent,
+ ThreadItemGroup,
+ ThreadItemGutter,
+ ThreadItemHeader,
+ ThreadItemTimestamp,
+} from './thread-item'
+import { Avatar, AvatarFallback } from '../avatar'
+import { Button } from '../button'
+
+const meta: Meta<typeof ChatStream> = {
+ title: 'Primitives/Chat/ChatStream',
+ component: ChatStream,
+ tags: ['autodocs'],
+}
+
+export default meta
+type Story = StoryObj<typeof meta>
+
+const LINES = [
+ 'Reading the request and locating the jwt.verify call inside the auth middleware.',
+ 'The verify call sets no algorithms allowlist, so a token signed with "none" could be accepted.',
+ 'Tracing where the signing secret is loaded from and confirming it is never logged.',
+ 'Planning to pin the algorithm to HS256 and validate the issuer and audience claims.',
+ 'Scanning the existing tests around the middleware so the fix stays covered.',
+ 'Drafting the patch with a regression test that rejects tampered and unsigned tokens.',
+]
+
+const LINE_DELAY_MS = 800
+
+/** Pinned: the window follows the newest line, older ones dissolve off the top. */
+export const Pinned: Story = {
+ render: () => (
+ <div className="w-[420px]">
+ <ChatStream pinned>
+ {LINES.slice(0, 4).map((line) => (
+ <ChatStreamLine key={line}>{line}</ChatStreamLine>
+ ))}
+ </ChatStream>
+ </div>
+ ),
+}
+
+/** Unpinned: an ordinary scroll area, showing the start, with both edges tracking the scroll. */
+export const Unpinned: Story = {
+ render: () => (
+ <div className="w-[420px]">
+ <ChatStream>
+ {LINES.map((line) => (
+ <ChatStreamLine key={line}>{line}</ChatStreamLine>
+ ))}
+ </ChatStream>
+ </div>
+ ),
+}
+
+/** Short output sits under the cap, so it renders with no fades and no scrollbar. */
+export const Short: Story = {
+ render: () => (
+ <div className="w-[420px]">
+ <ChatStream pinned>
+ <ChatStreamLine>Checked the cached schema; nothing to re-fetch.</ChatStreamLine>
+ </ChatStream>
+ </div>
+ ),
+}
+
+/** Override the 11.25rem cap per surface — a wide panel can afford more. */
+export const TallerCap: Story = {
+ render: () => (
+ <div className="w-[420px]">
+ <ChatStream className="[--quill-chat-stream-max-height:20rem]">
+ {LINES.map((line) => (
+ <ChatStreamLine key={line}>{line}</ChatStreamLine>
+ ))}
+ </ChatStream>
+ </div>
+ ),
+}
+
+function useStreamed(): { lines: string[]; streaming: boolean; replay: () => void } {
+ const [runId, setRunId] = React.useState(0)
+ const [count, setCount] = React.useState(0)
+
+ React.useEffect(() => {
+ setCount(0)
+ const timers = LINES.map((_, index) => setTimeout(() => setCount(index + 1), LINE_DELAY_MS * (index + 1)))
+ return () => timers.forEach(clearTimeout)
+ }, [runId])
+
+ return { lines: LINES.slice(0, count), streaming: count < LINES.length, replay: () => setRunId((id) => id + 1) }
+}
+
+function LiveStream(): React.ReactElement {
+ const { lines, streaming, replay } = useStreamed()
+ return (
+ <div className="flex w-[420px] flex-col gap-4">
+ <ChatStream pinned={streaming}>
+ {lines.map((line) => (
+ <ChatStreamLine key={line}>{line}</ChatStreamLine>
+ ))}
+ </ChatStream>
+ <Button variant="outline" size="sm" className="self-start" onClick={replay}>
+ Replay
+ </Button>
+ </div>
+ )
+}
+
+/**
+ * The arc: lines arrive and the window follows them, then `pinned` goes false and it hands over to
+ * the reader at the start. The app owns the timing; the primitive owns the follow.
+ */
+export const Live: Story = {
+ render: () => <LiveStream />,
+}
+
+function ThreadStream(): React.ReactElement {
+ const { lines, streaming, replay } = useStreamed()
+ return (
+ <div className="flex w-[520px] flex-col gap-4">
+ <ThreadItemGroup>
+ <ThreadItem>
+ <ThreadItemGutter>
+ <Avatar>
+ <AvatarFallback>MX</AvatarFallback>
+ </Avatar>
+ </ThreadItemGutter>
+ <ThreadItemContent>
+ <ThreadItemHeader>
+ <ThreadItemAuthor>Max</ThreadItemAuthor>
+ <ThreadItemTimestamp dateTime="2026-07-16T16:23:00">4:23 PM</ThreadItemTimestamp>
+ </ThreadItemHeader>
+ <ThreadItemBody>
+ <ChatMarker
+ defaultOpen
+ status={streaming ? 'running' : 'done'}
+ body={
+ <ChatStream pinned={streaming}>
+ {lines.map((line) => (
+ <ChatStreamLine key={line}>{line}</ChatStreamLine>
+ ))}
+ </ChatStream>
+ }
+ >
+ <ChatMarkerContent>
+ {streaming ? 'Thinking…' : `Thought for ${LINES.length}s`}
+ </ChatMarkerContent>
+ </ChatMarker>
+ </ThreadItemBody>
+ </ThreadItemContent>
+ </ThreadItem>
+ </ThreadItemGroup>
+ <Button variant="outline" size="sm" className="self-start" onClick={replay}>
+ Replay
+ </Button>
+ </div>
+ )
+}
+
+/**
+ * An agent streaming into a feed row — the composition this exists for. `ChatMarker` brings the
+ * summary and the shimmer, its `body` brings the rail, and the stream brings the follow. Nothing
+ * here is reasoning-specific: the same shape holds a tailing log or a streaming answer.
+ */
+export const InThread: Story = {
+ render: () => <ThreadStream />,
+}
diff --git a/packages/quill/packages/primitives/src/chat/chat-stream.tsx b/packages/quill/packages/primitives/src/chat/chat-stream.tsx
new file mode 100644
index 000000000000..8efa7c256002
--- /dev/null
+++ b/packages/quill/packages/primitives/src/chat/chat-stream.tsx
@@ -0,0 +1,170 @@
+import * as React from 'react'
+
+import './chat-stream.css'
+import { cn } from '../lib/utils'
+
+/**
+ * Output arriving live, in a window that follows it — an agent thinking out loud, a log tailing, a
+ * response streaming in.
+ *
+ * `pinned` is the whole API. While it's true the window stays anchored to the newest content: the
+ * stream slides up as it outgrows the cap, older lines dissolve off the top edge, and the reader
+ * can't scroll (there's nothing below to scroll to). Turn it off when the output stops and the
+ * window becomes an ordinary scroll area, left exactly where the pin ended — on the last thing
+ * said — for the reader to scroll back through.
+ *
+ * The pin is a transform, not a scroll. A scroll jump teleports the older lines; a transform can
+ * ease, and it doesn't affect layout — so the window still sizes to its content, capped by
+ * `--quill-chat-stream-max-height` (default `11.25rem`).
+ *
+ * It brings no chrome and no rail: drop it wherever the output belongs — a `ThreadItemBody` in a
+ * feed, a `ChatMarker`'s `body` behind a "Thinking…" summary — and let the container frame it.
+ */
+type ChatStreamProps = React.ComponentProps<'div'> & {
+ /** Follow the newest content. Turn it off when the output stops and the reader takes over. */
+ pinned?: boolean
+}
+
+function ChatStream({ pinned = false, className, children, onScroll, ...props }: ChatStreamProps): React.ReactElement {
+ const viewportRef = React.useRef<HTMLDivElement>(null)
+ const streamRef = React.useRef<HTMLDivElement>(null)
+
+ /*
+ * `pinned` is what the caller wants; `following` is what the window is doing. Releasing lags the
+ * prop by one slide.
+ *
+ * The last line almost always lands in the same render that ends the output — the final token
+ * arrives and the thing is done. Releasing on that render would cut the slide that carries the
+ * line into view, so the stream teleports to the end instead of easing there. Following through
+ * the final slide, then handing over, is the difference between the stream stopping and the
+ * stream snapping. Re-pinning has nothing to finish, so it takes effect immediately.
+ */
+ const [following, setFollowing] = React.useState(pinned)
+
+ // Written straight to the DOM rather than through state: this runs on every scroll frame and on
+ // every line, and a re-render per frame is how you drop them.
+ const sync = React.useCallback(() => {
+ const viewport = viewportRef.current
+ const stream = streamRef.current
+ if (!viewport || !stream) {
+ return
+ }
+ const setFade = (top: boolean, bottom: boolean): void => {
+ viewport.toggleAttribute('data-fade-top', top)
+ viewport.toggleAttribute('data-fade-bottom', bottom)
+ }
+ if (following) {
+ // A transform doesn't affect layout, so the viewport still sizes to the stream (capped),
+ // and the overflow is exactly what we slide by.
+ const overflow = Math.max(0, stream.offsetHeight - viewport.clientHeight)
+ stream.style.setProperty('--quill-chat-stream-offset', `${-overflow}px`)
+ // Nothing sits below the newest line, so only the top edge needs softening.
+ setFade(overflow > 0, false)
+ return
+ }
+ stream.style.setProperty('--quill-chat-stream-offset', '0px')
+ setFade(viewport.scrollTop > 1, viewport.scrollTop + viewport.clientHeight < viewport.scrollHeight - 1)
+ }, [following])
+
+ // Content arrives a line (or a token) at a time, resizing the stream rather than re-rendering
+ // this component — so watch the box, not the children.
+ React.useLayoutEffect(() => {
+ const stream = streamRef.current
+ if (!stream) {
+ return
+ }
+ const observer = new ResizeObserver(sync)
+ observer.observe(stream)
+ return () => observer.disconnect()
+ }, [sync])
+
+ // Re-pin at once; release only once the slide in flight has landed.
+ React.useEffect(() => {
+ if (pinned) {
+ setFollowing(true)
+ return
+ }
+ const stream = streamRef.current
+ if (!following || !stream) {
+ return
+ }
+ let released = false
+ const release = (): void => {
+ if (released) {
+ return
+ }
+ released = true
+ setFollowing(false)
+ }
+ const onEnd = (event: TransitionEvent): void => {
+ if (event.propertyName === 'translate') {
+ release()
+ }
+ }
+ stream.addEventListener('transitionend', onEnd)
+ // A slide that never starts fires no `transitionend` — the offset may not have changed, or
+ // reduced motion may have removed the transition entirely. Read the duration off the element
+ // rather than restating it here, so this can't drift from the CSS.
+ const duration = parseFloat(getComputedStyle(stream).transitionDuration) * 1000 || 0
+ const fallback = setTimeout(release, duration + 50)
+ return () => {
+ stream.removeEventListener('transitionend', onEnd)
+ clearTimeout(fallback)
+ }
+ }, [pinned, following])
+
+ const wasFollowing = React.useRef(following)
+
+ React.useLayoutEffect(() => {
+ const viewport = viewportRef.current
+ const stream = streamRef.current
+ // Letting go must not move anything: the reader is looking at the tail, and that's where the
+ // output ended. So hand the pin's transform over to the equivalent scroll offset — the two
+ // describe the same position, so the swap is invisible, and afterwards the reader can scroll
+ // back through it.
+ //
+ // Both in one frame with the transition suppressed. Left to animate, the transform would ease
+ // back to 0 while the scroll jumped instantly, and the content would lurch by the overflow in
+ // each direction before settling.
+ if (wasFollowing.current && !following && viewport && stream) {
+ const overflow = Math.max(0, stream.offsetHeight - viewport.clientHeight)
+ const transition = stream.style.transition
+ stream.style.transition = 'none'
+ stream.style.setProperty('--quill-chat-stream-offset', '0px')
+ viewport.scrollTop = overflow
+ void stream.offsetHeight
+ stream.style.transition = transition
+ }
+ wasFollowing.current = following
+ sync()
+ }, [following, sync])
+
+ return (
+ <div
+ ref={viewportRef}
+ data-quill
+ data-slot="stream"
+ data-pinned={following || undefined}
+ // Taken out of `props` and merged rather than spread over: the fades are derived from
+ // the scroll position, so a caller's own handler must not be able to replace the sync
+ // that keeps them true.
+ onScroll={(event) => {
+ sync()
+ onScroll?.(event)
+ }}
+ className={cn('quill-chat-stream', className)}
+ {...props}
+ >
+ <div ref={streamRef} data-slot="stream-lines" className="quill-chat-stream__lines">
+ {children}
+ </div>
+ </div>
+ )
+}
+
+/** One line of output. Reveals itself as it arrives, while the stream is pinned. */
+function ChatStreamLine({ className, ...props }: React.ComponentProps<'p'>): React.ReactElement {
+ return <p data-slot="stream-line" className={cn('quill-chat-stream__line', className)} {...props} />
+}
+
+export { ChatStream, ChatStreamLine }
diff --git a/packages/quill/packages/primitives/src/chat/chat-task-list.css b/packages/quill/packages/primitives/src/chat/chat-task-list.css
new file mode 100644
index 000000000000..a271537c8b58
--- /dev/null
+++ b/packages/quill/packages/primitives/src/chat/chat-task-list.css
@@ -0,0 +1,169 @@
+@layer components {
+ /*
+ * The row, trigger affordance, rail, collapse, and shimmer come from `lib/disclosure.css`; the
+ * bullet and its outcome tints from `lib/status.css`. What's left here is the header's progress
+ * ring and rolling count, and the task row itself.
+ */
+ .quill-chat-task-list {
+ display: flex;
+ flex-direction: column;
+ gap: 0;
+ align-items: stretch;
+ width: 100%;
+ }
+
+ .quill-chat-task-list__label {
+ min-width: 0;
+ overflow: hidden;
+ color: var(--foreground);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ /* The leading slot's swap lives in `lib/disclosure.css`; the ring below is the task list's own. */
+
+ .quill-chat-task-list__items {
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+ margin: 0;
+ list-style: none;
+ }
+
+ /*
+ * The ring reads clockwise from 12, which is where a clock face says progress starts. Rotating
+ * the element is cheaper and less error-prone than re-deriving every arc's start angle.
+ */
+ .quill-chat-task-list__ring {
+ rotate: -90deg;
+ }
+
+ .quill-chat-task-list__ring-track {
+ color: var(--muted-foreground);
+ opacity: 0.5;
+ }
+
+ /*
+ * The arc grows toward its target as steps land — new arc appearing, so ease-out: it commits
+ * immediately and settles, rather than creeping off the mark.
+ */
+ .quill-chat-task-list__ring-fill {
+ color: var(--foreground);
+ transition: stroke-dasharray 250ms cubic-bezier(0.215, 0.61, 0.355, 1);
+ }
+
+ .quill-chat-task-list__count {
+ margin-inline-start: auto;
+ font-variant-numeric: tabular-nums;
+ }
+
+ .quill-chat-task-list__digits {
+ display: inline-flex;
+ }
+
+ /*
+ * A digit is a one-line window. `em` keeps the window tied to the font size it sits in, so the
+ * count can be dropped into a different text size without the glyphs clipping.
+ */
+ .quill-chat-task-list__char {
+ display: inline-block;
+ height: 1.625em;
+ overflow: hidden;
+ line-height: 1.625;
+ text-align: center;
+ }
+
+ /*
+ * Two glyphs stacked; the window shows one at a time. The old digit leaves as the new one
+ * arrives — an entrance, so ease-out. Transform only: the window never reflows the row.
+ */
+ .quill-chat-task-list__char-roll {
+ display: flex;
+ flex-direction: column;
+ animation: quill-chat-task-list__roll 250ms cubic-bezier(0.215, 0.61, 0.355, 1) forwards;
+ will-change: transform;
+ }
+
+ /*
+ * Aligned to the start, not centred: a step that wraps is still one step, and centring floats its
+ * bullet into the middle of the paragraph, next to no line in particular.
+ */
+ .quill-chat-task {
+ display: flex;
+ gap: 0.375rem;
+ align-items: flex-start;
+ min-width: 0;
+ font-size: var(--text-xs, 0.75rem);
+ line-height: 1.625;
+ color: var(--muted-foreground);
+ }
+
+ /*
+ * Start-alignment pins the bullet to the row's top edge, but the text's first glyph sits lower
+ * than that — centred in its own line box. So drop the bullet by half the difference to put it on
+ * the line rather than above it. Derived rather than eyeballed (it lands on ~2.75px) so it holds
+ * if the row's type changes.
+ */
+ .quill-chat-task .quill-chat-bullet {
+ padding-block-start: calc((1.625em - 0.875rem) / 2);
+ }
+
+ /*
+ * Wraps by default — a step's text is the point of the row, and clipping it to fit is the caller's
+ * decision, not the primitive's. `min-width: 0` is what lets it shrink inside the row's flex at
+ * all, with or without truncation.
+ */
+ .quill-chat-task__label {
+ min-width: 0;
+ }
+
+ /*
+ * Opted into: label and detail clamp to one line together. They share the element so the ellipsis
+ * lands after whichever runs out of room, rather than each clipping on its own.
+ */
+ .quill-chat-task--truncate .quill-chat-task__label {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ /*
+ * The active step deliberately sets no color: `quill-shimmer` owns it, clipping its gradient to
+ * the glyphs (and handing a flat `--foreground` back under reduced motion). The utility is
+ * unlayered, so it now outranks a rule like this anyway — but setting a colour here would still
+ * be a lie about who owns it.
+ */
+ .quill-chat-task[data-status='failed'] .quill-chat-task__label {
+ color: var(--destructive-foreground);
+ }
+
+ /* Supporting detail — a duration, an exit code — tied to its label by a separator. */
+ .quill-chat-task__detail {
+ color: var(--muted-foreground);
+ }
+
+ .quill-chat-task__detail::before {
+ margin-inline: 0.375rem;
+ content: '·';
+ }
+
+ @keyframes quill-chat-task-list__roll {
+ from {
+ translate: 0 0;
+ }
+
+ to {
+ translate: 0 -50%;
+ }
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .quill-chat-task-list__ring-fill {
+ transition: none;
+ }
+
+ .quill-chat-task-list__char-roll {
+ animation: none;
+ }
+ }
+}
diff --git a/packages/quill/packages/primitives/src/chat/chat-task-list.stories.tsx b/packages/quill/packages/primitives/src/chat/chat-task-list.stories.tsx
new file mode 100644
index 000000000000..1109491b159a
--- /dev/null
+++ b/packages/quill/packages/primitives/src/chat/chat-task-list.stories.tsx
@@ -0,0 +1,262 @@
+import type { Meta, StoryObj } from '@storybook/react'
+import * as React from 'react'
+
+import { Button } from '../button'
+import {
+ ChatTask,
+ ChatTaskDetail,
+ ChatTaskList,
+ ChatTaskListContent,
+ ChatTaskListCount,
+ ChatTaskListLabel,
+ ChatTaskListProgress,
+ ChatTaskListTrigger,
+ type ChatTaskStatus,
+} from './chat-task-list'
+
+const meta: Meta<typeof ChatTaskList> = {
+ title: 'Primitives/Chat/ChatTaskList',
+ component: ChatTaskList,
+ tags: ['autodocs'],
+}
+
+export default meta
+type Story = StoryObj<typeof meta>
+
+const TODOS = [
+ 'Scaffold the project structure, Scaffold the project structure and some more for longer text',
+ 'Build the component registry',
+ 'Implement entitlement gating',
+ 'Wire up Stripe checkout',
+ 'Polish the landing page',
+]
+
+const STEP_MS = 1600
+
+function statusesFor(current: number, total: number): ChatTaskStatus[] {
+ return Array.from({ length: total }, (_, index) => {
+ if (index < current) {
+ return 'done'
+ }
+ return index === current ? 'active' : 'pending'
+ })
+}
+
+function TodoList({ current }: { current: number }): React.ReactElement {
+ const statuses = statusesFor(current, TODOS.length)
+ return (
+ <ChatTaskList value={Math.max(current, 0)} total={TODOS.length} defaultOpen>
+ <ChatTaskListTrigger>
+ <ChatTaskListProgress />
+ <ChatTaskListLabel>To-dos</ChatTaskListLabel>
+ <ChatTaskListCount />
+ </ChatTaskListTrigger>
+ <ChatTaskListContent>
+ {TODOS.map((label, index) => (
+ <ChatTask key={label} status={statuses[index]} className="whitespace-normal">
+ {label}
+ </ChatTask>
+ ))}
+ </ChatTaskListContent>
+ </ChatTaskList>
+ )
+}
+
+/** Mid-plan: two done, one running, the rest waiting. The header ring tracks the same count. */
+export const Running: Story = {
+ render: () => (
+ <div className="w-[420px]">
+ <TodoList current={2} />
+ </div>
+ ),
+}
+
+/** Nothing started yet — the header shows a plain list, not an empty ring. */
+export const NotStarted: Story = {
+ render: () => (
+ <div className="w-[420px]">
+ <TodoList current={-1} />
+ </div>
+ ),
+}
+
+/** Every step landed: the header turns over to a check and the count reads full. */
+export const Complete: Story = {
+ render: () => (
+ <div className="w-[420px]">
+ <TodoList current={TODOS.length} />
+ </div>
+ ),
+}
+
+/** Collapsed — the resting state once the plan is just history in a long transcript. */
+export const Collapsed: Story = {
+ render: () => (
+ <div className="w-[420px]">
+ <ChatTaskList value={5} total={5}>
+ <ChatTaskListTrigger>
+ <ChatTaskListProgress />
+ <ChatTaskListLabel>To-dos</ChatTaskListLabel>
+ <ChatTaskListCount />
+ </ChatTaskListTrigger>
+ <ChatTaskListContent>
+ {TODOS.map((label) => (
+ <ChatTask key={label} status="done">
+ {label}
+ </ChatTask>
+ ))}
+ </ChatTaskListContent>
+ </ChatTaskList>
+ </div>
+ ),
+}
+
+/** The four task states together, so the bullets and inks can be compared at rest. */
+export const TaskStates: Story = {
+ render: () => (
+ <div className="w-[420px]">
+ <ChatTaskList value={1} total={4} defaultOpen>
+ <ChatTaskListTrigger>
+ <ChatTaskListProgress />
+ <ChatTaskListLabel>States</ChatTaskListLabel>
+ <ChatTaskListCount />
+ </ChatTaskListTrigger>
+ <ChatTaskListContent>
+ <ChatTask status="done">Done — settled, and it worked</ChatTask>
+ <ChatTask status="active">Active — running right now</ChatTask>
+ <ChatTask status="pending">Pending — not started</ChatTask>
+ <ChatTask status="failed">
+ Failed — it broke
+ <ChatTaskDetail>exit 1</ChatTaskDetail>
+ </ChatTask>
+ </ChatTaskListContent>
+ </ChatTaskList>
+ </div>
+ ),
+}
+
+const LONG = 'Pin the algorithm to HS256 and validate the issuer and audience claims on every incoming request'
+
+/**
+ * A step that outgrows its row wraps, and its bullet stays on the first line rather than floating
+ * into the middle of the paragraph. Pass `truncate` to clamp it to one line instead — the label and
+ * its detail clip together, so the ellipsis lands wherever the room runs out.
+ */
+export const LongLabels: Story = {
+ render: () => (
+ <div className="w-[320px]">
+ <ChatTaskList value={1} total={3} defaultOpen>
+ <ChatTaskListTrigger>
+ <ChatTaskListProgress />
+ <ChatTaskListLabel>Wrapping vs truncating</ChatTaskListLabel>
+ <ChatTaskListCount />
+ </ChatTaskListTrigger>
+ <ChatTaskListContent>
+ <ChatTask status="done">{LONG}</ChatTask>
+ <ChatTask status="active" truncate>
+ {LONG}
+ </ChatTask>
+ <ChatTask status="failed">
+ {LONG}
+ <ChatTaskDetail>exit 1: port 8000 already in use</ChatTaskDetail>
+ </ChatTask>
+ </ChatTaskListContent>
+ </ChatTaskList>
+ </div>
+ ),
+}
+
+/**
+ * Setting up a sandbox is the same primitive — a plan, worked through. Nothing here is a `variant`:
+ * it's the sandbox's own copy, plus `ChatTaskDetail` carrying what each step produced and a `failed`
+ * step showing why the environment never came up.
+ */
+export const SandboxSetup: Story = {
+ render: () => (
+ <div className="w-[420px]">
+ <ChatTaskList value={2} total={5} defaultOpen>
+ <ChatTaskListTrigger>
+ <ChatTaskListProgress />
+ <ChatTaskListLabel>Setting up sandbox</ChatTaskListLabel>
+ <ChatTaskListCount />
+ </ChatTaskListTrigger>
+ <ChatTaskListContent>
+ <ChatTask status="done">
+ Pull image
+ <ChatTaskDetail>node:22 · 1.2s</ChatTaskDetail>
+ </ChatTask>
+ <ChatTask status="done">
+ Clone repository
+ <ChatTaskDetail>3.4s</ChatTaskDetail>
+ </ChatTask>
+ <ChatTask status="failed">
+ Start services
+ <ChatTaskDetail>exit 1: port 8000 already in use</ChatTaskDetail>
+ </ChatTask>
+ <ChatTask status="pending">Install dependencies</ChatTask>
+ <ChatTask status="pending">Run migrations</ChatTask>
+ </ChatTaskListContent>
+ </ChatTaskList>
+ </div>
+ ),
+}
+
+/** A sandbox that came up clean, for comparison against the failure above. */
+export const SandboxReady: Story = {
+ render: () => (
+ <div className="w-[420px]">
+ <ChatTaskList value={3} total={3}>
+ <ChatTaskListTrigger>
+ <ChatTaskListProgress />
+ <ChatTaskListLabel>Sandbox ready</ChatTaskListLabel>
+ <ChatTaskListCount />
+ </ChatTaskListTrigger>
+ <ChatTaskListContent>
+ <ChatTask status="done">
+ Pull image
+ <ChatTaskDetail>node:22 · 1.2s</ChatTaskDetail>
+ </ChatTask>
+ <ChatTask status="done">
+ Install dependencies
+ <ChatTaskDetail>18.9s</ChatTaskDetail>
+ </ChatTask>
+ <ChatTask status="done">
+ Start services
+ <ChatTaskDetail>web on :8000</ChatTaskDetail>
+ </ChatTask>
+ </ChatTaskListContent>
+ </ChatTaskList>
+ </div>
+ ),
+}
+
+function LiveTaskList(): React.ReactElement {
+ const [runId, setRunId] = React.useState(0)
+ const [current, setCurrent] = React.useState(-1)
+
+ React.useEffect(() => {
+ setCurrent(-1)
+ const timers = [setTimeout(() => setCurrent(0), 700)]
+ for (let index = 0; index < TODOS.length; index++) {
+ timers.push(setTimeout(() => setCurrent(index + 1), 700 + (index + 1) * STEP_MS))
+ }
+ return () => timers.forEach(clearTimeout)
+ }, [runId])
+
+ return (
+ <div className="flex w-[420px] flex-col gap-4">
+ <TodoList current={current} />
+ <Button variant="outline" size="sm" className="self-start" onClick={() => setRunId((id) => id + 1)}>
+ Replay
+ </Button>
+ </div>
+ )
+}
+
+/**
+ * The whole arc: list icon → filling ring → check, with the count rolling a digit at a time as each
+ * step lands. The app owns the timing; the primitive owns the roll and the ring.
+ */
+export const Live: Story = {
+ render: () => <LiveTaskList />,
+}
diff --git a/packages/quill/packages/primitives/src/chat/chat-task-list.tsx b/packages/quill/packages/primitives/src/chat/chat-task-list.tsx
new file mode 100644
index 000000000000..88c0a2f783c9
--- /dev/null
+++ b/packages/quill/packages/primitives/src/chat/chat-task-list.tsx
@@ -0,0 +1,294 @@
+import './chat-task-list.css'
+import './lib/disclosure.css'
+import './lib/status.css'
+
+import { Collapsible as CollapsiblePrimitive } from '@base-ui/react/collapsible'
+import {
+ ChevronRightIcon,
+ CircleArrowRightIcon,
+ CircleCheckIcon,
+ CircleDashedIcon,
+ CircleXIcon,
+ ListIcon,
+} from 'lucide-react'
+import * as React from 'react'
+
+import { useReducedMotion } from '../lib/use-reduced-motion'
+import { cn } from '../lib/utils'
+
+/**
+ * The plan an agent is working through — a checklist that fills in as steps land. Adapted from the
+ * aicss to-do list pattern. Sibling of {@link ./chat-marker#ChatMarker}, which covers what the agent
+ * *did* — a note, a call, a group of them. This is the *plan*: many steps, an aggregate count, and
+ * each step carrying its own outcome.
+ *
+ * The list holds no state. `value`/`total` are the app's count of finished steps, and every `ChatTask`
+ * carries its own `status` — nothing is inferred from the children, because only the app knows which
+ * step is running or why one broke.
+ *
+ * It's the same primitive whether the steps are to-dos or a sandbox booting; only the copy and the
+ * statuses differ. There's no `variant` — a checklist is a checklist.
+ *
+ * Steps wrap by default; pass `truncate` to a `ChatTask` to clamp it to one line instead.
+ */
+type ChatTaskStatus = 'pending' | 'active' | 'done' | 'failed'
+
+const TASK_ICON: Record<ChatTaskStatus, React.ReactElement> = {
+ pending: <CircleDashedIcon />,
+ active: <CircleArrowRightIcon />,
+ done: <CircleCheckIcon />,
+ failed: <CircleXIcon />,
+}
+
+type ChatTaskListContextValue = {
+ value: number
+ total: number
+}
+
+const ChatTaskListContext = React.createContext<ChatTaskListContextValue | null>(null)
+
+function useChatTaskListContext(slot: string): ChatTaskListContextValue {
+ const context = React.useContext(ChatTaskListContext)
+ if (!context) {
+ throw new Error(`${slot} must be used within a ChatTaskList`)
+ }
+ return context
+}
+
+type ChatTaskListProps = React.ComponentProps<typeof CollapsiblePrimitive.Root> & {
+ /** Steps finished so far. Drives the header icon and the count; never inferred from children. */
+ value: number
+ /** Steps in the plan. */
+ total: number
+}
+
+function ChatTaskList({ value, total, className, ...props }: ChatTaskListProps): React.ReactElement {
+ const context = React.useMemo(() => ({ value, total }), [value, total])
+
+ return (
+ <ChatTaskListContext.Provider value={context}>
+ <CollapsiblePrimitive.Root
+ data-quill
+ data-slot="task-list"
+ className={cn('quill-chat-task-list', className)}
+ {...props}
+ />
+ </ChatTaskListContext.Provider>
+ )
+}
+
+function ChatTaskListTrigger({
+ className,
+ children,
+ ...props
+}: React.ComponentProps<typeof CollapsiblePrimitive.Trigger>): React.ReactElement {
+ return (
+ <CollapsiblePrimitive.Trigger
+ data-slot="task-list-trigger"
+ className={cn('quill-chat-row', 'quill-chat-row--interactive', 'quill-chat-task-list__trigger', className)}
+ {...props}
+ >
+ {children}
+ </CollapsiblePrimitive.Trigger>
+ )
+}
+
+/**
+ * The header's at-a-glance state: a list before anything starts, a ring that fills as steps land, a
+ * check once they all have. Derived from `value`/`total`, so it can't drift from the count beside it.
+ *
+ * It doubles as the disclosure affordance: hovering or focusing the row swaps the state icon for a
+ * chevron, the same trade `CollapsibleTrigger`'s `icon` prop makes. The state is what you want at
+ * rest; the chevron only matters once you've reached for it, so it doesn't need to sit there
+ * permanently taking up the row.
+ */
+function ChatTaskListProgress({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+ const { value, total } = useChatTaskListContext('ChatTaskListProgress')
+ const done = total > 0 && value >= total
+
+ return (
+ <span
+ data-slot="task-list-progress"
+ aria-hidden="true"
+ className={cn('quill-chat-swap', 'quill-chat-task-list__progress', className)}
+ {...props}
+ >
+ <span
+ data-slot="task-list-progress-icon"
+ data-status={done ? 'done' : undefined}
+ className={cn('quill-chat-bullet', 'quill-chat-swap__icon')}
+ >
+ {/* No steps yet, or no plan at all: a list, not a ring of nothing. Guarding `total`
+ here also keeps the ring's percentage from dividing by zero. */}
+ {value <= 0 || total <= 0 ? (
+ <ListIcon />
+ ) : done ? (
+ <CircleCheckIcon />
+ ) : (
+ <ProgressRing value={value} total={total} />
+ )}
+ </span>
+ <ChevronRightIcon aria-hidden="true" className={cn('quill-chat-chevron', 'quill-chat-swap__chevron')} />
+ </span>
+ )
+}
+
+function ProgressRing({ value, total }: { value: number; total: number }): React.ReactElement {
+ // `pathLength` renormalizes the circle to 100 user units, so the arc is the percentage itself —
+ // no circumference math, and no inline style to carry it.
+ const percent = Math.round((Math.min(Math.max(value, 0), total) / total) * 100)
+
+ return (
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" className="quill-chat-task-list__ring">
+ <circle
+ className="quill-chat-task-list__ring-track"
+ cx="12"
+ cy="12"
+ r="10.5"
+ stroke="currentColor"
+ strokeWidth="2.2"
+ strokeDasharray="2.2 4.4"
+ strokeLinecap="round"
+ />
+ <circle
+ className="quill-chat-task-list__ring-fill"
+ cx="12"
+ cy="12"
+ r="10.5"
+ pathLength="100"
+ stroke="currentColor"
+ strokeWidth="2.2"
+ strokeDasharray={`${percent} 100`}
+ strokeLinecap="round"
+ />
+ </svg>
+ )
+}
+
+function ChatTaskListLabel({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+ return <span data-slot="task-list-label" className={cn('quill-chat-task-list__label', className)} {...props} />
+}
+
+/**
+ * `2/5`, where each digit rolls to its successor. The rolling glyphs are decorative — the real value
+ * goes to screen readers once, as text, instead of announcing a half-rolled pair.
+ */
+function ChatTaskListCount({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+ const { value, total } = useChatTaskListContext('ChatTaskListCount')
+ const shown = `${Math.min(Math.max(value, 0), total)}/${total}`
+
+ return (
+ <span data-slot="task-list-count" className={cn('quill-chat-task-list__count', className)} {...props}>
+ <span className="sr-only">
+ {Math.min(Math.max(value, 0), total)} of {total} done
+ </span>
+ <span aria-hidden="true" className="quill-chat-task-list__digits">
+ {shown.split('').map((char, index) => (
+ // Digits are positional: index is the identity here, the glyph is the value.
+ // eslint-disable-next-line react/no-array-index-key
+ <RollingChar key={index} char={char} />
+ ))}
+ </span>
+ </span>
+ )
+}
+
+const ROLL_MS = 250
+
+function RollingChar({ char }: { char: string }): React.ReactElement {
+ const previous = React.useRef(char)
+ const [roll, setRoll] = React.useState<{ from: string; to: string } | null>(null)
+ const reducedMotion = useReducedMotion()
+
+ React.useEffect(() => {
+ if (char === previous.current) {
+ return
+ }
+ const from = previous.current
+ previous.current = char
+ if (reducedMotion) {
+ return
+ }
+ setRoll({ from, to: char })
+ const timer = setTimeout(() => setRoll(null), ROLL_MS)
+ return () => clearTimeout(timer)
+ }, [char, reducedMotion])
+
+ if (!roll) {
+ return <span className="quill-chat-task-list__char">{char}</span>
+ }
+
+ return (
+ <span className="quill-chat-task-list__char">
+ <span className="quill-chat-task-list__char-roll">
+ <span>{roll.from}</span>
+ <span>{roll.to}</span>
+ </span>
+ </span>
+ )
+}
+
+function ChatTaskListContent({ className, children, ...props }: React.ComponentProps<'ol'>): React.ReactElement {
+ return (
+ <CollapsiblePrimitive.Panel
+ data-slot="task-list-panel"
+ className={cn('quill-chat-collapse', 'quill-chat-rail', 'quill-chat-task-list__panel')}
+ >
+ <ol data-slot="task-list-items" className={cn('quill-chat-task-list__items', className)} {...props}>
+ {children}
+ </ol>
+ </CollapsiblePrimitive.Panel>
+ )
+}
+
+type ChatTaskProps = React.ComponentProps<'li'> & {
+ status?: ChatTaskStatus
+ /** Clamp the label to one line with an ellipsis. Off by default — a long step wraps. */
+ truncate?: boolean
+}
+
+function ChatTask({
+ status = 'pending',
+ truncate = false,
+ className,
+ children,
+ ...props
+}: ChatTaskProps): React.ReactElement {
+ return (
+ <li
+ data-slot="task"
+ data-status={status}
+ className={cn('quill-chat-task', truncate && 'quill-chat-task--truncate', className)}
+ {...props}
+ >
+ <span data-status={status} className="quill-chat-bullet">
+ {/* Keyed so a status change mounts a fresh icon, which replays the reveal. */}
+ <React.Fragment key={status}>{TASK_ICON[status]}</React.Fragment>
+ </span>
+ {/* The running step is live work, so it shimmers like every other live row in the family. */}
+ <span
+ data-slot="task-label"
+ className={cn('quill-chat-task__label', status === 'active' && 'quill-shimmer')}
+ >
+ {children}
+ </span>
+ </li>
+ )
+}
+
+/** What the step produced: a duration, an exit code, the line that explains a failure. */
+function ChatTaskDetail({ className, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+ return <span data-slot="task-detail" className={cn('quill-chat-task__detail', className)} {...props} />
+}
+
+export {
+ ChatTaskList,
+ ChatTaskListTrigger,
+ ChatTaskListProgress,
+ ChatTaskListLabel,
+ ChatTaskListCount,
+ ChatTaskListContent,
+ ChatTask,
+ ChatTaskDetail,
+ type ChatTaskStatus,
+}
diff --git a/packages/quill/packages/primitives/src/chat/lib/disclosure.css b/packages/quill/packages/primitives/src/chat/lib/disclosure.css
new file mode 100644
index 000000000000..2518c6b9de8a
--- /dev/null
+++ b/packages/quill/packages/primitives/src/chat/lib/disclosure.css
@@ -0,0 +1,171 @@
+@layer components {
+ /*
+ * The shell every chat disclosure shares: a dense status row that can act as a trigger, and a rail
+ * that indents whatever it discloses. Live text uses the `quill-shimmer` utility (styles/).
+ *
+ * These are the parts `ChatMarker` and `ChatTaskList` would otherwise each grow their own copy of.
+ * They're composed onto the component's own BEM block rather than @extend-ed, so a
+ * component reads `cn('quill-chat-row', 'quill-chat-marker')` and keeps its own hook for
+ * consumer overrides. Anything specific to one component stays in that component's CSS.
+ */
+ .quill-chat-row {
+ position: relative;
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ width: 100%;
+ min-height: 1rem;
+ font-size: var(--text-xs, 0.75rem);
+ line-height: 1.625;
+ color: var(--muted-foreground);
+ text-align: left;
+ }
+
+ /* A row that toggles something: gains a hit area that bleeds past the text, and an affordance. */
+ .quill-chat-row--interactive {
+ padding-inline: 0.25rem;
+ margin-inline: -0.25rem;
+ cursor: pointer;
+ background-color: transparent;
+ border: none;
+ border-radius: 0.375rem;
+ }
+
+ /*
+ * Base UI marks an inert trigger with `aria-disabled`, never the native `disabled` attribute — it
+ * keeps the button focusable so screen readers still reach it (the same trade quill's Button
+ * makes for `loading`). So `:disabled` matches nothing here, and gating on it silently does
+ * nothing: a force-open row would light up on hover as if it toggled something.
+ */
+ .quill-chat-row--interactive:not([aria-disabled='true']):hover {
+ background-color: var(--fill-hover);
+ }
+
+ /* Keyboard focus needs a real ring, not just the hover fill (WCAG 2.4.7). */
+ .quill-chat-row--interactive:not([aria-disabled='true']):focus-visible {
+ background-color: var(--fill-hover);
+ outline: none;
+ box-shadow: 0 0 0 2px color-mix(in oklab, var(--ring) 50%, transparent);
+ }
+
+ /*
+ * Hugs the end of the text it toggles rather than parking at the row's far edge — stranded across
+ * a wide row a chevron reads as unrelated to the thing it opens.
+ */
+ .quill-chat-chevron {
+ flex-shrink: 0;
+ width: 0.875rem;
+ height: 0.875rem;
+ color: var(--muted-foreground);
+ transition: rotate 150ms ease;
+ }
+
+ [data-panel-open] > .quill-chat-chevron {
+ rotate: 90deg;
+ }
+
+ /*
+ * A chevron that stays out of the way until the row is worth acting on. The marker uses this so
+ * a wall of status rows doesn't read as a wall of controls; a row whose whole point is to expand
+ * (reasoning, a tool call) shows its chevron outright instead.
+ */
+ .quill-chat-chevron--reveal {
+ opacity: 0;
+ transition:
+ opacity 150ms ease,
+ rotate 150ms ease;
+ }
+
+ :hover > .quill-chat-chevron--reveal,
+ :focus-visible > .quill-chat-chevron--reveal,
+ [data-panel-open] > .quill-chat-chevron--reveal {
+ opacity: 1;
+ }
+
+ /*
+ * The leading slot: a state icon at rest, the chevron once you reach for the row. Same trade as
+ * `CollapsibleTrigger`'s `icon` prop — the state is what you want at a glance, the affordance
+ * only matters on approach, and the row is too dense to carry both.
+ *
+ * The pair is stacked in one grid cell and cross-faded rather than swapped with `display`:
+ * `display: none` unmounts, which restarts any animation the icon carries (the bullet's reveal),
+ * popping it back in on every hover-out. Both stay mounted, which costs the accessibility tree
+ * nothing — the slot is `aria-hidden`, since the row's text already says the state.
+ */
+ .quill-chat-swap {
+ display: grid;
+ flex-shrink: 0;
+ place-items: center;
+ }
+
+ .quill-chat-swap > * {
+ grid-area: 1 / 1;
+ }
+
+ .quill-chat-swap__icon {
+ transition: opacity 150ms ease;
+ }
+
+ /* Rotate is restated because `.quill-chat-chevron` has equal specificity and could land later. */
+ .quill-chat-swap__chevron {
+ opacity: 0;
+ transition:
+ opacity 150ms ease,
+ rotate 150ms ease;
+ }
+
+ /*
+ * Gated on `aria-disabled` (see above — `:disabled` never matches): a force-open row (reasoning,
+ * while it's still thinking) has nothing to toggle and renders no chevron, so hovering or
+ * focusing it must not fade the icon out to nothing.
+ */
+ .quill-chat-row--interactive:not([aria-disabled='true']):hover .quill-chat-swap__icon,
+ .quill-chat-row--interactive:not([aria-disabled='true']):focus-visible .quill-chat-swap__icon {
+ opacity: 0;
+ }
+
+ .quill-chat-row--interactive:not([aria-disabled='true']):hover .quill-chat-swap__chevron,
+ .quill-chat-row--interactive:not([aria-disabled='true']):focus-visible .quill-chat-swap__chevron {
+ opacity: 1;
+ }
+
+ .quill-chat-row--interactive[data-panel-open] .quill-chat-swap__chevron {
+ rotate: 90deg;
+ }
+
+ /* The rail: indents disclosed content and ties it back to the row that opened it. */
+ .quill-chat-rail {
+ padding-inline-start: 0.875rem;
+ margin-inline-start: 0.375rem;
+ border-inline-start: 1px solid var(--border);
+ }
+
+ /*
+ * Collapse/expand. An entrance either way, so ease-out — it leaves immediately and settles.
+ * Height is a layout property, but Base UI hands us a resolved pixel height and there's no
+ * transform that can reveal content without clipping it, so this is the honest trade.
+ */
+ .quill-chat-collapse {
+ overflow: hidden;
+ transition: height 200ms cubic-bezier(0.215, 0.61, 0.355, 1);
+ }
+
+ .quill-chat-collapse[data-starting-style],
+ .quill-chat-collapse[data-ending-style] {
+ height: 0;
+ }
+
+ .quill-chat-collapse[data-open] {
+ height: var(--collapsible-panel-height);
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .quill-chat-chevron,
+ .quill-chat-chevron--reveal,
+ .quill-chat-collapse,
+ .quill-chat-swap__icon,
+ .quill-chat-swap__chevron {
+ transition: none;
+ }
+ }
+}
diff --git a/packages/quill/packages/primitives/src/chat/lib/status.css b/packages/quill/packages/primitives/src/chat/lib/status.css
new file mode 100644
index 000000000000..0a689f972f91
--- /dev/null
+++ b/packages/quill/packages/primitives/src/chat/lib/status.css
@@ -0,0 +1,62 @@
+@layer components {
+ /*
+ * The status bullet every chat row walks through: a leading icon that swaps as work progresses,
+ * and the two tints that read as an outcome. Shared by `ChatSource` (a page being fetched) and
+ * `ChatTask` (a step being done) — each supplies its own icons, since only the middle of the
+ * walk differs; the ends are always "not started yet" and "settled".
+ *
+ * The tints key off `data-status` on whatever row wraps the bullet, so a component opts in by
+ * putting the attribute on its row and the class on its bullet.
+ */
+ .quill-chat-bullet {
+ display: flex;
+ flex-shrink: 0;
+ align-items: center;
+ }
+
+ .quill-chat-bullet svg:not([class*='size-']) {
+ width: 0.875rem;
+ height: 0.875rem;
+ }
+
+ /* Each status mounts its own icon, so the swap is an entrance: ease-out, and quick. */
+ .quill-chat-bullet > * {
+ animation: quill-chat__bullet-in 150ms cubic-bezier(0.215, 0.61, 0.355, 1);
+ }
+
+ /*
+ * `--success`/`--destructive` are fill tokens; the ink that reads on a surface is the
+ * `-foreground` half of each pair.
+ *
+ * The status must sit on the bullet itself — never matched from an ancestor. A row's status is
+ * not its children's: a descendant selector let an errored group paint every bullet in its body
+ * red, including the ones that had succeeded. Nesting is normal here (a group discloses rows,
+ * each with its own outcome), so the tint has to key off the element it describes.
+ */
+ .quill-chat-bullet[data-status='done'] {
+ color: var(--success-foreground);
+ }
+
+ .quill-chat-bullet[data-status='failed'],
+ .quill-chat-bullet[data-status='error'] {
+ color: var(--destructive-foreground);
+ }
+
+ @keyframes quill-chat__bullet-in {
+ from {
+ opacity: 0;
+ scale: 0.8;
+ }
+
+ to {
+ opacity: 1;
+ scale: 1;
+ }
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .quill-chat-bullet > * {
+ animation: none;
+ }
+ }
+}
diff --git a/packages/quill/packages/primitives/src/index.ts b/packages/quill/packages/primitives/src/index.ts
index e9bbd6b6038c..62ccbb8f8562 100644
--- a/packages/quill/packages/primitives/src/index.ts
+++ b/packages/quill/packages/primitives/src/index.ts
@@ -1,4 +1,5 @@
import './styles/layers.css'
+import './styles/utilities.css'
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from './accordion'
export {
@@ -34,7 +35,15 @@ export { Avatar, AvatarImage, AvatarFallback, AvatarGroup } from './avatar'
export { Badge, badgeVariants } from './badge'
export { Button, buttonVariants, type ButtonProps } from './button'
export { ChatBubbleGroup, ChatBubble, ChatBubbleContent, ChatBubbleReactions, bubbleVariants } from './chat/chat-bubble'
-export { ChatMarker, ChatMarkerIcon, ChatMarkerContent, markerVariants } from './chat/chat-marker'
+export { ChatGlobe } from './chat/chat-globe'
+export {
+ ChatMarker,
+ ChatMarkerIcon,
+ ChatMarkerContent,
+ ChatMarkerValue,
+ markerVariants,
+ type ChatMarkerStatus,
+} from './chat/chat-marker'
export {
ChatMessageGroup,
ChatMessage,
@@ -54,6 +63,19 @@ export {
useChatMessageScrollerScrollable,
useChatMessageScrollerVisibility,
} from './chat/chat-message-scroller'
+export { ChatSource, ChatSourceList, ChatSourceTitle, ChatSourceUrl, type ChatSourceStatus } from './chat/chat-source'
+export { ChatStream, ChatStreamLine } from './chat/chat-stream'
+export {
+ ChatTask,
+ ChatTaskDetail,
+ ChatTaskList,
+ ChatTaskListContent,
+ ChatTaskListCount,
+ ChatTaskListLabel,
+ ChatTaskListProgress,
+ ChatTaskListTrigger,
+ type ChatTaskStatus,
+} from './chat/chat-task-list'
export {
ThreadItemGroup,
ThreadItem,
diff --git a/packages/quill/packages/primitives/src/item.css b/packages/quill/packages/primitives/src/item.css
index d581b0d99430..fdfc919f9e77 100644
--- a/packages/quill/packages/primitives/src/item.css
+++ b/packages/quill/packages/primitives/src/item.css
@@ -252,7 +252,7 @@
align-items: center;
width: fit-content;
overflow: hidden;
- font-size: var(--text-xs, 0.75rem);
+ font-size: var(--text-sm, 0.875rem);
font-weight: 500;
line-height: 1.375;
text-underline-offset: 4px;
@@ -264,7 +264,7 @@
.quill-item__description {
display: -webkit-box;
overflow: hidden;
- font-size: var(--text-xxs, 0.625rem);
+ font-size: var(--text-xs, 0.75rem);
font-weight: 400;
line-height: 1rem;
color: var(--muted-foreground);
diff --git a/packages/quill/packages/primitives/src/item.stories.tsx b/packages/quill/packages/primitives/src/item.stories.tsx
index 4146bfac71b0..2fbd71ff886f 100644
--- a/packages/quill/packages/primitives/src/item.stories.tsx
+++ b/packages/quill/packages/primitives/src/item.stories.tsx
@@ -97,7 +97,7 @@ export const Tones: Story = {
{ tone: 'destructive' as const, title: 'Destructive', description: 'Failed or removed' },
]
return (
- <ItemGroup className="max-w-sm">
+ <ItemGroup className="max-w-md">
{tones.map(({ tone, title, description }) => (
<Item
key={title}
@@ -209,7 +209,7 @@ export const DropdownInItem: Story = {
const [open, setOpen] = useState(true)
return (
- <Item variant="outline" className="max-w-sm">
+ <Item variant="outline" className="max-w-md">
<ItemContent>
<ItemTitle>Basic Item</ItemTitle>
<ItemDescription>A simple item with title and description.</ItemDescription>
@@ -259,7 +259,7 @@ export const DropdownCheckboxesInItem: Story = {
setChecked((prev) => ({ ...prev, [username]: !prev[username] }))
}
return (
- <Item variant="outline" className="max-w-sm">
+ <Item variant="outline" className="max-w-md">
<ItemContent>
<ItemTitle>Basic Item</ItemTitle>
<ItemDescription>A simple item with title and description.</ItemDescription>
@@ -311,7 +311,7 @@ export const DropdownCheckboxesInItemWithSelectAll: Story = {
}
return (
- <Item variant="outline" className="max-w-sm">
+ <Item variant="outline" className="max-w-md">
<ItemContent>
<ItemTitle>Basic Item</ItemTitle>
<ItemDescription>
@@ -364,7 +364,7 @@ export const DropdownRadiosInItem: Story = {
const [radioValue, setRadioValue] = useState('John Doe')
return (
- <Item variant="outline" className="max-w-sm">
+ <Item variant="outline" className="max-w-md">
<ItemContent>
<ItemTitle>Basic Item</ItemTitle>
<ItemDescription>A simple item with title and description.</ItemDescription>
@@ -406,7 +406,7 @@ export const SelectInItem: Story = {
const [open, setOpen] = useState(true)
return (
- <Item variant="outline" className="max-w-sm mt-32">
+ <Item variant="outline" className="max-w-md mt-32">
<ItemContent>
<ItemTitle>Basic Item</ItemTitle>
<ItemDescription>A simple item with title and description.</ItemDescription>
@@ -453,7 +453,7 @@ export const ComboboxInItem: Story = {
const [open, setOpen] = useState(true)
return (
- <Item variant="outline" className="max-w-sm mt-32">
+ <Item variant="outline" className="max-w-md mt-32">
<ItemContent>
<ItemTitle>Basic Item</ItemTitle>
<ItemDescription>A simple item with title and description.</ItemDescription>
diff --git a/packages/quill/packages/primitives/src/item.tsx b/packages/quill/packages/primitives/src/item.tsx
index 2fa90f020769..018d4b681075 100644
--- a/packages/quill/packages/primitives/src/item.tsx
+++ b/packages/quill/packages/primitives/src/item.tsx
@@ -214,7 +214,7 @@ function ItemMedia({
)
}
-const itemContentVariants = cva('quill-item__content flex flex-1 flex-col gap-0.5', {
+const itemContentVariants = cva('quill-item__content flex flex-1 flex-col gap-1', {
variants: {
variant: {
default: '',
diff --git a/packages/quill/packages/primitives/src/lib/use-reduced-motion.ts b/packages/quill/packages/primitives/src/lib/use-reduced-motion.ts
new file mode 100644
index 000000000000..2f3d56fc99ad
--- /dev/null
+++ b/packages/quill/packages/primitives/src/lib/use-reduced-motion.ts
@@ -0,0 +1,27 @@
+import * as React from 'react'
+
+const QUERY = '(prefers-reduced-motion: reduce)'
+
+function subscribe(onChange: () => void): () => void {
+ const list = window.matchMedia(QUERY)
+ list.addEventListener('change', onChange)
+ return () => list.removeEventListener('change', onChange)
+}
+
+/**
+ * Whether the user asked for reduced motion.
+ *
+ * CSS is the right place to honour this for anything a media query can reach, so reach for this hook
+ * only when it can't — SMIL (`<animate>`) is the case in quill today: it ignores CSS entirely, so the
+ * only way to stop it is to not render it.
+ */
+function useReducedMotion(): boolean {
+ return React.useSyncExternalStore(
+ subscribe,
+ () => window.matchMedia(QUERY).matches,
+ // Server render can't know; assume motion is fine and let the client correct on hydration.
+ () => false
+ )
+}
+
+export { useReducedMotion }
diff --git a/packages/quill/packages/primitives/src/styles/utilities.css b/packages/quill/packages/primitives/src/styles/utilities.css
new file mode 100644
index 000000000000..7ab11dcbbb21
--- /dev/null
+++ b/packages/quill/packages/primitives/src/styles/utilities.css
@@ -0,0 +1,55 @@
+/*
+ * Cross-cutting utilities — classes that aren't a component's, and that any text in a quill app can
+ * reach for. Loaded from `index.ts`, so they're there whenever the package is.
+ */
+
+/*
+ * Live text: a highlight sweeping through a line to say work is still in flight.
+ *
+ * The gradient is clipped to the glyphs, so the text itself must be transparent for the sweep to
+ * show at all — meaning this rule owns `color`, and anything that sets `color` after it wins and
+ * silently paints over the animation. That's why it's unlayered (see layers.css: unlayered beats
+ * every layer): inside `@layer components` it lost to any `text-*` utility, and inside
+ * `@layer utilities` it would come down to import order against Tailwind's own.
+ *
+ * Text only — `background-clip: text` can't reach an SVG stroke, so an icon needs its own treatment.
+ *
+ * Retune per surface with `--quill-shimmer-base` / `--quill-shimmer-highlight`; the defaults read as
+ * muted text brightening to full.
+ */
+.quill-shimmer {
+ color: transparent;
+ background-image: linear-gradient(
+ 90deg,
+ var(--quill-shimmer-base, var(--muted-foreground)) 0%,
+ var(--quill-shimmer-base, var(--muted-foreground)) 30%,
+ var(--quill-shimmer-highlight, var(--foreground)) 50%,
+ var(--quill-shimmer-base, var(--muted-foreground)) 70%,
+ var(--quill-shimmer-base, var(--muted-foreground)) 100%
+ );
+ background-clip: text;
+ background-size: 200% 100%;
+ animation: quill-shimmer__sweep 2s linear infinite;
+}
+
+@keyframes quill-shimmer__sweep {
+ from {
+ background-position: 100% 0;
+ }
+
+ to {
+ background-position: -100% 0;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ /*
+ * The gradient is the text's only colour, so stopping the animation isn't enough — the colour has
+ * to be handed back, or the text stays invisible.
+ */
+ .quill-shimmer {
+ color: var(--quill-shimmer-highlight, var(--foreground));
+ background-image: none;
+ animation: none;
+ }
+}