Conversation
Prevent vertical layout jumping and reflow during assistant stream rendering by keeping the smooth-stream cursor active throughout active streaming, positioning the cursor inline at leaf elements and list items rather than container lists, and disabling orphan-rebalancing line wrapping during active streams. Fixes vastsa#1345
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem / 问题
In v0.16.0, during assistant response streaming, the message layout visibly jumps, shakes, and reflows vertically (reported in #1345).
Root Causes
showCursorwas calculated asdisplayContent.length < (message.content || "").length. Because chunk tokens arrive in network bursts and the typewriter loop drains at 60–120 fps, the buffer repeatedly caught up with the current source length between packet bursts. This caused the cursor element to toggle on and off multiple times per second during active streaming..assistant-turn-fragment.smooth-cursor .prose-chat > :last-child::afterplaced the cursor pseudo-element directly under the container<ul>or<ol>. In CSS layout, an inline-block child inside a block list container forces an extra line box after the list items. Each time the cursor toggled on/off, an entire ~20px line was added and removed below the list, repeatedly resizing the container and triggering follow scroll jitter..prose-chatappliestext-wrap: pretty. Chromium's orphan-prevention algorithm repeatedly recalculates line breaks across up to four lines backward as each token or cursor width changes, causing previous lines to reflow and bounce vertically.Fix / 修复
AssistantTurnParts.tsx, maintainshowCursoractive while streaming (streaming && enabled && Boolean(displayContent)), letting CSSsmooth-stream-blinkhandle the cursor blinking naturally without coupling presence to network packet arrival intervals.li(or its inner trailing element) rather than the list container itself, preventing orphan line-box generation under lists, blockquotes, and code blocks.text-wrap: wrapon.assistant-turn-fragment.streaming .prose-chatso earlier lines stay locked in place as tokens stream in. Once streaming completes, the.streamingclass is removed andtext-wrap: prettyformats the final settled message.apps/desktop/test/chat-streaming-layout.test.mjscovering cursor presence stability, leaf element placement, and stream text-wrap stabilization.Fixes #1345