Skip to content

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

Merged
mafredri merged 2 commits into
mainfrom
mathias/stream-whitespace-deltas
Oct 13, 2026
Merged

mafredri merged 2 commits into
mainfrom
mathias/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.

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. 🏂🏻

@mafredri

mafredri commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

@codex review
/coder-agents-review Please limit the review to P0, P1, and P2 issues only.

@coder-agents-review

coder-agents-review Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-10-09 13:38 UTC by @mafredri

Review history
  • R1 (2026-10-09): 9 reviewers, 2 P2, COMMENT. Review

deep-review v0.13.0 | Round 1 | 782fb30..5bd405d

Last posted: Round 1, 2 findings (2 P2), COMMENT. Review

Finding inventory

Finding inventory: PR #30551

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P4 Dropped by orchestrator (author requested P0-P2 only) streamState.test.ts:82 Whitespace-only test names at lines 82 and 90 describe the removed drop-all rule R1 Netero No
CRF-2 P2 Open messageParsing.ts:24 appendText comment claims it matches appendTextBlock; they disagree for whitespace after another part type R1 Netero Note, Gon P2 Yes
CRF-3 P2 Open streamState.ts:28 text-case comment opens by restating the identity check below it R1 Gon Yes
CRF-4 P3 Dropped by orchestrator (author requested P0-P2 only) blockUtils.ts:14 appendTextBlock doc does not state the same-reference no-op contract streamState relies on R1 Gon P3, Knov Note, Bisky Note No
CRF-5 Nit Dropped by orchestrator (author requested P0-P2 only) blockUtils.ts:10 Doc says "text or thinking block"; block type is response or thinking R1 Gon No
CRF-6 Note Dropped by orchestrator (author requested P0-P2 only) blockUtils.ts:22 Fix changes thinking disclosure titles for split reasoning deltas; no test covers it R1 Nami No
CRF-7 OOS Out of scope (body) coderd/x/chatd/chatprompt/chatprompt.go:1475 Whitespace-only text parts dropped when replaying interrupted turns to the model R1 Knov No
CRF-8 OOS Out of scope (body) streamState.ts:51 Unchanged comment uses an em dash R1 Gon No
CRF-9 OOS Out of scope (body) messageParsing.ts:242 Unchanged comment uses an em dash R1 Gon No

Contested and acknowledged

Round log

Round 1

Full panel (round 1). Netero first pass: 1 P4, 1 Note, no P0, panel proceeded. Panel: ging-ts, nami, melody (specialists), pariston, mafuuu (core), bisky (tests changed), gon, leorio (once-per-PR floor), knov (wildcard). Six reviewers reported no findings. Gon: 2 P2, 1 P3, 1 Nit. CRF-2 merges Netero's Note with Gon's P2 on the same divergence. The PR author asked in IC_kwDOGkVX1s8AAAABaoTeeA that the review be limited to P0, P1, and P2, so P3 and below and Notes are recorded but not posted. Drop gate for CRF-2 and CRF-3: kept at P2 because Gon's rubric sets P2 for wrong or restating comments and the downgrade argument (wording-only) was weaker than the rubric. Reviewed against 782fb30..5bd405d.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T13:41:17.769419Z 5bd405d Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 5bd405d79d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR keeps whitespace-only text and reasoning deltas that follow a block of the same type, so paragraph breaks survive in live streams and in stored per-delta parts. 2 P2 findings, both about comments. As you asked, only P0 to P2 findings are posted.

Out of scope (needs a ticket or explicit acceptance by a human):

  • coderd/x/chatd/chatprompt/chatprompt.go:1475: whitespace-only text parts are skipped when an interrupted turn is replayed to the model, so the model's history still has the joined writing.Like this text this PR fixes in the UI.
  • site/src/pages/AgentsPage/components/ChatConversation/streamState.ts:51: unchanged comment uses an em dash, which make lint/emdash is meant to reject.
  • site/src/pages/AgentsPage/components/ChatConversation/messageParsing.ts:242: unchanged comment uses an em dash, which make lint/emdash is meant to reject.

🤖 This review was automatically generated with Coder Agents.

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.
appendText ignores part type, so it does not match appendTextBlock
for whitespace after another part type. The stream state comment now
gives only the reason for its check.
@mafredri
mafredri force-pushed the mathias/stream-whitespace-deltas branch from 6d0d736 to aad92cb Compare October 13, 2026 11:50
@linear-code

linear-code Bot commented Oct 13, 2026

Copy link
Copy Markdown

CODAGT-1124

@mafredri
mafredri marked this pull request as ready for review October 13, 2026 12:07
@mafredri
mafredri requested a review from a team as a code owner October 13, 2026 12:07
@mafredri
mafredri merged commit e7b7687 into main Oct 13, 2026
33 checks passed
@mafredri
mafredri deleted the mathias/stream-whitespace-deltas branch October 13, 2026 12:47
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 13, 2026
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.

2 participants