Skip to content

[SE-641] @ mention users in documents - #26018

Open
ihordubas99 wants to merge 7 commits into
feature/se-641-mention-users-in-documents-backend-part-2from
feature/se-641-mention-users-extension
Open

ihordubas99 wants to merge 7 commits into
feature/se-641-mention-users-in-documents-backend-part-2from
feature/se-641-mention-users-extension

Conversation

@ihordubas99

@ihordubas99 ihordubas99 commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Ticket

https://community.openproject.org/wp/SE-641

Moved from opf/op-blocknote-extensions#274, where the earlier review discussion lives. The OpenProject side is a separate PR, #25917. The notification endpoint this calls comes from #26028.

What are you trying to accomplish?

Users can mention people in a document. Typing @ opens a menu with the members of the document's project who are not locked. Picking someone inserts an inline mention with their avatar and name, linking to their profile, and notifies that person.

The mention is stored in the document markdown in exactly the form CKEditor uses, so OpenProject renders it as a user link with a hover card without special cases.

Inside the editor a mention behaves like an inline work package. Clicking it selects it and opens a popover to open the profile or remove the mention. A selected mention can be removed with Backspace and moved with drag and drop.

Screenshots

image image image

What approach did you choose and why?

Stored format. BlockNote's markdown export keeps only the text of elements it does not know, so a real <mention> element would be saved as a plain "@name" and lose its id. Text nodes are copied verbatim, so the server-side spec writes the canonical tag as text. A markdown test pins the exact output in case BlockNote ever starts escaping text. In the browser the clipboard gets a real <mention> element, and a mention copied from a CKEditor field pastes as a mention.

Notifications. Hocuspocus saves the changes of everyone editing with the token of the first user who connected, so OpenProject can't tell from a save who added a mention. Instead, the editor calls POST /api/v3/notifications when a mention is inserted, and the author is the user whose session makes the request. initializeOpBlockNoteExtensions takes the documentId for this, and UserMentionNotificationExtension sends one request per mentioned user whenever mentions are picked, pasted or duplicated locally. Moving a mention or its block and changes arriving from collaborators through Yjs don't notify. Cut and paste counts as a new insert.

Search. The menu asks /api/v3/principals for users who are not locked and are members of the document's project, matching name, login or email. Like CKEditor, it only opens where a word starts, so typing an email address does not open it.

Shared building blocks. A mention needs what the inline work package already had, such as the options popover, node selection, closing on an outside press and a suggestion menu. Instead of copying these, they moved into lib/components/shared and a few generic hooks, and the work package code now uses them too. That is why the diff touches many work package files. The first three commits are this refactoring without behaviour changes and can be reviewed on their own.

Two small fixes come with the refactoring. Clicking an open inline work package again now closes its popover inside a shadow root instead of reopening it, and a blank # search cancels a pending search again.

Public API. Only additions. The client gets openProjectUserMentionSpec, OpenProjectMentionMenu, UserMentionNotificationExtension, the trigger constants and the optional documentId in initializeOpBlockNoteExtensions. The extension has to be passed in the editor's extensions, because BlockNote doesn't register extensions of inline content specs. The server entry gets openProjectUserMentionStaticSpec and the stored-format helpers for hocuspocus.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@ihordubas99 ihordubas99 self-assigned this Oct 14, 2026
@ihordubas99
ihordubas99 requested a balanced review from Copilot October 14, 2026 12:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ihordubas99 ihordubas99 changed the title Feature/se 641 mention users extension [SE-641] @ mention users in documents Oct 14, 2026
@ihordubas99
ihordubas99 marked this pull request as ready for review October 14, 2026 12:49
@ihordubas99
ihordubas99 force-pushed the feature/se-641-mention-users-extension branch 2 times, most recently from 8e3a317 to 5d12057 Compare October 16, 2026 09:31
@ihordubas99 ihordubas99 mentioned this pull request Oct 16, 2026
1 of 3 tasks
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/bim/spec/features/viewer/create_viewpoint_spec.rb[1:1:1:1]
  • rspec ./spec/features/work_packages/cancel_editing_spec.rb[1:5]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #26018, linked for reference only):

- `rspec ./modules/bim/spec/features/viewer/create_viewpoint_spec.rb[1:1:1:1]`
- `rspec ./spec/features/work_packages/cancel_editing_spec.rb[1:5]`

Treat this as a standalone task, unrelated to PR #26018. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #26018 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @ihordubas99 to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @ihordubas99, and request a review from @ihordubas99.
On every commit, set @ihordubas99 as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@ihordubas99
ihordubas99 force-pushed the feature/se-641-mention-users-extension branch from 5d12057 to 9e836eb Compare October 16, 2026 11:01
@ihordubas99
ihordubas99 changed the base branch from dev to feature/se-641-mention-users-in-documents-backend-part-2 October 16, 2026 11:02
@ihordubas99
ihordubas99 added this pull request to stack #26090 October 16, 2026 11:03
@ihordubas99
ihordubas99 force-pushed the feature/se-641-mention-users-extension branch from 9e836eb to 9b05cf9 Compare October 23, 2026 13:32
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./spec/features/work_packages/table/delete_work_packages_with_descendants_spec.rb[1:2:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #26018, linked for reference only):

- `rspec ./spec/features/work_packages/table/delete_work_packages_with_descendants_spec.rb[1:2:1]`

Treat this as a standalone task, unrelated to PR #26018. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #26018 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @ihordubas99 to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @ihordubas99, and request a review from @ihordubas99.
On every commit, set @ihordubas99 as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@ihordubas99
ihordubas99 force-pushed the feature/se-641-mention-users-extension branch from 9b05cf9 to c6b8d88 Compare October 27, 2026 12:46
@ihordubas99
ihordubas99 force-pushed the feature/se-641-mention-users-extension branch from c6b8d88 to 78490d4 Compare October 27, 2026 13:44

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants