feat(chat): smooth streaming, one live line, and one-line rows in the ACP chat

Merged
AV
2mo ago
+1067-622

Links

Summary

This PR reworks how a live turn looks and moves in the ACP chat:

  1. Loader: the text shimmer sweeps a highlight instead of a dark notch, in CSS, and respects reduced motion.
  2. Streaming: replies appear a whole word at a time at a steady pace, and each new paragraph fades in. Before, text landed in bursts.
  3. One live line: a single clock line under the prompt sweeps while the turn runs. The separate "Working…" line is gone.
  4. Rows: reasoning and tool calls are one line each. Runs of two or more calls sit on a rail with a summary line.

Also includes:

  • A running tool call joins its run in the shared timeline, instead of jumping in when it settles.
  • A wider column, a pill prompt bubble, and message actions under a turn's last reply only.
  • The walkthrough page source in docs/pages/.

Part 1: Loader

Why

The band was painted in the page background over grey text, so the sweep read as a dark notch, or a washed-out gap in light mode. It ran through motion/react every frame and ignored prefers-reduced-motion.

What / How

  • The band is the foreground colour over a base of the foreground at 40%.
  • The keyframe sits behind an animate-shimmer token in packages/ui/src/motion.css. The desktop renderer imports that file because it does not load the packages/ui theme sheet.
  • background-repeat used padding-box, which is not a repeat keyword, so both layers tiled. It is now no-repeat.
  • Reduced motion renders plain muted text with no animation. The public API and the 2 s default are unchanged.
  • Tempo in the chat: the clock sweeps at 1 s; thinking, running titles and run summaries sweep at 1.6 s.

Part 2: Streaming

Why

Measured on a real reply, text arrived in bursts: nothing for 0.3 to 0.5 s, then up to 145 characters at once.

What / How

  • usePacedText reveals whole words at no less than 90 characters a second, closes on a backlog in about 0.22 s, and shows text already present at mount at once.
  • MarkdownView fades each new block in over 320 ms. The streaming tail is keyed like the stable block it becomes, so a finished paragraph keeps its DOM.
  • Empty blocks between paragraphs no longer add a second flex gap.
Real replyBeforeAfter
Median time between screen updates51 ms17 ms
Largest jump in one update145 chars37 chars

Part 3: One live line and layout

  • transcriptRows places the turn clock after the prompt. WorkingFor sweeps it at 1 s while the turn runs and leaves "Worked for 8s" at half strength.
  • WorkingIndicator and showsWorkingIndicator are deleted. In one measured turn the indicator mounted, unmounted after 95 ms and mounted again, restarting its sweep each time.
  • The column is 56rem with 16px row gutters and a 4px row rhythm. Prose is 14px on a 24px line at 78% strength.
  • The prompt bubble is a 10% foreground fill: a pill when it fits one line, 12px corners otherwise, up to 36rem wide.
  • Copy, branch and time render under a turn's last reply once it settles, instead of reserving an invisible row under every reply.

Part 4: Rows

  • Reasoning: one line. "Thinking..." sweeps until the thought has words, then the first paragraph shows at half strength and pulses while it streams. Clicking it opens the whole thought.
  • Tool calls: one line with no output preview and no "Show detail" link. Commands are 13px mono and files are a small mono chip. A running call turns a dashed ring and sweeps its title. Clicking the line opens the call's output.
  • Runs: two or more calls sit under a summary line with the steps on a rail. The summary sweeps while a step runs.
  • Timeline: collapseWorkLog in packages/chat now lets a running call join its run, so the live step sits on the rail instead of beside it.

Manual QA Checklist

Driven over CDP in the dev app, in an ACP chat with a real Claude agent, in both themes. The before shots came from the base commit with a scripted agent.

  • A streamed multi-paragraph reply grows word by word with no bursts; each paragraph fades in.
  • The clock sits under the prompt, sweeps while running and reads "Worked for Ns" after.
  • There is no separate working line at the bottom of a turn.
  • A single tool call is one line; clicking it opens its output.
  • A run of three shell calls shows a summary and a rail; the running step sits on the rail with its ring.
  • A settled run folds to its summary.
  • Copy and branch appear only under a turn's last reply, on hover.
  • Reduced motion (emulated): the clock, summary and titles compute to animation: none and render plain text; the ring holds still.
  • Computed tempos: clock 1 s, summary and running title 1.6 s, ring spin-slow 3.6s linear infinite.

Testing

CheckResult
bun test in packages/ui, packages/chat and the desktop ChatSession treePass
apps/desktop full suite209 failures, identical to the base commit; none in the chat
tsc in packages/ui and packages/chat-uiPass
tsc in packages/chat and apps/desktopNo errors in changed files; the rest is a worktree path-casing artifact and a duplicate @better-auth/core install, both present on base
  • Only the final tree was typechecked, not each commit.
  • bun run check:i18n fails on main because apps/marketing/src/app/providers.test.tsx adds a greeting id that isn't in the catalogs. Apart from that entry, the catalogs here equal the extractor's output. This PR adds no strings and removes four from every locale: "Working…", "Show detail", "Hide detail" and "+N more lines".

Design Decisions

  • Per-block fade, not per-word. Inserting an element in this renderer can restyle the whole document, about 6,500 elements and roughly 40 ms per insertion. Per-word spans insert elements every frame and capped the reveal near 20 fps. Growing an existing text node stays cheap, so pacing grows text nodes and only new blocks fade.
  • Keep the dashed ring on a running tool call, as originally specified.

Known Limitations

  • The whole-document restyle comes from the app's :has() rules. With the 14 group-has-* variants present, every insertion restyled the whole document. With every :has() rule removed, a synthetic stream ran at 120 fps with 36 ms of style work in total. Fixing that is an app-wide CSS change, left for its own PR; the numbers are on the walkthrough page.
  • The run summary uses past tense ("Ran 2 commands") while a step still runs.
  • Runs fold when the turn ends, not as soon as the agent writes prose.

Follow-ups

  • Show the model name on the clock line. This needs new strings in 17 locales.
  • Animate steps arriving on the rail.
  • Revisit per-word fading after the :has() audit.

Summary by CodeRabbit

  • New Features

    • Chat responses now appear at a readable pace with subtle fade effects that respect reduced-motion settings.
    • Refreshed chat transcripts feature clearer spacing, compact user-message bubbles, and more distinct tool activity indicators.
    • Reasoning summaries and tool activity are easier to scan, with expandable details and clearer status cues.
  • Improvements

    • Related tool calls are grouped together, including calls that are still running.
    • Copy, branching, and timestamp controls appear on the latest completed reply.
    • Chat content stays aligned as the transcript resizes.