Skip to content

The agent that grows with you

refactor(desktop): register the preferences IPC from main, beside the local-skin pre-paint read

Teknium170ff2344c64
diff --git a/apps/desktop/electron/fs-ipc.ts b/apps/desktop/electron/fs-ipc.ts
index 6b90af62d6f..a70a1cf8459 100644
--- a/apps/desktop/electron/fs-ipc.ts
+++ b/apps/desktop/electron/fs-ipc.ts
@@ -21,7 +21,6 @@ import { DESKTOP_PROFILE_NAME_RE } from './desktop-profile'
import { readDirForIpc } from './fs-read-dir'
import { gitRootForIpc } from './git-root'
import { registerPluginFilesIpc } from './plugin-files-ipc'
-import { registerUiPreferencesIpc } from './ui-preferences'
export interface FsIpcDeps {
hermesHome: string
@@ -63,18 +62,6 @@ export function registerFsIpc({
trashItem: target => shell.trashItem(target)
})
- // The machine's UI preferences file beside the root home (#145213), shared
- // with this machine's Webapp. `hermesHome` is already the root, never a profile.
- registerUiPreferencesIpc({
- ipcMain,
- hermesHome,
- broadcast: snapshot => {
- for (const window of BrowserWindow.getAllWindows()) {
- window.webContents.send('hermes:ui-preferences:changed', snapshot)
- }
- }
- })
-
ipcMain.handle('hermes:fs:gitRoot', async (_event, startPath) => gitRootForIpc(startPath))
// Reveal a path in the OS file manager (Finder / Explorer / Files).
diff --git a/apps/desktop/electron/local-skin.ts b/apps/desktop/electron/local-skin.ts
index 3883c42929e..b601e42b90f 100644
--- a/apps/desktop/electron/local-skin.ts
+++ b/apps/desktop/electron/local-skin.ts
@@ -190,3 +190,25 @@ export function readLocalSkinPayload(
return skin ? { profile, skin } : null
}
+
+interface LocalSkinIpcMain {
+ on(channel: string, listener: (event: { returnValue: unknown; sender: { id: number } }) => void): void
+}
+
+/**
+ * The preload reads this small, sanitized payload synchronously so the renderer
+ * can register the local skin before its first theme paint. It stays independent
+ * of the selected gateway, which can be an offline remote primary. The window
+ * route is more specific than the global next-launch preference: a peer can be
+ * booting another profile while that preference changes.
+ */
+export function registerLocalSkinIpc(
+ ipcMain: LocalSkinIpcMain,
+ hermesHome: string,
+ windowProfile: (senderId: number) => null | string | undefined,
+ primaryProfile: () => null | string | undefined
+): void {
+ ipcMain.on('hermes:skin:local', event => {
+ event.returnValue = readLocalSkinPayload(hermesHome, windowProfile(event.sender.id), primaryProfile())
+ })
+}
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 5de9f7917b3..5d5a921b9f8 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -349,7 +349,7 @@ import { relaunchIfNoSandboxCameTooLate } from './linux-sandbox-relaunch'
import { createLocalBackendLifecycle, waitForTeardown } from './local-backend-lifecycle'
import { resolveIpcFileReadPath, resolveMediaStreamFile, resolvePreviewTargetPath } from './local-read-path'
import { resolveDesktopClientVersion } from './local-runtime-version'
-import { localSkinProfileKey, readLocalSkinPayload } from './local-skin'
+import { localSkinProfileKey, registerLocalSkinIpc } from './local-skin'
import { ACTIVE_LOG_POLL_MS, planLogRotation, reclaimActiveLogIfOversized } from './log-rotation'
import { registerMachineProfile } from './machine-profile'
import { createMainProcessLagWatchdog } from './main-process-lag-watchdog'
@@ -589,6 +589,7 @@ import {
windowOpacityFor,
windowOpacityOptions
} from './translucency'
+import { registerMachineUiPreferences } from './ui-preferences-ipc'
import {
UPDATE_HANDOFF_DWELL_MS,
UPDATE_WAIT_POLL_MS,
@@ -17074,18 +17075,10 @@ ipcMain.on('hermes:logs:renderer-error', (_event, report) => {
flushDesktopLogBufferSync()
})
-// The preload reads this small, sanitized payload synchronously so the renderer
-// can register the local skin before its first theme paint. It stays independent
-// of the selected gateway, which can be an offline remote primary.
-ipcMain.on('hermes:skin:local', event => {
- // The window route is more specific than the global next-launch preference:
- // a peer can be booting another profile while that preference changes.
- event.returnValue = readLocalSkinPayload(
- HERMES_HOME,
- windowConnectionRoutes.get(event.sender.id)?.profile,
- primaryProfileKey()
- )
-})
+// Pre-paint payloads the preload reads synchronously: the local skin, and this
+// machine's shared UI preferences (#145213) — see local-skin.ts, ui-preferences.ts.
+registerLocalSkinIpc(ipcMain, HERMES_HOME, id => windowConnectionRoutes.get(id)?.profile, primaryProfileKey)
+registerMachineUiPreferences(HERMES_HOME)
// Renderer error toasts (notifyError): the toast shows the summarized copy,
// so the caller posts the full error here for desktop.log. Fire-and-forget,
diff --git a/apps/desktop/electron/ui-preferences-ipc.ts b/apps/desktop/electron/ui-preferences-ipc.ts
new file mode 100644
index 00000000000..253cabc42f9
--- /dev/null
+++ b/apps/desktop/electron/ui-preferences-ipc.ts
@@ -0,0 +1,19 @@
+// Wires the machine's UI preferences store (ui-preferences.ts) into Electron:
+// every app window hears about a change, whoever made it.
+import { BrowserWindow, ipcMain } from 'electron'
+
+import { registerUiPreferencesIpc } from './ui-preferences'
+
+/** `hermesHome` is main's resolved ROOT home (never a profile's), the one the
+ * Webapp's Python server resolves too. */
+export function registerMachineUiPreferences(hermesHome: string): () => void {
+ return registerUiPreferencesIpc({
+ ipcMain,
+ hermesHome,
+ broadcast: snapshot => {
+ for (const window of BrowserWindow.getAllWindows()) {
+ window.webContents.send('hermes:ui-preferences:changed', snapshot)
+ }
+ }
+ })
+}
diff --git a/website/docs/user-guide/desktop.md b/website/docs/user-guide/desktop.md
index a3f1636cd9d..5019cfd57ee 100644
--- a/website/docs/user-guide/desktop.md
+++ b/website/docs/user-guide/desktop.md
@@ -406,6 +406,12 @@ Manage providers, models, tools, and credentials from a real UI instead of editi
First-run onboarding has been redesigned on a unified overlay design system, and you can pick **Choose provider later** to skip provider setup and get into the app first.
+#### Where your display preferences live
+
+Display preferences (theme and light/dark mode, session-list density and sidebar layout, status-bar readouts, transcript and tool display, sounds, keybinds, saved layouts, and model-picker favourites) are stored once per computer, in `ui-preferences.json` in the root Hermes home (`~/.hermes/ui-preferences.json` by default; with a custom `HERMES_HOME`, the root of that home, never a profile folder). The desktop app on that computer and every browser that opens the [Webapp](#use-the-desktop-workspace-from-a-browser) it serves read and write the same file. A change in one reaches the others: the desktop app's windows get it within a couple of seconds and Webapp tabs when they regain focus or within about ten seconds. Theme, mode, density and the other settings an open window already follows across windows repaint at once; the rest apply the next time a window or tab loads. This includes another device, a private window, and another address for the same Webapp (`127.0.0.1`, the LAN address, `webapp.public_url`).
+
+The file belongs to the computer, not to a gateway connection or a profile. A desktop app connected to a remote gateway, or to several gateways, keeps its own computer's preferences. Settings that are already per profile, such as the theme picked for one profile, stay per profile inside the file. Credentials, sign-ins, permission grants, drafts and per-window state (open tabs, pane layout, scroll position, zoom) are never written to it and stay in each window or browser. The first time an app or browser finds no file, it copies its existing settings into a new one. After that it never overwrites the file; it adopts the values already there.
+
#### Per-profile settings: the "Applies to" scope
When you have two or more [profiles](./profiles.md), the config-backed settings pages — **Model, Workspace, Safety, Memory & Context, Voice, Chat, Advanced, and Tools & Keys** — plus **Providers → Custom Endpoints** and the **Messaging** overlay show a shared **Applies to** chip row at the top. It selects which profile your edits target: