Repository navigation
fix(chat): keep StreamingMarkdown render path after stream finishes [v0.5.3] - #10
Merged
Merged
Conversation
… preserves h2 styling [v0.5.3] Message.tsx previously swapped from <StreamingMarkdown> to <MessageContent> at end-of-stream. MessageContent relies on Tailwind's `prose` class, but @tailwindcss/typography isn't installed in consuming apps — so h2 collapsed from 1.35em (StreamingMarkdown inline BLOCK_STYLES) to browser default ~21px, producing a visible heading-shrink at end-of-stream (e.g. "Estimación rápida"). Fix: render <StreamingMarkdown> for ALL assistant messages and toggle the `isStreaming` prop based on isStreamingThis. User messages keep <MessageContent> (user input rarely has markdown). The .cf-stream-root wrapper stays mounted; only .cf-stream-active drops at completion — chars freeze in place, zero layout shift, no h2 regression. Tests updated: - "renders MessageContent for user messages" (was: not streaming) - "renders StreamingMarkdown with cf-stream-active class when isStreamingThis" - "renders StreamingMarkdown WITHOUT cf-stream-active when streaming a different message" - "keeps StreamingMarkdown rendered when stream finishes — only drops cf-stream-active" 8/8 tests pass. tsc --noEmit clean.
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.
Summary
h2"Estimación rápida" (and any other heading) collapsed from1.35emto browser default~21pxthe moment the stream finished.Message.tsxswapped from<StreamingMarkdown>(inlineBLOCK_STYLESwithfontSize: 1.35emon h2) to<MessageContent>(which relies on Tailwindproseclass).@tailwindcss/typographyis not installed in consuming apps (TimelyAI / Landing / InboxAI) — soproseis a no-op and headings fall back to the browser default.<StreamingMarkdown>for all assistant messages and toggle theisStreamingprop based onisStreamingThis. User messages still use<MessageContent>(user input rarely has markdown).Before / after
Before: during stream →
<StreamingMarkdown>withcf-stream-root cf-stream-active, h2 inline-styled1.35em. Stream finishes → component swaps to<MessageContent>which renders<h2>Estimación rápida</h2>with only theproseclass.proseresolves to nothing (plugin not installed) → h2 reverts to UA default (~21px / 1.5em bold) → visible shrink.After: during stream → same. Stream finishes → same component stays mounted; only
.cf-stream-activeclass drops. h2 keeps its inlinefontSize: 1.35em, char spans freeze in place. Zero layout shift, zero size change.Why not install
@tailwindcss/typography?That's a bigger change touching every consumer's tailwind config and potentially clashing with brand styles. The
StreamingMarkdowninlineBLOCK_STYLESare already the canonical rendering for streamed assistant output — we just keep using them post-stream too. Cheap, surgical, behavior-preserving.Files
src/components/chat-widget/Message.tsx— single-branch swapsrc/__tests__/components/Message.streaming.test.tsx— 4 tests rewritten around the new contract (StreamingMarkdown stays mounted; onlycf-stream-activetoggles)package.json—0.5.2 → 0.5.3CHANGELOG.md—[0.5.3]entryTest plan
npx tsc --noEmit— clean (no new TS errors)npx vitest run src/__tests__/components/Message.streaming.test.tsx src/__tests__/components/StreamingMarkdown.debug.test.tsx— 8/8 passhttps://ui.cofoundy.dev/iframe.html?id=chat-message--streaming-finished&viewMode=storyand grep forfont-size:1.35emin the h2 attribute — should be present (was absent before this fix)Chat/Message → Streaming Finishedshould look identical toStreaming Chunkymid-stream w.r.t. heading sizeOut of scope
StreamingMarkdown.tsx,useStreamingDrip.ts, streaming CSS — unchanged (already correct)@tailwindcss/typographyinstall — deliberately deferred