Skip to content

feat(web): render inline hex color swatches in chat messages - #6099

Open
pranav100000 wants to merge 2 commits into
pingdotgg:mainfrom
pranav100000:feat/hex-swatches-5815
Open

feat(web): render inline hex color swatches in chat messages#6099
pranav100000 wants to merge 2 commits into
pingdotgg:mainfrom
pranav100000:feat/hex-swatches-5815

Conversation

@pranav100000

@pranav100000 pranav100000 commented Aug 11, 2026

Copy link
Copy Markdown

When an assistant message contains a hex color literal (e.g. #FF5733), render a small color-swatch chip beside it. New HexColorInlineText component wired into ChatMarkdown; hex inside code spans/blocks is left untouched; supports 3/6/8-digit hex. Tests included (29 passing).

Closes #5815.

Note

Render inline hex color swatches next to hex literals in chat messages

  • Adds HexColorSwatch and HexColorInlineText components in HexColorInlineText.tsx to detect standalone #RRGGBB and #RRGGBBAA literals in plain text and render a small decorative color swatch inline.
  • Updates ChatMarkdown.tsx to also render swatches when a hex literal appears inside an inline code span.
  • Updates SkillInlineText.tsx to wrap plain text segments with HexColorInlineText, so skill chip text also gets swatch decoration.
  • Issue-like shorthand (e.g. #123) and embedded tokens are intentionally excluded via boundary checks in HEX_COLOR_TOKEN_REGEX.
  • Swatches are marked aria-hidden and do not affect the accessibility tree or copied text.

Macroscope summarized 59609db.


Note

Low Risk
Presentation-only chat markdown changes with conservative hex matching and no auth or data handling impact.

Overview
Chat messages now show a small color swatch next to full-form hex literals (#RRGGBB / #RRGGBBAA) while leaving the text unchanged.

A new HexColorInlineText helper scans plain text and attaches HexColorSwatch (decorative, aria-hidden). It is wired through SkillInlineText for paragraphs, lists, and skill-adjacent runs, and through ChatMarkdown for inline code when the span is only a hex literal. Shorthand hex and issue-like #5815 / #123 are not matched so GitHub-style references stay plain.

Tests cover parsing edge cases, markdown/skill integration, and timeline rendering for prose vs inline code.

Reviewed by Cursor Bugbot for commit 59609db. Bugbot is set up for automated code reviews on this repo. Configure here.

…gg#5815)

Chat prose and inline code spans that name a hex color now show a small
swatch beside the literal, so reading a color no longer means leaving the
thread.

Prose runs through the existing SkillInlineText walker, which ChatMarkdown
already applies to `p`/`li` and which skips `code` and `a` subtrees; inline
code is handled in ChatMarkdown's `code` renderer. Only the full #RRGGBB and
#RRGGBBAA forms match — shorthand #RGB is indistinguishable from an issue
reference like pingdotgg#123. The swatch is decorative: aria-hidden keeps it out of
the accessibility tree and out of copied markdown.
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: def8774b-4467-4ce6-a2fb-bb5586d593b2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 11, 2026
@pranav100000
pranav100000 marked this pull request as ready for review August 11, 2026 07:53

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 77a0d1d. Configure here.

Comment thread apps/web/src/components/ChatMarkdown.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

return <p {...props}>{renderSkillInlineMarkdownChildren(children, skills)}</p>;

P2 Badge Decorate hex literals outside paragraphs and list items

When a literal appears in a Markdown heading or GFM table cell, such as ## Accent #FF5733, react-markdown does not route that text through the custom p or li renderers, so the literal remains undecorated. Apply the transformation at the text/AST layer or add coverage for the other text-bearing Markdown elements so swatches work throughout a chat message.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

import remarkBreaks from "remark-breaks";
import remarkGfm from "remark-gfm";
import { remarkGithubAlerts } from "../markdown-github-alerts";
import { HexColorSwatch, parseHexColorLiteral } from "./chat/HexColorInlineText";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Render the swatches in the mobile chat client

When the same thread is opened on mobile, apps/mobile/src/features/threads/ThreadFeed.tsx:967-982 renders message text through SelectableMarkdownText or react-native-nitro-markdown, and neither renderer has equivalent hex decoration; this web-only integration therefore makes the feature disappear on mobile while web and desktop display it. Add equivalent mobile support, preferably by sharing the literal parsing rules.

AGENTS.md reference: AGENTS.md:L67-L70

Useful? React with 👍 / 👎.

@macroscopeapp

macroscopeapp Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces a new user-facing feature (inline color swatches for hex codes in chat), which warrants human review for new capability introductions. The implementation is well-tested and low-risk, but introduces visible UI changes.

You can customize Macroscope's approvability policy. Learn more.

The prose path already wraps a literal and its swatch in whitespace-nowrap;
the inline-code path appended the swatch as a bare sibling inside <code>, and
an atomic inline creates a soft wrap opportunity even with no whitespace, so a
narrow column could drop the swatch onto its own line.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 59609db85c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// The plain runs around skill chips are the same runs that carry hex colors.
if (cursor === 0) {
return <>{props.text}</>;
return <HexColorInlineText text={props.text} />;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply swatches to headings and table cells

Route all ordinary markdown text through the new decorator, not only text reached through SkillInlineText. ChatMarkdown calls renderSkillInlineMarkdownChildren only for paragraph and list-item renderers, so inputs such as ## Accent #FF5733 or a table cell containing #FF5733 bypass this component and render no swatch, even though the same literal in a paragraph works.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Render color swatches next to color literals in chat markdown

1 participant