diff --git a/apps/desktop/src/lib/__tests__/aiMarkdown.spec.ts b/apps/desktop/src/lib/__tests__/aiMarkdown.spec.ts
new file mode 100644
index 000000000..92a578028
--- /dev/null
+++ b/apps/desktop/src/lib/__tests__/aiMarkdown.spec.ts
@@ -0,0 +1,94 @@
+import { describe, expect, it } from "vitest";
+import { aiMarkdownLinkUrlFromClick, formatAiInlineMarkdown, handleAiMarkdownLinkClick, normalizeAiMarkdownLink } from "@/lib/aiMarkdown";
+
+describe("formatAiInlineMarkdown", () => {
+ it("renders http links for external browser handling", () => {
+ const html = formatAiInlineMarkdown("See [docs](https://example.com/a?x=1&y=2).");
+
+ expect(html).toContain('href="https://example.com/a?x=1&y=2"');
+ expect(html).toContain('target="_blank"');
+ expect(html).toContain('rel="noopener noreferrer"');
+ });
+
+ it("does not render unsafe link schemes", () => {
+ const html = formatAiInlineMarkdown("[run](javascript:alert(1))");
+
+ expect(html).toContain("run");
+ expect(html).not.toContain("javascript:");
+ expect(html).not.toContain("
{
+ const html = formatAiInlineMarkdown("");
+
+ expect(html).toContain("<script>alert(1)</script>");
+ expect(html).not.toContain("