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
feat(llm): stop hiding the AI settings in standalone
Elian Doran6a18e472da6c
diff --git a/apps/client/src/services/experimental_features.spec.ts b/apps/client/src/services/experimental_features.spec.tsindex d117467a5a..16d055a219 100644--- a/apps/client/src/services/experimental_features.spec.ts+++ b/apps/client/src/services/experimental_features.spec.ts@@ -2,19 +2,15 @@ import { beforeEach, describe, expect, it, vi } from "vitest";// Shared, mutable control state for the utils mock. `vi.hoisted` runs before// the hoisted `vi.mock` factory, so the factory can safely reference it.-const ctrl = vi.hoisted(() => ({ standalone: false, mobile: false }));+const ctrl = vi.hoisted(() => ({ mobile: false }));-// Partial-mock ./utils so we can flip `isStandalone` (a const in the target,-// read here as a live getter) and `isMobile` at runtime, while keeping the+// Partial-mock ./utils so we can flip `isMobile` at runtime, while keeping the// rest of the real module intact (e.g. `isShare` used by options.ts).vi.mock("./utils.js", async (orig) => {const actual = (await orig()) as Record<string, unknown>;return {...actual,- isMobile: () => ctrl.mobile,- get isStandalone() {- return ctrl.standalone;- }+ isMobile: () => ctrl.mobile};});@@ -38,19 +34,13 @@ async function freshModule(stored: unknown, opts: { newLayout?: boolean; aiEnabldescribe("experimental_features", () => {beforeEach(() => {- ctrl.standalone = false;ctrl.mobile = false;vi.restoreAllMocks();});- it("lists all features when not standalone, hides llm in standalone", async () => {+ it("lists every feature", async () => {const { mod } = await freshModule([]);-- ctrl.standalone = false;expect(mod.getAvailableExperimentalFeatures().map((f) => f.id)).toEqual(["new-layout", "llm"]);-- ctrl.standalone = true;- expect(mod.getAvailableExperimentalFeatures().map((f) => f.id)).toEqual(["new-layout"]);});it("new-layout is enabled via mobile or the newLayout option", async () => {@@ -69,15 +59,7 @@ describe("experimental_features", () => {expect(opt.mod.isExperimentalFeatureEnabled("new-layout")).toBe(true);});- it("llm is always disabled in standalone mode", async () => {- const { mod } = await freshModule([], { aiEnabled: true });- ctrl.standalone = true;- expect(mod.isExperimentalFeatureEnabled("llm")).toBe(false);- });-- it("non-standalone llm enablement is driven by the aiEnabled option", async () => {- ctrl.standalone = false;-+ it("llm enablement is driven by the aiEnabled option", async () => {const enabled = await freshModule([], { aiEnabled: true });expect(enabled.mod.isExperimentalFeatureEnabled("llm")).toBe(true);@@ -87,7 +69,6 @@ describe("experimental_features", () => {});it("drops new-layout and llm from the persisted set and re-derives them separately", async () => {- ctrl.standalone = false;ctrl.mobile = false;// both stored entries are stripped; with the options off nothing is re-added@@ -99,16 +80,13 @@ describe("experimental_features", () => {expect(readded.mod.getEnabledExperimentalFeatureIds().sort()).toEqual(["llm", "new-layout"]);});- it("adds new-layout via mobile and keeps llm out in standalone", async () => {+ it("adds new-layout via mobile alongside an option-driven llm", async () => {const { mod } = await freshModule([], { aiEnabled: true });- ctrl.standalone = true;ctrl.mobile = true;- // mobile -> new-layout added; standalone -> llm not added despite aiEnabled- expect(mod.getEnabledExperimentalFeatureIds()).toEqual(["new-layout"]);+ expect(mod.getEnabledExperimentalFeatureIds()).toEqual(["new-layout", "llm"]);});it("warns and treats the set as empty when persisted JSON is invalid", async () => {- ctrl.standalone = false;ctrl.mobile = false;const warn = vi.spyOn(console, "warn").mockImplementation(() => {});const { mod } = await freshModule("not-json");@@ -117,7 +95,6 @@ describe("experimental_features", () => {});it("toggleExperimentalFeature adds/removes a feature and persists the set", async () => {- ctrl.standalone = false;const { mod, options } = await freshModule([]);const save = vi.spyOn(options, "save").mockResolvedValue(undefined);diff --git a/apps/client/src/services/experimental_features.ts b/apps/client/src/services/experimental_features.tsindex 28acaeb785..61d09d4afd 100644--- a/apps/client/src/services/experimental_features.ts+++ b/apps/client/src/services/experimental_features.ts@@ -1,6 +1,6 @@import { t } from "./i18n";import options from "./options";-import { isMobile, isStandalone } from "./utils";+import { isMobile } from "./utils";export interface ExperimentalFeature {id: string;@@ -23,9 +23,9 @@ export const experimentalFeatures = [export type ExperimentalFeatureId = typeof experimentalFeatures[number]["id"];-/** Returns experimental features available for the current platform (excludes LLM in standalone mode). */+/** Returns experimental features available for the current platform. */export function getAvailableExperimentalFeatures() {- return experimentalFeatures.filter(f => !(f.id === "llm" && isStandalone));+ return experimentalFeatures;}let enabledFeatures: Set<ExperimentalFeatureId> | null = null;@@ -36,9 +36,7 @@ export function isExperimentalFeatureEnabled(featureId: ExperimentalFeatureId):}if (featureId === "llm") {- // LLM features require server-side API calls that don't work in standalone mode- // due to CORS restrictions from LLM providers (OpenAI, Google don't allow browser requests)- return !isStandalone && options.is("aiEnabled");+ return options.is("aiEnabled");}return getEnabledFeatures().has(featureId);@@ -49,7 +47,7 @@ export function getEnabledExperimentalFeatureIds() {if (isMobile() || options.is("newLayout")) {values.push("new-layout");}- if (!isStandalone && options.is("aiEnabled")) {+ if (options.is("aiEnabled")) {values.push("llm");}return values;diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex a17dbeabfb..d36e65625b 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -3826,7 +3826,6 @@},"llm": {"disabled_placeholder": "AI features are turned off. Enable them to configure providers and MCP.",- "not_available_in_standalone": "AI/LLM features are not available in the standalone version of Trilium, as LLM providers do not allow direct access from a browser.","feature_not_enabled": "Enable the LLM experimental feature in Settings → Advanced → Experimental features to use AI integrations.","add_provider": "Add Provider","add_provider_title": "Add AI Provider",diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsxindex 48e83f5404..08fcc49bbe 100644--- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx@@ -11,7 +11,6 @@ import { WidgetsByParent } from "../../services/bundle";import { t } from "../../services/i18n";import options from "../../services/options";import { DEFAULT_GUTTER_SIZE } from "../../services/resizer";-import { isStandalone } from "../../services/utils";import ActionButton from "../react/ActionButton";import Button from "../react/Button";import { useActiveNoteContext, useGetContextData, useLegacyWidget, useNoteProperty, useTriliumEvent, useTriliumOption, useTriliumOptionBool, useTriliumOptionJson } from "../react/hooks";@@ -283,7 +282,7 @@ function useItems(rightPaneVisible: boolean, widgetsByParent: WidgetsByParent):// Loaded lazily because the chat pulls in the whole LLM + CKEditor graph,// which users without the LLM experimental feature should never download.el: <LazyComponent loader={() => import("./SidebarChat.jsx")} />,- enabled: noteType !== "llmChat" && !isStandalone && aiEnabled,+ enabled: noteType !== "llmChat" && aiEnabled,position: 1000,tab: "chat"},diff --git a/apps/client/src/widgets/type_widgets/options/llm.tsx b/apps/client/src/widgets/type_widgets/options/llm.tsxindex add8ef9264..efeb7454dc 100644--- a/apps/client/src/widgets/type_widgets/options/llm.tsx+++ b/apps/client/src/widgets/type_widgets/options/llm.tsx@@ -6,7 +6,6 @@ import { useCallback, useEffect, useMemo, useState } from "preact/hooks";import dialog from "../../../services/dialog";import { t } from "../../../services/i18n";import server from "../../../services/server";-import { isStandalone } from "../../../services/utils";import ActionButton from "../../react/ActionButton";import Button from "../../react/Button";import CodeBlock from "../../react/CodeBlock";@@ -24,17 +23,6 @@ import AddProviderModal, { type LlmProviderConfig, PROVIDER_TYPES } from "./llm/export default function LlmSettings() {const [aiEnabled, setAiEnabled] = useTriliumOptionBool("aiEnabled");- if (isStandalone) {- return (- <>- <OptionsPageHeader helpUrl="GBBMSlVSOIGP" />- <OptionsSection>- <NoItems icon="bx bx-bot" text={t("llm.not_available_in_standalone")} />- </OptionsSection>- </>- );- }-return (<><OptionsPageHeader