Repository navigation
feat: Add @mention support for rich text editors - #932
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
React Doctor found 3 new issues in 2 files · 3 warnings · score 77 / 100 (Needs work) · 0 fixed · vs 3 warnings
Reviewed by React Doctor for commit |
There was a problem hiding this comment.
💡 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".
| "translation_created", | ||
| "translation_published", | ||
| "translation_restored", | ||
| "translation_updated", | ||
| "unhidden", | ||
| "updated", |
There was a problem hiding this comment.
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 👍 / 👎.
| row => | ||
| !("publishedAt" in row) || | ||
| (row.publishedAt !== null && | ||
| new Date(row.publishedAt as Date | string) <= new Date()), |
There was a problem hiding this comment.
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 👍 / 👎.
| <UserPreview className="mention" nameCode={nameCode}> | ||
| @{name} | ||
| </UserPreview> |
There was a problem hiding this comment.
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 👍 / 👎.
| <p className="text-muted-foreground leading-relaxed text-pretty"> | ||
| {forbidden ? t("forbidden") : t("load_error")} | ||
| </p> |
There was a problem hiding this comment.
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 👍 / 👎.
dd61760 to
1566dad
Compare
There was a problem hiding this comment.
💡 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".
| 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}`}))`, | ||
| ); |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
💡 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) { |
There was a problem hiding this comment.
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>
2d11ca4 to
244ec21
Compare
| const row = rowOf.get(userId); | ||
| if (!row) continue; | ||
|
|
||
| const { eventId } = await c.get("notifications").publish({ |
There was a problem hiding this comment.
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.
Description
What?
Implements a complete mentions system allowing members to
@mentioneach 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:@mentionnode with autocomplete suggestions, integrated into all rich-text editorscore_mentionstable to track mentions with proper indexing and foreign keyssyncMentions()function that mirrors stored mentions to current text, handling adds/removes and notificationsallowMentionsandmaxMentionsPerItem(default 25, configurable in role settings)GET /users/mentions- suggestions for the editor popupGET /users/mentioned- resolve current names for stored mention IDsmentionsenabled (default)defineMentionTarget()allows plugins to use mentions on their own tablesWhy?
Mentions are a core social feature enabling direct engagement between members. This implementation:
Implementation Notes
mentions: falseemitContentEvent) queues mentions for all write paths (create, update, publish, etc.)GET /users/mentionedto handle renamesILIKEsearch