Skip to content

feat(desktop): live @mention and #channel preview in message composer#149

Merged
wesbillman merged 2 commits intomainfrom
feat/composer-mention-preview
Mar 21, 2026
Merged

feat(desktop): live @mention and #channel preview in message composer#149
wesbillman merged 2 commits intomainfrom
feat/composer-mention-preview

Conversation

@baxen
Copy link
Collaborator

@baxen baxen commented Mar 21, 2026

Summary

Adds a transparent overlay to the message composer that renders @mention and #channel tokens with styled highlight pills as the user types.

Changes

  • ComposerMentionOverlay.tsx (new) — Parses composer text into segments (plain text, @mention, #channel) and renders mentions/channels with colored pill styling (bg-primary/15 text-primary).
  • MessageComposer.tsx — Wraps the textarea in a relative container with the overlay positioned behind it. The textarea text is made transparent (text-transparent) so the overlay's styled tokens show through, while the native caret, selection, scroll, and IME behavior are fully preserved.

How it works

  1. The textarea renders with text-transparent and caret-foreground so the cursor is visible but the raw text is not.
  2. An aria-hidden overlay sits behind the textarea and mirrors the content with highlighted pills for @ and # tokens.
  3. Scroll position is synced via an onScroll handler so the overlay stays aligned during multi-line input.

Testing

  • Verified visually that mentions and channels highlight in real time as you type.
  • Confirmed cursor, selection, paste, and IME input work normally.
  • All CI checks pass (fmt, clippy, unit tests, desktop build, tauri check).

@baxen baxen requested a review from wesbillman as a code owner March 21, 2026 00:54
Copy link

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

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: aa67c51cf5

ℹ️ 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".


type Segment = { type: "text" | "mention" | "channel"; value: string };

const MENTION_OR_CHANNEL_RE = /@\S+|#\w[\w-]*/g;

Choose a reason for hiding this comment

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

P2 Badge Match mention tokens that include spaced display names

useMentions.insertMention builds mentions as @${displayName} and displayName values commonly include spaces, but this regex uses @\S+, which stops at the first space. As a result, a mention like @Jane Doe is rendered as a partial pill (@Jane) plus plain text (Doe), so the new live preview is inconsistent with the actual mention semantics (extractMentionPubkeys still treats the full display name as one mention) and gives misleading feedback while composing.

Useful? React with 👍 / 👎.

baxen and others added 2 commits March 21, 2026 09:42
Adds a transparent overlay to the message composer that renders @mention
and #channel tokens with styled highlight pills as the user types.
The textarea text becomes transparent while the overlay shows the
formatted version, keeping native cursor, selection, and IME support.
@wesbillman wesbillman force-pushed the feat/composer-mention-preview branch from aa67c51 to c2f63a6 Compare March 21, 2026 16:45
@wesbillman wesbillman merged commit 3bdd867 into main Mar 21, 2026
12 of 13 checks passed
@wesbillman wesbillman deleted the feat/composer-mention-preview branch March 21, 2026 16:59
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.

2 participants