Skip to content

feat: Add @mention support for rich text editors - #932

Merged
aXenDeveloper merged 1 commit into
canaryfrom
claude/epic-turing-3m2ipu
Nov 23, 2026
Merged

aXenDeveloper merged 1 commit into
canaryfrom
claude/epic-turing-3m2ipu

Conversation

@aXenDeveloper

Copy link
Copy Markdown
Owner

Description

What?

Implements a complete mentions system allowing members to @mention each other in rich-text editors across the platform. When a member is mentioned in public content they can read, they receive a notification. The feature includes:

  • TipTap mention node and popup: New @mention node with autocomplete suggestions, integrated into all rich-text editors
  • Database schema: core_mentions table to track mentions with proper indexing and foreign keys
  • Mention syncing: syncMentions() function that mirrors stored mentions to current text, handling adds/removes and notifications
  • Role-based controls: Per-role settings for allowMentions and maxMentionsPerItem (default 25, configurable in role settings)
  • Notification system: Members notified once when mentioned in public, readable content; edits only notify newly added members
  • API endpoints:
    • GET /users/mentions - suggestions for the editor popup
    • GET /users/mentioned - resolve current names for stored mention IDs
  • Content Engine integration: Automatic mention target creation for all rich-text fields with mentions enabled (default)
  • Plugin support: defineMentionTarget() allows plugins to use mentions on their own tables
  • UI components: Mention rendering with user preview cards, mention suggestion list with keyboard navigation

Why?

Mentions are a core social feature enabling direct engagement between members. This implementation:

  • Provides a consistent mention experience across all editors (comments, forum posts, blog articles, etc.)
  • Ensures members are only notified when they can actually read the content
  • Respects role-based mention limits to prevent spam
  • Integrates seamlessly with existing notification and access control systems
  • Allows plugins to extend mentions to custom content types

Implementation Notes

  • Mentions are on by default for all rich-text fields; can be disabled per-field with mentions: false
  • The actor (author) is determined from the record's author field or public write owner, so moderator edits notify as the author
  • Retraction recounts groups: Removing a mention detaches its notification event, so grouped notifications like "Anna and 1 other" drop back to just "Anna"
  • One unified hook (emitContentEvent) queues mentions for all write paths (create, update, publish, etc.)
  • No server-side name resolution: Browsers batch-fetch current names via GET /users/mentioned to handle renames
  • Suggestions exclude the typing member and use prefix-ranked ILIKE search

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T21:21:30.215649Z 244ec21 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

React Doctor found 3 new issues in 2 files · 3 warnings · score 77 / 100 (Needs work) · 0 fixed · vs canary

3 warnings

scripts/prepare-database.ts

  • ⚠️ L73 await inside a loop async-await-in-loop
  • ⚠️ L944 await inside a loop async-await-in-loop

src/lib/mentions/sync.ts

  • ⚠️ L199 await inside a loop async-await-in-loop

Reviewed by React Doctor for commit 244ec21. See inline comments for fixes.

@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: dd61760c31

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

Comment on lines +34 to +39
"translation_created",
"translation_published",
"translation_restored",
"translation_updated",
"unhidden",
"updated",

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 Sync mentions for restores and translation removals

Restoring a revision or deleting/unpublishing a translation does not queue a mention sync because SYNCING_ACTIONS omits restored, translation_deleted, and translation_unpublished. These actions are emitted by editorial-effects.ts and translation-effects.ts without an accompanying updated event. Consequently, restored text never notifies newly mentioned members, and mentions removed by these operations retain their notifications until another qualifying edit occurs. Include these text-changing actions in the synchronization lifecycle.

Useful? React with 👍 / 👎.

Comment on lines +155 to +158
row =>
!("publishedAt" in row) ||
(row.publishedAt !== null &&
new Date(row.publishedAt as Date | string) <= new Date()),

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 Check translation status before collecting mentions

When a previously published translation is unpublished, translation-model.ts deliberately preserves publishedAt and changes only status to draft. This filter therefore still includes that translation. Editing its draft text subsequently emits translation_updated and can notify members mentioned only in unpublished content, since the target access hook checks the base record rather than the translation. Use the translation's public-visibility predicate, including its status, instead of testing only its publication timestamp.

Useful? React with 👍 / 👎.

