Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
perf(desktop): 壁纸覆盖窗口时关闭原生毛玻璃
Dashf7f014b68563
diff --git a/apps/desktop/src/main/__tests__/vibrancyConfig.test.ts b/apps/desktop/src/main/__tests__/vibrancyConfig.test.tsindex 1e865c85aa..c7151150f5 100644--- a/apps/desktop/src/main/__tests__/vibrancyConfig.test.ts+++ b/apps/desktop/src/main/__tests__/vibrancyConfig.test.ts@@ -12,7 +12,12 @@ vi.mock('../logger.js', () => ({}),}));-import { resolveVibrancyConfig } from '../vibrancyConfig';+import type { BrowserWindow } from 'electron';+import {+ resolveVibrancyConfig,+ resolveWindowVibrancyConfig,+ setWindowWallpaperCovered,+} from '../vibrancyConfig';const MATERIAL_VALUES = ['sidebar',@@ -25,11 +30,49 @@ const MATERIAL_VALUES = [] as const;describe('E4D resolveVibrancyConfig(familyId→vibrancy/backgroundColor 映射)', () => {+ // Regression: an opaque in-app wallpaper used to leave the hidden native backdrop running.+ it.each(['darwin', 'win32', 'linux'])(+ 'wallpaper coverage disables native material on %s',+ (platform) => {+ for (const isDark of [false, true]) {+ const config = resolveVibrancyConfig('cindy', isDark, platform, {+ getSystemVersion: () => '10.0.22631',+ wallpaperCovered: true,+ });+ expect(config.vibrancy).toBeNull();+ expect(config.backgroundColor).toBe(isDark ? '#1f1f1e' : '#f8f8f6');+ if (platform === 'win32') expect(config.backgroundMaterial).toBe('none');+ }+ },+ );+beforeEach(() => {delete process.env.XDT_VIBRANCY_MATERIAL;delete process.env.XDT_BACKDROP_MATERIAL;});+ it.each(['darwin', 'win32'])(+ 'restores %s material per window without cross-window coverage leaks',+ (platform) => {+ const coveredWindow = {} as BrowserWindow;+ const loadingWindow = {} as BrowserWindow;+ const options = { getSystemVersion: () => '10.0.22631' };+ setWindowWallpaperCovered(coveredWindow, true);+ for (const isDark of [false, true]) {+ expect(+ resolveWindowVibrancyConfig(coveredWindow, 'cindy', isDark, platform, options),+ ).toEqual(resolveVibrancyConfig('default', isDark, platform, options));+ expect(+ resolveWindowVibrancyConfig(loadingWindow, 'cindy', isDark, platform, options),+ ).toEqual(resolveVibrancyConfig('cindy', isDark, platform, options));+ }+ setWindowWallpaperCovered(coveredWindow, false);+ expect(resolveWindowVibrancyConfig(coveredWindow, 'cindy', true, platform, options)).toEqual(+ resolveVibrancyConfig('cindy', true, platform, options),+ );+ },+ );+afterEach(() => {vi.restoreAllMocks();delete process.env.XDT_VIBRANCY_MATERIAL;diff --git a/apps/desktop/src/main/__tests__/window-theme-mode-store.test.ts b/apps/desktop/src/main/__tests__/window-theme-mode-store.test.tsindex e9398069d4..1c2fc62bfa 100644--- a/apps/desktop/src/main/__tests__/window-theme-mode-store.test.ts+++ b/apps/desktop/src/main/__tests__/window-theme-mode-store.test.ts@@ -44,6 +44,11 @@ describe('window theme mode store', () => {familyId: 'cindy',isDark: false,});+ for (const wallpaperCovered of [true, false]) {+ expect(+ parseWindowThemeVibrancyPayload({ familyId: 'cindy', isDark: false, wallpaperCovered }),+ ).toEqual({ familyId: 'cindy', isDark: false, wallpaperCovered });+ }for (const invalid of [null,@@ -52,6 +57,7 @@ describe('window theme mode store', () => {{ familyId: 'x'.repeat(513), isDark: false },{ familyId: 'cindy', isDark: 'false' },{ familyId: 'cindy', isDark: false, mode: 'auto' },+ { familyId: 'cindy', isDark: false, wallpaperCovered: 'true' },{ familyId: 'cindy', isDark: false, systemModeFollowsSystem: 'yes' },]) {expect(parseWindowThemeVibrancyPayload(invalid)).toBeNull();diff --git a/apps/desktop/src/main/bootstrap-electron.ts b/apps/desktop/src/main/bootstrap-electron.tsindex a387e9f860..a42e49a779 100644--- a/apps/desktop/src/main/bootstrap-electron.ts+++ b/apps/desktop/src/main/bootstrap-electron.ts@@ -75,7 +75,11 @@ import {shell,Tray,} from 'electron';-import { resolveVibrancyConfig } from './vibrancyConfig';+import {+ resolveVibrancyConfig,+ resolveWindowVibrancyConfig,+ setWindowWallpaperCovered,+} from './vibrancyConfig';import { getSessionThinkingSnapshots, getHistoryToolName, drainPersistQueue } from './messagePersistBroadcaster';import { applyVibrancyToSecondaryWindows } from './secondary-windows';import { rememberResolvedAppTheme, resolveAppThemeIsDark } from './resolved-app-theme';@@ -4713,7 +4717,7 @@ const registerIpcHandlers = () => {function applyWindowVibrancy(familyId: string, isDark: boolean): void {const win = mainWindowRef;if (!win || win.isDestroyed()) return;- const config = resolveVibrancyConfig(familyId, isDark, process.platform);+ const config = resolveWindowVibrancyConfig(win, familyId, isDark, process.platform);if (process.platform === 'darwin') {win.setVibrancy(config.vibrancy as 'under-window' | null);}@@ -4730,6 +4734,12 @@ const registerIpcHandlers = () => {const payload = parseWindowThemeVibrancyPayload(rawPayload);if (!payload) return;if (payload.mode === undefined || payload.systemModeFollowsSystem === undefined) return;+ if (payload.wallpaperCovered !== undefined) {+ const senderWindow = BrowserWindow.fromWebContents(event.sender);+ if (senderWindow && !senderWindow.isDestroyed()) {+ setWindowWallpaperCovered(senderWindow, payload.wallpaperCovered);+ }+ }if (process.platform === 'win32') {writeWindowThemeSnapshot(payload.mode,diff --git a/apps/desktop/src/main/secondary-windows.ts b/apps/desktop/src/main/secondary-windows.tsindex cd9b6b2a8d..9a6621c955 100644--- a/apps/desktop/src/main/secondary-windows.ts+++ b/apps/desktop/src/main/secondary-windows.ts@@ -28,7 +28,7 @@ import {type ScreenPoint,} from './windowBounds.js';import { readWindowBehaviorSettings } from './window-behavior-settings-store.js';-import { resolveVibrancyConfig } from './vibrancyConfig.js';+import { resolveVibrancyConfig, resolveWindowVibrancyConfig } from './vibrancyConfig.js';import {createWindowBackdropMaterialArgument,WINDOW_BACKDROP_MATERIAL_CHANGED_CHANNEL,@@ -278,7 +278,7 @@ export function isSecondaryAppWindow(win: BrowserWindow | null | undefined): booexport function applyVibrancyToSecondaryWindows(familyId: string, isDark: boolean): void {for (const win of secondaryWindows) {if (win.isDestroyed()) continue;- const config = resolveVibrancyConfig(familyId, isDark, process.platform);+ const config = resolveWindowVibrancyConfig(win, familyId, isDark, process.platform);if (process.platform === 'darwin') {win.setVibrancy(config.vibrancy as 'under-window' | null);}diff --git a/apps/desktop/src/main/vibrancyConfig.ts b/apps/desktop/src/main/vibrancyConfig.tsindex d99db734a3..49f5ed6233 100644--- a/apps/desktop/src/main/vibrancyConfig.ts+++ b/apps/desktop/src/main/vibrancyConfig.ts@@ -4,6 +4,7 @@* 不透明。Windows 11 CINDY family 启用 Electron backgroundMaterial;Windows 10/Linux* 回退不透明。*/+import type { BrowserWindow } from 'electron';import { createLogger } from './logger.js';import {CINDY_ACRYLIC_WINDOW_BACKING,@@ -23,6 +24,29 @@ export interface VibrancyConfig {export interface ResolveVibrancyConfigOptions {getSystemVersion?: () => string;+ wallpaperCovered?: boolean;+}++// Coverage belongs to the rendered window, not the shared wallpaper selection:+// another window may still be loading its canvas. Never persist this display state.+const wallpaperCoveredWindows = new WeakSet<BrowserWindow>();++export function setWindowWallpaperCovered(win: BrowserWindow, covered: boolean): void {+ if (covered) wallpaperCoveredWindows.add(win);+ else wallpaperCoveredWindows.delete(win);+}++export function resolveWindowVibrancyConfig(+ win: BrowserWindow,+ familyId: string,+ isDark: boolean,+ platform: string,+ options?: ResolveVibrancyConfigOptions,+): VibrancyConfig {+ return resolveVibrancyConfig(familyId, isDark, platform, {+ ...options,+ wallpaperCovered: wallpaperCoveredWindows.has(win),+ });}function readWindowsSystemVersion(options?: ResolveVibrancyConfigOptions): string | null {@@ -68,7 +92,7 @@ export function resolveVibrancyConfig(platform: string,options?: ResolveVibrancyConfigOptions,): VibrancyConfig {- const isCindy = familyId === 'cindy';+ const isCindy = familyId === 'cindy' && !options?.wallpaperCovered;const opaqueBg = isDark ? '#1f1f1e' : '#f8f8f6';if (platform === 'darwin') {// 材质 A/B 旋钮(dev 调参用):XDT_VIBRANCY_MATERIAL=sidebar|hud|under-window|fullscreen-ui|diff --git a/apps/desktop/src/main/window-theme-mode-store.ts b/apps/desktop/src/main/window-theme-mode-store.tsindex 3a27eac56f..253adcaaa0 100644--- a/apps/desktop/src/main/window-theme-mode-store.ts+++ b/apps/desktop/src/main/window-theme-mode-store.ts@@ -23,6 +23,7 @@ export interface WindowThemeVibrancyPayload {isDark: boolean;mode?: AppThemeMode;systemModeFollowsSystem?: boolean;+ wallpaperCovered?: boolean;}const DEFAULTS: WindowThemeSnapshot = { mode: 'system' };@@ -32,19 +33,22 @@ export function parseWindowThemeVibrancyPayload(raw: unknown): WindowThemeVibranif (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;const value = raw as Record<string, unknown>;if (- typeof value.familyId !== 'string'- || value.familyId.trim().length === 0- || value.familyId.length > MAX_FAMILY_ID_LENGTH- || typeof value.isDark !== 'boolean'- || (value.mode !== undefined && !isAppThemeMode(value.mode))- || (- value.systemModeFollowsSystem !== undefined- && typeof value.systemModeFollowsSystem !== 'boolean'- )- ) return null;+ typeof value.familyId !== 'string' ||+ value.familyId.trim().length === 0 ||+ value.familyId.length > MAX_FAMILY_ID_LENGTH ||+ typeof value.isDark !== 'boolean' ||+ (value.wallpaperCovered !== undefined && typeof value.wallpaperCovered !== 'boolean') ||+ (value.mode !== undefined && !isAppThemeMode(value.mode)) ||+ (value.systemModeFollowsSystem !== undefined &&+ typeof value.systemModeFollowsSystem !== 'boolean')+ )+ return null;return {familyId: value.familyId,isDark: value.isDark,+ ...(typeof value.wallpaperCovered === 'boolean'+ ? { wallpaperCovered: value.wallpaperCovered }+ : {}),...(isAppThemeMode(value.mode) ? { mode: value.mode } : {}),...(typeof value.systemModeFollowsSystem === 'boolean'? { systemModeFollowsSystem: value.systemModeFollowsSystem }diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.tsindex 8c54d1521f..bedbf079ca 100644--- a/apps/desktop/src/preload/preload.ts+++ b/apps/desktop/src/preload/preload.ts@@ -2934,12 +2934,14 @@ contextBridge.exposeInMainWorld('electronAPI', {isDark: boolean,mode: 'system' | 'light' | 'dark',systemModeFollowsSystem: boolean,+ wallpaperCovered?: boolean,): void => {ipcRenderer.send('theme:apply-vibrancy', {familyId,isDark,mode,systemModeFollowsSystem,+ wallpaperCovered,});},},diff --git a/apps/desktop/src/renderer/hooks/__tests__/useTheme.test.tsx b/apps/desktop/src/renderer/hooks/__tests__/useTheme.test.tsxindex 1de8fa0fec..6a40f6e742 100644--- a/apps/desktop/src/renderer/hooks/__tests__/useTheme.test.tsx+++ b/apps/desktop/src/renderer/hooks/__tests__/useTheme.test.tsx@@ -55,6 +55,7 @@ describe('useTheme 跨窗口主题同步(D2-3)', () => {systemPrefersDark = false;localStorage.clear();delete document.documentElement.dataset.theme;+ delete document.documentElement.dataset.wallpaperActive;document.documentElement.classList.remove('dark');vi.spyOn(themeService, 'applyTheme').mockImplementation(() => {});(window as unknown as { electronAPI: unknown }).electronAPI = {@@ -67,7 +68,7 @@ describe('useTheme 跨窗口主题同步(D2-3)', () => {localStorage.setItem('theme', 'dark');renderHook(() => useTheme(), { wrapper });- expect(applyVibrancyMock).toHaveBeenCalledWith('cindy', true, 'dark', true);+ expect(applyVibrancyMock).toHaveBeenCalledWith('cindy', true, 'dark', true, false);});it('utility 窗口复用 ThemeProvider 时不写全局窗口材质快照', () => {@@ -81,7 +82,7 @@ describe('useTheme 跨窗口主题同步(D2-3)', () => {localStorage.setItem('theme.familyId', 'eclipse');renderHook(() => useTheme(), { wrapper });- expect(applyVibrancyMock).toHaveBeenCalledWith('eclipse', true, 'system', false);+ expect(applyVibrancyMock).toHaveBeenCalledWith('eclipse', true, 'system', false, false);});it('系统深色下真首启按亮色门的实际主题上报 backing,门结束后恢复深色', () => {@@ -89,12 +90,12 @@ describe('useTheme 跨窗口主题同步(D2-3)', () => {expect(getInitialThemeVariant().theme.type).toBe('light');renderHook(() => useTheme(), { wrapper });- expect(applyVibrancyMock).toHaveBeenLastCalledWith('cindy', false, 'system', true);+ expect(applyVibrancyMock).toHaveBeenLastCalledWith('cindy', false, 'system', true, false);act(() => {endLoginFirstLaunchLightGate();});- expect(applyVibrancyMock).toHaveBeenLastCalledWith('cindy', true, 'system', true);+ expect(applyVibrancyMock).toHaveBeenLastCalledWith('cindy', true, 'system', true, false);});it('其他窗口切 theme → storage 事件 → 本窗口 theme state 跟随并重应用', () => {@@ -107,6 +108,46 @@ describe('useTheme 跨窗口主题同步(D2-3)', () => {expect(themeService.applyTheme).toHaveBeenCalled();});+ // Protocol regression: wallpaper rendering used to leave the native material enabled.+ it('reports actual canvas coverage, deduplicates unchanged coverage and stops observing on unmount', async () => {+ localStorage.setItem('theme', 'dark');+ const { result, unmount } = renderHook(() => useTheme(), { wrapper });+ const root = document.documentElement;+ await act(async () => {+ root.dataset.wallpaperActive = 'true';+ });+ expect(applyVibrancyMock).toHaveBeenLastCalledWith('cindy', true, 'dark', true, true);++ const count = applyVibrancyMock.mock.calls.length;+ await act(async () => {+ root.dataset.wallpaperActive = 'true';+ });+ expect(applyVibrancyMock).toHaveBeenCalledTimes(count);++ act(() => {+ result.current.setTheme('light');+ });+ expect(applyVibrancyMock).toHaveBeenLastCalledWith('cindy', false, 'light', true, true);+ await act(async () => {+ delete root.dataset.wallpaperActive;+ });+ expect(applyVibrancyMock).toHaveBeenLastCalledWith('cindy', false, 'light', true, false);++ unmount();+ applyVibrancyMock.mockClear();+ await act(async () => {+ root.dataset.wallpaperActive = 'true';+ });+ expect(applyVibrancyMock).not.toHaveBeenCalled();+ });++ it('reports a wallpaper canvas already present at ThemeProvider mount', () => {+ localStorage.setItem('theme', 'dark');+ document.documentElement.dataset.wallpaperActive = 'true';+ renderHook(() => useTheme(), { wrapper });+ expect(applyVibrancyMock).toHaveBeenLastCalledWith('cindy', true, 'dark', true, true);+ });+it('无存档时默认 cindy,其他窗口切 familyId=default 后本窗口跟随', () => {const { result } = renderHook(() => useTheme(), { wrapper });expect(result.current.familyId).toBe('cindy');diff --git a/apps/desktop/src/renderer/hooks/useTheme.ts b/apps/desktop/src/renderer/hooks/useTheme.tsindex bb9fb3aca6..da60532767 100644--- a/apps/desktop/src/renderer/hooks/useTheme.ts+++ b/apps/desktop/src/renderer/hooks/useTheme.ts@@ -236,6 +236,7 @@ export function endLoginFirstLaunchLightGate(): void {resolveSessionIsDark(mode),mode,systemModeFollowsSystem(familyId),+ document.documentElement.dataset.wallpaperActive === 'true',);}@@ -356,12 +357,26 @@ export function ThemeProvider({// setFamily/storage 跨窗口同步/mount 三个场景(任一变化都重应用)。useEffect(() => {if (!syncWindowVibrancy) return;- window.electronAPI?.theme?.applyVibrancy?.(- familyId,- resolveSessionIsDark(theme),- theme,- systemModeFollowsSystem(familyId),- );+ const root = document.documentElement;+ let lastCovered: boolean | undefined;+ const sync = () => {+ // Use the same condition as the opaque wallpaper canvas, including a+ // retained image while its replacement loads and the 0%-visibility veil.+ const covered = root.dataset.wallpaperActive === 'true';+ if (covered === lastCovered) return;+ lastCovered = covered;+ window.electronAPI?.theme?.applyVibrancy?.(+ familyId,+ resolveSessionIsDark(theme),+ theme,+ systemModeFollowsSystem(familyId),+ covered,+ );+ };+ sync();+ const observer = new MutationObserver(sync);+ observer.observe(root, { attributes: true, attributeFilter: ['data-wallpaper-active'] });+ return () => observer.disconnect();}, [familyId, localThemeRev, syncWindowVibrancy, theme, systemPrefersDark]);const fallbackFromType = useMemo<ThemeType | null>(() => {diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.tsindex a19c3db9aa..0546f3f920 100644--- a/apps/desktop/src/renderer/vite-env.d.ts+++ b/apps/desktop/src/renderer/vite-env.d.ts@@ -4049,6 +4049,7 @@ interface ElectronAPI {isDark: boolean,mode: 'system' | 'light' | 'dark',systemModeFollowsSystem: boolean,+ wallpaperCovered?: boolean,) => void;};/**diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.mdindex 3e78e0d411..05a8d10961 100644--- a/docs/design-rules/DESIGN.md+++ b/docs/design-rules/DESIGN.md@@ -110,6 +110,12 @@ Earlier unreleased artwork (including Blue Gaze, Amber Light and the 2026-10-16trimmed on 2026-10-17) is not shipped and needs no compatibility.The new artwork uses the existing continuous cover fit, theme-derived visibilityand blur controls. None remains the default and restores the theme canvas.+While a window's opaque in-app wallpaper canvas is active, disable its covered+native macOS Vibrancy / Windows backdrop material. Restore the theme's native+material when that canvas is removed. Use actual per-window canvas state rather+than the saved selection; pending replacements may retain the previous canvas.+The visibility veil (including 0%) remains opaque to the desktop. Wallpaper blur+and in-app overlay blur keep their existing behavior.The picker remains an inline compact grid (user choice, 2026-10-15): usecontainer-width-driven columns with a 6rem minimum, 8px grid gaps, 16:9 previews,and a 4px gap before each readable name. At the standard 1280px window width this