Skip to content

FIX Restore chat bubble contrast in light mode#1708

Merged
romanlutz merged 1 commit into
microsoft:mainfrom
romanlutz:fix/gui-light-mode-bubble-contrast
May 13, 2026
Merged

FIX Restore chat bubble contrast in light mode#1708
romanlutz merged 1 commit into
microsoft:mainfrom
romanlutz:fix/gui-light-mode-bubble-contrast

Conversation

@romanlutz
Copy link
Copy Markdown
Contributor

@romanlutz romanlutz commented May 10, 2026

Fixes finding documented in PyRIT-gui-findings/findings/usability-light-mode-contrast/.

Summary

Chat bubbles silently lost the user-bubble background override. Confirmed via getComputedStyle on a live page: both user and assistant bubbles rendered with the same colorNeutralBackground3 (rgb(245, 245, 245)). In light mode this also collapsed the visual distinction between the assistant bubble and the surrounding chat area, both of which sit at near-white luminance.

Two contributing causes:

  1. mergeClasses was missing. The bubble className was built by string concatenation:

    `${styles.messageContent} ${isUser ? styles.userMessageContent : ''}`

    With Griffel's atomic CSS, conflicting properties on two sibling classes are not deduped — the user override could not win. Switched both bubble class assignments to mergeClasses, the documented way to compose Griffel rule sets.

  2. Assistant bubble background too close to the chat area. The assistant bubble used colorNeutralBackground3, which sits ~5/255 luminance below colorNeutralBackground2 (the chat area). Below the 3:1 WCAG threshold for non-text UI components. Switched to colorNeutralBackground1 + a colorNeutralStroke2 border so it pops against the chat area in both themes. The user bubble keeps colorBrandBackground (now actually applied) plus a matching brand-stroke border for symmetry.

Tests

  • New regression test asserts the user and assistant bubble containers receive distinct className strings, and that the user bubble carries at least one style hook the assistant bubble doesn't. This guards against future re-introduction of the string-concat bug or accidental removal of the userMessageContent override.
  • Existing 44 MessageList tests continue to pass; lint and type-check are clean.

Verification

Reproduced on the fix branch by setting an active target, sending a prompt, and toggling light/dark mode. User bubble renders solidly in brand-blue with white text; assistant bubble renders cleanly with a subtle border, clearly distinct from the chat-area background in both themes.

Screenshots

before - light
before-light

after - light
after-light

after - dark
after-dark

The chat bubble styles silently lost the user-bubble background override:
both user and assistant bubbles ended up rendering with the same
colorNeutralBackground3 (rgb(245,245,245)), confirmed via
getComputedStyle on a live page. In light mode this also collapsed
the visual distinction between the assistant bubble and the surrounding
chat area, both of which sit at near-white luminance.

Two contributing causes:

1. The bubble className was built by string concatenation:
       `${styles.messageContent} ${isUser ? styles.userMessageContent : ''}`
   With Griffel's atomic CSS, conflicting properties on two sibling
   classes are not deduped — the user-bubble override could not win.
   Switched both bubble class assignments to mergeClasses, which is
   the documented way to compose Griffel rule sets safely.

2. The assistant bubble used colorNeutralBackground3, which sits ~5/255
   luminance below colorNeutralBackground2 (the chat area). Below the
   3:1 WCAG threshold for non-text UI components. Switched the
   assistant bubble to colorNeutralBackground1 + a colorNeutralStroke2
   border so it pops against the chat area in both themes.

   For the user bubble, switched to colorBrandBackground2 (the lighter
   brand tint, same token used by activeRow in TargetTable) instead of
   the deep colorBrandBackground. The bubble's footer text uses
   colorNeutralForeground3 which is unreadable on a deep brand
   background; the lighter tint preserves contrast for both the
   message body and the dim timestamp/role labels without needing
   per-element color overrides.

Tests:

- Added a regression test asserting the user and assistant bubble
  containers receive distinct className strings, and that the user
  bubble carries at least one style hook the assistant bubble doesn't.
  This guards against future re-introduction of the string-concat bug
  or accidental removal of the userMessageContent override.
- Existing 44 MessageList tests continue to pass; lint and type-check
  are clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@romanlutz romanlutz force-pushed the fix/gui-light-mode-bubble-contrast branch from acc1748 to 2f4849c Compare May 10, 2026 23:16
@romanlutz romanlutz added this pull request to the merge queue May 13, 2026
Merged via the queue into microsoft:main with commit 875bf71 May 13, 2026
48 checks passed
@romanlutz romanlutz deleted the fix/gui-light-mode-bubble-contrast branch May 13, 2026 00:57
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