Skip to content

fix(ui): merge citation-split text blocks into one paragraph flow - #1023

Merged
Pizzaface merged 1 commit into
mainfrom
fix/merge-citation-text-blocks
Nov 5, 2026
Merged

Pizzaface merged 1 commit into
mainfrom
fix/merge-citation-text-blocks

Conversation

@Pizzaface

Copy link
Copy Markdown
Owner

Problem

When Anthropic's web search adds citations, the API splits the answer into a separate text block at every citation boundary. rendering.tsx rendered each block as its own MessageResponse in a flex-col gap-2, so quoted fragments and connectors like , and showed up as separate paragraphs.

Fix

New mergeAdjacentTextBlocks() in session-viewer/utils.ts joins neighbouring plain text blocks before rendering. Server-tool metadata blocks (_serverToolUse / _webSearchResult), tool calls and thinking blocks stay separate.

Checks

  • bun test src/components/session-viewer (481 pass, incl. new unit test)
  • UI tsc --noEmit: no errors in session-viewer
  • Not verified in the browser

Caveat: merging assumes neighbouring text blocks carry their own spacing (true for Anthropic citation fragments). A provider that sends separate-paragraph text blocks without a trailing newline would now run them together.

Anthropic web search splits assistant text at every citation boundary
into separate text blocks; each rendered as its own MessageResponse in a
flex-col, so fragments like ', and' appeared on their own lines.
@Pizzaface
Pizzaface marked this pull request as ready for review November 5, 2026 20:10
@Pizzaface
Pizzaface merged commit 595312b into main Nov 5, 2026
14 checks passed
@Pizzaface
Pizzaface deleted the fix/merge-citation-text-blocks branch November 5, 2026 20:10
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.

1 participant