From 4e06b7f1f53b426fa590c6a452478ebc24d6a544 Mon Sep 17 00:00:00 2001 From: roboomp Date: Wed, 29 Jul 2026 10:16:03 +0000 Subject: [PATCH] fix(tui): prevented UUID prefixes rendering color swatches Excluded canonical hash-prefixed UUIDs from prose hex-color matching while preserving standalone 8-digit CSS colors. Fixes #7002 (cherry picked from commit b423fe6e51bb1d45b88916f885f1b81e1ce54ff0) --- packages/tui/CHANGELOG.md | 4 ++++ packages/tui/src/components/markdown.ts | 11 ++++++----- packages/tui/test/markdown.test.ts | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/packages/tui/CHANGELOG.md b/packages/tui/CHANGELOG.md index a8d45c1af..64648878e 100644 --- a/packages/tui/CHANGELOG.md +++ b/packages/tui/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fixed hash-prefixed UUIDs in prose being misclassified as 8-digit CSS colors and receiving spurious swatches ([#7002](https://github.com/can1357/oh-my-pi/issues/7002)). + ## [17.1.8] - 2026-07-28 ### Fixed diff --git a/packages/tui/src/components/markdown.ts b/packages/tui/src/components/markdown.ts index cd11dc778..74762014f 100644 --- a/packages/tui/src/components/markdown.ts +++ b/packages/tui/src/components/markdown.ts @@ -1284,11 +1284,12 @@ function collapseInlineHtml(tokens: Token[]): Token[] { const DEFAULT_COLOR_SWATCH_GLYPH = "■"; // `#` + 3-8 hex digits, not glued to a surrounding word/`#`/`&` (avoids HTML -// entities like ☃ and paths like foo#fff) and not trailed by more hex -// (so over-long runs never produce a misleading swatch). Length/letter rules -// are enforced in classifyHexColor since the alternation can't express "exactly -// 3, 6, or 8". -const HEX_COLOR_REGEX = /(? { expect(code.includes("■")).toBe(false); }); + it("does not swatch hash-prefixed UUIDs in prose", () => { + const uuid = new Markdown( + "Use feedback ID #6635765d-4a44-4a5e-a536-a8b72b0395b5 for testing.", + 0, + 0, + defaultMarkdownTheme, + ) + .render(80) + .join(""); + expect(uuid.includes("■")).toBe(false); + + const color = new Markdown("Use color #6635765d.", 0, 0, defaultMarkdownTheme).render(80).join(""); + expect(color.includes(swatchFor("6635765d"))).toBeTruthy(); + }); + it("uses the theme's colorSwatch symbol when provided", () => { const themed = { ...defaultMarkdownTheme, symbols: { ...defaultMarkdownTheme.symbols, colorSwatch: "▢" } }; const out = new Markdown("Accent #C5FFD6.", 0, 0, themed).render(80).join("\n");