Skip to content

Build your personal knowledge base with Trilium Notes

refactor(desktop): group tray + autostart IPC under systemIntegration

Elian Doran90d5629f3937
diff --git a/apps/build-docs/src/electron_api_entrypoint.ts b/apps/build-docs/src/electron_api_entrypoint.ts
index dd1a05b4e7..bfc0ee2c8a 100644
--- a/apps/build-docs/src/electron_api_entrypoint.ts
+++ b/apps/build-docs/src/electron_api_entrypoint.ts
@@ -32,7 +32,7 @@ export type {
ElectronPrintingApi,
ElectronShellApi,
ElectronSpellcheckApi,
- ElectronTrayApi,
+ ElectronSystemIntegrationApi,
ElectronWindowApi
} from "../../../packages/commons/src/lib/electron_api_interface.js";
diff --git a/apps/client/src/services/utils.ts b/apps/client/src/services/utils.ts
index 352a682e38..10b647ce86 100644
--- a/apps/client/src/services/utils.ts
+++ b/apps/client/src/services/utils.ts
@@ -33,7 +33,7 @@ export function restartDesktopApp() {
* On any other platform than Electron, nothing happens.
*/
function reloadTray() {
- window.electronApi?.tray.reloadTray();
+ window.electronApi?.systemIntegration.reloadTray();
}
/**
@@ -42,7 +42,7 @@ function reloadTray() {
* On any other platform than Electron, nothing happens.
*/
function reapplyLaunchOnStartup() {
- window.electronApi?.autoLaunch.reapply();
+ window.electronApi?.systemIntegration.reapplyLaunchOnStartup();
}
function parseDate(str: string) {
diff --git a/apps/desktop/src/preload.spec.ts b/apps/desktop/src/preload.spec.ts
index c53ab5667a..d6f17c197b 100644
--- a/apps/desktop/src/preload.spec.ts
+++ b/apps/desktop/src/preload.spec.ts
@@ -371,20 +371,16 @@ describe("preload script", () => {
});
});
- describe("tray", () => {
- const tray = () => getGroup("tray");
+ describe("systemIntegration", () => {
+ const systemIntegration = () => getGroup("systemIntegration");
it("reloadTray sends correct IPC message", () => {
- tray().reloadTray();
+ systemIntegration().reloadTray();
expect(ipcRendererSent).toContainEqual({ channel: "reload-tray", args: [] });
});
- });
-
- describe("autoLaunch", () => {
- const autoLaunch = () => getGroup("autoLaunch");
- it("reapply sends correct IPC message", () => {
- autoLaunch().reapply();
+ it("reapplyLaunchOnStartup sends correct IPC message", () => {
+ systemIntegration().reapplyLaunchOnStartup();
expect(ipcRendererSent).toContainEqual({ channel: "reapply-launch-on-startup", args: [] });
});
});
diff --git a/apps/desktop/src/preload.ts b/apps/desktop/src/preload.ts
index 0dd6a525ec..aee615ef5a 100644
--- a/apps/desktop/src/preload.ts
+++ b/apps/desktop/src/preload.ts
@@ -155,14 +155,11 @@ contextBridge.exposeInMainWorld("electronApi", {
}
},
- tray: {
+ systemIntegration: {
reloadTray() {
ipcRenderer.send("reload-tray");
- }
- },
-
- autoLaunch: {
- reapply() {
+ },
+ reapplyLaunchOnStartup() {
ipcRenderer.send("reapply-launch-on-startup");
}
},
diff --git a/packages/commons/src/lib/electron_api_interface.ts b/packages/commons/src/lib/electron_api_interface.ts
index d23a0dd7fa..876dc3303e 100644
--- a/packages/commons/src/lib/electron_api_interface.ts
+++ b/packages/commons/src/lib/electron_api_interface.ts
@@ -342,16 +342,12 @@ export interface ElectronSpellcheckApi {
getAvailableSpellCheckerLanguages(): string[];
}
-/** System tray controls. */
-export interface ElectronTrayApi {
+/** OS integration controls — system tray and autostart / launch-on-login. */
+export interface ElectronSystemIntegrationApi {
/** Rebuilds the tray icon and menu — call after changing tray-related settings. */
reloadTray(): void;
-}
-
-/** Autostart / launch-on-login controls. */
-export interface ElectronAutoLaunchApi {
- /** Re-applies the OS autostart entry after the `launchOnStartup` option changes. */
- reapply(): void;
+ /** Re-applies the OS autostart entry after the `launchOnStartup` / `hideOnAutoStart` options change. */
+ reapplyLaunchOnStartup(): void;
}
/**
@@ -496,10 +492,8 @@ export interface ElectronApi {
contextMenu: ElectronContextMenuApi;
/** Chromium spell checker controls (dictionary, language list). */
spellcheck: ElectronSpellcheckApi;
- /** System tray menu controls. */
- tray: ElectronTrayApi;
- /** Autostart / launch-on-login controls. */
- autoLaunch: ElectronAutoLaunchApi;
+ /** OS integration — system tray and autostart / launch-on-login. */
+ systemIntegration: ElectronSystemIntegrationApi;
/** Printing and PDF export pipeline. */
printing: ElectronPrintingApi;
/** Read/write access to Chromium's back/forward navigation history. */