The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): glass cold launch — omit backgroundColor instead of alpha-0
SHL0MS985db37cadb8
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex c762c70f6e5..00180eb6349 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -288,7 +288,12 @@ import {} from './ssh-connection'import { createStreamThrottle } from './stream-throttle'import { nativeOverlayWidth as computeNativeOverlayWidth, macTitleBarOverlayHeight } from './titlebar-overlay-width'-import { glassActive, normalizePayload as normalizeTranslucencyPayload, windowOpacityFor } from './translucency'+import {+ glassActive,+ normalizePayload as normalizeTranslucencyPayload,+ windowBackingOptions,+ windowOpacityFor+} from './translucency'import {compareApiUrl,parseCompareBehindCount,@@ -915,10 +920,18 @@ function windowOpacity() {// 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+// the window backing BEFORE macOS composites the window, so glass needs the+// backing dropped 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).+//+// CAUTION (measured, macOS 26 / Electron 40): a runtime+// setBackgroundColor('#00000000') is silently LOST on a window whose+// compositor hasn't been up for a few seconds — including calls from+// 'ready-to-show' and 'did-finish-load'. Cold launches therefore must not+// rely on this path: windows are BORN with the right backing+// (windowBackingOptions at each creation site). This path only has to cover+// live toggles from Settings, where the window is long settled.function applyWindowTranslucency(win) {if (!win || win.isDestroyed()) {return@@ -939,11 +952,13 @@ function applyWindowTranslucency(win) {}}-// 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()+// Constructor backing for a chat window under the CURRENT translucency state:+// glass omits backgroundColor so vibrancy shows from the first frame (a+// non-transparent window silently ignores constructor alpha, and runtime+// swaps are lost early in a window's life — see applyWindowTranslucency);+// otherwise the opaque themed anti-flash backing.+function chatWindowBackingOptions() {+ return windowBackingOptions(translucencyState, getWindowBackgroundColor())}function isHexColor(value) {@@ -10679,7 +10694,7 @@ 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: initialWindowBackgroundColor(),+ ...chatWindowBackingOptions(),webPreferences: chatWindowWebPreferences(PRELOAD_PATH)})@@ -10777,7 +10792,7 @@ function createInstanceWindow() {opacity: windowOpacity(),icon,show: false,- backgroundColor: initialWindowBackgroundColor(),+ ...chatWindowBackingOptions(),webPreferences: chatWindowWebPreferences(PRELOAD_PATH)})@@ -11644,7 +11659,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: initialWindowBackgroundColor(),+ ...chatWindowBackingOptions(),// 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,diff --git a/apps/desktop/electron/translucency.test.ts b/apps/desktop/electron/translucency.test.tsindex e8a2625ebd1..ef69b2a90ac 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, glassActive, normalizeMode, normalizePayload, windowOpacityFor } from './translucency'+import { clampIntensity, glassActive, normalizeMode, normalizePayload, windowBackingOptions, windowOpacityFor } from './translucency'describe('clampIntensity', () => {it('clamps to 0-100 and rounds', () => {@@ -70,3 +70,17 @@ describe('glassActive', () => {expect(glassActive({ intensity: 60, mode: 'clear' })).toBe(false)})})++describe('windowBackingOptions', () => {+ it('omits backgroundColor entirely while glass is active', () => {+ // Spreading a themed color (even alpha-0) would be silently treated as+ // opaque on a non-transparent window and block the vibrancy material.+ expect(windowBackingOptions({ intensity: 60, mode: 'glass' }, '#111111')).toEqual({})+ })++ it('keeps the themed anti-flash backing otherwise', () => {+ expect(windowBackingOptions({ intensity: 0, mode: 'glass' }, '#111111')).toEqual({ backgroundColor: '#111111' })+ expect(windowBackingOptions({ intensity: 60, mode: 'clear' }, '#111111')).toEqual({ backgroundColor: '#111111' })+ expect(windowBackingOptions({ intensity: 0, mode: 'clear' }, '#f7f7f7')).toEqual({ backgroundColor: '#f7f7f7' })+ })+})diff --git a/apps/desktop/electron/translucency.ts b/apps/desktop/electron/translucency.tsindex 407a8813aae..017c3660780 100644--- a/apps/desktop/electron/translucency.ts+++ b/apps/desktop/electron/translucency.ts@@ -53,9 +53,35 @@ export function normalizePayload(payload: unknown, isMac: boolean): { intensity:* 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+ * transparent page. Glass needs the backing gone; any other state keeps the* opaque themed backing.*/export function glassActive(state: { intensity: number; mode: TranslucencyMode }): boolean {return state.mode === 'glass' && state.intensity > 0}++/**+ * BrowserWindow constructor options for a chat window's backing, given the+ * translucency state at creation time.+ *+ * Glass active → OMIT `backgroundColor` entirely: on a `vibrancy` window the+ * NSVisualEffectView then shows through a transparent page from the first+ * frame. Passing an alpha color instead does NOT work — the docs only support+ * constructor alpha with `transparent: true`, and `#00000000` on a normal+ * window is quietly treated as opaque.+ *+ * Glass inactive → the opaque themed backing (anti-flash paint before the+ * renderer's first paint, and what clear mode fades against).+ *+ * A runtime `setBackgroundColor` swap (see applyWindowTranslucency in main)+ * only settles reliably on a window that has been compositing for a while —+ * measured on macOS 26/Electron 40: swaps issued during roughly the first+ * seconds of a fresh process were lost, including from 'ready-to-show' and+ * 'did-finish-load' — so creation must not rely on a post-creation fixup.+ */+export function windowBackingOptions(+ state: { intensity: number; mode: TranslucencyMode },+ themedColor: string+): { backgroundColor?: string } {+ return glassActive(state) ? {} : { backgroundColor: themedColor }+}