Skip to content

bubble: Add BubbleVariant::text_view_style for readable rich text - #3329

Open
Bombatomica64 wants to merge 1 commit into
longbridge:mainfrom
Bombatomica64:fix/bubble-textview-color
Open

Bombatomica64 wants to merge 1 commit into
longbridge:mainfrom
Bombatomica64:fix/bubble-textview-color

Conversation

@Bombatomica64

@Bombatomica64 Bombatomica64 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3326

Description

TextView paints its own text color on its root, so it does not inherit the color a Bubble sets on its content. In a Filled bubble, Markdown is drawn in the theme foreground on the primary surface: white on white in dark mode. Links (primary) disappear too, and code backgrounds (accent/muted) are tuned for the page, not for a primary surface.

Changing TextView to inherit the parent color would affect every TextView in the library, so this PR takes the smaller, additive route: BubbleVariant::text_view_style(cx) returns a TextViewStyle that matches the bubble.

  • The text color is the variant's own text color, e.g. primary_foreground for Filled and destructive for Destructive.
  • For Filled, links use the text color (they stay underlined), and code/inline-code backgrounds are the text color at 12% opacity, so they read on the primary surface.
  • The per-variant text color now lives in one private BubbleVariant::text_color, used by both BubbleContent and the new method, so they cannot drift apart. The rendered colors of every variant are unchanged.

If you'd prefer TextView to inherit the surrounding text color instead, or BubbleContent to apply this automatically, I'm happy to rework it.

Screenshot

Screen recordings on Android (Redroid, dark theme) of opening a screen with Markdown in a Filled bubble, Kit 0.7.0 with and without this diff.

Before

pr3329-before.mp4

After

pr3329-after.mp4

Before: the text and link are white on the white bubble; only the inline code chip shows. After: dark text, an underlined link, and a tinted code chip. (Filled renders at regular weight in both because of an unrelated Android variable-font issue.)
Builds: demo-pr3329.

Public API

  • gpui_component::bubble::BubbleVariant::text_view_style(self, cx: &App) -> gpui_base::TextViewStyle: a TextViewStyle whose text, link and code colors match this bubble variant's surface, for rich text inside a bubble.

How to Test

  • cargo test -p gpui-component --features test-support --lib: 579 passed. The new text_view_style_matches_the_bubble_surface checks, in the dark theme, that Filled uses primary_foreground for text and links with a code background distinct from primary, that Outline keeps foreground and the theme link color, and that Destructive uses destructive.

  • cargo doc -p gpui-component --no-deps reports nothing for bubble.rs. The existing warnings are in other files.

  • Usage:

    Bubble::new().with_variant(BubbleVariant::Filled).child(
        TextView::markdown("reply", text).style(BubbleVariant::Filled.text_view_style(cx)),
    )

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes. (Not run: no desktop session here; see How to Test.)
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific) (not platform-specific)

Thanks for taking the time to review this.

🤖 Generated with Claude Code

TextView paints its own text color, so a TextView inside a Filled bubble
drew the theme foreground on the primary surface (white on white in dark
mode), with primary links and accent code backgrounds equally hidden.

BubbleVariant::text_view_style returns a TextViewStyle whose text color
matches the bubble; for Filled it also derives link and code colors from
the text color. The per-variant text color now lives in one place and is
used by both the bubble surface and the style.

Closes longbridge#3326

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 30, 2026 07:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Bombatomica64

Bombatomica64 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

I've added before/after screen recordings to the Screenshot section (Android, dark theme, Kit 0.7.0 with and without this diff).

Before

pr3329-before.mp4

After

pr3329-after.mp4

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.

Bubble: TextView inside a Filled bubble ignores the bubble text color (white on white in dark mode)

3 participants