From 4af62d000d717b06727b3653cc611ec88a65838c Mon Sep 17 00:00:00 2001 From: fanzzzd Date: Wed, 4 Mar 2026 11:14:26 +0800 Subject: [PATCH 1/2] fix: reapply glass effect after resize --- .../app/hooks/useLiquidGlassEffect.test.tsx | 19 +++++++++++++++++++ .../app/hooks/useLiquidGlassEffect.ts | 17 ++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/features/app/hooks/useLiquidGlassEffect.test.tsx b/src/features/app/hooks/useLiquidGlassEffect.test.tsx index 665ffcbf0..33c59e285 100644 --- a/src/features/app/hooks/useLiquidGlassEffect.test.tsx +++ b/src/features/app/hooks/useLiquidGlassEffect.test.tsx @@ -74,6 +74,25 @@ describe("useLiquidGlassEffect", () => { }); }); + it("reapplies liquid glass after resize", async () => { + vi.mocked(isGlassSupported).mockResolvedValue(true); + + renderHook(() => useLiquidGlassEffect({ reduceTransparency: false })); + + await waitFor(() => { + expect(setLiquidGlassEffect).toHaveBeenCalled(); + }); + const beforeResizeCalls = vi.mocked(setLiquidGlassEffect).mock.calls.length; + + window.dispatchEvent(new Event("resize")); + + await waitFor(() => { + expect(vi.mocked(setLiquidGlassEffect).mock.calls.length).toBeGreaterThan( + beforeResizeCalls, + ); + }); + }); + it("applies Acrylic effect on Windows when liquid glass is unsupported", async () => { vi.mocked(isGlassSupported).mockResolvedValue(false); setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64)"); diff --git a/src/features/app/hooks/useLiquidGlassEffect.ts b/src/features/app/hooks/useLiquidGlassEffect.ts index 8601af0aa..db6a85e1e 100644 --- a/src/features/app/hooks/useLiquidGlassEffect.ts +++ b/src/features/app/hooks/useLiquidGlassEffect.ts @@ -17,10 +17,10 @@ export function useLiquidGlassEffect({ reduceTransparency, onDebug }: Params) { useEffect(() => { let cancelled = false; + const windowHandle = getCurrentWindow(); const apply = async () => { try { - const window = getCurrentWindow(); if (reduceTransparency) { if (supportedRef.current === null) { supportedRef.current = await isGlassSupported(); @@ -28,7 +28,7 @@ export function useLiquidGlassEffect({ reduceTransparency, onDebug }: Params) { if (supportedRef.current) { await setLiquidGlassEffect({ enabled: false }); } - await window.setEffects({ effects: [] }); + await windowHandle.setEffects({ effects: [] }); return; } @@ -39,7 +39,7 @@ export function useLiquidGlassEffect({ reduceTransparency, onDebug }: Params) { return; } if (supportedRef.current) { - await window.setEffects({ effects: [] }); + await windowHandle.setEffects({ effects: [] }); await setLiquidGlassEffect({ enabled: true, cornerRadius: 16, @@ -54,7 +54,7 @@ export function useLiquidGlassEffect({ reduceTransparency, onDebug }: Params) { const isWindows = userAgent.includes("Windows"); if (isWindows) { - await window.setEffects({ + await windowHandle.setEffects({ effects: [Effect.Acrylic], state: EffectState.Active, }); @@ -64,7 +64,7 @@ export function useLiquidGlassEffect({ reduceTransparency, onDebug }: Params) { if (!isMac && !isLinux) { return; } - await window.setEffects({ + await windowHandle.setEffects({ effects: [Effect.HudWindow], state: EffectState.Active, radius: 16, @@ -84,9 +84,16 @@ export function useLiquidGlassEffect({ reduceTransparency, onDebug }: Params) { }; void apply(); + const handleResize = () => { + if (!cancelled && !reduceTransparency) { + void apply(); + } + }; + window.addEventListener("resize", handleResize); return () => { cancelled = true; + window.removeEventListener("resize", handleResize); }; }, [onDebug, reduceTransparency]); } From 7f6713074bf8215ca74c0d9af4e38e8472c825d5 Mon Sep 17 00:00:00 2001 From: fanzzzd Date: Wed, 4 Mar 2026 11:21:41 +0800 Subject: [PATCH 2/2] fix: guard window lookup in liquid glass apply --- src/features/app/hooks/useLiquidGlassEffect.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/features/app/hooks/useLiquidGlassEffect.ts b/src/features/app/hooks/useLiquidGlassEffect.ts index db6a85e1e..56721cdd5 100644 --- a/src/features/app/hooks/useLiquidGlassEffect.ts +++ b/src/features/app/hooks/useLiquidGlassEffect.ts @@ -17,10 +17,11 @@ export function useLiquidGlassEffect({ reduceTransparency, onDebug }: Params) { useEffect(() => { let cancelled = false; - const windowHandle = getCurrentWindow(); const apply = async () => { try { + const windowHandle = getCurrentWindow(); + if (reduceTransparency) { if (supportedRef.current === null) { supportedRef.current = await isGlassSupported();