Skip to content

Build your personal knowledge base with Trilium Notes

refactor: remove the layout switch

Elian Doranc4a31c2a9cf9
diff --git a/apps/client/src/services/experimental_features.spec.ts b/apps/client/src/services/experimental_features.spec.ts
index 84d1c45bbd..219ba69152 100644
--- a/apps/client/src/services/experimental_features.spec.ts
+++ b/apps/client/src/services/experimental_features.spec.ts
@@ -1,30 +1,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(() => ({ mobile: false }));
-
-// 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
- };
-});
-
// `enabledFeatures` is module-level cached on first read of getEnabledFeatures,
// so each scenario re-imports a fresh module copy. The fresh copy binds to a
// fresh `options` singleton, so we re-import and spy on THAT instance.
-async function freshModule(stored: unknown, opts: { newLayout?: boolean; aiEnabled?: boolean } = {}) {
+async function freshModule(stored: unknown, opts: { aiEnabled?: boolean } = {}) {
vi.resetModules();
const options = (await import("./options.js")).default;
vi.spyOn(options, "get").mockReturnValue(
typeof stored === "string" ? stored : JSON.stringify(stored)
);
vi.spyOn(options, "is").mockImplementation((name) => {
- if (name === "newLayout") return opts.newLayout ?? false;
if (name === "aiEnabled") return opts.aiEnabled ?? false;
return false;
});
@@ -34,29 +19,12 @@ async function freshModule(stored: unknown, opts: { newLayout?: boolean; aiEnabl
describe("experimental_features", () => {
beforeEach(() => {
- ctrl.mobile = false;
vi.restoreAllMocks();
});
it("lists every feature", async () => {
const { mod } = await freshModule([]);
- expect(mod.getAvailableExperimentalFeatures().map((f) => f.id)).toEqual(["new-layout", "llm"]);
- });
-
- it("new-layout is enabled via mobile or the newLayout option", async () => {
- // neither mobile nor option -> disabled
- const { mod } = await freshModule([]);
- ctrl.mobile = false;
- expect(mod.isExperimentalFeatureEnabled("new-layout")).toBe(false);
-
- // mobile short-circuits to enabled
- ctrl.mobile = true;
- expect(mod.isExperimentalFeatureEnabled("new-layout")).toBe(true);
-
- // not mobile but the option is true -> enabled
- const opt = await freshModule([], { newLayout: true });
- ctrl.mobile = false;
- expect(opt.mod.isExperimentalFeatureEnabled("new-layout")).toBe(true);
+ expect(mod.getAvailableExperimentalFeatures().map((f) => f.id)).toEqual(["llm"]);
});
it("llm enablement is driven by the aiEnabled option", async () => {
@@ -68,26 +36,15 @@ describe("experimental_features", () => {
expect(disabled.mod.isExperimentalFeatureEnabled("llm")).toBe(false);
});
- it("drops new-layout and llm from the persisted set and re-derives them separately", async () => {
- ctrl.mobile = false;
-
- // both stored entries are stripped; with the options off nothing is re-added
- const stripped = await freshModule(["new-layout", "llm"]);
+ it("drops llm from the persisted set and re-derives it from the aiEnabled option", async () => {
+ const stripped = await freshModule(["llm"]);
expect(stripped.mod.getEnabledExperimentalFeatureIds()).toEqual([]);
- // the dedicated options re-add the respective features
- const readded = await freshModule([], { newLayout: true, aiEnabled: true });
- expect(readded.mod.getEnabledExperimentalFeatureIds().sort()).toEqual(["llm", "new-layout"]);
- });
-
- it("adds new-layout via mobile alongside an option-driven llm", async () => {
- const { mod } = await freshModule([], { aiEnabled: true });
- ctrl.mobile = true;
- expect(mod.getEnabledExperimentalFeatureIds()).toEqual(["new-layout", "llm"]);
+ const readded = await freshModule([], { aiEnabled: true });
+ expect(readded.mod.getEnabledExperimentalFeatureIds()).toEqual(["llm"]);
});
it("warns and treats the set as empty when persisted JSON is invalid", async () => {
- ctrl.mobile = false;
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
const { mod } = await freshModule("not-json");
expect(mod.getEnabledExperimentalFeatureIds()).toEqual([]);
diff --git a/apps/client/src/services/experimental_features.ts b/apps/client/src/services/experimental_features.ts
index ba62d5bd79..de57a21745 100644
--- a/apps/client/src/services/experimental_features.ts
+++ b/apps/client/src/services/experimental_features.ts
@@ -1,6 +1,5 @@
import { t } from "./i18n";
import options from "./options";
-import { isMobile } from "./utils";
export interface ExperimentalFeature {
id: string;
@@ -9,11 +8,6 @@ export interface ExperimentalFeature {
}
export const experimentalFeatures = [
- {
- id: "new-layout",
- name: t("experimental_features.new_layout_name"),
- description: t("experimental_features.new_layout_description"),
- },
{
id: "llm",
name: t("experimental_features.llm_name"),
@@ -31,10 +25,6 @@ export function getAvailableExperimentalFeatures() {
let enabledFeatures: Set<ExperimentalFeatureId> | null = null;
export function isExperimentalFeatureEnabled(featureId: ExperimentalFeatureId): boolean {
- if (featureId === "new-layout") {
- return (isMobile() || options.is("newLayout"));
- }
-
if (featureId === "llm") {
return options.is("aiEnabled");
}
@@ -44,9 +34,6 @@ export function isExperimentalFeatureEnabled(featureId: ExperimentalFeatureId):
export function getEnabledExperimentalFeatureIds() {
const values = [ ...getEnabledFeatures().values() ];
- if (isMobile() || options.is("newLayout")) {
- values.push("new-layout");
- }
if (options.is("aiEnabled")) {
values.push("llm");
}
@@ -62,7 +49,6 @@ function getEnabledFeatures() {
console.warn("Failed to parse experimental features from options:", e);
}
enabledFeatures = new Set(features);
- enabledFeatures.delete("new-layout"); // handled separately.
enabledFeatures.delete("llm"); // handled separately, via the aiEnabled option.
}
return enabledFeatures;
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index ac8903e4b4..d4cb11e20f 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1795,8 +1795,6 @@
"experimental_features": {
"title": "Experimental Options",
"disclaimer": "These options are experimental and may cause instability. Use with caution.",
- "new_layout_name": "New Layout",
- "new_layout_description": "Try out the new layout for a more modern look and improved usability. Subject to heavy change in the upcoming releases.",
"llm_name": "AI / LLM Chat",
"llm_description": "Enable the AI chat sidebar and LLM chat notes powered by large language models."
},
@@ -3736,10 +3734,7 @@
"related_code_blocks": "Color scheme for code blocks in text notes",
"related_code_notes": "Color scheme for code notes",
"ui": "User interface",
- "ui_layout_style": "Layout style",
- "ui_layout_orientation": "Launcher bar orientation",
- "ui_old_layout": "Old layout",
- "ui_new_layout": "New layout"
+ "ui_layout_orientation": "Launcher bar orientation"
},
"units": {
"percentage": "%"
diff --git a/apps/client/src/widgets/buttons/global_menu.tsx b/apps/client/src/widgets/buttons/global_menu.tsx
index 7eabdf62ea..a15528eadd 100644
--- a/apps/client/src/widgets/buttons/global_menu.tsx
+++ b/apps/client/src/widgets/buttons/global_menu.tsx
@@ -133,7 +133,7 @@ function KeyboardActionMenuItem({ command, ...props }: MenuItemProps<KeyboardAct
return <MenuItem {...props} command={command} keyboardShortcut={command} />;
}
-export function VerticalLayoutIcon({ logoRef }: { logoRef?: RefObject<SVGSVGElement | null> }) {
+function VerticalLayoutIcon({ logoRef }: { logoRef?: RefObject<SVGSVGElement | null> }) {
return (
<svg ref={logoRef} viewBox="0 0 256 256" title={t("global_menu.menu")}>
<g>
diff --git a/apps/client/src/widgets/type_widgets/options/advanced.spec.tsx b/apps/client/src/widgets/type_widgets/options/advanced.spec.tsx
index fd5ff15539..ea598a2acf 100644
--- a/apps/client/src/widgets/type_widgets/options/advanced.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/advanced.spec.tsx
@@ -41,7 +41,6 @@ let host: HTMLElement;
beforeEach(() => {
mocks.features = [
- { id: "new-layout", name: "New layout", description: "…" },
{ id: "llm", name: "AI", description: "…" },
{ id: "spreadsheets", name: "Spreadsheets", description: "…" }
];
@@ -69,7 +68,7 @@ describe("the experimental features card", () => {
it("leaves out the features that are switched somewhere better suited to them", () => {
open();
- // The layout has its own illustrated choice on Appearance, and the AI switch heads its own page.
+ // The AI switch heads its own page.
expect(featureSwitches()).toHaveLength(1);
expect(host.querySelector(".tn-card-option-label")?.firstChild?.textContent).toBe("Spreadsheets");
});
diff --git a/apps/client/src/widgets/type_widgets/options/advanced.tsx b/apps/client/src/widgets/type_widgets/options/advanced.tsx
index cc80a1ef9a..ade16c2a55 100644
--- a/apps/client/src/widgets/type_widgets/options/advanced.tsx
+++ b/apps/client/src/widgets/type_widgets/options/advanced.tsx
@@ -20,8 +20,8 @@ export default function AdvancedSettings() {
function ExperimentalOptions() {
const [enabledFeatures, setEnabledFeatures] = useTriliumOptionJson<ExperimentalFeatureId[]>("experimentalFeatures", true);
- // Features with dedicated controls elsewhere (appearance settings and the AI/LLM page, respectively).
- const integratedFeatures: ExperimentalFeatureId[] = ["new-layout", "llm"];
+ // Features with dedicated controls elsewhere (the AI/LLM page).
+ const integratedFeatures: ExperimentalFeatureId[] = ["llm"];
const filteredFeatures = useMemo(() => getAvailableExperimentalFeatures().filter(e => !integratedFeatures.includes(e.id)), []);
const toggleFeature = useCallback((featureId: ExperimentalFeatureId, enabled: boolean) => {
diff --git a/apps/client/src/widgets/type_widgets/options/appearance.css b/apps/client/src/widgets/type_widgets/options/appearance.css
index 0731af2f4e..c921d9cad3 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance.css
+++ b/apps/client/src/widgets/type_widgets/options/appearance.css
@@ -2,16 +2,6 @@
margin-inline-end: 8px;
}
-.appearance-layout-choices {
- display: flex;
- flex-wrap: wrap;
- gap: 24px;
-
- > .tn-card {
- flex: 1 1 320px;
- }
-}
-
.orientation-illustration {
width: 170px;
height: 130px;
@@ -132,170 +122,3 @@
}
}
-.old-layout-illustration {
- width: 170px;
- height: 130px;
- border: 1px solid var(--main-border-color);
- border-radius: 6px;
- display: flex;
- background: var(--root-background);
- overflow: hidden;
-
- .launcher-pane {
- width: 10%;
- background: var(--launcher-pane-vert-background-color);
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 1px 0;
-
- svg {
- margin-top: 1px;
- margin-bottom: 5px;
- }
-
- .tn-icon {
- margin: 4px 0;
- font-size: 12px;
- opacity: 0.5;
- }
- }
-
- .tree {
- width: 20%;
- font-size: 4px;
- padding: 12px 5px;
- overflow: hidden;
- flex-shrink: 0;
- filter: blur(1px);
-
- ul {
- list-style-type: none;
- margin: 0;
- padding: 0;
- }
- }
-
- .main {
- display: flex;
- flex-direction: column;
- flex-grow: 1;
- font-size: 8px;
-
- .tab-bar {
- height: 10px;
- flex-shrink: 0;
- }
-
- .content {
- padding-inline-start: 6px;
- background-color: var(--main-background-color);
- flex-grow: 1;
- border-top-left-radius: 6px;
- display: flex;
- flex-direction: column;
- min-height: 0;
-
- .title-bar {
- display: flex;
- align-items: center;
- font-size: 14px;
- padding: 5px;
-
- .title {
- margin-inline-start: 4px;
- flex-grow: 1;
- font-size: 12px;
- }
- }
-
- .ribbon {
- padding: 0 5px;
-
- .tn-icon {
- font-size: 10px;
- }
-
- .ribbon-header {
- display: flex;
- gap: 3px;
- }
-
- .ribbon-body {
- border: 0 solid var(--main-text-color);
- border-top-width: 1px;
- border-bottom-width: 1px;
- margin: 2px 0;
-
- .ribbon-body-content {
- height: 4px;
- margin-block: 4px;
- background: repeating-linear-gradient(90deg, currentColor, currentColor 10px, transparent 10px, transparent 22px);
- opacity: .5;
- }
- }
- }
-
- .note-header {
- display: flex;
- flex-direction: column;
- padding-inline: 2px;
-
- .note-toolbar {
- align-self: flex-end;
- }
-
- .note-inline-title {
- display: flex;
- align-items: center;
- padding-bottom: 4px;
-
- .note-icon {
- display: flex;
- width: 22px;
- height: 22px;
- justify-content: center;
- align-items: center;
- border-radius: 50%;
- background: var(--note-icon-hover-background-color);
- font-size: 12px;
- color: var(--note-icon-color);
- }
-
- .note-title-row {
- margin-inline-start: 4px;
- line-height: 1;
-
- .title {
- font-size: 11px;
- }
-
- .subtitle {
- font-size: 6px;
- opacity: .5;
- }
- }
- }
- }
-
- .content-inner {
- font-size: 6px;
- overflow: hidden;
- padding: 5px;
- opacity: 0.5;
- filter: blur(1px);
- }
-
- .status-bar {
- background-color: var(--left-pane-background-color);
- flex-shrink: 0;
- padding: 0 2px;
- display: flex;
-
- &> .status-bar-breadcrumb {
- flex-grow: 1;
- }
- }
- }
- }
-}
diff --git a/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx b/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx
index fb8fe86e11..7cc8615754 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx
@@ -8,7 +8,7 @@ const mocks = vi.hoisted(() => ({
stored: {} as Record<string, string | boolean>
}));
-// Both the desktop card and the illustrated layout choices turn on which kind of client this is.
+// Both the desktop card and the illustrated orientation choice turn on which kind of client this is.
vi.mock("../../../services/utils", async (importOriginal) => ({
...(await importOriginal<typeof import("../../../services/utils")>()),
isElectron: () => mocks.electron,
@@ -70,28 +70,18 @@ function open() {
}
-describe("the layout choices", () => {
- it("gives each an illustrated card of its own, side by side", () => {
+describe("the layout orientation", () => {
+ it("is offered as an illustrated card, but not on a phone", () => {
open();
+ expect(host.querySelector(".thumbnail-selector-option-card .orientation-illustration")).not.toBeNull();
+ expect(host.querySelectorAll(".radio-with-illustration")).toHaveLength(1);
- const cards = [ ...host.querySelectorAll(".appearance-layout-choices .tn-card") ];
- expect(cards).toHaveLength(2);
- expect(cards.every((card) => card.className.includes("thumbnail-selector-option-card"))).toBe(true);
- expect(host.querySelectorAll(".appearance-layout-choices .radio-with-illustration")).toHaveLength(2);
- });
-
- it("offers neither on a phone, where the window has no shape to choose", () => {
mocks.mobile = true;
open();
-
- expect(host.querySelector(".appearance-layout-choices")).toBeNull();
+ expect(host.querySelector(".orientation-illustration")).toBeNull();
});
- it("offers the edited notes setting on both layouts", () => {
- open();
- expect(host.querySelector("input.switch-toggle[id^='edited-notes-open-in-ribbon-']")).not.toBeNull();
-
- mocks.stored = { newLayout: true };
+ it("comes with the edited notes setting", () => {
open();
expect(host.querySelector("input.switch-toggle[id^='edited-notes-open-in-ribbon-']")).not.toBeNull();
});
diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsx
index a41606b910..660811c063 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance.tsx
+++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx
@@ -6,8 +6,7 @@ import zoomService from "../../../components/zoom";
import { ColorScheme, resolveColorScheme, THEME_FAMILY_SCHEMES } from "../../../services/color_scheme";
import { t } from "../../../services/i18n";
import server from "../../../services/server";
-import { isElectron, isMobile, reloadFrontendApp } from "../../../services/utils";
-import { VerticalLayoutIcon } from "../../buttons/global_menu";
+import { isElectron, isMobile } from "../../../services/utils";
import { Card, CardSection, OptionCardSection } from "../../react/Card";
import Dropdown from "../../react/Dropdown";
import { FormListHeader, FormListItem } from "../../react/FormList";
@@ -72,7 +71,7 @@ export default function AppearanceSettings() {
<>
<OptionsPageHeader />
<UserInterface />
- {!isMobile() && <LayoutChoices />}
+ {!isMobile() && <LayoutOrientation />}
<Fonts />
{isElectron() && <ElectronIntegration /> }
<Performance />
@@ -194,45 +193,6 @@ function UserInterface() {
);
}
-/**
- * The two choices that decide the shape of the window, each shown as a picture rather than named in
- * words. Neither fits a settings row — an illustration is too large to stand as a value beside a
- * label — so each takes a card of its own, with what the choice is called as the card's heading.
- *
- * Side by side, being read against one another rather than one after the other; a pane too narrow to
- * hold both puts them on lines of their own instead (see the CSS).
- */
-function LayoutChoices() {
- return (
- <div className="appearance-layout-choices">
- <LayoutOrientation />
- <LayoutStyle />
- </div>
- );
-}
-
-function LayoutStyle() {
- const [ newLayout, setNewLayout ] = useTriliumOptionBool("newLayout");
-
- return (
- <Card className="thumbnail-selector-option-card" heading={t("settings_appearance.ui_layout_style")}>
- <CardSection>
- <RadioWithIllustration
- currentValue={newLayout ? "new-layout" : "old-layout"}
- onChange={async newValue => {
- await setNewLayout(newValue === "new-layout");
- reloadFrontendApp();
- }}
- values={[
- { key: "old-layout", text: t("settings_appearance.ui_old_layout"), illustration: <LayoutIllustration /> },
- { key: "new-layout", text: t("settings_appearance.ui_new_layout"), illustration: <LayoutIllustration isNewLayout /> }
- ]}
- />
- </CardSection>
- </Card>
- );
-}
-
function LayoutOrientation() {
const [ layoutOrientation, setLayoutOrientation ] = useTriliumOption("layoutOrientation", true);
@@ -252,98 +212,6 @@ function LayoutOrientation() {
);
}
-function LayoutIllustration({ isNewLayout }: { isNewLayout?: boolean }) {
- return (
- <div className="old-layout-illustration">
- <div className="launcher-pane">
- <VerticalLayoutIcon />
- <Icon icon="bx bx-send" />
- <Icon icon="bx bx-file-blank" />
- <Icon icon="bx bx-search" />
- </div>
-
- <div className="tree">
- <ul>
- <li>Options</li>
- <ul>
- <li>Appearance</li>
- <li>Shortcuts</li>
- <li>Text Notes</li>
- <li>Code Notes</li>
- <li>Images</li>
- </ul>
- </ul>
- </div>
-
- <div className="main">
- <div className="tab-bar" />
-
- <div className="content">
-
- {(isNewLayout) ? (
- <div className="note-header">
- <div className="note-toolbar">
- <Icon icon="bx bx-dock-right" />
- </div>
- <div className="note-inline-title">
- <Icon className="note-icon" icon="bx bx-leaf" />
- <div className="note-title-row">
- <div className="title">Title</div>
- <div className="subtitle">Just a sample note</div>
- </div>
- </div>
- </div>
- ) : (
- <div>
- <div className="title-bar">
- <Icon icon="bx bx-leaf" />
- <span className="title">Title</span>
- <Icon icon="bx bx-dock-right" />
- </div>
- </div>
- )}
-
- {!isNewLayout && <div className="ribbon">
- <div className="ribbon-header">
- <Icon icon="bx bx-slider" />
- <Icon icon="bx bx-list-check" />
- <Icon icon="bx bx-list-plus" />
- <Icon icon="bx bx-collection" />
- </div>
-
- <div className="ribbon-body">
- <div className="ribbon-body-content" />
- </div>
- </div>}
-
- {isNewLayout && <div className="note-title-actions">
- <Icon icon="bx bx-chevron-down" />{" "}Promoted attributes
- </div>}
-
- <div className="content-inner">
- This is a "demo" document packaged with Trilium to showcase some of its features and also give you some ideas on how you might structure your notes. You can play with it, and modify the note content and tree structure as you wish.
- </div>
-
- {isNewLayout && <div className="status-bar">
- <div className="status-bar-breadcrumb">
- <Icon icon="bx bx-home" />
- <Icon icon="bx bx-chevron-right" />
- Note
- <Icon icon="bx bx-chevron-right" />
- Note
- </div>
-
- <div className="status-bar-actions">
- <Icon icon="bx bx-list-check" />
- <Icon icon="bx bx-info-circle" />
- </div>
- </div>}
- </div>
- </div>
- </div>
- );
-}
-
function OrientationIllustration({ orientation }: { orientation: "vertical" | "horizontal" }) {
const isHorizontal = orientation === "horizontal";
diff --git a/packages/commons/src/lib/options_interface.ts b/packages/commons/src/lib/options_interface.ts
index d6ce6cc679..44847581bc 100644
--- a/packages/commons/src/lib/options_interface.ts
+++ b/packages/commons/src/lib/options_interface.ts
@@ -290,7 +290,6 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi
/** Whether copying note content embeds internal images as data: URIs so they paste into external apps (internal paste stays reference-based). Hidden kill-switch. */
clipboardImageEmbedEnabled: boolean;
backgroundEffects: boolean;
- newLayout: boolean;
// PDF settings
/**
diff --git a/packages/trilium-core/src/routes/api/options.ts b/packages/trilium-core/src/routes/api/options.ts
index 50b423655e..e9fb037f99 100644
--- a/packages/trilium-core/src/routes/api/options.ts
+++ b/packages/trilium-core/src/routes/api/options.ts
@@ -151,7 +151,6 @@ const ALLOWED_OPTIONS = new Set<OptionNames>([
"splitEditorOrientation",
"seenCallToActions",
"experimentalFeatures",
- "newLayout",
"mfaMethod",
// LLM options
"aiEnabled",
diff --git a/packages/trilium-core/src/services/options_init.ts b/packages/trilium-core/src/services/options_init.ts
index c9216a64b8..91edf987b9 100644
--- a/packages/trilium-core/src/services/options_init.ts
+++ b/packages/trilium-core/src/services/options_init.ts
@@ -267,7 +267,6 @@ const defaultOptions: DefaultOption[] = [
{ name: "backdropEffectsEnabled", value: "true", isSynced: false },
{ name: "smoothScrollEnabled", value: "true", isSynced: false },
{ name: "hardwareAccelerationEnabled", value: "true", isSynced: false },
- { name: "newLayout", value: "true", isSynced: true },
// PDF
{ name: "pdfSignatures", value: "{}", isSynced: true },