Skip to content

Show a bot mention with the bot's face and colour - #518

Open
shubhook wants to merge 4 commits into
DuskBotAI:devfrom
shubhook:feat/bot-mention-icons-colors
Open

shubhook wants to merge 4 commits into
DuskBotAI:devfrom
shubhook:feat/bot-mention-icons-colors

Conversation

@shubhook

@shubhook shubhook commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #515

Before this change, @Name looked the same for every bot in the composer and in sent messages. Two bots with similar names, or a bot's name used in a sentence, were hard to tell apart.

With this change, a mention uses the face and identity colour the bot already has. The same data-bot-color / --identity-* tokens colour it, and each skin already tunes them for contrast.

  • In a sent message a mention is a chip: the bot's 16px face and name in its colour. Clicking or tapping the chip opens that bot's chat. The chip has no fill until hover or keyboard focus. On a coloured bubble it keeps the bubble's text colour. Copying the message still gives @Name.
  • In the composer the bot's face is drawn over the @, and the name is in the bot's colour. The textarea is unchanged. The face sits in the mirror layer behind it, over the unseen @ glyph, so the caret and selection stay exactly on the text.

Screenshots

Desktop, composer (2x):

composer

Desktop, sent message, and on hover over Redline (2x):

sent
sent, hover

Mobile, 390x844 (3x). The composer wraps so two faces start a line. Sent message:

Limitations of the composer face

The composer is a transparent <textarea> over a mirror div that must keep the same glyph widths. A 16px face is wider than the @ it covers, so:

  • A caret placed just before a mention overlaps the left edge of the face.
  • The face reaches about 4px into the space before it. After a word with no space (say@Juniper) it touches that word.
  • At the start of a line the face goes past the text's left edge. The mirror now paints 4px past each side of the field so it isn't cut off.
  • In forced-colours mode the face is hidden and the plain @Name shows.

The proper fix, for discussion

A contenteditable editor (Lexical, Tiptap/ProseMirror, or our own) could make a mention an atomic inline node. It would be a real chip in the field: Backspace removes it whole, it has its own width, and it never overlaps the caret.

  • What we'd gain: composer chips that match sent messages, no overlap limitations, and a base for other inline tokens (thread refs, files, slash commands).
  • What it costs: replacing the textarea that the composer is built around. Today that covers IME composition, the send-key handling, draft restore, paste, mobile keyboards (iOS and Android WebView text zoom), RTL, autocorrect, spellcheck, undo, and the existing composer tests. contenteditable behaves differently across WebKit, Chromium and Android WebView in exactly these areas, and the dependency adds bundle size.
  • The value: low today. The overlay covers the main need, telling bots apart while typing, at about 30 lines.

I think this is worth discussing before anyone starts it.

Commits

Each commit passes lint and tests on its own:

  1. Colour a bot mention with that bot's identity colour
  2. Show a bot mention in a message as a chip that opens the bot
  3. Draw a bot's face over the @ of its mention in the composer
  4. Space a sent mention chip like the words around it

Verification

  • pnpm typecheck, pnpm lint, and vitest over src/components and src/lib (972 files, 8730 tests) pass.
  • In an isolated fixture (control-dusk ui launch) with three bots (hoot, boo and mochi bodies; blue, red and purple), I checked at desktop 1280x800 and mobile 390x844:
    • the composer face over @, including at the start of a wrapped line
    • the sent chips, with no fill and then hover
    • that clicking or tapping a chip opens that bot's chat
    • that the page doesn't scroll sideways on mobile

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.
A sent mention shows the bot's face and name in its colour, and a click
opens that bot's chat. The chip has no fill until hover or keyboard focus.
The composer's mirror keeps plain coloured text, since its glyphs must stay
under the field's caret.
The face covers the unseen @ glyph, so the field's caret keeps its place.
The mirror paints 4px past each side of the field, so a face at the start
of a line is not cut off.
The chip's padding only gives the hover fill room, so matching negative
margins keep the gap before and after the name the width of a space.
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.

1 participant