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
chore(llm): update system prompt regarding Electron management
Elian Doran7bde730b563f
diff --git a/CLAUDE.md b/CLAUDE.mdindex aece6c70f9..e3927428a3 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -212,8 +212,14 @@ SQLite via `better-sqlite3`. SQL abstraction in `packages/trilium-core/src/servi### Electron Desktop App- Desktop entry point: `apps/desktop/src/main.ts`, window management: `apps/server/src/services/window.ts`-- IPC communication: use `electron.ipcMain.on(channel, handler)` on server side, `electron.ipcRenderer.send(channel, data)` on client side+- **Security**: `nodeIntegration` is **disabled** and `contextIsolation` is **enabled**. The renderer has no access to Node.js APIs or Electron internals.+- **Preload script** (`apps/desktop/src/preload.ts`): Uses `contextBridge.exposeInMainWorld("electronApi", ...)` to expose a whitelisted API to the renderer. Compiled to CJS via esbuild (dev: `scripts/electron-start.mts`, prod: `apps/desktop/scripts/build.ts`).+- **ElectronApi interface** (`packages/commons/src/lib/electron_api_interface.ts`): Shared type definition used by both the preload script (`satisfies ElectronApi`) and the client (`window.electronApi`). Grouped into sub-objects: `window`, `clipboard`, `shell`, `contextMenu`, `spellcheck`, `tray`, `printing`, `navigation`.+- **Client-side access**: Use `window.electronApi?.group.method()` — never use `require("electron")` or `dynamicRequire()` in client code.+- **Adding new Electron APIs**: Add the method to the interface in commons, implement it in `preload.ts`, add the IPC handler in `apps/server/src/services/window.ts`, and add a test in `apps/desktop/spec/preload.spec.ts`.+- **IPC handlers**: Use `electron.ipcMain.on(channel, handler)` for fire-and-forget, `electron.ipcMain.handle(channel, handler)` for async request/response, `ipcMain.on` + `event.returnValue` for synchronous queries.- Electron-only features should check `isElectron()` from `apps/client/src/services/utils.ts` (client) or `utils.isElectron` (server)+- **`@electron/remote` is removed** — do not use it. All renderer↔main communication goes through the preload bridge.Three inheritance mechanisms:1. **Standard**: `note.getInheritableAttributes()` walks parent tree