Skip to content

fix(web): preserve streamed text spacing#2174

Open
AcWrong02 wants to merge 1 commit into
MoonshotAI:mainfrom
AcWrong02:codex/fix-web-stream-text-wrapping
Open

fix(web): preserve streamed text spacing#2174
AcWrong02 wants to merge 1 commit into
MoonshotAI:mainfrom
AcWrong02:codex/fix-web-stream-text-wrapping

Conversation

@AcWrong02

@AcWrong02 AcWrong02 commented Jul 25, 2026

Copy link
Copy Markdown

Related Issue

#2184

Problem

In apps/kimi-web, streamed assistant text and thinking segments were merged with a hardcoded '\n' between consecutive chunks. Because stream chunks already carry the model's own whitespace (including paragraph breaks), this inserted newline turned token-sized chunks into one word per line — most visible for Chinese output, where tokens carry no trailing space.

What changed

In apps/kimi-web/src/composables/messagesToTurns.ts, stop inserting '\n' when appending to a trailing text/thinking block. Concatenate the chunk text directly so the model's original whitespace is preserved. The block-splitting behavior (a tool call between two text segments still splits them into separate blocks) is unchanged.

Added a test in apps/kimi-web/test/turn-logic.test.ts covering streamed text merged around empty thinking parts, asserting the result is 'one two three' rather than newline-separated fragments.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ff456a8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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