From bf1f2f431376e2a40bd0f634b094ae0942d1f7da Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Sat, 14 Feb 2026 09:41:10 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=A8=EF=B8=8F=20refactor:=20Better=20Wh?= =?UTF-8?q?itespace=20handling=20in=20Chat=20Message=20rendering=20(#11791?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updated the rendering logic in the Part component to handle whitespace-only text more effectively. - Introduced a placeholder for whitespace-only last parts during streaming to enhance user experience. - Ensured non-last whitespace-only parts are skipped to avoid rendering empty containers, improving layout stability. --- .../components/Chat/Messages/Content/Part.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/client/src/components/Chat/Messages/Content/Part.tsx b/client/src/components/Chat/Messages/Content/Part.tsx index 4a74e3606f..f97d1343b9 100644 --- a/client/src/components/Chat/Messages/Content/Part.tsx +++ b/client/src/components/Chat/Messages/Content/Part.tsx @@ -67,9 +67,20 @@ const Part = memo( if (part.tool_call_ids != null && !text) { return null; } - /** Skip rendering if text is only whitespace to avoid empty Container */ - if (!isLast && text.length > 0 && /^\s*$/.test(text)) { - return null; + /** Handle whitespace-only text to avoid layout shift */ + if (text.length > 0 && /^\s*$/.test(text)) { + /** Show placeholder for whitespace-only last part during streaming */ + if (isLast && showCursor) { + return ( + + + + ); + } + /** Skip rendering non-last whitespace-only parts to avoid empty Container */ + if (!isLast) { + return null; + } } return (