refactor(llm): use dedicated widget for llm chat button

This commit is contained in:
Elian Doran 2025-03-16 23:22:14 +02:00
parent 7b643a7d82
commit d7167131cb
No known key found for this signature in database
3 changed files with 19 additions and 4 deletions

View File

@ -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");
}
}

View File

@ -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}"`);
}

View File

@ -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 },