Skip to content

The agent that grows with you

fix(desktop): resolve hidden translucency to off so Linux heals on launch

Teknium8da9e0b4329a
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index a1fdb2cbbf0..abc2ec1c8ba 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -738,8 +738,8 @@ const DARWIN_MAJOR = IS_MAC ? Number.parseInt(os.release(), 10) || 0 : 0
// Glass: macOS vibrancy, or Windows 11 22H2+ system backdrop. Computed once
// so the renderer, the persisted default, and every chat window agree.
const GLASS_SUPPORTED = glassSupportedOn(process.platform, os.release())
-// Clear rides setOpacity, a documented no-op on Linux, so neither mode works
-// there and Settings drops the row entirely.
+// Linux has no glass material and Settings drops the whole row there, so a
+// Linux window must never be handed a fade (see nativeOpacityFor).
const TRANSLUCENCY_SUPPORTED = translucencySupportedOn(process.platform)
const APP_ROOT = app.getAppPath()
diff --git a/apps/desktop/src/store/translucency.linux.test.ts b/apps/desktop/src/store/translucency.linux.test.ts
new file mode 100644
index 00000000000..0fd0d0b962c
--- /dev/null
+++ b/apps/desktop/src/store/translucency.linux.test.ts
@@ -0,0 +1,44 @@
+// @vitest-environment jsdom
+import { describe, expect, it, vi } from 'vitest'
+
+// Linux, as the preload bridge reports it: neither glass nor translucency.
+// Pinned before the store module evaluates (hoisted above the imports) so
+// TRANSLUCENCY_SUPPORTED resolves false, and the bridge records every state
+// the renderer hands main.
+const sent = vi.hoisted(() => {
+ const calls: unknown[] = []
+
+ Object.defineProperty(globalThis.navigator, 'platform', { configurable: true, value: 'Linux x86_64' })
+ Object.defineProperty(globalThis.window, 'hermesDesktop', {
+ configurable: true,
+ value: {
+ glassSupported: false,
+ translucencySupported: false,
+ setTranslucency: (state: unknown) => calls.push(state)
+ }
+ })
+
+ return calls
+})
+
+import { type TranslucencyState, windowOpacityFor } from '@hermes/shared/translucency'
+
+import { $translucency, setTranslucency, TRANSLUCENCY_SUPPORTED } from './translucency'
+
+// Settings hides the row on Linux, so nothing the store resolves may fade the
+// window: not the 29% platform default an untouched profile lands on, and not
+// a value that arrives from anywhere else.
+describe('translucency where Settings hides the row', () => {
+ it('resolves to an opaque window and tells main exactly that', () => {
+ expect(TRANSLUCENCY_SUPPORTED).toBe(false)
+
+ setTranslucency(60)
+
+ for (const state of [$translucency.get(), ...(sent as TranslucencyState[])]) {
+ expect(windowOpacityFor(state)).toBe(1)
+ }
+
+ expect(sent.length).toBeGreaterThan(0)
+ expect(document.documentElement.hasAttribute('data-hermes-clear')).toBe(false)
+ })
+})
diff --git a/apps/desktop/src/store/translucency.ts b/apps/desktop/src/store/translucency.ts
index a2a665bc755..c2ef7c73e98 100644
--- a/apps/desktop/src/store/translucency.ts
+++ b/apps/desktop/src/store/translucency.ts
@@ -76,9 +76,9 @@ export const GLASS_SUPPORTED =
: isMacPlatform() || isWindowsPlatform())
/**
- * Whether the setting is worth showing at all. Linux has neither half —
- * `setOpacity` is a documented no-op and there is no native material — so
- * Settings hides the row rather than offering a lever that does nothing.
+ * Whether the setting is offered at all. Linux has no native material and
+ * Settings hides the row there, so the setting also resolves to off there
+ * (see `$translucency`): a hidden lever must not move the window.
*/
export const TRANSLUCENCY_SUPPORTED =
!isBrowserHostedDesktop() &&
@@ -117,10 +117,20 @@ export function setAppearance(appearance: Appearance): void {
}
}
-/** The resolved state for the painted appearance — the shape every consumer reads. */
-export const $translucency = computed([$translucencyBook, $appearance], (book, appearance) =>
- resolveTranslucency(book, appearance, isWindowsPlatform())
-)
+/**
+ * The resolved state for the painted appearance — the shape every consumer reads.
+ *
+ * Where Settings hides the row, the setting resolves to off. The platform
+ * defaults (29% tint) would otherwise still resolve there, reach main over IPC
+ * and land in translucency.json, and Electron 44 does fade a Linux window when
+ * handed that value. Resolving to off also rewrites a value an earlier build
+ * persisted, so a stuck profile heals on its first launch.
+ */
+export const $translucency = computed([$translucencyBook, $appearance], (book, appearance) => {
+ const state = resolveTranslucency(book, appearance, isWindowsPlatform())
+
+ return TRANSLUCENCY_SUPPORTED ? state : { ...state, intensity: 0, fade: 0 }
+})
/** Write an edit against the appearance being painted. */
const edit = (patch: Partial<TranslucencyValues>): void => {
diff --git a/apps/shared/src/translucency.ts b/apps/shared/src/translucency.ts
index ed3af92abe0..48153710277 100644
--- a/apps/shared/src/translucency.ts
+++ b/apps/shared/src/translucency.ts
@@ -6,8 +6,9 @@
* shows through:
*
* - 'clear' — the main process maps the lever to native window opacity
- * (`setOpacity`), so the whole window fades, text included. macOS + Windows;
- * `setOpacity` is a no-op on Linux.
+ * (`setOpacity`), so the whole window fades, text included. macOS + Windows
+ * only: Linux hides the setting, so it must never fade a Linux window, even
+ * though Electron 44 does honour `setOpacity` there.
* - 'glass' — the window stays fully opaque at the native level and the
* renderer thins its page surfaces instead, letting a platform material
* read as a matte blur while text keeps full contrast. macOS rides
@@ -194,10 +195,9 @@ export function clampIntensity(value: unknown): number {
}
/**
- * Whether this OS can do ANY translucency. Clear rides `setOpacity`, which
- * Electron documents as doing nothing on Linux, and glass needs a native
- * material Linux does not have — so the whole setting is dead there and the
- * row should not be shown at all.
+ * Whether this OS offers translucency at all. Glass needs a native material
+ * Linux does not have, so Settings hides the row there — and a hidden setting
+ * must also have no effect, so both processes resolve it to off on Linux.
*/
export function translucencySupportedOn(platform: string): boolean {
return platform === 'darwin' || platform === 'win32'