Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(llm): stop offering note creation in the chat mention feed
Elian Doran81a4652f7c56
diff --git a/apps/client/src/services/note_autocomplete.spec.ts b/apps/client/src/services/note_autocomplete.spec.tsindex 1b3a45fdb5..5ce08e955e 100644--- a/apps/client/src/services/note_autocomplete.spec.ts+++ b/apps/client/src/services/note_autocomplete.spec.ts@@ -133,6 +133,15 @@ describe("note_autocomplete", () => {});});+ it("omits the creation rows when the host cannot act on them", async () => {+ server.get = vi.fn(async () => [+ { noteTitle: "Foo", notePathTitle: "Root / Foo", notePath: "root/abc" }+ ]) as typeof server.get;++ const result = (await noteAutocomplete.autocompleteSourceForCKEditor("Foo", false)) as any[];+ expect(result.map((r) => r.action)).toEqual([ undefined ]);+ });+it("falls back to empty name when notePathTitle is missing", async () => {server.get = vi.fn(async () => []) as typeof server.get;const result = (await noteAutocomplete.autocompleteSourceForCKEditor("X")) as any[];diff --git a/apps/client/src/services/note_autocomplete.ts b/apps/client/src/services/note_autocomplete.tsindex be57179b58..c912818e51 100644--- a/apps/client/src/services/note_autocomplete.ts+++ b/apps/client/src/services/note_autocomplete.ts@@ -83,7 +83,12 @@ export interface Options {isCommandPalette?: boolean;}-async function autocompleteSourceForCKEditor(queryText: string) {+/**+ * Feeds a CKEditor mention. Creation entries are offered only where the editor's host component+ * implements `createNoteForReferenceLink`, which is what `MentionCustomization` calls to act on+ * them.+ */+async function autocompleteSourceForCKEditor(queryText: string, allowCreatingNotes = true) {return await new Promise<MentionFeedObjectItem[]>((res, rej) => {autocompleteSource(queryText,@@ -104,7 +109,7 @@ async function autocompleteSourceForCKEditor(queryText: string) {);},{- allowCreatingNotes: true+ allowCreatingNotes});});diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsxindex 0c5423e2d4..ec09ed2402 100644--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatInputBar.tsx@@ -32,19 +32,13 @@ const READ_ONLY_LOCK = "llm-chat-streaming";const mentionFeeds: MentionFeed[] = [{marker: "@",- feed: (queryText) => note_autocomplete.autocompleteSourceForCKEditor(queryText),+ feed: (queryText) => note_autocomplete.autocompleteSourceForCKEditor(queryText, false),itemRenderer: (rawItem) => {const item = rawItem as Suggestion;const itemElement = document.createElement("button");const iconElement = document.createElement("span");- let iconClass = item.icon ?? "bx bx-note";- if (item.action === "create-note") {- iconClass = "bx bx-plus";- } else if (item.action === "create-child-note") {- iconClass = "bx bx-subdirectory-right";- }- iconElement.className = iconClass;+ iconElement.className = item.icon ?? "bx bx-note";itemElement.append(iconElement, document.createTextNode(" "));const titleContainer = document.createElement("span");