Skip to content

fix(frontend): prevent user message bubble overflow with long unbreakable strings - #3488

Merged
WillemJiang merged 3 commits into
bytedance:mainfrom
ech0hol:fix/user-message-overflow
Jun 11, 2026
Merged

fix(frontend): prevent user message bubble overflow with long unbreakable strings#3488
WillemJiang merged 3 commits into
bytedance:mainfrom
ech0hol:fix/user-message-overflow

Conversation

@ech0hol

@ech0hol ech0hol commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

fix(frontend): prevent user message bubble overflow with long unbreakable strings

  • Add max-w-full min-w-0 to constrain message container width
  • Change bubble width from w-fit to conditional w-full max-w-full (user) / w-fit (assistant)
  • Move break-words from outer wrapper to AIElementMessageResponse for precise text wrapping

Fixes #3484

Why

用户输入包含长不可换行字符串(如 =====================================、长 URL、无空格连续字符)时,用户消息气泡会被内容无限撑宽,超出页面容器导致页面出现横向滚动条

触发场景:用户粘贴长代码注释分隔线、长 URL、连续符号等无换行机会的字符串。

What changed

  • 用户消息气泡宽度现在与 AI 回复气泡保持一致,不再随内容无限扩展
  • 长不可换行字符串现在会在气泡边界处自动换行,不再撑破容器
  • 页面不再因用户消息出现横向滚动条

Surface area

  • Frontend UI — page / component / setting / interaction under frontend/
  • Backend API — endpoint / SSE event / request-response shape under backend/app
  • Agents / LangGraph — agent node, graph wiring, langgraph.json, or prompt change
  • Sandboxdocker/ or sandboxed execution
  • Skills — change under skills/
  • Dependencies — new/upgraded entry in backend/pyproject.toml or frontend/package.json (say what it buys us)
  • Default behavior change — changes existing behavior without the user opting in (default model, default setting, data shape)
  • Docs / tests / CI only — no runtime behavior change

Screenshots / Recording

改动后的代码块或Markdown文本可以正常展示
QQ_1781108821784
QQ_1781108769790

Bug fix verification

  • 问题可通过在前端输入框中粘贴长不可换行字符串(如 50+ 个 = 号)复现
  • 属于纯 CSS 样式 bug,不涉及逻辑层,不适合用单元测试覆盖
  • 验证方式:Docker 开发环境中实测长字符串气泡换行正常,横向滚动条消失

Validation

# 前端单元测试
# 结果:23/23 test files passed, 167/167 tests passed

@CLAassistant

CLAassistant commented Jun 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added area:frontend Next.js frontend under frontend/ risk:medium Medium risk: regular code changes size/XS PR changes < 20 lines labels Jun 10, 2026
@WillemJiang

WillemJiang commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

@SnapLap thanks for your contribution. Please fix the lint error and here are some review comments on the PR.

  1. overflow-x-clip replaces overflow-visible globally — In message.tsx:48, the change from overflow-visible to overflow-x-clip affects all message types (user and assistant), not just user messages. If assistant messages had any intentional overflow behavior (e.g., tooltips or absolutely positioned elements), this could cause them to clip unexpectedly.

