Skip to content

fix(chat): user bubble width — move 80% cap to .chat-message__main#325

Merged
blove merged 1 commit into
mainfrom
chat-bubble-fix-followup
May 15, 2026
Merged

fix(chat): user bubble width — move 80% cap to .chat-message__main#325
blove merged 1 commit into
mainfrom
chat-bubble-fix-followup

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 15, 2026

Summary

Follow-up to PR #313's text-wrap fix, which was insufficient. The bubble's `width: fit-content` couldn't escape a containing-block collapse: the bubble's `max-width: 80%` resolves against `.chat-message__main`, which collapsed to ~58px because of `flex: 1; min-width: 0` in the flex chain. Result: `80% × 58px = 46px` cap on the bubble — still narrower than "hello" — so "hello" rendered as "hel" / "lo".

Fix: for user-role messages, override `.chat-message__main`:

```css
:host([data-role="user"]) .chat-message__main {
flex: none;
width: fit-content;
max-width: 80%;
}
```

Now the 80% cap resolves against the host (full row, 720px), not the collapsed flex item. Bubble itself drops its percentage cap to avoid a circular constraint (bubble max-width 80% of fit-content main = 80% of bubble = recursive). Assistant-role bubbles retain the 80% cap on the bubble directly — they're not in the flex collapse path.

Verified manually: "hello" renders on one line, bubble 58.5px wide, main column 53px, sized to content. Tested via chrome MCP at localhost:4507 (cockpit-chat-timeline-angular standalone) after CSS hot-reload.

Test plan

  • `pnpm nx test chat` — green
  • Manual chrome MCP: "hello" submitted in chat-timeline-angular; bubble renders on one line at intrinsic content width
  • CI verifies full check stack

🤖 Generated with Claude Code

PR #313's `width: fit-content` on the bubble was insufficient. The
bubble's `max-width: 80%` resolved against `.chat-message__main`, which
collapsed to ~58px because of `flex: 1; min-width: 0` in the flex chain.
Result: 80% of 58px = 46px cap on the bubble, still forcing "hello" to
wrap as "hel" / "lo".

Fix: for user-role messages, override `.chat-message__main` to
`flex: none; width: fit-content; max-width: 80%`. The 80% cap now
resolves against the host element (full row, 720px) and propagates
correctly. Bubble itself drops the percentage cap (it would resolve
against the now-content-sized main, creating a circular constraint).
Assistant-role bubbles retain the 80% cap on the bubble directly —
they're not in the flex collapse path.

Verified: "hello" renders on one line. Bubble 58.5px wide, main column
53px, sized to content.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cacheplane Ready Ready Preview, Comment May 15, 2026 6:11pm

Request Review

@blove blove merged commit 131ce06 into main May 15, 2026
16 checks passed
blove added a commit that referenced this pull request May 16, 2026
…00% (#362)

* fix(chat): user-bubble word-wrap — give .chat-message__layout width:100%

Short user messages like "Show me the dashboard" wrap mid-phrase
("Show me the" / "dashboard"). Fixed three times before in #313, #325,
and c0b9e88, each by tweaking which element holds the 80% cap — none
addressed the architecture.

Root cause: user-role host is `display:flex; justify-content:flex-end`
with no width on .chat-message__layout. __main has max-width:80%, which
resolves against layout (its containing block). Layout in turn shrinks
to __main's content (flex item with auto basis). The browser breaks the
circular dependency by capping the bubble at its fit-content intrinsic
(~166px = the wrap-point width) instead of max-content (~200px = full
text on one line). Verified live: forced max-content = 199.75px,
fit-content = 166.20px, with old layoutW = 207.75px — the bug is exact.

Fix: layout gets width:100% so __main's 80% has a concrete (and full-
row) containing block. Host switches from flex to block; right-alignment
moves down to layout (`justify-content: flex-end` on the layout flex
container).

Verified via chrome MCP after fix: bubbleW = 199.75px (full max-content),
mainW = 199.75px, layoutW = 720px (full row), bubble renders single-line
right-aligned.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(chat): escape backticks in chat-message style comment (CI break)

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.

1 participant