Skip to content

fix: prevent long text overflow in agent chat message bubbles#336

Merged
jamiepine merged 1 commit intospacedriveapp:mainfrom
toanalien:fix/layout-agent-chat
Mar 6, 2026
Merged

fix: prevent long text overflow in agent chat message bubbles#336
jamiepine merged 1 commit intospacedriveapp:mainfrom
toanalien:fix/layout-agent-chat

Conversation

@toanalien
Copy link
Contributor

Problem

On the /agents/{id}/chat page, long unbreakable text (e.g. URLs or continuous strings without spaces) overflowed to the right outside the viewport instead of wrapping within the message bubble.

Root Cause

  • The messages scroll container had overflow-y-auto but no horizontal overflow constraint, allowing content to expand beyond the viewport width.
  • The user message <p> used break-words which only breaks at word boundaries — ineffective for continuous strings with no spaces.

Changes

interface/src/components/WebChatPanel.tsx

  • Added overflow-x-hidden to the messages scroll container to clamp horizontal overflow
  • Added min-w-0 overflow-hidden to the user message bubble div to enforce max-w-[85%] constraint inside flex layout
  • Changed break-wordsbreak-all on the message <p> to force-break continuous strings
  • Added whitespace-pre-wrap to preserve intentional line breaks

Testing

Verified with a long continuous string input (thisisthelongline...) — text now wraps correctly within the bubble.

Before

CleanShot 2026-03-06 at 11 01 16@2x

Fixed

CleanShot 2026-03-06 at 10 53 24@2x

Add overflow-x-hidden to messages scroll container, min-w-0 overflow-hidden
to user message bubble, and break-all with whitespace-pre-wrap to message
text to ensure long unbreakable strings wrap correctly.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb35f0f9-c163-42ba-a2da-38be9b0284a9

📥 Commits

Reviewing files that changed from the base of the PR and between eb6e877 and 699eeb3.

📒 Files selected for processing (1)
  • interface/src/components/WebChatPanel.tsx

Walkthrough

CSS styling adjustments to the WebChatPanel component to prevent horizontal overflow in the message list and ensure proper text wrapping and truncation for long user messages. Changes include overflow-hidden properties and text wrapping directives on message containers and content.

Changes

Cohort / File(s) Summary
Message Container Styling
interface/src/components/WebChatPanel.tsx
Added overflow-x-hidden to message list container, expanded user message bubble with min-width: 0 and overflow-hidden, and enhanced message content styling with break-all and whitespace-pre-wrap for proper text wrapping.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • jamiepine
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically describes the main fix: preventing text overflow in chat message bubbles.
Description check ✅ Passed The description comprehensively explains the problem, root cause, specific changes made, and includes before/after images demonstrating the fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

<div className="max-w-[85%] rounded-2xl rounded-br-md bg-accent/10 px-4 py-2.5">
<p className="text-sm text-ink">{item.content}</p>
<div className="max-w-[85%] min-w-0 overflow-hidden rounded-2xl rounded-br-md bg-accent/10 px-4 py-2.5">
<p className="text-sm text-ink break-all whitespace-pre-wrap">{item.content}</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break-all can be pretty aggressive for normal prose (may split words mid-word). You might get the same “never overflow” behavior with overflow-wrap:anywhere, which only breaks when needed.

Suggested change
<p className="text-sm text-ink break-all whitespace-pre-wrap">{item.content}</p>
<p className="text-sm text-ink break-words [overflow-wrap:anywhere] whitespace-pre-wrap">{item.content}</p>

@jamiepine jamiepine merged commit f99d29b into spacedriveapp:main Mar 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants