From 0280031ac01322c281982dca5888952ddea7b8ff Mon Sep 17 00:00:00 2001 From: shubhook Date: Fri, 4 Dec 2026 16:14:53 +0530 Subject: [PATCH 1/4] Colour a bot mention with that bot's identity colour Mention ranges carry the bot peer instead of a resolved hex value, and the span takes the bot-identity class with data-bot-color, so each skin's tuned identity ink colours it and a coloured bubble keeps its own text colour. --- src/components/ChatMarkdown.test.ts | 4 ++-- src/components/MentionColors.test.ts | 6 +++--- src/components/MentionText.test.ts | 5 ++--- src/components/MentionText.tsx | 4 +--- src/components/MentionTextarea.test.ts | 2 +- src/components/ThreadRefs.test.ts | 3 +-- src/lib/mentions.test.ts | 2 +- src/lib/mentions.ts | 26 +++++++++++++++++--------- src/styles.css | 3 --- 9 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/components/ChatMarkdown.test.ts b/src/components/ChatMarkdown.test.ts index 79ad1b6a4e..412529772c 100644 --- a/src/components/ChatMarkdown.test.ts +++ b/src/components/ChatMarkdown.test.ts @@ -77,8 +77,8 @@ describe("mention highlighting", () => { text: "@Atlas @Juniper @everyone", everyone: true, mentionPeers: [{ name: "Atlas", color: "blue" }, { name: "Juniper", color: "red" }], })); - expect(html).toContain('style="--mention-color:#286ef9">@Atlas'); - expect(html).toContain('style="--mention-color:#ef3a3f">@Juniper'); + expect(html).toContain('@Atlas'); + expect(html).toContain('@Juniper'); expect(html).toContain('@everyone'); }); it("highlights known mentions in prose, lists and tables", () => { diff --git a/src/components/MentionColors.test.ts b/src/components/MentionColors.test.ts index f087354864..e80cbe9440 100644 --- a/src/components/MentionColors.test.ts +++ b/src/components/MentionColors.test.ts @@ -1,7 +1,7 @@ import { createElement } from "react"; import { renderToStaticMarkup } from "react-dom/server"; import { expect, it } from "vitest"; -import { MAUS_COLORS, MAUS_COLOR_NAMES } from "@/lib/mascot"; +import { MAUS_COLOR_NAMES } from "@/lib/mascot"; import { MentionText } from "./MentionText"; import { ChatMarkdown } from "./ChatMarkdown"; @@ -13,10 +13,10 @@ it.each(["plain text", "Markdown"] as const)("keeps all ten bot colors independe const html = renderToStaticMarkup(renderer === "plain text" ? createElement(MentionText, { text, peers: roster, everyone: true }) : createElement(ChatMarkdown, { text, mentionPeers: roster, everyone: true })); - const highlights = [...html.matchAll(/([^<]+)<\/span>/g)] + const highlights = [...html.matchAll(/([^<]+)<\/span>/g)] .map(([, color, name]) => ({ name, color })); expect(highlights).toEqual(ordered.flatMap(({ name, color }) => [ - { name: `@${name}`, color: MAUS_COLORS[color] }, + { name: `@${name}`, color }, { name: "@everyone", color: undefined }, ])); expect(html.match(/<\/span> ordinary /g)).toHaveLength(ordered.length); diff --git a/src/components/MentionText.test.ts b/src/components/MentionText.test.ts index 870c7a13e6..8f7b110e02 100644 --- a/src/components/MentionText.test.ts +++ b/src/components/MentionText.test.ts @@ -2,7 +2,6 @@ import { createElement } from "react"; import { renderToStaticMarkup } from "react-dom/server"; import { expect, it } from "vitest"; import { MentionText } from "./MentionText"; -import { MAUS_COLORS } from "@/lib/mascot"; it("uses each bot's avatar palette and updates when its color changes", () => { for (const color of ["red", "blue"] as const) { @@ -10,8 +9,8 @@ it("uses each bot's avatar palette and updates when its color changes", () => { text: "@Atlas @Juniper @everyone", everyone: true, peers: [{ name: "Atlas", color }, { name: "Juniper", color: "purple" }], })); - expect(html).toContain(`style="--mention-color:${MAUS_COLORS[color]}">@Atlas`); - expect(html).toContain(`style="--mention-color:${MAUS_COLORS.purple}">@Juniper`); + expect(html).toContain(`@Atlas`); + expect(html).toContain('@Juniper'); expect(html).toContain('@everyone'); } }); diff --git a/src/components/MentionText.tsx b/src/components/MentionText.tsx index 2aa7b90494..69af4caea7 100644 --- a/src/components/MentionText.tsx +++ b/src/components/MentionText.tsx @@ -1,7 +1,6 @@ import { Fragment, type CSSProperties, type ReactNode } from "react"; import { mentionClassName, mentionRanges, type MentionPeer, type MentionPerson } from "@/lib/mentions"; import { linkRanges } from "@/lib/link-ranges"; - /** * `links` marks web addresses as link pills: "highlight" paints them only (the composer's mirror, which sits under the * real field and must never change the text's layout), "open" makes each one a link that opens outside the app. @@ -35,8 +34,7 @@ export function MentionText({ text, peers, everyone = false, person, links, hove : {value}; } else { - const style = range.color ? { "--mention-color": range.color } as CSSProperties : undefined; - node = {value}; + node = {value}; } return {prefix}{node}; }); diff --git a/src/components/MentionTextarea.test.ts b/src/components/MentionTextarea.test.ts index cadf7d4741..8b0e5a01cd 100644 --- a/src/components/MentionTextarea.test.ts +++ b/src/components/MentionTextarea.test.ts @@ -11,5 +11,5 @@ it.each(["auto", "rtl", "ltr"])("shares the %s direction between the native inpu })); expect(html).toContain(`