You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug 2085052 - For @mentions in comments, allow autocompletion when typing @ like github does - #2810
Typing @ and two or more characters in a comment box on an existing bug lists accounts whose nickname matches; picking one inserts "@nick ". Reuses /rest/user/suggest (an @-prefixed match is nickname-only). Lives in the Needinfo extension and is loaded only where a mention takes effect (mentions enabled, logged in, editbugs on the product).
…ping @ like github does
Typing @ and two or more characters in a comment box on an existing bug lists accounts whose nickname matches; picking one
inserts "@nick ". Reuses /rest/user/suggest (an @-prefixed match is nickname-only). Lives in the Needinfo extension and is loaded only where a mention takes effect (mentions enabled, logged in, editbugs on the product).
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Autocomplete can suppress valid mentions because it scans fenced-block backticks and can swallow Enter or Tab after selection changes invalidate the active mention.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Nickname uniqueness is inferred from a response capped at 25 accounts, so an ambiguous @mention can be offered even though saving it notifies neither account.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Autocomplete can offer nicknames that are ambiguous across all accounts
user/suggest limits its response to 25 accounts (Bugzilla/API/V1/UserObject.pm::suggest), so counting only those results cannot establish that a nickname is unique. If one enabled account named alice is returned but another falls outside that limit, this offers @alice even though _users_for_mentions rejects it as ambiguous and saving notifies neither account. Check uniqueness against all enabled accounts server-side, or return server-computed ambiguity information with each suggestion.
Nickname uniqueness is inferred from a response capped at 25 accounts, so an ambiguous @mention can be offered even though saving it notifies neither account.
Production has no duplicate nicknames today. I checked with the column's own collation (utf8mb4_unicode_520_ci), counting disabled accounts too. _generate_nickname refuses any nickname another account already holds, so the 25-account cap only matters if a duplicate exists, and none do. A UNIQUE index to enforce this in the schema will be handled in bug 2089200. Leaving this as is.
The reason will be displayed to describe this comment to others. Learn more.
On a restricted bug, will this suggest users who can't see it? _mentioned_users silently drops them on save, so the commenter could think they pinged someone when they didn't. Would it be worth passing the bug id so the server can filter with can_see_bug, or is the comment preview considered enough of a safety net here?
The reason will be displayed to describe this comment to others. Learn more.
Does the (?![\s\S]*\n[ \t]*\n) lookahead rescan to the end of before for every blank line, making this quadratic on long comments with many paragraphs (e.g. a pasted log)? Since it runs on every keystroke while typing a mention, would something like [...before.matchAll(/\n[ \t]*\n/g)].at(-1)?.index ?? 0 be simpler and linear?
The reason will be displayed to describe this comment to others. Learn more.
These regexes (and isIgnored) have to stay in sync with _extract_mentions by hand. Could we add a matching note in _extract_mentions pointing back at this file, so someone changing the Perl side knows to update the JS too?
The reason will be displayed to describe this comment to others. Learn more.
This test covers the existing /rest/user/suggest behaviour, but none of the new client-side logic (trigger regex, quote/code-span/fence handling, self and duplicate-nick filtering). Is there a reasonable way to cover that, e.g. a Selenium test in qa/t, or is manual testing the plan for now?
- Only suggest accounts that can see the bug: /rest/user/suggest takes an
optional bug_id and leaves out users failing can_see_bug, since
_mentioned_users drops them on save. The caller must be able to see the
bug too. Bugs in no groups skip the per-user check.
- Find the paragraph start in linear time instead of rescanning the text
for every blank line.
- Point _extract_mentions at the JS rules that mirror it.
- Add a Selenium test for the client-side logic: filtering, insertion and
the contexts where mentions are ignored.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Typing @ and two or more characters in a comment box on an existing bug lists accounts whose nickname matches; picking one inserts "@nick ". Reuses /rest/user/suggest (an @-prefixed match is nickname-only). Lives in the Needinfo extension and is loaded only where a mention takes effect (mentions enabled, logged in, editbugs on the product).