The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): glass was blocked by the webContents backing and two app-shell painters
SHL0MS1eb9cbdb7a12
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 1688c77d915..c762c70f6e5 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -288,7 +288,7 @@ import {} from './ssh-connection'import { createStreamThrottle } from './stream-throttle'import { nativeOverlayWidth as computeNativeOverlayWidth, macTitleBarOverlayHeight } from './titlebar-overlay-width'-import { normalizePayload as normalizeTranslucencyPayload, windowOpacityFor } from './translucency'+import { glassActive, normalizePayload as normalizeTranslucencyPayload, windowOpacityFor } from './translucency'import {compareApiUrl,parseCompareBehindCount,@@ -902,24 +902,50 @@ function writePersistedTranslucency(state) {let translucencyState = readPersistedTranslucency()+// Chat windows whose webContents backing follows translucency (primary,+// instance peers, session windows). The HUD / pet overlay / quick entry /+// wake indicator are `transparent: true` windows that own their backgrounds —+// painting a themed backing onto them would turn them into opaque rectangles.+const translucencyBackedWindows = new WeakSet()+function windowOpacity() {return windowOpacityFor(translucencyState.intensity, translucencyState.mode)}// Re-apply translucency to a live window (runtime toggle, no recreation).// `setOpacity` is a no-op on Linux, which is fine — it just stays opaque there.+// The backing swap is the glass half: Chromium composites the page against+// `backgroundColor` BEFORE macOS composites the window, so glass needs an+// alpha-0 backing for the vibrancy material to reach a transparent page, and+// every other state needs the opaque themed backing (anti-flash, and it is+// what makes clear mode fade to the desktop instead of to black).function applyWindowTranslucency(win) {- if (!win || win.isDestroyed() || typeof win.setOpacity !== 'function') {+ if (!win || win.isDestroyed()) {return}try {- win.setOpacity(windowOpacity())+ // Backing swap is scoped to registered chat windows (see+ // translucencyBackedWindows above).+ if (translucencyBackedWindows.has(win) && typeof win.setBackgroundColor === 'function') {+ win.setBackgroundColor(glassActive(translucencyState) ? '#00000000' : getWindowBackgroundColor())+ }++ if (typeof win.setOpacity === 'function') {+ win.setOpacity(windowOpacity())+ }} catch (error) {rememberLog(`[translucency] apply failed: ${error.message}`)}}+// Window creation: glass windows must be BORN with a transparent backing —+// flipping backgroundColor after creation repaints, but the first frames of a+// cold glass launch would flash the opaque backing first.+function initialWindowBackgroundColor() {+ return glassActive(translucencyState) ? '#00000000' : getWindowBackgroundColor()+}+function isHexColor(value) {return typeof value === 'string' && /^#[0-9a-f]{6}$/i.test(value)}@@ -10653,10 +10679,14 @@ function spawnSecondaryWindow({ sessionId, watch }: { sessionId?: string; watch?// covers it. ready-to-show fires after the boot-time paint in// themes/context.tsx, so the window appears already themed.show: false,- backgroundColor: getWindowBackgroundColor(),+ backgroundColor: initialWindowBackgroundColor(),webPreferences: chatWindowWebPreferences(PRELOAD_PATH)})+ // Chat-surface registration: applyWindowTranslucency swaps this window's+ // backing between opaque-themed and alpha-0 when glass toggles.+ translucencyBackedWindows.add(win)+if (IS_MAC) {win.setWindowButtonPosition?.(WINDOW_BUTTON_POSITION)}@@ -10747,12 +10777,15 @@ function createInstanceWindow() {opacity: windowOpacity(),icon,show: false,- backgroundColor: getWindowBackgroundColor(),+ backgroundColor: initialWindowBackgroundColor(),webPreferences: chatWindowWebPreferences(PRELOAD_PATH)})instanceWindows.add(win)+ // Chat-surface registration: see applyWindowTranslucency.+ translucencyBackedWindows.add(win)+if (IS_MAC) {win.setWindowButtonPosition?.(WINDOW_BUTTON_POSITION)}@@ -11611,7 +11644,7 @@ function createWindow() {// `backgroundColor` and follows the OS appearance) can't flash a light// material before the renderer paints the app theme. See createSessionWindow.show: false,- backgroundColor: getWindowBackgroundColor(),+ backgroundColor: initialWindowBackgroundColor(),// Shared with the secondary session windows (chatWindowWebPreferences);// stream-aware throttling is applied per-window via streamThrottle so a// live answer keeps painting while the window is blurred or minimized,@@ -11622,6 +11655,9 @@ function createWindow() {const createdMainWindow = mainWindow+ // Chat-surface registration: see applyWindowTranslucency.+ translucencyBackedWindows.add(mainWindow)+if (IS_MAC) {mainWindow.setWindowButtonPosition?.(WINDOW_BUTTON_POSITION)diff --git a/apps/desktop/electron/translucency.test.ts b/apps/desktop/electron/translucency.test.tsindex 17a6f4a002a..e8a2625ebd1 100644--- a/apps/desktop/electron/translucency.test.ts+++ b/apps/desktop/electron/translucency.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest'-import { clampIntensity, normalizeMode, normalizePayload, windowOpacityFor } from './translucency'+import { clampIntensity, glassActive, normalizeMode, normalizePayload, windowOpacityFor } from './translucency'describe('clampIntensity', () => {it('clamps to 0-100 and rounds', () => {@@ -62,3 +62,11 @@ describe('normalizePayload', () => {expect(normalizePayload({ intensity: 'x', mode: 'glass' }, false)).toEqual({ intensity: 0, mode: 'clear' })})})++describe('glassActive', () => {+ it('is on only for glass with nonzero intensity', () => {+ expect(glassActive({ intensity: 60, mode: 'glass' })).toBe(true)+ expect(glassActive({ intensity: 0, mode: 'glass' })).toBe(false)+ expect(glassActive({ intensity: 60, mode: 'clear' })).toBe(false)+ })+})diff --git a/apps/desktop/electron/translucency.ts b/apps/desktop/electron/translucency.tsindex acf38becd78..407a8813aae 100644--- a/apps/desktop/electron/translucency.ts+++ b/apps/desktop/electron/translucency.ts@@ -47,3 +47,15 @@ export function normalizePayload(payload: unknown, isMac: boolean): { intensity:mode: normalizeMode(record.mode, isMac)}}++/**+ * Whether glass is visually active. Decides the chat windows' webContents+ * backing: Chromium composites the page against the window's backgroundColor+ * BEFORE macOS composites the window, so an opaque backing (the normal+ * anti-white-flash paint) blocks the vibrancy material even under a fully+ * transparent page. Glass needs an alpha-0 backing; any other state keeps the+ * opaque themed backing.+ */+export function glassActive(state: { intensity: number; mode: TranslucencyMode }): boolean {+ return state.mode === 'glass' && state.intensity > 0+}diff --git a/apps/desktop/src/app/contrib/controller.tsx b/apps/desktop/src/app/contrib/controller.tsxindex ff5b21b56d0..f14f957c33a 100644--- a/apps/desktop/src/app/contrib/controller.tsx+++ b/apps/desktop/src/app/contrib/controller.tsx@@ -747,6 +747,12 @@ export function ContribController() {<ShellContextMenu><divclassName="flex h-screen min-h-0 w-screen flex-col bg-(--ui-bg-chrome) text-(--ui-text-primary)"+ // Window-glass hook: this div and the sidebar-wrapper above it are+ // the app shell's two full-window opaque painters; the+ // [data-hermes-glass] rules in styles.css clear them so the tint+ // painted by <body> is the only thing between the page and the+ // vibrancy material.+ data-contrib-shell=""style={{ '--titlebar-height': '0px' } as CSSProperties}>{/* Title bar: fixed chrome outside the grid, composable via slots.diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.cssindex 5b57159241c..1f2edb46246 100644--- a/apps/desktop/src/styles.css+++ b/apps/desktop/src/styles.css@@ -595,6 +595,16 @@background: color-mix(in srgb, var(--ui-bg-chrome) var(--translucency-glass-keep, 100%), transparent);}+ /* The app shell's two full-window opaque painters (the contrib controller+ root and the SidebarProvider wrapper) sit between <body> and every+ surface. Their fills are Tailwind utilities (bg-(--ui-bg-chrome) /+ bg-background), which cascade-layer above these base rules — hence the+ !important. Clearing them makes <body> the window's only field paint. */+ :root[data-hermes-glass] [data-contrib-shell],+ :root[data-hermes-glass] [data-slot='sidebar-wrapper'] {+ background-color: transparent !important;+ }+/* Surfaces that MASK sibling content must stay filled under glass — asee-through mask reads as text bleeding through text, not as glass. Thediff panel's sticky line-number gutter wears the editor surface