The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): matte glass option for window translucency
SHL0MSeb6f352be70c
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex ad14397dd14..1688c77d915 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -288,6 +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 {compareApiUrl,parseCompareBehindCount,@@ -872,30 +873,38 @@ function writePersistedThemeSource(mode) {nativeTheme.themeSource = readPersistedThemeSource()// Window translucency (see-through window). One lever, 0–100; 0 = off (the-// default). Mapped to the native window opacity so the desktop shows through-// the whole window. Persisted so a cold launch applies it at window creation,-// before the renderer reports its value. macOS + Windows only; `setOpacity` is-// a no-op on Linux. See store/translucency, and window-opacity for the ramp.+// default). Two modes share the lever (see electron/translucency.ts and+// store/translucency): 'clear' maps it to the native window opacity so the+// desktop shows through the whole window; 'glass' (macOS) keeps the window+// opaque and lets the renderer thin its surfaces over the vibrancy material+// instead — a matte blur with full-contrast text. Persisted so a cold launch+// applies it at window creation, before the renderer reports its value.+// macOS + Windows only; `setOpacity` is a no-op on Linux. See window-opacity+// for the clear ramp.const TRANSLUCENCY_CONFIG_PATH = path.join(app.getPath('userData'), 'translucency.json')function readPersistedTranslucency() {try {- return clampIntensity(JSON.parse(fs.readFileSync(TRANSLUCENCY_CONFIG_PATH, 'utf8')).intensity)+ return normalizeTranslucencyPayload(JSON.parse(fs.readFileSync(TRANSLUCENCY_CONFIG_PATH, 'utf8')), IS_MAC)} catch {- return 0+ return { intensity: 0, mode: 'clear' as const }}}-function writePersistedTranslucency(intensity) {+function writePersistedTranslucency(state) {try {fs.mkdirSync(path.dirname(TRANSLUCENCY_CONFIG_PATH), { recursive: true })- fs.writeFileSync(TRANSLUCENCY_CONFIG_PATH, JSON.stringify({ intensity }, null, 2), 'utf8')+ fs.writeFileSync(TRANSLUCENCY_CONFIG_PATH, JSON.stringify(state, null, 2), 'utf8')} catch (error) {rememberLog(`[translucency] write failed: ${error.message}`)}}-let translucencyIntensity = readPersistedTranslucency()+let translucencyState = readPersistedTranslucency()++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.@@ -905,7 +914,7 @@ function applyWindowTranslucency(win) {}try {- win.setOpacity(windowOpacity(translucencyIntensity))+ win.setOpacity(windowOpacity())} catch (error) {rememberLog(`[translucency] apply failed: ${error.message}`)}@@ -10635,7 +10644,7 @@ function spawnSecondaryWindow({ sessionId, watch }: { sessionId?: string; watch?titleBarOverlay: getTitleBarOverlayOptions(),trafficLightPosition: IS_MAC ? WINDOW_BUTTON_POSITION : undefined,vibrancy: IS_MAC ? 'sidebar' : undefined,- opacity: windowOpacity(translucencyIntensity),+ opacity: windowOpacity(),icon,// Don't show until the renderer's first themed paint is ready. macOS// `vibrancy` ignores `backgroundColor` and paints a translucent OS@@ -10735,7 +10744,7 @@ function createInstanceWindow() {titleBarOverlay: getTitleBarOverlayOptions(),trafficLightPosition: IS_MAC ? WINDOW_BUTTON_POSITION : undefined,vibrancy: IS_MAC ? 'sidebar' : undefined,- opacity: windowOpacity(translucencyIntensity),+ opacity: windowOpacity(),icon,show: false,backgroundColor: getWindowBackgroundColor(),@@ -11596,7 +11605,7 @@ function createWindow() {titleBarOverlay: getTitleBarOverlayOptions(),trafficLightPosition: IS_MAC ? WINDOW_BUTTON_POSITION : undefined,vibrancy: IS_MAC ? 'sidebar' : undefined,- opacity: windowOpacity(translucencyIntensity),+ opacity: windowOpacity(),icon,// Hidden until the first themed paint so macOS `vibrancy` (which ignores// `backgroundColor` and follows the OS appearance) can't flash a light@@ -13730,13 +13739,13 @@ ipcMain.on('hermes:native-theme', (_event, mode) => {// See-through window translucency. Persist + re-apply opacity to every open// window at runtime (no recreation, so caching/sessions are untouched).ipcMain.on('hermes:translucency', (_event, payload) => {- const next = clampIntensity(payload && payload.intensity)+ const next = normalizeTranslucencyPayload(payload, IS_MAC)- if (next === translucencyIntensity) {+ if (next.intensity === translucencyState.intensity && next.mode === translucencyState.mode) {return}- translucencyIntensity = next+ translucencyState = nextwritePersistedTranslucency(next)for (const win of BrowserWindow.getAllWindows()) {diff --git a/apps/desktop/electron/translucency.test.ts b/apps/desktop/electron/translucency.test.tsnew file mode 100644index 00000000000..17a6f4a002a--- /dev/null+++ b/apps/desktop/electron/translucency.test.ts@@ -0,0 +1,64 @@+import { describe, expect, it } from 'vitest'++import { clampIntensity, normalizeMode, normalizePayload, windowOpacityFor } from './translucency'++describe('clampIntensity', () => {+ it('clamps to 0-100 and rounds', () => {+ expect(clampIntensity(-5)).toBe(0)+ expect(clampIntensity(0)).toBe(0)+ expect(clampIntensity(49.6)).toBe(50)+ expect(clampIntensity(100)).toBe(100)+ expect(clampIntensity(250)).toBe(100)+ })++ it('treats junk as 0 (opaque)', () => {+ expect(clampIntensity(undefined)).toBe(0)+ expect(clampIntensity(NaN)).toBe(0)+ expect(clampIntensity('glass')).toBe(0)+ expect(clampIntensity(null)).toBe(0)+ })+})++describe('normalizeMode', () => {+ it('accepts glass on macOS only', () => {+ expect(normalizeMode('glass', true)).toBe('glass')+ expect(normalizeMode('glass', false)).toBe('clear')+ })++ it('falls back to clear for legacy and junk values', () => {+ expect(normalizeMode(undefined, true)).toBe('clear')+ expect(normalizeMode('clear', true)).toBe('clear')+ expect(normalizeMode('acrylic', true)).toBe('clear')+ expect(normalizeMode(42, true)).toBe('clear')+ })+})++describe('windowOpacityFor', () => {+ it('keeps the legacy clear-mode ramp with its 0.3 floor', () => {+ expect(windowOpacityFor(0, 'clear')).toBe(1)+ expect(windowOpacityFor(50, 'clear')).toBeCloseTo(0.65)+ expect(windowOpacityFor(100, 'clear')).toBeCloseTo(0.3)+ })++ it('never fades the native window in glass mode', () => {+ expect(windowOpacityFor(0, 'glass')).toBe(1)+ expect(windowOpacityFor(60, 'glass')).toBe(1)+ expect(windowOpacityFor(100, 'glass')).toBe(1)+ })+})++describe('normalizePayload', () => {+ it('parses a modern payload', () => {+ expect(normalizePayload({ intensity: 40, mode: 'glass' }, true)).toEqual({ intensity: 40, mode: 'glass' })+ })++ it('parses a legacy intensity-only payload as clear', () => {+ expect(normalizePayload({ intensity: 70 }, true)).toEqual({ intensity: 70, mode: 'clear' })+ })++ it('survives junk payloads', () => {+ expect(normalizePayload(null, true)).toEqual({ intensity: 0, mode: 'clear' })+ expect(normalizePayload('nope', true)).toEqual({ intensity: 0, mode: 'clear' })+ expect(normalizePayload({ intensity: 'x', mode: 'glass' }, false)).toEqual({ intensity: 0, mode: 'clear' })+ })+})diff --git a/apps/desktop/electron/translucency.ts b/apps/desktop/electron/translucency.tsnew file mode 100644index 00000000000..acf38becd78--- /dev/null+++ b/apps/desktop/electron/translucency.ts@@ -0,0 +1,49 @@+/**+ * Window translucency mapping shared by main-process call sites.+ *+ * Two modes ride one persisted lever (see src/store/translucency.ts):+ * - 'clear': the 0-100 intensity maps to native window opacity — the whole+ * window (text included) fades so the desktop shows through unblurred.+ * - 'glass': the window stays fully opaque at the native level; the renderer+ * thins its background surfaces instead so the macOS vibrancy material+ * (already attached to every chat window) shows through as a matte blur+ * while text keeps full contrast. macOS only — other platforms fall back+ * to 'clear'.+ */++export type TranslucencyMode = 'clear' | 'glass'++export function clampIntensity(value: unknown): number {+ const n = Math.round(Number(value))++ return Number.isFinite(n) ? Math.min(100, Math.max(0, n)) : 0+}++/** Unknown or unsupported values fall back to 'clear' (the legacy behavior). */+export function normalizeMode(value: unknown, isMac: boolean): TranslucencyMode {+ return value === 'glass' && isMac ? 'glass' : 'clear'+}++/**+ * Native window opacity for a mode + intensity. Glass never fades the native+ * window — the see-through effect is painted by the renderer over vibrancy.+ * Clear keeps the historical ramp: floor at 0.3 so the most see-through+ * setting is still usable rather than nearly invisible. 0 → fully opaque.+ */+export function windowOpacityFor(intensity: number, mode: TranslucencyMode): number {+ if (mode === 'glass') {+ return 1+ }++ return 1 - (clampIntensity(intensity) / 100) * 0.7+}++/** Parse a persisted translucency.json / IPC payload into a safe shape. */+export function normalizePayload(payload: unknown, isMac: boolean): { intensity: number; mode: TranslucencyMode } {+ const record = payload && typeof payload === 'object' ? (payload as Record<string, unknown>) : {}++ return {+ intensity: clampIntensity(record.intensity),+ mode: normalizeMode(record.mode, isMac)+ }+}diff --git a/apps/desktop/src/app/settings/appearance-settings.tsx b/apps/desktop/src/app/settings/appearance-settings.tsxindex fc7dda78cb7..322d047dddd 100644--- a/apps/desktop/src/app/settings/appearance-settings.tsx+++ b/apps/desktop/src/app/settings/appearance-settings.tsx@@ -22,7 +22,10 @@ import { $sessionListDensity, type SessionListDensity, setSessionListDensity } fimport { $toolViewMode, setToolViewMode } from '@/store/tool-view'import {$translucency,+ $translucencyMode,+ GLASS_SUPPORTED,setTranslucency,+ setTranslucencyMode,TRANSLUCENCY_MAX,TRANSLUCENCY_MIN,TRANSLUCENCY_STEP@@ -264,6 +267,7 @@ export function AppearanceSettings() {const embedAllowed = useStore($embedAllowed)const composerPopoutGesturesEnabled = useStore($composerPopoutGesturesEnabled)const translucency = useStore($translucency)+ const translucencyMode = useStore($translucencyMode)const reactionsEnabled = useStore($reactionsEnabled)const backdrop = useStore($backdrop)const installs = useStore($marketplaceInstalls)@@ -469,6 +473,19 @@ export function AppearanceSettings() {<ListRowaction={<div className="flex items-center gap-3">+ {GLASS_SUPPORTED && (+ <SegmentedControl+ onChange={id => {+ triggerHaptic('selection')+ setTranslucencyMode(id)+ }}+ options={[+ { id: 'clear' as const, label: a.translucencyModeClear },+ { id: 'glass' as const, label: a.translucencyModeGlass }+ ]}+ value={translucencyMode}+ />+ )}<inputaria-label={a.translucencyTitle}className="h-1 w-40 cursor-pointer appearance-none rounded-full bg-(--ui-stroke-tertiary)"@@ -488,7 +505,7 @@ export function AppearanceSettings() {</span></div>}- description={a.translucencyDesc}+ description={translucencyMode === 'glass' ? a.translucencyGlassDesc : a.translucencyDesc}title={a.translucencyTitle}/>diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.tsindex 43949e2823a..276c6b16614 100644--- a/apps/desktop/src/global.d.ts+++ b/apps/desktop/src/global.d.ts@@ -226,7 +226,7 @@ declare global {setActiveWork?: (payload: HermesActiveWork) => voidsetTitleBarTheme?: (payload: HermesTitleBarTheme) => voidsetNativeTheme?: (mode: 'dark' | 'light' | 'system') => void- setTranslucency?: (payload: { intensity: number }) => void+ setTranslucency?: (payload: { intensity: number; mode?: 'clear' | 'glass' }) => voidsetKeepAwake?: (on: boolean) => voidsetDisableF12?: (blocked: boolean) => voidsetPreviewShortcutActive?: (active: boolean) => voiddiff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex bb0735a9d35..cba03b7e517 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -410,6 +410,9 @@ export const ar = defineLocale({reasoningCollapsedDesc: 'أبقِ التفكير المتدفق متاحًا دون توسيعه حتى تفتحه.',translucencyTitle: 'شفافية النافذة',translucencyDesc: 'إظهار سطح المكتب من خلال النافذة بالكامل. متاح على macOS وWindows فقط.',+ translucencyGlassDesc: 'زجاج غير لامع: يظهر سطح المكتب كضبابية ناعمة بينما يبقى النص واضحًا. متاح على macOS فقط.',+ translucencyModeClear: 'شفاف',+ translucencyModeGlass: 'زجاج',backdropTitle: 'خلفية النافذة',backdropDesc: 'اختيار مقدار مزج خلفية سطح المكتب مع سطح Hermes.',reactionsTitle: 'تفاعلات الرسائل',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex a2cb1da8975..b3a795a2aab 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -486,6 +486,9 @@ export const en: Translations = {terminalFontReset: 'Use default',translucencyTitle: 'Window Translucency',translucencyDesc: 'See your desktop through the whole window. macOS and Windows only.',+ translucencyGlassDesc: 'Matte glass: the desktop shows through as a smooth blur while text stays sharp. macOS only.',+ translucencyModeClear: 'Clear',+ translucencyModeGlass: 'Glass',backdropTitle: 'Chat Backdrop',backdropDesc: 'The faint statue image behind the conversation.',reactionsTitle: 'Message Reactions',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 97afc3b791f..2c38998016b 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -344,6 +344,9 @@ export const ja = defineLocale({terminalFontReset: '既定値を使用',translucencyTitle: 'ウィンドウの透過',translucencyDesc: 'ウィンドウ全体を透過させてデスクトップを表示します。macOS と Windows のみ。',+ translucencyGlassDesc: 'マットガラス: デスクトップが滑らかなぼかしとして透け、テキストは鮮明なまま。macOS のみ。',+ translucencyModeClear: 'クリア',+ translucencyModeGlass: 'ガラス',backdropTitle: 'チャット背景',backdropDesc: '会話の背後に表示される淡い彫像の画像。',reactionsTitle: 'メッセージリアクション',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex ae72423ba3d..130f141fd7b 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -386,6 +386,9 @@ export interface Translations {terminalFontReset: stringtranslucencyTitle: stringtranslucencyDesc: string+ translucencyGlassDesc: string+ translucencyModeClear: string+ translucencyModeGlass: stringbackdropTitle: stringbackdropDesc: stringreactionsTitle: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 4fc02e89fa0..d45a2e9a4d6 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -336,6 +336,9 @@ export const zhHant = defineLocale({terminalFontReset: '使用預設字型',translucencyTitle: '視窗透明',translucencyDesc: '讓整個視窗透出桌面。僅支援 macOS 與 Windows。',+ translucencyGlassDesc: '霧面玻璃:桌面以柔和模糊透出,文字保持清晰。僅支援 macOS。',+ translucencyModeClear: '透明',+ translucencyModeGlass: '玻璃',backdropTitle: '聊天背景',backdropDesc: '對話後方那張淡淡的雕像圖片。',reactionsTitle: '訊息回應',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 60e5d8c0288..73b0d485398 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -476,6 +476,9 @@ export const zh: Translations = {terminalFontReset: '使用默认字体',translucencyTitle: '窗口透明',translucencyDesc: '让整个窗口透出桌面。仅支持 macOS 和 Windows。',+ translucencyGlassDesc: '磨砂玻璃:桌面以柔和模糊透出,文字保持清晰。仅支持 macOS。',+ translucencyModeClear: '透明',+ translucencyModeGlass: '玻璃',backdropTitle: '聊天背景',backdropDesc: '对话后方那张淡淡的雕像图片。',reactionsTitle: '消息回应',diff --git a/apps/desktop/src/store/translucency.test.ts b/apps/desktop/src/store/translucency.test.tsindex b3edc6da23f..438f908ba86 100644--- a/apps/desktop/src/store/translucency.test.ts+++ b/apps/desktop/src/store/translucency.test.ts@@ -1,13 +1,27 @@+// @vitest-environment jsdomimport { beforeEach, describe, expect, it } from 'vitest'import { onPersistenceEvent, type PersistenceEvent } from '@/lib/storage'-import { $translucency, setTranslucency, TRANSLUCENCY_MAX, TRANSLUCENCY_MIN, TRANSLUCENCY_STEP } from './translucency'+import {+ $translucency,+ $translucencyMode,+ GLASS_SUPPORTED,+ glassSurfaceKeep,+ setTranslucency,+ setTranslucencyMode,+ TRANSLUCENCY_MAX,+ TRANSLUCENCY_MIN,+ TRANSLUCENCY_STEP+} from './translucency'const KEY = 'hermes.desktop.translucency.v1'describe('window translucency lever', () => {- beforeEach(() => setTranslucency(TRANSLUCENCY_MIN))+ beforeEach(() => {+ setTranslucency(TRANSLUCENCY_MIN)+ setTranslucencyMode('clear')+ })it('steps in single percent so the readable low end is reachable', () => {expect(TRANSLUCENCY_STEP).toBe(1)@@ -56,4 +70,47 @@ describe('window translucency lever', () => {expect(writes).toContainEqual({ key: KEY, op: 'write', value: '23' })})++ it('mirrors intensity and mode to the desktop bridge', () => {+ const calls: Array<{ intensity: number; mode?: string }> = []+ window.hermesDesktop = {+ setTranslucency: (payload: { intensity: number; mode?: 'clear' | 'glass' }) => calls.push(payload)+ } as never++ setTranslucency(40)+ expect(calls.at(-1)).toEqual({ intensity: 40, mode: 'clear' })+ })++ it('rejects glass off macOS and applies it on macOS', () => {+ setTranslucency(50)+ setTranslucencyMode('glass')++ if (GLASS_SUPPORTED) {+ expect($translucencyMode.get()).toBe('glass')+ expect(document.documentElement.hasAttribute('data-hermes-glass')).toBe(true)+ expect(document.documentElement.style.getPropertyValue('--translucency-glass-keep')).toBe('65%')+ } else {+ expect($translucencyMode.get()).toBe('clear')+ expect(document.documentElement.hasAttribute('data-hermes-glass')).toBe(false)+ }+ })++ it('removes the glass attribute at zero intensity or back on clear', () => {+ setTranslucency(50)+ setTranslucencyMode('glass')+ setTranslucency(0)+ expect(document.documentElement.hasAttribute('data-hermes-glass')).toBe(false)++ setTranslucency(50)+ setTranslucencyMode('clear')+ expect(document.documentElement.hasAttribute('data-hermes-glass')).toBe(false)+ })+})++describe('glassSurfaceKeep', () => {+ it('mirrors the clear-mode opacity ramp with its 30% floor', () => {+ expect(glassSurfaceKeep(0)).toBe(100)+ expect(glassSurfaceKeep(50)).toBe(65)+ expect(glassSurfaceKeep(100)).toBeCloseTo(30)+ })})diff --git a/apps/desktop/src/store/translucency.ts b/apps/desktop/src/store/translucency.tsindex b63c7c446eb..33dd27920ca 100644--- a/apps/desktop/src/store/translucency.ts+++ b/apps/desktop/src/store/translucency.ts@@ -2,19 +2,32 @@* Window translucency (see-through window).** One lever, 0–100. 0 = off (fully opaque, the default). Higher = more of the- * desktop shows through the whole window — the main process maps it to the- * native window opacity (`setOpacity`), the same effect as the Windows- * shift-scroll trick. macOS + Windows only; Linux has no runtime window- * opacity, so it's a no-op there.+ * desktop shows through. Two modes decide HOW it shows through:*- * The renderer owns the value and mirrors it to the main process over IPC.+ * - 'clear' — the main process maps the lever to native window opacity+ * (`setOpacity`), the same effect as the Windows shift-scroll trick. The+ * whole window fades, text included. macOS + Windows; Linux has no runtime+ * window opacity, so it's a no-op there.+ * - 'glass' — macOS only. The window stays opaque at the native level; this+ * store thins the renderer's page surfaces instead (see the+ * `[data-hermes-glass]` block in styles.css), so the vibrancy material every+ * chat window already carries shows through as a matte blur while text keeps+ * full contrast.+ *+ * The renderer owns both values and mirrors them to the main process over IPC.*/import { atom } from 'nanostores'import { persistString, storedString } from '@/lib/storage'+export type TranslucencyMode = 'clear' | 'glass'+const KEY = 'hermes.desktop.translucency.v1'+const MODE_KEY = 'hermes.desktop.translucency-mode.v1'++/** Glass rides on macOS vibrancy; other platforms only have Clear. */+export const GLASS_SUPPORTED = typeof navigator !== 'undefined' && /mac/i.test(navigator.platform || navigator.userAgent || '')// Slider bounds — mirror `electron/window-opacity.ts` (TRANSLUCENCY_MIN / MAX)// so the control and the main-process clamp agree on the same range. The step@@ -31,15 +44,69 @@ const read = (): number => {return Number.isFinite(n) ? clamp(n) : 0}+const readMode = (): TranslucencyMode => (GLASS_SUPPORTED && storedString(MODE_KEY) === 'glass' ? 'glass' : 'clear')+export const $translucency = atom<number>(typeof window === 'undefined' ? 0 : read())+export const $translucencyMode = atom<TranslucencyMode>(typeof window === 'undefined' ? 'clear' : readMode())+export function setTranslucency(intensity: number): void {$translucency.set(clamp(intensity))}+export function setTranslucencyMode(mode: TranslucencyMode): void {+ $translucencyMode.set(mode === 'glass' && GLASS_SUPPORTED ? 'glass' : 'clear')+}++// Glass thins surfaces only in real chat windows (primary + secondary session+// windows). The HUD, pet overlay, quick entry and wake indicator are+// transparent special-purpose windows that manage their own backgrounds — a+// page-surface rewrite there would fight them.+const isChatWindow = (): boolean => {+ try {+ const win = new URLSearchParams(window.location.search).get('win')++ return win === null || win === 'secondary'+ } catch {+ return false+ }+}++/**+ * Percent of the surface tint KEPT at a given intensity. Mirrors clear mode's+ * opacity ramp (floor 0.3): at 100 the surfaces keep a 30% wash so the glass+ * stays matte — tinted blur, not bare desktop.+ */+export const glassSurfaceKeep = (intensity: number): number => 100 - clamp(intensity) * 0.7++const applyGlassSurfaces = (intensity: number, mode: TranslucencyMode): void => {+ if (typeof document === 'undefined') {+ return+ }++ const root = document.documentElement+ const on = mode === 'glass' && intensity > 0 && GLASS_SUPPORTED && isChatWindow()++ if (on) {+ root.setAttribute('data-hermes-glass', '')+ root.style.setProperty('--translucency-glass-keep', `${glassSurfaceKeep(intensity)}%`)+ } else {+ root.removeAttribute('data-hermes-glass')+ root.style.removeProperty('--translucency-glass-keep')+ }+}+if (typeof window !== 'undefined') {- $translucency.subscribe(intensity => {+ const sync = () => {+ const intensity = $translucency.get()+ const mode = $translucencyMode.get()+persistString(KEY, String(intensity))- window.hermesDesktop?.setTranslucency?.({ intensity })- })+ persistString(MODE_KEY, mode)+ applyGlassSurfaces(intensity, mode)+ window.hermesDesktop?.setTranslucency?.({ intensity, mode })+ }++ $translucency.subscribe(sync)+ $translucencyMode.subscribe(sync)}diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.cssindex 8d3591e3f8a..362f4985c65 100644--- a/apps/desktop/src/styles.css+++ b/apps/desktop/src/styles.css@@ -558,6 +558,44 @@--ui-widget-surface-background: color-mix(in srgb, var(--ui-bg-editor) 88%, #000);}+ /* ── Window glass (Settings → Appearance → Window Translucency: Glass) ──+ Set on <html> by store/translucency.ts; macOS chat windows only. Every+ chat window already carries an NSVisualEffectView (`vibrancy: 'sidebar'`+ in electron/main.ts) that WindowServer composites BELOW the web contents;+ the page normally buries it under fully opaque surfaces. Glass thins+ exactly the two field surfaces — the chat surface and the sidebar — to+ `--translucency-glass-keep` (set inline from the intensity slider, floor+ 30%) so the material shows through as a matte desktop blur, while cards,+ popovers, the composer and every raised control keep their opaque fills+ and text keeps full contrast. Unlike Clear, nothing on the page fades.+ Surfaces that MASK in-page content are deliberately not thinned: the+ editor surface backs the diff gutter's sticky line-number mask and the+ active pane tab, and the find bar reads --ui-surface-background —+ in-page transparency there reads as text bleeding through text, not as+ glass. The two thinned surfaces already cover the window, so the pane+ container behind them never shows.++ The boot script in index.html pins an opaque inline background on <html>+ before first paint; it has to go transparent here or it sits behind the+ translucent <body> and blocks the material. The terminal surface is+ pinned back to the opaque chrome mix: xterm resolves its surface var to a+ concrete color for its canvas (see right-sidebar/terminal/selection.ts),+ which does not composite page alpha. */+ :root[data-hermes-glass] {+ background-color: transparent !important;+ --ui-chat-surface-background: color-mix(+ in srgb,+ var(--ui-bg-chrome) var(--translucency-glass-keep, 100%),+ transparent+ );+ --ui-sidebar-surface-background: color-mix(+ in srgb,+ var(--ui-bg-sidebar) var(--translucency-glass-keep, 100%),+ transparent+ );+ --ui-terminal-surface-background: var(--ui-bg-chrome);+ }+* {box-sizing: border-box;border-color: var(--dt-border);