Skip to content

Agentic UI: stream assistant replies as they arrive and keep your place while they do - #4824

Open
shaunandrews wants to merge 1 commit into
trunkfrom
claude/studio-chat-streaming-broken-56290c
Open

shaunandrews wants to merge 1 commit into
trunkfrom
claude/studio-chat-streaming-broken-56290c

Conversation

@shaunandrews

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

  • Investigated and built with Claude Code, tested live in studio ui.
  • Worth a close look: the reveal pacing constants at the top of use-smooth-streaming-text.ts, and the follow/unfollow rules in the session view's scroll handler. Both were tuned by feel.

Proposed Changes

  • Since AI sessions: adopt pi-coding-agent SessionManager end-to-end #3360 the agentic UI only showed an assistant reply once the whole message had finished. The CLI already forwarded pi's message_update deltas over IPC and SSE; the renderer dropped them. Replies now appear as they stream, in studio ui and in the Desktop app.
  • Streamed text is revealed at a metered pace and only ever cut at word boundaries, so network bursts read as an even flow and a half-typed word can't wrap and jump when it completes. Once the reply ends the remainder drains quickly. Respects prefers-reduced-motion.
  • Tool rows appear when their message completes, never with half-built arguments.
  • Scrolling up while a reply streams holds your place. An upward wheel tick pauses following immediately, even before the "scrolled away" slack is crossed; scrollbar drags and keyboard jumps pause it once they clearly move up; returning to the bottom resumes it. The state-based check from Agentic UI: pause chat autoscroll while reading earlier messages #4575 lost the race once content grew every frame.
  • Earlier messages no longer re-parse their Markdown on every frame while a reply streams.
  • Trade-off: pi ships the full partial message with every delta, so a long reply moves quadratic bytes over the loopback transport. Fine locally; trimming message_update to its delta in the CLI adapter is a possible follow-up.

Testing Instructions

  • npm run cli:build:ui && node apps/cli/dist/cli/main.mjs ui --no-open, open http://localhost:8081.
  • Send a text-only prompt, e.g. "Without using any tools, write four short paragraphs about why WordPress uses hooks." The reply should appear word by word under the thinking indicator, finish with the copy button, and not duplicate after the run ends.
  • Wheel up while it streams: the view stays put and "Scroll to latest" appears. Scroll back to the bottom: following resumes.
  • Send a prompt that uses tools: text before each tool call streams; the tool row appears when that message completes.
  • Reload mid-reply: the partial text continues from the next delta.
  • Unit: npm test -- apps/ui/src/data/queries apps/ui/src/hooks/use-smooth-streaming-text.test.ts apps/ui/src/ui-classic/components/session-view apps/ui/src/components/markdown

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

🤖 Generated with Claude Code

…ing position while they do

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 52eecf3 vs trunk

app-size

Metric trunk 52eecf3 Diff Change
App Size (Mac) 1456.85 MB 1456.86 MB +0.01 MB ⚪ 0.0%

site-editor

Metric trunk 52eecf3 Diff Change
load 1157 ms 1181 ms +24 ms ⚪ 0.0%

site-startup

Metric trunk 52eecf3 Diff Change
siteCreation 7495 ms 7525 ms +30 ms ⚪ 0.0%
siteStartup 2868 ms 3394 ms +526 ms 🔴 18.3%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants