fix: render mentions whose ID contains any non-whitespace character as chips (#29864)

* fix: render channel mentions whose ID contains spaces or parentheses, such as workspace model IDs

* fix: accept any non-whitespace mention ID, matching the model ID rule on dev
This commit is contained in:
G30 2026-09-09 19:27:35 -04:00 committed by GitHub
parent 540467b90a
commit eb9b7b659f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -499,7 +499,7 @@
const escaped = line.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
// Now replace the escaped mention patterns back into real spans
const withMentions = escaped.replace(
/&lt;([@#$])([\w.\-:/]+)(?:\|([^&]*?))?&gt;|&lt;\/([\w.\-:/]+)\|([^&]*?)&gt;/g,
/&lt;([@#$])([^|&\s]+)(?:\|([^&]*?))?&gt;|&lt;\/([\w.\-:/]+)\|([^&]*?)&gt;/g,
(_, ch, id, label, slashSkillId, slashSkillLabel) => {
const mentionChar = ch || '$';
const mentionId = id || slashSkillId;

View file

@ -40,7 +40,7 @@ export function mentionExtension(opts: MentionOptions = {}) {
// Compile the regex once when the extension is created, not on every tokenizer call.
// mentionStart fires on every '<' in the document, making the tokenizer a hot path.
const trigger = opts.triggerChar ?? '@';
const re = new RegExp(`^<\\${trigger}([\\w.\\-:/]+)(?:\\|([^>]*))?>`);
const re = new RegExp(`^<\\${trigger}([^|>\\s]+)(?:\\|([^>]*))?>`);
const snapshot: MentionOptions = {
triggerChar: trigger,
className: opts.className,