Skip to content

feat(native-chat): make native chat replies flow in and the transcript glide when following - #26238

Merged
brennanb2025 merged 12 commits into
stablyai:mainfrom
AmoabaKelvin:smooth-native-chat-streaming-and-follow
Oct 8, 2026
Merged

brennanb2025 merged 12 commits into
stablyai:mainfrom
AmoabaKelvin:smooth-native-chat-streaming-and-follow

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​463 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​463
Prod 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​829 $\color{#cf222e}{\Huge{\mathbf{−}}}$​58 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​771

ELI5

A reply could still jump when it finished with a Mermaid diagram. The source disappeared before the diagram was ready, and the visible message changed height before its reserved blank space caught up. A hidden native-chat reproduction captured the same closing line moving down 147 image pixels between consecutive frames. The last paragraph now stays in place as the diagram finishes, while text continues to flow within its 350 ms reveal deadline.

What Changed

Preserves Kelvin’s commits and the existing fixed-latency text reveal, selected-word preservation, settled-span cleanup, stable markdown renderers, and main’s diagram error recovery. Current main was merged once as authorized; no further main sync or PR merge was performed.

Mounted messages now contribute their real height to the document immediately. Estimated blank space remains only for messages outside the rendered window. The existing scroll owner handles bottom following, history prepends, rail jumps, and reader input; hidden panes retain their last measured row sizes until they have visible boxes again.

Removed the transcript transform and its compensation and interaction-cancellation machinery. The bottom is updated from actual layout before paint when a diagram, code block, media item, or folded run changes height. Scrolling up still leaves the reader in control, and clicking ordinary transcript space cannot detach a short first reply.

Native chat keeps the existing source code block visible until the completed diagram is ready, then replaces it in one layout change. Streaming or partially revealed source never reaches Mermaid. Surrounding paragraphs, links, and other code remain mounted, and the finished diagram does not replay the streaming fade. Sidebar comments retain main’s default behavior.

Why

The previous layout tests flushed row measurements and scroll corrections together, so they missed the interval when the message had changed but its reserved height had not. Normal document flow removes that mismatch. Retaining the already displayed source avoids a temporary collapse below the viewport, where no scroll offset could preserve the last paragraph. More transform guards or delayed painting would leave those causes in place.

Intended difference: text has independent 350 ms arrival deadlines and a 300 ms word fade. The common pattern displays received text immediately; the fixed bound prevents a large burst from waiting behind a reading-speed queue. Reduced motion displays text immediately without fading.

Intended difference: native chat retains existing diagram source during rendering. The common pattern uses a loading placeholder; keeping the existing block preserves its height without adding a new notice. This is opt-in and does not change sidebar comments.

Intended difference: top-level markdown pieces and remend’s text-only unfinished-link repair remain to reduce repeated parsing. Sanitization stays in place, and these choices do not add a second scroll owner.

Linked Issue

Follow-up to Brennan’s October 8 live testing of this PR, including the remaining Claude Haiku and Codex completion jump; no separate issue was created.

Visual Proof

The before capture uses the merged pre-fix head and streams a heading, prose, a 12-node flowchart, TypeScript code, and four trailing paragraphs through the real native-chat composer and provider path. The after captures use committed head 4b3e706 and the same scenario with synthetic Claude-shaped and Codex-shaped agent processes in fresh isolated hidden macOS apps. Full app windows are shown.

Before: the closing line moves from image y = 580 to y = 727 as the empty diagram slot becomes SVG.

Before completion jump

After, Claude-shaped completion: the source remains visible until SVG is ready and the closing line stays at y = 730.

After Claude completion

After, Codex-shaped completion: the exact user-message echo settles delivery, the working line disappears, and the diagram replaces source without moving the closing line.

After Codex completion

Kelvin’s original recordings: before and after.

Testing

  • 189 focused tests across 22 explicit layout, history, navigation, first-reply, pacing, selection, markdown, and sidebar files.
  • Renderer typecheck and the final full typecheck passed through tc-gate.
  • Hidden Electron native-chat replay completed two turns each with Claude-shaped and Codex-shaped processes and real Mermaid SVG output.
  • All 22 static pre-push checks and an additional full typecheck ran: 22 passed; the sole max-lines failure is the unchanged main IPC file at 301 lines, byte-identical to the authorized merged main commit 22974c5.
  • Final-head GitHub CI completed: all five unit shards, all five Linux compatibility jobs, packaging, persistence, static analysis/typecheck and other completed checks pass; no new failures versus main.

Final CI: PR workflow and desktop persistence/Linux compatibility both completed successfully. End-to-end, real input-method, real WSL, mobile-on-main and desktop-template checks were explicitly skipped and are not claimed as passes. Main’s recent completed persistence run 37839088336 was also successful; the five Linux checks are green here.

The navigation test now delivers delayed browser scroll events for writes made during a commit, as well as writes made while resize callbacks settle. The new regression changes a mounted row’s actual height before delivering its virtualizer resize callback, pins from the content resize alone, and asserts that the later cache update causes no second movement. Substituting the original absolute-positioned layout fails this test: the document reports zero growth instead of 1,056 pixels. Deferred-diagram tests keep the exact code-block markup until SVG is ready; error recovery and sanitization still pass.

The after captures track the completed closing line through both turns, alongside animation-frame scroll geometry. Claude’s two completed replies have 122 and 164 tracked painted frames; Codex’s have 149 and 78. All have zero closing-line displacement, including source-to-SVG replacement; intermediate layout reads can precede the browser’s resize callback and are not treated as painted evidence. No transcript transform remains. Each second prompt was sent after scrolling away from the end and seeing Jump to latest; the sent question became visible and the reply followed. Native folder workspaces were exercised; Windows, Linux, SSH, real provider binaries, late-loading media, and interaction flows were not rendered in this round. Navigation and selection have focused unit coverage, and layout reflow is exercised through row-size changes. No wire format, execution ownership, or saved-data model changed.

Text deadline tests cover overlapping bursts, a 100,000-character burst, completion, remount/reconnect, hidden catch-up, and reduced motion. Earlier synthetic 5,000-word diagnostics remain limited to development React/happy-dom: 150 peak word spans and zero settled spans, versus 5,000 retained spans on the original PR. Those are not production frame-time measurements.

  1. In a brand-new Claude Haiku chat, then Codex, ask for a 12-node Mermaid HTTP-cache flowchart, code, and four trailing paragraphs. Leave following enabled: the last paragraph should stay still as source becomes a diagram and the reply finishes.
  2. While a short first reply starts, click transcript space or pass over Copy and leave the pointer still. The reply should keep following as it grows beyond the viewport.
  3. Scroll up deliberately, select text and use Add to chat, right-click, and jump with the rail or Jump to latest. Controls should remain aligned and deliberate navigation should retain control.
  4. Repeat with reduced motion, a large text burst, and a late-loading image or folded tool run. Text must finish within the deadline; content reflow must keep a following reader at the bottom and a detached reader in place.

Review

Self-reviewed visible-row and unloaded-gap arithmetic, scroll ownership, hidden measurements, selection stability, opt-in defaults, diagram lifecycle, and renderer compatibility. Independent review is requested. Larger follow-ups remain separate: parsing within a single huge paragraph/list/table and production frame-time measurement. No new notice, banner, control, or documentation file was added.

Agent skill upstream boundary

  • Not applicable: no upstream skill source or supporting files copied.

Checklist

  • Explained the problem, user-facing change, mechanism, and alternatives.
  • Before/after full-app screenshots uploaded and embedded.
  • Cross-platform, folder-workspace, SSH, saved-data, and provider compatibility considered.
  • Preserved contributor commits and original visual proof.
  • Final-head CI completely classified.
  • Brennan’s live retry complete (October 8: approved after round 3).

Snapshots land a clause at a time, 50-700 ms apart. Drawing behind them
at an eased speed is what makes a reply read as flowing.
… latest

The offset is still pinned at once; only what the pin moved is eased, so
nothing races the virtualizer or a reply that keeps growing.
dependencies is for packages the main process loads at runtime.
@coderabbitai

coderabbitai Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Caution

CodeRabbit couldn't post its review summary.

Error details
HttpError

@brennanb2025

brennanb2025 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Update (reopened): I closed this earlier because I was worried about the pacing: holding text back and releasing it word by word could let output queue up behind what has already arrived. After trying it live, I actually really like how it looks, so I've reopened it and we'll work on getting it in. That one's my bad, sorry @AmoabaKelvin.

We'll push a few changes on top of your commits: merging main, fixing the React Doctor error, and switching the pacing to a fixed delay, so every bit of text shows a set amount of time after it arrives and nothing can pile up.

Original comment

Superseded by #26380. Thanks @AmoabaKelvin, this got the problem right, and #26380 reuses your top-level block splitter, its tests, and the incremental markdown rendering approach.

#26380 is narrower on purpose: it shows the reply text the moment it arrives instead of holding it back and releasing it word by word. Each new paragraph or block fades in once while the reply streams (skipped when the OS "reduce motion" setting is on), and an unfinished **, backtick, or code fence is repaired before it renders so raw markdown never flashes. The follow glide and the animated "Jump to latest" are left out, so scrolling behaves as it does today.

@brennanb2025 brennanb2025 reopened this Oct 8, 2026
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes add incremental Markdown block rendering, word-fade rendering, and Mermaid source retention while diagrams render. Native-chat replies gain paced text reveal and dedicated user and assistant row components. Transcript rows now use normal flow with measured wrappers and spacers, and hidden panes use cached measurements. New tests cover rendering, reveal timing, row behavior, and transcript layout.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 3591b

A changed diagram can briefly show its old rendering until the new one finishes. This is minor and corrects itself, so it is mergeable with a small follow-up fix.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 34.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 69 functions across 48 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main native-chat changes: flowing replies and smoother transcript movement while following.
Description check ✅ Passed The description is detailed and covers the user impact, implementation, rationale, visual proof, testing, review notes, and checklist. The linked-issue section does not provide an actual issue referen…
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 18dca1ac-8016-4446-891c-5c4fffd00970
📥 Commits

Reviewing files that changed from the base of the PR and between 1c10232 and 3591bce.

📒 Files selected for processing (20)
  • src/renderer/src/components/editor/MermaidBlock.test.tsx
  • src/renderer/src/components/editor/MermaidBlock.tsx
  • src/renderer/src/components/native-chat/NativeChatMarkdown.mermaid.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMarkdown.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.growth-windowing.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.message-rail-windowing.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.older-history.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.rail-history-jump.test.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.tsx
  • src/renderer/src/components/native-chat/NativeChatMessageList.windowing-test-support.tsx
  • src/renderer/src/components/native-chat/NativeChatPacedMarkdown.tsx
  • src/renderer/src/components/native-chat/NativeChatTranscriptItems.tsx
  • src/renderer/src/components/native-chat/native-chat-window-test-layout.ts
  • src/renderer/src/components/native-chat/native-chat-windowing-test-harness.tsx
  • src/renderer/src/components/native-chat/use-native-chat-transcript-window.ts
  • src/renderer/src/components/sidebar/CommentMarkdown.tsx
  • src/renderer/src/components/sidebar/CommentMermaidBlock.tsx
  • src/renderer/src/components/sidebar/comment-markdown-code-renderers.tsx
  • src/renderer/src/components/sidebar/comment-markdown-mermaid-policy.ts
  • src/renderer/src/components/sidebar/comment-mermaid-fence.tsx
💤 Files with no reviewable changes (1)
  • src/renderer/src/components/native-chat/NativeChatPacedMarkdown.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Comment on lines +107 to +108
if (result === null && pendingContent !== undefined) {
return <>{pendingContent}</>

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Show pending source when the diagram content changes.

If content changes after a diagram renders, result still contains the previous SVG. The new render runs, but this branch skips pendingContent and displays the old diagram until that render finishes. Associate each result with the content that produced it. Show pendingContent whenever the result belongs to different content.

@brennanb2025

Copy link
Copy Markdown
Contributor

The end-of-reply jump was still present when a reply finished with a Mermaid diagram: the displayed source disappeared before SVG was ready, temporarily shrinking the transcript below the viewport, and mounted rows could change height before their reserved space caught up. A real native-chat reproduction captured the completed closing line moving 147 image pixels. At head 4b3e706, mounted messages own their real height, the existing scroll owner follows actual layout, and native chat retains the existing diagram source until SVG is ready; the transcript transform and its compensation machinery are removed. The user-facing result is that the trailing paragraph stays in place through diagram replacement and completion, while the 350 ms text deadline remains.

The final hidden macOS captures use fresh isolated folder workspaces and synthetic Claude-shaped and Codex-shaped processes through the real native-chat composer. Two replies per provider complete with real SVG output and zero painted closing-line displacement across 122/164 and 149/78 tracked frames, including a second send after scrolling away from the end. The before/after full-app strips are embedded in the PR body. Intermediate DOM reads are distinguished from painted frames; this is not a claim that every intermediate layout read is unchanged. The delayed-measurement regression fails with the actual original layout, and navigation tests now deliver delayed browser scroll events for commit-time writes without weakening their assertions.

189 focused tests pass across 22 explicit files, and renderer plus full queued typechecks pass. All 22 static pre-push checks ran; the sole local lint failure is the unchanged main IPC file at 301 lines, byte-identical to merged main 22974c5. Final-head GitHub CI completed successfully: all five unit shards, all five Linux compatibility jobs, packaging, desktop persistence and all other completed checks pass, with no new failures versus main (PR workflow, persistence and Linux compatibility). The five skipped checks are end-to-end, real input-method, real WSL, mobile-on-main and desktop-template; they are not counted as passes.

Self-reviewed scrolling, window gaps, hidden restoration, markdown defaults, pending-diagram lifecycle, selection, and sanitization. The intended differences from the common pattern are labelled in the body. Real provider binaries, Windows/Linux/SSH rendering, late-loading media and all selection/context-menu interaction flows were not rendered in this round; navigation and selection have automated coverage. Larger parsing work inside huge paragraphs, lists and tables and production frame-time measurement remain separate. Brennan’s live retry checklist is in the body. No new notice, saved-data field, wire format, or documentation file was added; contributor commits and original recordings are preserved, and the PR is not merged.

…6238-r3

# Conflicts:
#	src/renderer/src/components/native-chat/NativeChatMessageList.tsx
#	src/renderer/src/components/native-chat/NativeChatMessageRow.tsx
@brennanb2025
brennanb2025 merged commit 3c07588 into stablyai:main Oct 8, 2026
40 checks passed
@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks again for this one, Kelvin. The look is great. Here's what we added on top while getting it ready to merge:

  • Text never piles up. Every piece of a reply now shows within a fixed 350 ms of arriving, instead of being released at a reading pace that could fall behind on fast replies. The per-word fade stays.
  • New chats follow their first reply. Clicking or selecting during a short first reply no longer stops the chat from scrolling with it.
  • No jump at the end of a reply. A finished diagram's source now stays on screen until the drawn diagram is ready, instead of collapsing to an empty box first, which made the chat jump up and back down.
  • One scroll owner. Transcript rows now sit in normal layout and the existing virtualizer does all the scrolling, which replaces the transform-based glide. This removed a lot of special-case code (about 830 lines out, 280 in) and fixed the end-of-reply movement for both Claude and Codex.
  • Merged main and resolved the conflicts.

Two small follow-ups will go in a separate PR: keeping a wide diagram's horizontal scroll position when the reply finishes, and pruning the list of already-revealed rows in very long chats.

brennanb2025 added a commit that referenced this pull request Oct 9, 2026
Resolves conflicts with #26238 (paced, block-by-block reply rendering) in
NativeChatMarkdown.tsx and CommentMarkdown.tsx: keep fadeWords/growing and
the fileLinkExists plumbing together. Adds tests that a paced reply asks the
host only once fully revealed, and that block-split rendering re-renders when
existence answers change.
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.

2 participants