From 1b082f780e5fa133ccaa1a248b970ec70d6dd103 Mon Sep 17 00:00:00 2001 From: pcarter Date: Wed, 15 Apr 2026 14:46:38 -0700 Subject: [PATCH] render in ui --- app/rendered-markdown.tsx | 6 +++++- tests/unit.test.ts | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/rendered-markdown.tsx b/app/rendered-markdown.tsx index f2ab260..cb8abed 100644 --- a/app/rendered-markdown.tsx +++ b/app/rendered-markdown.tsx @@ -21,7 +21,11 @@ function RenderedMarkdown({ () => followupsEnabled ? splitMessageFollowups(text ?? '') : { content: text ?? '', followups: [] }, [followupsEnabled, text], ); - const rendered = useMemo(() => html ?? renderMarkdown(content), [html, content]); + const preferClientRender = followupsEnabled && text !== undefined; + const rendered = useMemo( + () => preferClientRender ? renderMarkdown(content) : html ?? renderMarkdown(content), + [preferClientRender, html, content], + ); const handleClick = async (event: React.MouseEvent) => { const button = (event.target as HTMLElement).closest('button[data-copy-code]'); diff --git a/tests/unit.test.ts b/tests/unit.test.ts index 9980e80..cc998df 100644 --- a/tests/unit.test.ts +++ b/tests/unit.test.ts @@ -350,6 +350,10 @@ test('followup UI wiring hides XML in assistant messages and submits the selecte pageSource.includes('await submitTurn(followup);'), 'clicking a followup should immediately submit that followup as the next turn', ); + assert.ok( + pageSource.includes('setMessages(withRenderedMessages(item.messages));'), + 'history-loaded chats should still rebuild assistant message rendering on the client', + ); assert.ok( renderedMarkdownSource.includes('className="followup-button"'), 'RenderedMarkdown should render followups as dedicated themed buttons', @@ -358,6 +362,10 @@ test('followup UI wiring hides XML in assistant messages and submits the selecte renderedMarkdownSource.includes('followupsEnabled'), 'RenderedMarkdown should explicitly opt into followup parsing for assistant messages', ); + assert.ok( + renderedMarkdownSource.includes('const preferClientRender = followupsEnabled && text !== undefined;'), + 'followup rendering should prefer client-side markdown from raw text when followups are enabled', + ); assert.ok( css.includes('.followup-button'), 'globals.css should include styling for the followup buttons', -- 2.51.2