mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-22 18:34:08 +01:00
🗨️ refactor: Better Whitespace handling in Chat Message rendering (#11791)
- 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.
This commit is contained in:
parent
65d1382678
commit
bf1f2f4313
1 changed files with 14 additions and 3 deletions
|
|
@ -67,9 +67,20 @@ const Part = memo(
|
||||||
if (part.tool_call_ids != null && !text) {
|
if (part.tool_call_ids != null && !text) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/** Skip rendering if text is only whitespace to avoid empty Container */
|
/** Handle whitespace-only text to avoid layout shift */
|
||||||
if (!isLast && text.length > 0 && /^\s*$/.test(text)) {
|
if (text.length > 0 && /^\s*$/.test(text)) {
|
||||||
return null;
|
/** Show placeholder for whitespace-only last part during streaming */
|
||||||
|
if (isLast && showCursor) {
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<EmptyText />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/** Skip rendering non-last whitespace-only parts to avoid empty Container */
|
||||||
|
if (!isLast) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue