Skip to content

fix(site): keep paragraph breaks in streamed chat text - #30550

Closed
mafredri wants to merge 1 commit into
mainfrom
mathias/codagt-236-stream-whitespace-deltas
Closed

mafredri wants to merge 1 commit into
mainfrom
mathias/codagt-236-stream-whitespace-deltas

Conversation

@mafredri

@mafredri mafredri commented Oct 9, 2026

Copy link
Copy Markdown
Member

The chat transcript dropped every whitespace-only text or reasoning delta (appendTextBlock, appendText, and the stream state guard in front of them). A provider can stream a paragraph break as its own "\n\n" delta, so the live preview showed writing.Like this until the saved message replaced it, and markdown that depends on line starts (headings, lists) rendered as inline text until then. Interrupted turns stored one part per delta show the same joined text permanently. #29661 would stop storing new ones that way; this change also renders the existing rows correctly.

Whitespace-only text now extends the preceding block of the same type and is dropped only where it would start a block. A leading whitespace delta therefore still leaves the stream state null, so it does not end the "starting" phase, which is what the old guard was for.

Likely the cause of CODAGT-236 (markdown formatting jumps when streaming completes).

These tests fail on main and pass here:

appendTextBlock > appends whitespace-only text to a matching block
parseMessageContent > keeps whitespace-only parts between text parts
applyMessagePartToStreamState > keeps whitespace-only 'text' deltas between paragraphs
applyMessagePartToStreamState > keeps whitespace-only 'reasoning' deltas between paragraphs
Decision log
  • Fixed in the shared helpers rather than only in streamState.ts: appendTextBlock also drops the whitespace when rendering stored messages, and appendText had the same check for the markdown field, which renders user messages and notices and feeds "Copy message".
  • Kept dropping whitespace that would start a block, instead of removing the filter. Without it, a leading whitespace delta creates a non-null stream state with no blocks and ends the "starting" phase early, and whitespace between a thinking block and a response would create an empty block.
  • Side effect: parsed.markdown can now end in whitespace when the last part is whitespace, so "Copy message" may include trailing newlines. Emptiness checks in messageHelpers.ts already use .trim().

🤖 This PR was created with the help of Coder Agents, and will be reviewed by a human. 🏂🏻

The chat transcript dropped every whitespace-only text or reasoning
delta. A provider can stream a paragraph break as its own "\n\n"
delta, so the live preview showed "writing.Like this" until the saved
message replaced it. Interrupted turns stored one part per delta show
the same joined text after the turn ends.

Whitespace-only text now extends the preceding block of the same type
and is dropped only where it would start a block, so a leading
whitespace delta still does not end the starting phase.
@linear-code

linear-code Bot commented Oct 9, 2026

Copy link
Copy Markdown

CODAGT-236

@mafredri mafredri closed this Oct 9, 2026
@mafredri
mafredri deleted the mathias/codagt-236-stream-whitespace-deltas branch October 9, 2026 13:33
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 9, 2026
@mafredri

mafredri commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

Superseded by #30551. Renaming the branch to drop the unrelated ticket ID closed this PR.

🤖 This comment was automatically generated with Coder Agents.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant