Skip to content

The agent that grows with you

fix(desktop): avoid inactive Windows backdrop

UniversePeakc9f361441d9f
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index f08a536cb90..8d4c8f7c5d5 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -576,6 +576,7 @@ import {
translucencySupportedOn,
vibrancyFor as vibrancyForTranslucency,
windowBackingOptions,
+ windowBackgroundMaterialOptions,
windowOpacityFor,
windowOpacityOptions
} from './translucency'
@@ -1608,7 +1609,7 @@ function chatWindowSurfaceOptions() {
// opts into the documented transparent-window limits — including that a
// RESIZABLE transparent window is unsupported and breaks (electron#48421).
// Every chat window is resizable.
- backgroundMaterial: IS_WINDOWS && GLASS_SUPPORTED ? backgroundMaterialFor(translucencyState) : undefined,
+ ...windowBackgroundMaterialOptions(translucencyState, IS_WINDOWS, GLASS_SUPPORTED),
...windowOpacityOptions(translucencyState),
...windowBackingOptions(translucencyState, getWindowBackgroundColor())
}
diff --git a/apps/desktop/electron/translucency.test.ts b/apps/desktop/electron/translucency.test.ts
index 7ae03c8e0b1..5f4b4fad81c 100644
--- a/apps/desktop/electron/translucency.test.ts
+++ b/apps/desktop/electron/translucency.test.ts
@@ -41,6 +41,7 @@ import {
type TranslucencyState,
translucencySupportedOn,
vibrancyFor,
+ windowBackgroundMaterialOptions,
windowBackingOptions,
windowOpacityFor,
windowOpacityOptions,
@@ -469,6 +470,21 @@ describe('windowBackingOptions', () => {
})
})
+describe('windowBackgroundMaterialOptions', () => {
+ it('omits the Windows backdrop when glass is inactive', () => {
+ expect(windowBackgroundMaterialOptions(glass(0), true, true)).toEqual({})
+ expect(windowBackgroundMaterialOptions(clear(60), true, true)).toEqual({})
+ expect(windowBackgroundMaterialOptions(glass(60), false, true)).toEqual({})
+ expect(windowBackgroundMaterialOptions(glass(60), true, false)).toEqual({})
+ })
+
+ it('passes the selected backdrop only for active supported Windows glass', () => {
+ expect(windowBackgroundMaterialOptions(glass(60, 'under-window'), true, true)).toEqual({
+ backgroundMaterial: 'acrylic'
+ })
+ })
+})
+
// A glass window on Windows is fully opaque natively — the tint is the
// renderer's and fade defaults to zero — so it used to be handed `opacity: 1`
// on every launch. Electron's Windows setOpacity layers the window before it
diff --git a/apps/desktop/electron/translucency.ts b/apps/desktop/electron/translucency.ts
index deac4ef95df..7979edec26d 100644
--- a/apps/desktop/electron/translucency.ts
+++ b/apps/desktop/electron/translucency.ts
@@ -11,7 +11,13 @@
* then fail to bundle.
*/
-import { glassActive, type TranslucencyState, windowOpacityFor } from '../../shared/src/translucency'
+import {
+ backgroundMaterialFor,
+ glassActive,
+ type TranslucencyState,
+ type WindowsBackgroundMaterial,
+ windowOpacityFor
+} from '../../shared/src/translucency'
export {
backgroundMaterialFor,
@@ -73,6 +79,21 @@ export function windowBackingOptions(state: TranslucencyState, themedColor: stri
return glassActive(state) ? {} : { backgroundColor: themedColor }
}
+/**
+ * Return the native Windows backdrop only when glass is actually active.
+ * Electron treats even the `none` backdrop as a translucent-window opt-in,
+ * which disables native maximize and resize commands on Windows.
+ */
+export function windowBackgroundMaterialOptions(
+ state: TranslucencyState,
+ isWindows: boolean,
+ glassSupported: boolean
+): { backgroundMaterial?: WindowsBackgroundMaterial } {
+ return isWindows && glassSupported && glassActive(state)
+ ? { backgroundMaterial: backgroundMaterialFor(state) }
+ : {}
+}
+
/**
* Whether a window's native opacity is worth setting at all.
*