From eb9b7b659fb80b3c5d652f2ff8bc72dba03b8735 Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Wed, 9 Sep 2026 19:27:35 -0400 Subject: [PATCH] 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 --- src/lib/components/common/RichTextInput.svelte | 2 +- src/lib/utils/marked/mention-extension.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index 37e4e9bdd3..61654914b2 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/src/lib/components/common/RichTextInput.svelte @@ -499,7 +499,7 @@ const escaped = line.replace(/&/g, '&').replace(//g, '>'); // Now replace the escaped mention patterns back into real spans const withMentions = escaped.replace( - /<([@#$])([\w.\-:/]+)(?:\|([^&]*?))?>|<\/([\w.\-:/]+)\|([^&]*?)>/g, + /<([@#$])([^|&\s]+)(?:\|([^&]*?))?>|<\/([\w.\-:/]+)\|([^&]*?)>/g, (_, ch, id, label, slashSkillId, slashSkillLabel) => { const mentionChar = ch || '$'; const mentionId = id || slashSkillId; diff --git a/src/lib/utils/marked/mention-extension.ts b/src/lib/utils/marked/mention-extension.ts index 835ce30714..2932da4c7c 100644 --- a/src/lib/utils/marked/mention-extension.ts +++ b/src/lib/utils/marked/mention-extension.ts @@ -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,