Skip to content

The open-source app everyone uses to manage agents at work

Fix mention pills by allowing custom URL schemes in Lexical LinkNode

dotta0e8e162cd52f
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 56a8a46ade..cdc34c26dd 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -22,7 +22,7 @@ importers:
version: 5.9.3
vitest:
specifier: ^3.0.5
cli:
dependencies:
@@ -583,6 +583,9 @@ importers:
'@dnd-kit/utilities':
specifier: ^3.2.2
version: 3.2.2([email protected])
+ '@lexical/link':
+ specifier: 0.35.0
+ version: 0.35.0
'@mdxeditor/editor':
specifier: ^3.52.4
@@ -685,7 +688,7 @@ importers:
vitest:
specifier: ^3.0.5
packages:
@@ -12164,7 +12167,7 @@ snapshots:
- tsx
- yaml
dependencies:
'@types/chai': 5.2.3
'@vitest/expect': 3.2.4
diff --git a/ui/package.json b/ui/package.json
index 5ce1555337..112fa86efd 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -13,14 +13,15 @@
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
+ "@lexical/link": "0.35.0",
"@mdxeditor/editor": "^3.52.4",
"@paperclipai/adapter-claude-local": "workspace:*",
"@paperclipai/adapter-codex-local": "workspace:*",
"@paperclipai/adapter-cursor-local": "workspace:*",
"@paperclipai/adapter-gemini-local": "workspace:*",
+ "@paperclipai/adapter-openclaw-gateway": "workspace:*",
"@paperclipai/adapter-opencode-local": "workspace:*",
"@paperclipai/adapter-pi-local": "workspace:*",
- "@paperclipai/adapter-openclaw-gateway": "workspace:*",
"@paperclipai/adapter-utils": "workspace:*",
"@paperclipai/shared": "workspace:*",
"@radix-ui/react-slot": "^1.2.4",
diff --git a/ui/src/components/MarkdownEditor.tsx b/ui/src/components/MarkdownEditor.tsx
index afbd29fc90..84218a09fb 100644
--- a/ui/src/components/MarkdownEditor.tsx
+++ b/ui/src/components/MarkdownEditor.tsx
@@ -26,11 +26,22 @@ import {
thematicBreakPlugin,
type RealmPlugin,
} from "@mdxeditor/editor";
+import { LinkNode } from "@lexical/link";
import { buildAgentMentionHref, buildProjectMentionHref } from "@paperclipai/shared";
import { AgentIcon } from "./AgentIconPicker";
import { applyMentionChipDecoration, clearMentionChipDecoration, parseMentionChipHref } from "../lib/mention-chips";
import { cn } from "../lib/utils";
+/* ---- Allow custom mention URL schemes in Lexical's LinkNode ---- */
+// Lexical only allows http(s)/mailto/sms/tel by default, converting
+// everything else to about:blank. We need agent:// and project://
+// to survive the markdown→Lexical import so mention chips render.
+const _origSanitizeUrl = LinkNode.prototype.sanitizeUrl;
+LinkNode.prototype.sanitizeUrl = function sanitizeUrl(url: string): string {
+ if (/^(agent|project):\/\//.test(url)) return url;
+ return _origSanitizeUrl.call(this, url);
+};
+
/* ---- Mention types ---- */
export interface MentionOption {