Suggestion: Consider scoping the overflow change to user messages only:
"overflow-visible group-[.is-user]:overflow-x-clip"

  1. break-words on the wrapper vs. the content — The break-words class is added to the outer wrapper MessageContent, but the actual text is inside MessageResponse. Depending on the nesting, break-words on the parent may not propagate correctly to the deepest text node if there are intermediate elements with white-space: nowrap or similar. Worth verifying that the word-breaking actually applies where the text renders.

  2. w-full max-w-full on bubble vs. assistant messages — In message-list-item.tsx:319, the change to AIElementMessageContent className="w-full max-w-full" affects the bubble for both user and assistant messages (this component is used for both paths in the same file). The original w-fit gave assistant messages a natural-width bubble. Now both will stretch to w-full, which may visually change how assistant responses look (they'll take full width even for short replies).

Suggestion: Apply w-full max-w-full conditionally:
<AIElementMessageContent className={cn(isHuman ? "w-full max-w-full" : "w-fit")}>

@WillemJiang WillemJiang added the reviewing A maintainer is reviewing this PR label Jun 11, 2026
…able strings

- Add max-w-full min-w-0 to user message wrapper div to constrain width
- Change bubble width from w-fit to w-full max-w-full for consistent layout
- Add break-words to user message content for long string wrapping
- Add overflow-x-clip as defensive overflow protection
@ech0hol
ech0hol force-pushed the fix/user-message-overflow branch from 7311e91 to 8920a5e Compare June 11, 2026 02:35
@ech0hol

ech0hol commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

@WillemJiang Thanks for the detailed review! All three points addressed in this update:

1.overflow-x-clip scoping — You're right that it shouldn't be global. In fact, after deeper analysis, I realized message.tsx doesn't need any changes at all. My initial fix was over-scoped — I added overflow-x-clip there trying to clip overflow at the MessageContent level, but the real root cause is that the user message bubble in message-list-item.tsx lacked width constraints. Once max-w-full and min-w-0 are added to the wrapper div there, the original overflow-visible works fine for both message types. So message.tsx has been reverted to match main with no modifications.

2.break-words moved to inner element — Great suggestion. Moved from the outer MessageContent wrapper to AIElementMessageResponse, which directly wraps the rendered text. This ensures overflow-wrap: break-word applies at the text rendering layer with no risk of intermediate CSS interference.

3.w-full max-w-full conditional — Appreciate the suggestion! I initially implemented the ternary as you suggested, but upon closer inspection, this AIElementMessageContent is already inside an if (isHuman) block (line 302), so isHuman is always true here and the "w-fit" branch is unreachable. The assistant path uses a separate AIElementMessageContent (line 333) with its own className, so it's unaffected regardless. Simplified to just className="w-full max-w-full" to avoid dead code.

@WillemJiang
WillemJiang merged commit 0367fe6 into bytedance:main Jun 11, 2026
11 checks passed
@WillemJiang WillemJiang added this to the 2.0.0 milestone Jun 15, 2026
@ech0hol
ech0hol deleted the fix/user-message-overflow branch June 21, 2026 13:13
@ech0hol
ech0hol restored the fix/user-message-overflow branch June 21, 2026 13:13
@ech0hol
ech0hol deleted the fix/user-message-overflow branch June 21, 2026 13:17
Wingxxx pushed a commit to Wingxxx/deer-flow that referenced this pull request Jun 22, 2026
…able strings (bytedance#3488)

- Add max-w-full min-w-0 to user message wrapper div to constrain width
- Change bubble width from w-fit to w-full max-w-full for consistent layout
- Add break-words to user message content for long string wrapping
- Add overflow-x-clip as defensive overflow protection

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
Wingxxx pushed a commit to Wingxxx/deer-flow that referenced this pull request Jun 23, 2026
…able strings (bytedance#3488)

- Add max-w-full min-w-0 to user message wrapper div to constrain width
- Change bubble width from w-fit to w-full max-w-full for consistent layout
- Add break-words to user message content for long string wrapping
- Add overflow-x-clip as defensive overflow protection

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
marvin9551 pushed a commit to marvin9551/deer-flow that referenced this pull request Aug 21, 2026
…able strings (bytedance#3488)

- Add max-w-full min-w-0 to user message wrapper div to constrain width
- Change bubble width from w-fit to w-full max-w-full for consistent layout
- Add break-words to user message content for long string wrapping
- Add overflow-x-clip as defensive overflow protection

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
jihtsan pushed a commit to jihtsan/dnx-deer-flow that referenced this pull request Aug 29, 2026
…able strings (bytedance#3488)

- Add max-w-full min-w-0 to user message wrapper div to constrain width
- Change bubble width from w-fit to w-full max-w-full for consistent layout
- Add break-words to user message content for long string wrapping
- Add overflow-x-clip as defensive overflow protection

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Next.js frontend under frontend/ reviewing A maintainer is reviewing this PR risk:medium Medium risk: regular code changes size/XS PR changes < 20 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Horizontal overflow from long chat messages not constrained in container.

3 participants