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
refactor(llm): use dedicated widget for llm chat button
Elian Dorand7167131cb25
diff --git a/src/public/app/widgets/buttons/llm_chat_button.ts b/src/public/app/widgets/buttons/llm_chat_button.tsnew file mode 100644index 0000000000..ea1b9b24e7--- /dev/null+++ b/src/public/app/widgets/buttons/llm_chat_button.ts@@ -0,0 +1,15 @@+import type FNote from "../../entities/fnote.js";+import CommandButtonWidget from "./command_button.js";++export default class LlmChatButton extends CommandButtonWidget {++ constructor(note: FNote) {+ super();++ this.command("showLlmChat")+ .title(() => note.title)+ .icon(() => note.getIcon())+ .class("launcher-button");+ }++}diff --git a/src/public/app/widgets/containers/launcher.ts b/src/public/app/widgets/containers/launcher.tsindex 942bdb60b4..7374969232 100644--- a/src/public/app/widgets/containers/launcher.ts+++ b/src/public/app/widgets/containers/launcher.ts@@ -13,6 +13,7 @@ import HistoryNavigationButton from "../buttons/history_navigation.js";import QuickSearchLauncherWidget from "../quick_search_launcher.js";import type FNote from "../../entities/fnote.js";import type { CommandNames } from "../../components/app_context.js";+import LlmChatButton from "../buttons/llm_chat_button.js";interface InnerWidget extends BasicWidget {settings?: {@@ -124,7 +125,7 @@ export default class LauncherWidget extends BasicWidget {case "quickSearch":return new QuickSearchLauncherWidget(this.isHorizontalLayout);case "llmChatLauncher":- return new ScriptLauncher(note);+ return new LlmChatButton(note);default:throw new Error(`Unrecognized builtin widget ${builtinWidget} for launcher ${note.noteId} "${note.title}"`);}diff --git a/src/services/hidden_subtree_launcherbar.ts b/src/services/hidden_subtree_launcherbar.tsindex b785d35922..a63cc86bfd 100644--- a/src/services/hidden_subtree_launcherbar.ts+++ b/src/services/hidden_subtree_launcherbar.ts@@ -72,11 +72,10 @@ export default function buildLaunchBarConfig() {id: "_lbLlmChat",title: t("hidden-subtree.llm-chat-title"),type: "launcher",- command: "showLlmChat",icon: "bx bx-bot",+ builtinWidget: "llmChatLauncher",attributes: [- { type: "label", name: "desktopOnly" },- { type: "label", name: "launcherType", value: "command" }+ { type: "label", name: "desktopOnly" }]},{ id: "_lbCalendar", ...sharedLaunchers.calendar },