Comment on lines +42 to +44
<UserPreview className="mention" nameCode={nameCode}>
@{name}
</UserPreview>

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 Preserve mention attributes on rendered profile links

When someone copies a mention from a rendered post into an editor, this UserPreview renders a profile link without data-type="mention", data-id, or the snapshot attributes. The new editor parser explicitly recognizes a[data-type="mention"], so the normal React-rendered post cannot round-trip a copied mention: it becomes an ordinary link and no longer participates in mention extraction or notifications. Preserve the mention attributes on the rendered trigger, as the HTML serializer already does.

Useful? React with 👍 / 👎.

Comment on lines +178 to +180
<p className="text-muted-foreground leading-relaxed text-pretty">
{forbidden ? t("forbidden") : t("load_error")}
</p>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use the required Empty view for suggestion failures

When the initial suggestions request fails, this popup renders a bare paragraph rather than the required Empty error surface. Root AGENTS.md explicitly applies that requirement to popover lists with no query data; the current branch also omits the prescribed title/description structure and identifying icon. Render the failure through Empty with role="alert", retaining the existing in-place retry and its omission for a 403.

AGENTS.md reference: AGENTS.md:L53-L53

Useful? React with 👍 / 👎.

@aXenDeveloper aXenDeveloper changed the title Add @mention support for rich text editors feat: Add @mention support for rich text editors Nov 23, 2026
@github-actions github-actions Bot added the 💡 Feature A new feature label Nov 23, 2026
@aXenDeveloper
aXenDeveloper force-pushed the claude/epic-turing-3m2ipu branch from dd61760 to 1566dad Compare November 23, 2026 19:02

@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: 1566dad547

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

Comment on lines +122 to +126
const outcome = await c.get("db").transaction(async tx => {
// Two saves of one target must not both see a member as new.
await tx.execute(
sql`select pg_advisory_xact_lock(hashtext(${`mentions:${pluginId}:${targetType}:${targetId}`}))`,
);

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 Serialize the content snapshot with the mention update

When two edits of the same record are processed concurrently, this lock serializes mention writes but not the text they reflect: processContentMentions reads the record and translations before calling syncMentions. An older task can read the previous text, pause during its subsequent lookups, and acquire this lock after a newer task has synced the latest edit. It then reinstates removed mentions, potentially sends notifications for them, and retracts mentions that remain in the current text. The queue supports concurrent processing, and both tasks finish successfully, so retries will not repair the final state. Read the current text under the same per-target lock, or reject stale snapshots using a record version.

Useful? React with 👍 / 👎.

@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: 41d1acb6ad

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

);
}

if (suggestions.isError && items.length === 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Show a warning when cached mention suggestions fail to refresh

When a suggestions query already has cached members and its background refetch fails, items remains nonempty, so this condition skips error feedback and renders the stale list without a warning or retry. Root AGENTS.md explicitly requires failed background refetches to retain their content and display an Alert variant="warning" with an in-place retry above it. Add that separate error state while keeping the existing suggestions visible.

AGENTS.md reference: AGENTS.md:L81-L81

Useful? React with 👍 / 👎.

…tions

- @mentions in the rich-text editor, enabled by default, delivered right away
- Mention notifications, new notification toasts and a mark-all-read confirmation dialog
- Simplified notification fanout/inbox processing and type handling
- Mentions implementation plan and docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aXenDeveloper
aXenDeveloper force-pushed the claude/epic-turing-3m2ipu branch from 2d11ca4 to 244ec21 Compare November 23, 2026 21:18
const row = rowOf.get(userId);
if (!row) continue;

const { eventId } = await c.get("notifications").publish({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

React Doctor · react-doctor/async-await-in-loop (warning)

This for…of loop waits before starting the next iteration. If iterations perform independent asynchronous work, consider bounded concurrency; await syntax alone does not establish a speedup.

Fix → Consider concurrent calls only for independent asynchronous work. Shared queues or synchronous work may not benefit. Preserve resource limits, transaction ordering, and failure/cancellation semantics; observe all callback promises.

Docs

@aXenDeveloper
aXenDeveloper merged commit ad384e1 into canary Nov 23, 2026
7 checks passed
@aXenDeveloper
aXenDeveloper deleted the claude/epic-turing-3m2ipu branch November 23, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💡 Feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant