agent_crew icon indicating copy to clipboard operation
agent_crew copied to clipboard

Fix: chat messages overflow container breaking layout

Open sre-helmcode opened this issue 8 months ago • 1 comments

Problem

Chat messages containing long lines of text, inline code, or code blocks expand beyond the chat container, breaking the page layout. The content pushes past the right edge of the chat panel instead of wrapping or scrolling within bounds.

Visible symptoms:

  • Message bubbles extend beyond the right edge of the chat panel
  • Horizontal scrollbar may appear on the page body
  • Activity panel gets pushed off-screen or compressed
  • Most noticeable with long inline code, monospace text, or unbroken long lines

Root Cause

Classic CSS flexbox overflow bug combined with missing overflow constraints at multiple levels:

1. Chat panel missing min-w-0 (TeamMonitorPage.tsx line 526)

<div className="flex flex-1 flex-col rounded-lg border ...">

In flexbox, the default min-width is auto, which prevents a flex item from shrinking below its content size. When content is wider than the flex allocation, the item grows beyond it. Fix: add min-w-0.

2. Chat scroll area missing horizontal overflow control (line 534)

<div className="flex-1 overflow-y-auto p-4">

Has overflow-y-auto but no overflow-x handling. Fix: add overflow-x-hidden.

3. Message bubble div missing word-break (line 583)

<div className={`rounded-lg px-3 py-2 text-sm ${...}`}>
  <MarkdownRenderer>{getChatText(msg)}</MarkdownRenderer>
</div>

No overflow-hidden, overflow-wrap: break-word, or word-break. Long unbroken text expands the bubble. Fix: add overflow-hidden and break-words.

4. Inline <code> in MarkdownRenderer (Markdown.tsx line 44-47)

code: ({ children }) => (
  <code className="rounded bg-slate-700/50 px-1 py-0.5 font-mono text-xs">
    {children}
  </code>
),

No break-all or overflow-wrap. Long inline code snippets (file paths, variable names, URLs) don't wrap. Fix: add break-all or overflow-wrap: anywhere.

5. <pre> container constraint

The <pre> element has overflow-x-auto (good), but since the parent message bubble has no overflow constraint, the auto-scroll doesn't activate correctly.

Affected Files

  • frontend/src/pages/TeamMonitorPage.tsx — chat panel layout, scroll area, message bubbles
  • frontend/src/components/Markdown.tsx — inline code and pre element styling

Suggested Fix Points

  1. TeamMonitorPage.tsx line 526: Add min-w-0 to chat panel flex child
  2. TeamMonitorPage.tsx line 534: Add overflow-x-hidden to scroll container
  3. TeamMonitorPage.tsx line 583: Add overflow-hidden break-words to message bubble
  4. Markdown.tsx line 44-47: Add break-all to inline <code> element

sre-helmcode avatar Mar 12 '26 13:03 sre-helmcode

Already fixed in commit 6eb5f4e. Closing as completed.

sre-helmcode avatar Mar 12 '26 18:03 sre-helmcode