Skip to content

Build your personal knowledge base with Trilium Notes

feat(tree): move the AI quick action into More and AI chat to the first group

Elian Doran69c646d27773
diff --git a/apps/client/src/services/note_types.spec.ts b/apps/client/src/services/note_types.spec.ts
index aad20f760c..194ed5cacb 100644
--- a/apps/client/src/services/note_types.spec.ts
+++ b/apps/client/src/services/note_types.spec.ts
@@ -439,7 +439,7 @@ describe("new template badges", () => {
}
});
- it("puts the snippets in a submenu of the menu, and the AI quick action beside the AI chat", async () => {
+ it("puts the snippets in a submenu of the menu, and the AI quick action under More", async () => {
withTemplates();
const restore = withTemplatesRoot([
fakeTemplate("tpl-text-snippet", [ "template", "textSnippet" ], "Text snippet"),
@@ -459,8 +459,11 @@ describe("new template badges", () => {
expect(submenu.items.every((i: any) => i.command === "insertChildNote")).toBe(true);
// Only in the submenu, and followed by no other group of built-in templates.
expect(menu.some((i) => i.templateNoteId === "tpl-code-snippet")).toBe(false);
- const types = titles(menu);
- expect(types.indexOf("tpl-ai")).toBe(types.indexOf("llmChat") + 1);
+ // The AI quick action is configuration, created as rarely as the other entries of More.
+ expect(titles(menu)).not.toContain("tpl-ai");
+ const more = menu.find((i) => i.title === "note_types.more");
+ // After the note types it holds, as the templates follow the note types everywhere in the menu.
+ expect(titles(more.items).slice(-2)).toEqual([ "separator", "tpl-ai" ]);
// The chooser's flat list keeps the snippets inline, after a separator.
const list: any[] = await noteTypesService.getNoteTypeItems();
@@ -472,7 +475,9 @@ describe("new template badges", () => {
// Without the AI features, neither the chat nor the quick action is offered.
llmFlag.mockReturnValue(false);
- const withoutAi = titles(noteTypesService.buildNoteTypeItems(data, "insertChildNote" as never));
+ const withoutAiMenu: any[] = noteTypesService.buildNoteTypeItems(data, "insertChildNote" as never);
+ const withoutAi = titles([ ...withoutAiMenu, ...withoutAiMenu.at(-1).items ]);
+ expect(withoutAiMenu.at(-1).title).toBe("note_types.more");
expect(withoutAi).not.toContain("llmChat");
expect(withoutAi).not.toContain("tpl-ai");
} finally {
@@ -489,15 +494,12 @@ describe("new template badges", () => {
const data = await noteTypesService.loadNoteTypeData();
const menu: any[] = noteTypesService.buildNoteTypeItems(data, "insertChildNote" as never);
expect(menu.map(key)).toEqual([
- "text", "markdown", "code", "spreadsheet",
+ "text", "markdown", "code", "spreadsheet", "llmChat",
"separator",
"canvas", "mermaid", "mindMap", "relationMap",
"separator",
- "llmChat", "text",
- "separator",
"note_types.more"
]);
- expect(menu[11].templateNoteId).toBe("tpl-ai");
// No creatable type is left out or offered twice, at the top level and under More.
const offered = [ ...menu, ...menu.at(-1).items ].filter((i) => i.command && !i.templateNoteId).map(key);
@@ -505,10 +507,10 @@ describe("new template badges", () => {
.map((nt) => (nt.mime === "text/x-markdown" ? "markdown" : nt.type));
expect([ ...offered ].sort()).toEqual([ ...creatable, "noteMap", "search" ].sort());
- // Without AI, its group leaves no separator behind.
+ // Without AI, the chat is left out of its group.
llmFlag.mockReturnValue(false);
const withoutAi = noteTypesService.buildNoteTypeItems(data, "insertChildNote" as never).map(key);
- expect(withoutAi.slice(-3)).toEqual([ "relationMap", "separator", "note_types.more" ]);
+ expect(withoutAi.slice(0, 5)).toEqual([ "text", "markdown", "code", "spreadsheet", "separator" ]);
// The chooser's flat list keeps the order of `NOTE_TYPES`, which the note type switcher shares.
const list = (await noteTypesService.getNoteTypeItems()).map(key);
diff --git a/apps/client/src/services/note_types.ts b/apps/client/src/services/note_types.ts
index f25775e32e..e4567a5d70 100644
--- a/apps/client/src/services/note_types.ts
+++ b/apps/client/src/services/note_types.ts
@@ -225,8 +225,8 @@ type NoteTypeLayout = "menu" | "list";
* The note type items. A `"menu"` groups the note types by kind ({@link MENU_GROUPS}) and opens the
* snippets, the collections and the rarely created note types from submenus; a `"list"`, such as
* the note type chooser draws, cannot open one, so it lists them inline in the order of
- * {@link NOTE_TYPES}. The AI quick action template stands beside the AI chat note type, and is
- * offered only alongside it.
+ * {@link NOTE_TYPES}. The AI quick action template is offered only where AI is enabled: last in
+ * the menu's "More" submenu, after its note types, and beside the AI chat note type in the list.
*/
function buildNoteTypeItems(data: NoteTypeData, command?: TreeCommandNames, layout: NoteTypeLayout = "menu") {
const { builtInTemplateNotes, userTemplateNotes, newTemplates } = data;
@@ -246,9 +246,8 @@ function buildNoteTypeItems(data: NoteTypeData, command?: TreeCommandNames, layo
* last group opens from the "More" submenu. A note type in none of them is not offered.
*/
const MENU_GROUPS: Pick<NoteTypeMapping, "type" | "mime">[][] = [
- [ { type: "text" }, { type: "code", mime: MARKDOWN_NOTE_TYPE_MIME }, { type: "code", mime: "text/plain" }, { type: "spreadsheet" } ],
- [ { type: "canvas" }, { type: "mermaid" }, { type: "mindMap" }, { type: "relationMap" } ],
- [ { type: "llmChat" } ]
+ [ { type: "text" }, { type: "code", mime: MARKDOWN_NOTE_TYPE_MIME }, { type: "code", mime: "text/plain" }, { type: "spreadsheet" }, { type: "llmChat" } ],
+ [ { type: "canvas" }, { type: "mermaid" }, { type: "mindMap" }, { type: "relationMap" } ]
];
const MORE_GROUP: Pick<NoteTypeMapping, "type" | "mime">[] = [
{ type: "noteMap" }, { type: "render" }, { type: "search" }, { type: "webView" }
@@ -261,7 +260,7 @@ function buildMenuItems(blankTypes: MenuCommandItem<TreeCommandNames>[], builtIn
const item = blankTypes.find((blankType) => blankType.type === type && (mime === undefined || blankType.mime === mime));
if (!item) return [];
if (type === "code" && mime === "text/plain") item.items = getCodeLanguageItems(command);
- return type === "llmChat" ? [ item, ...builtIn("aiQuickAction") ] : [ item ];
+ return [ item ];
});
const items: MenuItem<TreeCommandNames>[] = [];
@@ -277,7 +276,8 @@ function buildMenuItems(blankTypes: MenuCommandItem<TreeCommandNames>[], builtIn
items.push(...withLeading(SEPARATOR, builtIn("other")), SEPARATOR);
if (snippets.length > 0) items.push({ title: t("note_types.snippet"), uiIcon: "bx bx-align-left", items: snippets });
if (collections.length > 0) items.push({ title: t("note_types.book"), uiIcon: "bx bx-book", items: collections });
- items.push({ title: t("note_types.more"), uiIcon: "bx bx-dots-horizontal-rounded", items: inGroup(MORE_GROUP) });
+ const aiQuickActions = isExperimentalFeatureEnabled("llm") ? builtIn("aiQuickAction") : [];
+ items.push({ title: t("note_types.more"), uiIcon: "bx bx-dots-horizontal-rounded", items: [ ...inGroup(MORE_GROUP), ...withLeading(SEPARATOR, aiQuickActions) ] });
return items;
}
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/In-editor AI assistant/Custom AI quick actions.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/In-editor AI assistant/Custom AI quick actions.html
index 250fc4c7df..5817ebb221 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/In-editor AI assistant/Custom AI quick actions.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Text/In-editor AI assistant/Custom AI quick actions.html
@@ -7,10 +7,10 @@
<h2>Creating a custom quick action</h2>
<p>In the&nbsp;<a class="reference-link" href="#root/_help_oPVyFC7WL2Lp">Note Tree</a>: </p>
<ol>
- <li>Right click a note where to place the text snippet.</li>
+ <li>Right-click the note where you want to place the quick action.</li>
<li>Select <em>Insert child note</em>.</li>
- <li>Select <em>AI Quick Action</em>, next to <em>AI Chat</em>. Both appear only
- when AI is enabled.</li>
+ <li>Select <em>More</em> → <em>AI Quick Action</em>. The entry appears only when
+ AI is enabled.</li>
</ol>
<p>Afterwards, simply type in the content of the note the desired prompt.
The text can be formatted in the same manner as a normal text note and
diff --git a/docs/User Guide/User Guide/Note Types/Text/In-editor AI assistant/Custom AI quick actions.md b/docs/User Guide/User Guide/Note Types/Text/In-editor AI assistant/Custom AI quick actions.md
index 57a39ccbc5..d40f698dc2 100644
--- a/docs/User Guide/User Guide/Note Types/Text/In-editor AI assistant/Custom AI quick actions.md
+++ b/docs/User Guide/User Guide/Note Types/Text/In-editor AI assistant/Custom AI quick actions.md
@@ -5,9 +5,9 @@ _Quick actions_ are a feature of the <a class="reference-link" href="../In-edit
In the <a class="reference-link" href="../../../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree.md">Note Tree</a>: 
-1. Right click a note where to place the text snippet.
+1. Right-click the note where you want to place the quick action.
2. Select _Insert child note_.
-3. Select _AI Quick Action_, next to _AI Chat_. Both appear only when AI is enabled.
+3. Select _More_ → _AI Quick Action_. The entry appears only when AI is enabled.
Afterwards, simply type in the content of the note the desired prompt. The text can be formatted in the same manner as a normal text note and it will be passed to the LLM as Markdown.