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(options): move page master toggles into a labelled row (closes #10938)
Elian Doran1d6d75791aa9
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 09d6246086..af38588b9d 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2328,7 +2328,7 @@"title": "Spell Check","description": "These options apply only for desktop builds, browsers will use their own native spell check.","enable": "Check spelling",- "disabled_placeholder": "Spell check is turned off. Enable it to choose languages and manage the custom dictionary.",+ "enable_description": "Underlines misspelled words as you type, with corrections offered in the right-click menu.","language_code_label": "Spell Check Languages","custom_dictionary_title": "Custom Dictionary","custom_dictionary_description": "Words added to the dictionary are synced across all your devices.",@@ -3847,7 +3847,8 @@"direction-down": "Branches downwards"},"llm": {- "disabled_placeholder": "AI features are turned off. Enable them to configure providers and MCP.",+ "enabled": "AI features",+ "enabled_description": "Adds the AI chat sidebar and LLM chat notes, using the providers configured below.","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/type_widgets/options/llm.spec.tsx b/apps/client/src/widgets/type_widgets/options/llm.spec.tsxindex b61d3616b3..aad4891154 100644--- a/apps/client/src/widgets/type_widgets/options/llm.spec.tsx+++ b/apps/client/src/widgets/type_widgets/options/llm.spec.tsx@@ -77,6 +77,31 @@ function mcpRow() {};}+describe("the AI master switch", () => {+ it("is a named row, so what it turns on is stated rather than left to a tooltip", () => {+ open();++ const toggle = host.querySelector<HTMLInputElement>("input.switch-toggle[id^='ai-enabled-']");+ expect(toggle).not.toBeNull();++ // Bound to the switch, not merely text near it — the switch's accessible name.+ const row = toggle?.closest(".option-row");+ expect(row?.querySelector("label")?.getAttribute("for")).toBe(toggle?.id);+ expect(row?.querySelector("label")?.textContent).toBe("llm.enabled");+ expect(row?.querySelector(".option-row-description")?.textContent).toBe("llm.enabled_description");+ });++ it("stays on the page when off, so the way back on is where the settings were", () => {+ mocks.stored = { aiEnabled: "false", mcpEnabled: "true" };+ open();++ expect(host.querySelector("input.switch-toggle[id^='ai-enabled-']")).not.toBeNull();+ // Everything it governs is gone, and nothing stands in for it: the switch is the page.+ expect(host.querySelector("input.switch-toggle[id^='mcp-enabled-']")).toBeNull();+ expect(host.querySelector(".no-items")).toBeNull();+ });+});+describe("the MCP card in standalone", () => {it("offers the endpoint where Trilium listens on one", () => {open();diff --git a/apps/client/src/widgets/type_widgets/options/llm.tsx b/apps/client/src/widgets/type_widgets/options/llm.tsxindex 05879e41aa..4d48264fdd 100644--- a/apps/client/src/widgets/type_widgets/options/llm.tsx+++ b/apps/client/src/widgets/type_widgets/options/llm.tsx@@ -12,7 +12,6 @@ import Button from "../../react/Button";import CodeBlock from "../../react/CodeBlock";import Collapsible from "../../react/Collapsible";import FormTextBox from "../../react/FormTextBox";-import FormToggle from "../../react/FormToggle";import { useTriliumOption, useTriliumOptionBool } from "../../react/hooks";import MaskedIcon from "../../react/MaskedIcon";import NoItems from "../../react/NoItems";@@ -26,28 +25,23 @@ export default function LlmSettings() {return (<>- <OptionsPageHeader- helpUrl="GBBMSlVSOIGP"- actions={- <FormToggle- switchOnName="" switchOffName=""- switchOnTooltip={t("experimental_features.llm_name")}- switchOffTooltip={t("experimental_features.llm_name")}- currentValue={aiEnabled}- onChange={setAiEnabled}- />- }- />+ <OptionsPageHeader helpUrl="GBBMSlVSOIGP" />++ <OptionsSection>+ <OptionsRowWithToggle+ name="ai-enabled"+ label={t("llm.enabled")}+ description={t("llm.enabled_description")}+ currentValue={aiEnabled}+ onChange={setAiEnabled}+ />+ </OptionsSection>- {aiEnabled ? (+ {aiEnabled && (<><ProviderSettings /><McpSettings /></>- ) : (- <OptionsSection>- <NoItems icon="bx bx-bot" text={t("llm.disabled_placeholder")} />- </OptionsSection>)}</>);diff --git a/apps/client/src/widgets/type_widgets/options/spellcheck.tsx b/apps/client/src/widgets/type_widgets/options/spellcheck.tsxindex 1a050f542c..3b141e5903 100644--- a/apps/client/src/widgets/type_widgets/options/spellcheck.tsx+++ b/apps/client/src/widgets/type_widgets/options/spellcheck.tsx@@ -5,12 +5,11 @@ import { t } from "../../../services/i18n";import { isElectron } from "../../../services/utils";import Button from "../../react/Button";import FormText from "../../react/FormText";-import FormToggle from "../../react/FormToggle";import { useTriliumOption, useTriliumOptionBool } from "../../react/hooks";import NoItems from "../../react/NoItems";import CheckboxList from "./components/CheckboxList";import OptionsPageHeader from "./components/OptionsPageHeader";-import OptionsRow from "./components/OptionsRow";+import OptionsRow, { OptionsRowWithToggle } from "./components/OptionsRow";import OptionsSection from "./components/OptionsSection";export default function SpellcheckSettings() {@@ -42,25 +41,23 @@ function ElectronSpellcheckSettings() {return (<>- <OptionsPageHeader actions={- <FormToggle- switchOnName="" switchOffName=""- switchOnTooltip={t("spellcheck.enable")}- switchOffTooltip={t("spellcheck.enable")}+ <OptionsPageHeader />++ <OptionsSection>+ <OptionsRowWithToggle+ name="spellcheck-enabled"+ label={t("spellcheck.enable")}+ description={t("spellcheck.enable_description")}currentValue={spellCheckEnabled}onChange={onToggle}/>- } />+ </OptionsSection>- {spellCheckEnabled ? (+ {spellCheckEnabled && (<><SpellcheckLanguages /><CustomDictionary /></>- ) : (- <OptionsSection>- <NoItems icon="bx bx-check-double" text={t("spellcheck.disabled_placeholder")} />- </OptionsSection>)}</>);