fix(ui): prevent reasoning block from expanding chat playground layout - #32485
Conversation
The expanded reasoning block did not constrain its width or break long unbreakable tokens, so its inline-block bubble grew past its max width and pushed the whole page wider (#32481). Mirror the message body handling by capping the container width and breaking long words/code.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Greptile SummaryThis PR constrains the
Confidence Score: 4/5Safe to merge; the change is confined to presentation logic in a single UI component with a companion regression test. The fix is correct and targeted. The only imperfection is the non-existent Tailwind class No files require special attention beyond the bogus Tailwind class in
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/chat_ui/ReasoningContent.tsx | Adds width-constraining and word-break styles to prevent the reasoning block from expanding the chat layout; one non-existent Tailwind class (wrap-break-word) was introduced but is functionally harmless since the inline style prop covers the same behavior. |
| ui/litellm-dashboard/src/components/chat_ui/ReasoningContent.test.tsx | New test file covering empty content, expand/collapse toggle, and the regression that ensures the container carries the layout-constraining class and word-break styles. |
Reviews (1): Last reviewed commit: "fix(ui): prevent reasoning block from ex..." | Re-trigger Greptile
| {isExpanded && ( | ||
| <div className="mt-2 p-3 bg-gray-50 border border-gray-200 rounded-md text-sm text-gray-700"> | ||
| <div | ||
| className="mt-2 p-3 bg-gray-50 border border-gray-200 rounded-md text-sm text-gray-700 max-w-full overflow-x-auto whitespace-pre-wrap wrap-break-word" |
There was a problem hiding this comment.
wrap-break-word is not a valid Tailwind CSS utility class and will be silently ignored by the browser. The correct Tailwind class for overflow-wrap: break-word is break-words. The actual break-word behavior here is covered by the inline style prop, so this is harmless but dead/misleading code.
| className="mt-2 p-3 bg-gray-50 border border-gray-200 rounded-md text-sm text-gray-700 max-w-full overflow-x-auto whitespace-pre-wrap wrap-break-word" | |
| className="mt-2 p-3 bg-gray-50 border border-gray-200 rounded-md text-sm text-gray-700 max-w-full overflow-x-auto whitespace-pre-wrap break-words" |
Merging this PR will improve performance by 26.69%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_completion_with_tools |
4.2 ms | 3.2 ms | +31.16% |
| ⚡ | test_completion_simple_message |
4 ms | 3.3 ms | +22.38% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing litellm_fix_reasoning_block_ui_overflow (ff5c073) with litellm_internal_staging (bfff5e8)
Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
BerriAI#32485) The expanded reasoning block did not constrain its width or break long unbreakable tokens, so its inline-block bubble grew past its max width and pushed the whole page wider (BerriAI#32481). Mirror the message body handling by capping the container width and breaking long words/code. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Relevant issues
Fixes #32481
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Reproduced live in the chat playground (
ui/litellm-dashboarddev server on :3000 talking to a real proxy on :4000). Since the bug only needs a reasoning payload that contains a single unbreakable token, I streamed one through the real proxy from a local OpenAI-compatible backend whose response carriesreasoning_contentwith a ~450 char token that has no spaces or hyphens, then sent a message from the playground. The UI path (streaming parse ->ChatMessageBubble->ReasoningContent) is exactly what an end user hits with a real reasoning model; only the token content is seeded so the repro is deterministicBEFORE (pre-fix component, matching base
litellm_internal_staging@ cd6e8cd): the expanded reasoning block keeps the long token on one line, so the assistant bubble grows past itsmax-w-[80%]cap and the chat area gets a horizontal scrollbarAFTER (@ ff5c073): the same reasoning payload wraps inside the bubble, the bubble stays within its cap and there is no horizontal scroll
Type
🐛 Bug Fix
Changes
ui/litellm-dashboard/src/components/chat_ui/ReasoningContent.tsx: constrain the expanded reasoning container width and break long words/code so it cannot push the layout wider. This mirrors the handling already used for the message body inChatMessageBubble: the container caps atmax-w-full, wraps long words (wordBreak/overflowWrap: break-word), scrolls overflow within itself (overflow-x-auto), and long code lines wrap viawrapLongLineswith aprecapped atmaxWidth: 100%. Also uses the valid Tailwindbreak-wordsclass (waswrap-break-word, which Tailwind silently ignores) per Greptile feedbackAdded
ui/litellm-dashboard/src/components/chat_ui/ReasoningContent.test.tsxwith a regression test that renders a long unbreakable token and asserts the container caps its width and breaks long words. The test fails on the pre-fix component and passes afterLink to Devin session: https://app.devin.ai/sessions/28a101fae22343fcb8e5ab66c3750533
Link to Devin session: https://app.devin.ai/sessions/08d2a4c499964900800e7e43849024f1
Requested by: @ishaan-berri