Skip to content

The agent that grows with you

feat(desktop): frost picker, sidebar glass, full-range tint and peek

Brooklyn Nicholsonefa15b5eb43a
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 02dabf562a9..1273458a319 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -291,6 +291,7 @@ import { nativeOverlayWidth as computeNativeOverlayWidth, macTitleBarOverlayHeig
import {
glassActive,
normalizeState as normalizeTranslucency,
+ vibrancyFor as vibrancyForTranslucency,
windowBackingOptions,
windowOpacityFor
} from './translucency'
@@ -936,10 +937,18 @@ function applyWindowTranslucency(win) {
}
try {
- // Backing swap is scoped to registered chat windows (see
+ // Backing swap + material are scoped to registered chat windows (see
// translucencyBackedWindows above).
- if (translucencyBackedWindows.has(win) && typeof win.setBackgroundColor === 'function') {
- win.setBackgroundColor(glassActive(translucencyState) ? '#00000000' : getWindowBackgroundColor())
+ if (translucencyBackedWindows.has(win)) {
+ if (typeof win.setBackgroundColor === 'function') {
+ win.setBackgroundColor(glassActive(translucencyState) ? '#00000000' : getWindowBackgroundColor())
+ }
+
+ // Glass frost level = the vibrancy material (macOS has no blur-radius
+ // knob). Animate the hop so slider-adjacent switches feel continuous.
+ if (IS_MAC && typeof win.setVibrancy === 'function') {
+ win.setVibrancy(vibrancyForTranslucency(translucencyState), { animationDuration: 150 })
+ }
}
if (typeof win.setOpacity === 'function') {
@@ -963,7 +972,14 @@ function applyWindowTranslucency(win) {
// deliberately not chat windows.
function chatWindowSurfaceOptions() {
return {
- vibrancy: IS_MAC ? ('sidebar' as const) : undefined,
+ vibrancy: IS_MAC ? vibrancyForTranslucency(translucencyState) : undefined,
+ // Pin the material to its ACTIVE appearance: several NSVisualEffectView
+ // materials collapse to a shared inactive look when the window blurs
+ // (measured on macOS 26: sidebar, popover and under-window composited
+ // pixel-identically once unfocused), which would quietly erase the
+ // user's frost choice whenever they click elsewhere. Only observable
+ // under glass — everywhere else the page buries the material.
+ visualEffectState: IS_MAC ? ('active' as const) : undefined,
opacity: windowOpacity(),
...windowBackingOptions(translucencyState, getWindowBackgroundColor())
}
@@ -13794,7 +13810,12 @@ ipcMain.on('hermes:native-theme', (_event, mode) => {
ipcMain.on('hermes:translucency', (_event, payload) => {
const next = normalizeTranslucency(payload, IS_MAC)
- if (next.intensity === translucencyState.intensity && next.mode === translucencyState.mode) {
+ if (
+ next.intensity === translucencyState.intensity &&
+ next.mode === translucencyState.mode &&
+ next.material === translucencyState.material &&
+ next.scope === translucencyState.scope
+ ) {
return
}
diff --git a/apps/desktop/electron/translucency.test.ts b/apps/desktop/electron/translucency.test.ts
index 53f43f603cc..d550acd9ade 100644
--- a/apps/desktop/electron/translucency.test.ts
+++ b/apps/desktop/electron/translucency.test.ts
@@ -12,14 +12,23 @@ import { describe, expect, it } from 'vitest'
import {
clampIntensity,
+ DEFAULT_GLASS_MATERIAL,
+ DEFAULT_GLASS_SCOPE,
+ GLASS_MATERIALS,
+ GLASS_SCOPES,
glassActive,
+ type GlassMaterial,
glassSurfaceKeep,
+ normalizeMaterial,
normalizeMode,
+ normalizeScope,
normalizeState,
TRANSLUCENCY_CURVE,
TRANSLUCENCY_MAX,
TRANSLUCENCY_MIN,
TRANSLUCENCY_OPACITY_FLOOR,
+ type TranslucencyState,
+ vibrancyFor,
windowBackingOptions,
windowOpacityFor
} from './translucency'
@@ -27,8 +36,19 @@ import {
/** The linear ramp the curve replaced. Endpoints must still agree with it. */
const legacyOpacity = (intensity: number) => 1 - (intensity / 100) * 0.7
-const clear = (intensity: number) => ({ intensity, mode: 'clear' as const })
-const glass = (intensity: number) => ({ intensity, mode: 'glass' as const })
+const clear = (intensity: number): TranslucencyState => ({
+ intensity,
+ mode: 'clear',
+ material: DEFAULT_GLASS_MATERIAL,
+ scope: DEFAULT_GLASS_SCOPE
+})
+
+const glass = (intensity: number, material: GlassMaterial = DEFAULT_GLASS_MATERIAL): TranslucencyState => ({
+ intensity,
+ mode: 'glass',
+ material,
+ scope: DEFAULT_GLASS_SCOPE
+})
describe('lever bounds', () => {
it('keeps the bounds and floor stable so persisted settings survive upgrades', () => {
@@ -132,33 +152,86 @@ describe('windowOpacityFor', () => {
})
describe('glassSurfaceKeep', () => {
- it('mirrors the clear-mode ramp floor so glass stays matte, never bare desktop', () => {
+ // Full range on purpose: the top of the lever is bare, untinted blur, so the
+ // slider spans opaque theme -> clean glass. Text and cards keep their own
+ // opaque tokens, which is what makes 100% usable rather than unreadable.
+ it('runs linear to zero so the top of the lever is untinted glass', () => {
expect(glassSurfaceKeep(0)).toBe(100)
- expect(glassSurfaceKeep(50)).toBe(65)
- expect(glassSurfaceKeep(100)).toBeCloseTo(30)
+ expect(glassSurfaceKeep(50)).toBe(50)
+ expect(glassSurfaceKeep(100)).toBe(0)
})
it('clamps its input like every other consumer of the lever', () => {
expect(glassSurfaceKeep(-40)).toBe(100)
- expect(glassSurfaceKeep(240)).toBeCloseTo(30)
+ expect(glassSurfaceKeep(240)).toBe(0)
+ })
+})
+
+describe('normalizeMaterial / normalizeScope', () => {
+ it('accepts every shipped material and area', () => {
+ for (const material of GLASS_MATERIALS) {
+ expect(normalizeMaterial(material)).toBe(material)
+ }
+
+ for (const scope of GLASS_SCOPES) {
+ expect(normalizeScope(scope)).toBe(scope)
+ }
+ })
+
+ // The picker was rebuilt from a material census precisely because several
+ // NSVisualEffectView materials composite identically; a value that isn't in
+ // the shipped ladder must not reach setVibrancy.
+ it('falls back for junk, and for materials deliberately left out of the ladder', () => {
+ expect(normalizeMaterial('sidebar')).toBe(DEFAULT_GLASS_MATERIAL)
+ expect(normalizeMaterial('hud')).toBe(DEFAULT_GLASS_MATERIAL)
+ expect(normalizeMaterial(undefined)).toBe(DEFAULT_GLASS_MATERIAL)
+ expect(normalizeMaterial(7)).toBe(DEFAULT_GLASS_MATERIAL)
+ expect(normalizeScope('rail')).toBe(DEFAULT_GLASS_SCOPE)
+ expect(normalizeScope(null)).toBe(DEFAULT_GLASS_SCOPE)
+ })
+})
+
+describe('vibrancyFor', () => {
+ it('uses the chosen frost material only while glass is actually on', () => {
+ expect(vibrancyFor(glass(60, 'header'))).toBe('header')
+ expect(vibrancyFor(glass(60, 'popover'))).toBe('popover')
+ })
+
+ // 'sidebar' is what the titlebar band was designed against, so every
+ // non-glass state has to land back on it rather than keeping a stale pick.
+ it('falls back to the long-standing sidebar material otherwise', () => {
+ expect(vibrancyFor(glass(0, 'header'))).toBe('sidebar')
+ expect(vibrancyFor(clear(60))).toBe('sidebar')
})
})
describe('normalizeState', () => {
it('parses a modern payload', () => {
- expect(normalizeState({ intensity: 40, mode: 'glass' }, true)).toEqual({ intensity: 40, mode: 'glass' })
+ expect(normalizeState({ intensity: 40, mode: 'glass', material: 'header', scope: 'sidebar' }, true)).toEqual({
+ intensity: 40,
+ mode: 'glass',
+ material: 'header',
+ scope: 'sidebar'
+ })
})
// The migration contract: a pre-glass translucency.json is intensity-only and
// always meant clear. It must NOT silently become glass on update.
it('keeps a legacy intensity-only payload on clear', () => {
- expect(normalizeState({ intensity: 70 }, true)).toEqual({ intensity: 70, mode: 'clear' })
+ expect(normalizeState({ intensity: 70 }, true)).toEqual({
+ intensity: 70,
+ mode: 'clear',
+ material: DEFAULT_GLASS_MATERIAL,
+ scope: DEFAULT_GLASS_SCOPE
+ })
})
it('survives junk payloads', () => {
- expect(normalizeState(null, true)).toEqual({ intensity: 0, mode: 'clear' })
- expect(normalizeState('nope', true)).toEqual({ intensity: 0, mode: 'clear' })
- expect(normalizeState({ intensity: 'x', mode: 'glass' }, false)).toEqual({ intensity: 0, mode: 'clear' })
+ const fallback = { intensity: 0, material: DEFAULT_GLASS_MATERIAL, mode: 'clear', scope: DEFAULT_GLASS_SCOPE }
+
+ expect(normalizeState(null, true)).toEqual(fallback)
+ expect(normalizeState('nope', true)).toEqual(fallback)
+ expect(normalizeState({ intensity: 'x', material: 'nope', mode: 'glass', scope: 'nope' }, false)).toEqual(fallback)
})
})
diff --git a/apps/desktop/electron/translucency.ts b/apps/desktop/electron/translucency.ts
index 59d486e456f..30c12970826 100644
--- a/apps/desktop/electron/translucency.ts
+++ b/apps/desktop/electron/translucency.ts
@@ -15,9 +15,17 @@ import { glassActive, type TranslucencyState } from '../../shared/src/translucen
export {
clampIntensity,
+ DEFAULT_GLASS_MATERIAL,
+ DEFAULT_GLASS_SCOPE,
+ GLASS_MATERIALS,
+ GLASS_SCOPES,
glassActive,
+ type GlassMaterial,
+ type GlassScope,
glassSurfaceKeep,
+ normalizeMaterial,
normalizeMode,
+ normalizeScope,
normalizeState,
TRANSLUCENCY_CURVE,
TRANSLUCENCY_MAX,
@@ -26,6 +34,7 @@ export {
TRANSLUCENCY_STEP,
type TranslucencyMode,
type TranslucencyState,
+ vibrancyFor,
windowOpacityFor
} from '../../shared/src/translucency'
diff --git a/apps/desktop/src/app/overlays/peek-scope.test.ts b/apps/desktop/src/app/overlays/peek-scope.test.ts
new file mode 100644
index 00000000000..9ff226542c2
--- /dev/null
+++ b/apps/desktop/src/app/overlays/peek-scope.test.ts
@@ -0,0 +1,31 @@
+// @vitest-environment jsdom
+/**
+ * The peek is scoped with :has() so only the settings overlay that owns the
+ * translucency row pays for an opacity transition. jsdom implements :has() in
+ * matches(), so the scoping claim is checkable directly: the marked overlay
+ * matches the peek selector and an unmarked one does not.
+ */
+import { describe, expect, it } from 'vitest'
+
+const PEEK_SELECTOR = '[data-overlay-surface]:has([data-translucency-peek-scope])'
+
+describe('peek scoping', () => {
+ it('matches only the overlay that armed the interaction', () => {
+ document.body.innerHTML = `
+ <div data-overlay-surface id="settings">
+ <div data-translucency-peek-scope></div>
+ </div>
+ <div data-overlay-surface id="command-center">
+ <div></div>
+ </div>
+ `
+
+ const settings = document.getElementById('settings')
+ const commandCenter = document.getElementById('command-center')
+
+ expect(settings?.matches(PEEK_SELECTOR)).toBe(true)
+ // The regression this guards: an unscoped rule gave EVERY overlay in the
+ // app a 420ms opacity transition for the life of the process.
+ expect(commandCenter?.matches(PEEK_SELECTOR)).toBe(false)
+ })
+})
diff --git a/apps/desktop/src/app/settings/appearance-settings.tsx b/apps/desktop/src/app/settings/appearance-settings.tsx
index 6a983c4e653..cbc452c838d 100644
--- a/apps/desktop/src/app/settings/appearance-settings.tsx
+++ b/apps/desktop/src/app/settings/appearance-settings.tsx
@@ -22,9 +22,16 @@ import { $sessionListDensity, type SessionListDensity, setSessionListDensity } f
import { $toolViewMode, setToolViewMode } from '@/store/tool-view'
import {
$translucency,
+ beginTranslucencyPeek,
+ endTranslucencyPeek,
+ GLASS_MATERIALS,
+ GLASS_SCOPES,
GLASS_SUPPORTED,
+ pulseTranslucencyPeek,
setTranslucency,
+ setTranslucencyMaterial,
setTranslucencyMode,
+ setTranslucencyScope,
TRANSLUCENCY_MAX,
TRANSLUCENCY_MIN,
TRANSLUCENCY_STEP
@@ -255,6 +262,19 @@ function MarketplaceThemeResults({
)
}
+// Keys a range input treats as a step, so the peek can flash the live window
+// for keyboard adjustment the way a pointer drag holds it open.
+const SLIDER_STEP_KEYS = new Set([
+ 'ArrowDown',
+ 'ArrowLeft',
+ 'ArrowRight',
+ 'ArrowUp',
+ 'End',
+ 'Home',
+ 'PageDown',
+ 'PageUp'
+])
+
export function AppearanceSettings() {
const { t, isSavingLocale } = useI18n()
const { themeName, mode, resolvedMode, availableThemes, setTheme, setMode } = useTheme()
@@ -470,12 +490,23 @@ export function AppearanceSettings() {
<ListRow
action={
- <div className="flex items-center gap-3">
+ <div
+ className="flex items-center gap-3"
+ // Arms the peek for the overlay this row lives in — the
+ // ghosting rules in styles.css scope to it, so no other
+ // overlay pays for an opacity transition it never uses.
+ data-translucency-peek-scope=""
+ >
{GLASS_SUPPORTED && (
<SegmentedControl
onChange={id => {
triggerHaptic('selection')
setTranslucencyMode(id)
+
+ // Show the change through the overlay it just altered.
+ if (translucency.intensity > 0) {
+ pulseTranslucencyPeek()
+ }
}}
options={[
{ id: 'clear' as const, label: a.translucencyModeClear },
@@ -489,10 +520,24 @@ export function AppearanceSettings() {
className="h-1 w-40 cursor-pointer appearance-none rounded-full bg-(--ui-stroke-tertiary)"
max={TRANSLUCENCY_MAX}
min={TRANSLUCENCY_MIN}
+ // Peek while the hand is on the slider: the overlay (scrim +
+ // near-opaque card) ghosts so the window behind IS the live
+ // preview. Pointer pair covers mouse/touch drags; the
+ // keyboard path pulses per step instead (blur ends any
+ // residual hold).
+ onBlur={endTranslucencyPeek}
onChange={event => {
triggerHaptic('selection')
setTranslucency(Number(event.target.value))
}}
+ onKeyDown={event => {
+ if (SLIDER_STEP_KEYS.has(event.key)) {
+ pulseTranslucencyPeek()
+ }
+ }}
+ onLostPointerCapture={endTranslucencyPeek}
+ onPointerDown={beginTranslucencyPeek}
+ onPointerUp={endTranslucencyPeek}
step={TRANSLUCENCY_STEP}
style={{ accentColor: 'var(--dt-primary)' }}
type="range"
@@ -503,6 +548,52 @@ export function AppearanceSettings() {
</span>
</div>
}
+ below={
+ translucency.mode === 'glass' && GLASS_SUPPORTED ? (
+ <div className="mt-3 flex flex-col gap-2.5">
+ <div className="flex items-center gap-3">
+ <span className="w-12 text-[length:var(--conversation-caption-font-size)] text-(--ui-text-tertiary)">
+ {a.translucencyFrostTitle}
+ </span>
+ <SegmentedControl
+ onChange={id => {
+ triggerHaptic('selection')
+ setTranslucencyMaterial(id)
+
+ if (translucency.intensity > 0) {
+ pulseTranslucencyPeek()
+ }
+ }}
+ options={GLASS_MATERIALS.map(material => ({
+ id: material,
+ label: a.translucencyFrost[material]
+ }))}
+ value={translucency.material}
+ />
+ </div>
+ <div className="flex items-center gap-3">
+ <span className="w-12 text-[length:var(--conversation-caption-font-size)] text-(--ui-text-tertiary)">
+ {a.translucencyScopeTitle}
+ </span>
+ <SegmentedControl
+ onChange={id => {
+ triggerHaptic('selection')
+ setTranslucencyScope(id)
+
+ if (translucency.intensity > 0) {
+ pulseTranslucencyPeek()
+ }
+ }}
+ options={GLASS_SCOPES.map(scope => ({
+ id: scope,
+ label: a.translucencyScope[scope]
+ }))}
+ value={translucency.scope}
+ />
+ </div>
+ </div>
+ ) : undefined
+ }
description={translucency.mode === 'glass' ? a.translucencyGlassDesc : a.translucencyDesc}
title={a.translucencyTitle}
/>
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index cba03b7e517..30132b7be20 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -413,6 +413,18 @@ export const ar = defineLocale({
translucencyGlassDesc: 'زجاج غير لامع: يظهر سطح المكتب كضبابية ناعمة بينما يبقى النص واضحًا. متاح على macOS فقط.',
translucencyModeClear: 'شفاف',
translucencyModeGlass: 'زجاج',
+ translucencyFrostTitle: 'نوع الضبابية',
+ translucencyFrost: {
+ 'under-window': 'عميق',
+ popover: 'ناعم',
+ titlebar: 'ساطع',
+ header: 'متوهج'
+ },
+ translucencyScopeTitle: 'النطاق',
+ translucencyScope: {
+ window: 'النافذة كاملة',
+ sidebar: 'الشريط الجانبي فقط'
+ },
backdropTitle: 'خلفية النافذة',
backdropDesc: 'اختيار مقدار مزج خلفية سطح المكتب مع سطح Hermes.',
reactionsTitle: 'تفاعلات الرسائل',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index b3a795a2aab..81df9663f1e 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -486,9 +486,22 @@ 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.',
+ translucencyGlassDesc:
+ 'Matte glass: the desktop shows through as a smooth blur while text stays sharp. macOS only.',
translucencyModeClear: 'Clear',
translucencyModeGlass: 'Glass',
+ translucencyFrostTitle: 'Frost',
+ translucencyFrost: {
+ 'under-window': 'Deep',
+ popover: 'Soft',
+ titlebar: 'Bright',
+ header: 'Glare'
+ },
+ translucencyScopeTitle: 'Area',
+ translucencyScope: {
+ window: 'Whole window',
+ sidebar: 'Sidebar only'
+ },
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.ts
index 2c38998016b..148df8523bf 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -347,6 +347,18 @@ export const ja = defineLocale({
translucencyGlassDesc: 'マットガラス: デスクトップが滑らかなぼかしとして透け、テキストは鮮明なまま。macOS のみ。',
translucencyModeClear: 'クリア',
translucencyModeGlass: 'ガラス',
+ translucencyFrostTitle: 'くもりの質感',
+ translucencyFrost: {
+ 'under-window': '深い',
+ popover: 'やわらか',
+ titlebar: '明るい',
+ header: 'まぶしい'
+ },
+ translucencyScopeTitle: '適用範囲',
+ translucencyScope: {
+ window: 'ウィンドウ全体',
+ sidebar: 'サイドバーのみ'
+ },
backdropTitle: 'チャット背景',
backdropDesc: '会話の背後に表示される淡い彫像の画像。',
reactionsTitle: 'メッセージリアクション',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 130f141fd7b..053c1f0599a 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -389,6 +389,18 @@ export interface Translations {
translucencyGlassDesc: string
translucencyModeClear: string
translucencyModeGlass: string
+ translucencyFrostTitle: string
+ translucencyFrost: {
+ 'under-window': string
+ popover: string
+ titlebar: string
+ header: string
+ }
+ translucencyScopeTitle: string
+ translucencyScope: {
+ window: string
+ sidebar: string
+ }
backdropTitle: string
backdropDesc: string
reactionsTitle: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index d45a2e9a4d6..092bbf4e996 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -339,6 +339,18 @@ export const zhHant = defineLocale({
translucencyGlassDesc: '霧面玻璃:桌面以柔和模糊透出,文字保持清晰。僅支援 macOS。',
translucencyModeClear: '透明',
translucencyModeGlass: '玻璃',
+ translucencyFrostTitle: '磨砂質感',
+ translucencyFrost: {
+ 'under-window': '深邃',
+ popover: '柔和',
+ titlebar: '明亮',
+ header: '透亮'
+ },
+ translucencyScopeTitle: '套用範圍',
+ translucencyScope: {
+ window: '整個視窗',
+ sidebar: '僅側邊欄'
+ },
backdropTitle: '聊天背景',
backdropDesc: '對話後方那張淡淡的雕像圖片。',
reactionsTitle: '訊息回應',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 73b0d485398..70d2582aaa1 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -479,6 +479,18 @@ export const zh: Translations = {
translucencyGlassDesc: '磨砂玻璃:桌面以柔和模糊透出,文字保持清晰。仅支持 macOS。',
translucencyModeClear: '透明',
translucencyModeGlass: '玻璃',
+ translucencyFrostTitle: '磨砂质感',
+ translucencyFrost: {
+ 'under-window': '深邃',
+ popover: '柔和',
+ titlebar: '明亮',
+ header: '透亮'
+ },
+ translucencyScopeTitle: '应用范围',
+ translucencyScope: {
+ window: '整个窗口',
+ sidebar: '仅侧边栏'
+ },
backdropTitle: '聊天背景',
backdropDesc: '对话后方那张淡淡的雕像图片。',
reactionsTitle: '消息回应',
diff --git a/apps/desktop/src/store/translucency.test.ts b/apps/desktop/src/store/translucency.test.ts
index 9e78bdbe342..a6a0d9fcde3 100644
--- a/apps/desktop/src/store/translucency.test.ts
+++ b/apps/desktop/src/store/translucency.test.ts
@@ -5,10 +5,17 @@ import { onPersistenceEvent, type PersistenceEvent } from '@/lib/storage'
import {
$translucency,
+ $translucencyPeek,
+ beginTranslucencyPeek,
+ DEFAULT_GLASS_MATERIAL,
+ DEFAULT_GLASS_SCOPE,
+ endTranslucencyPeek,
GLASS_SUPPORTED,
isChatWindow,
setTranslucency,
+ setTranslucencyMaterial,
setTranslucencyMode,
+ setTranslucencyScope,
TRANSLUCENCY_MAX,
TRANSLUCENCY_MIN,
TRANSLUCENCY_STEP
@@ -33,7 +40,12 @@ describe('window translucency lever', () => {
})
it('defaults to off and clear', () => {
- expect($translucency.get()).toEqual({ intensity: TRANSLUCENCY_MIN, mode: 'clear' })
+ expect($translucency.get()).toEqual({
+ intensity: TRANSLUCENCY_MIN,
+ mode: 'clear',
+ material: DEFAULT_GLASS_MATERIAL,
+ scope: DEFAULT_GLASS_SCOPE
+ })
})
it('accepts every step the slider can emit', () => {
@@ -78,17 +90,29 @@ describe('window translucency lever', () => {
stop()
}
- expect(writes.at(-1)).toEqual({ key: KEY, op: 'write', value: JSON.stringify({ intensity: 23, mode: 'clear' }) })
+ expect(writes.at(-1)).toEqual({
+ key: KEY,
+ op: 'write',
+ value: JSON.stringify({
+ intensity: 23,
+ mode: 'clear',
+ material: DEFAULT_GLASS_MATERIAL,
+ scope: DEFAULT_GLASS_SCOPE
+ })
+ })
})
it('mirrors the whole state 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
+ const calls: unknown[] = []
+ window.hermesDesktop = { setTranslucency: (payload: unknown) => calls.push(payload) } as never
setTranslucency(40)
- expect(calls.at(-1)).toEqual({ intensity: 40, mode: 'clear' })
+ expect(calls.at(-1)).toEqual({
+ intensity: 40,
+ mode: 'clear',
+ material: DEFAULT_GLASS_MATERIAL,
+ scope: DEFAULT_GLASS_SCOPE
+ })
})
})
@@ -105,7 +129,7 @@ describe('glass mode', () => {
if (GLASS_SUPPORTED) {
expect($translucency.get().mode).toBe('glass')
expect(glassAttr()).toBe(true)
- expect(keep()).toBe('65%')
+ expect(keep()).toBe('50%')
} else {
expect($translucency.get().mode).toBe('clear')
expect(glassAttr()).toBe(false)
@@ -145,6 +169,75 @@ describe('glass mode', () => {
})
})
+describe('frost and area', () => {
+ beforeEach(() => {
+ setTranslucencyMode('clear')
+ setTranslucency(TRANSLUCENCY_MIN)
+ setTranslucencyMaterial(DEFAULT_GLASS_MATERIAL)
+ setTranslucencyScope(DEFAULT_GLASS_SCOPE)
+ })
+
+ it('carries the chosen material without disturbing the rest of the state', () => {
+ setTranslucency(40)
+ setTranslucencyMaterial('header')
+
+ expect($translucency.get().material).toBe('header')
+ expect($translucency.get().intensity).toBe(40)
+ })
+
+ it('rejects a material outside the shipped ladder', () => {
+ setTranslucencyMaterial('sidebar' as never)
+ expect($translucency.get().material).toBe(DEFAULT_GLASS_MATERIAL)
+ })
+
+ // The sidebar scope is the Finder shape, and styles.css keys its split-paint
+ // gradient off this attribute — so the attribute IS the contract.
+ it('publishes the area as an attribute only while glass is on', () => {
+ setTranslucency(50)
+ setTranslucencyScope('sidebar')
+
+ if (GLASS_SUPPORTED) {
+ setTranslucencyMode('glass')
+ expect(document.documentElement.getAttribute('data-hermes-glass-scope')).toBe('sidebar')
+
+ setTranslucencyScope('window')
+ expect(document.documentElement.getAttribute('data-hermes-glass-scope')).toBe('window')
+
+ setTranslucencyMode('clear')
+ }
+
+ expect(document.documentElement.hasAttribute('data-hermes-glass-scope')).toBe(false)
+ })
+})
+
+// A held slider drag and a timed pulse from a picker click can overlap, which
+// is why the peek counts rather than toggling: the drag must not be cancelled
+// by a pulse expiring underneath it.
+describe('translucency peek', () => {
+ it('stays open until every overlapping hold has ended', () => {
+ beginTranslucencyPeek()
+ beginTranslucencyPeek()
+ expect(document.documentElement.hasAttribute('data-hermes-translucency-peek')).toBe(true)
+
+ endTranslucencyPeek()
+ expect(document.documentElement.hasAttribute('data-hermes-translucency-peek')).toBe(true)
+
+ endTranslucencyPeek()
+ expect(document.documentElement.hasAttribute('data-hermes-translucency-peek')).toBe(false)
+ })
+
+ it('never goes negative, so a stray release cannot wedge the next peek open', () => {
+ endTranslucencyPeek()
+ endTranslucencyPeek()
+ expect($translucencyPeek.get()).toBe(0)
+
+ beginTranslucencyPeek()
+ expect(document.documentElement.hasAttribute('data-hermes-translucency-peek')).toBe(true)
+ endTranslucencyPeek()
+ expect(document.documentElement.hasAttribute('data-hermes-translucency-peek')).toBe(false)
+ })
+})
+
// Glass rewrites page surfaces, which is only correct in a real chat window.
// The HUD, pet overlay, quick entry and wake indicator are transparent
// special-purpose windows that own their own backgrounds.
diff --git a/apps/desktop/src/store/translucency.ts b/apps/desktop/src/store/translucency.ts
index eee1e9681ee..9753caa3241 100644
--- a/apps/desktop/src/store/translucency.ts
+++ b/apps/desktop/src/store/translucency.ts
@@ -13,33 +13,49 @@
import {
clampIntensity,
+ DEFAULT_GLASS_MATERIAL,
+ DEFAULT_GLASS_SCOPE,
+ GLASS_MATERIALS,
+ GLASS_SCOPES,
+ type GlassMaterial,
+ type GlassScope,
glassSurfaceKeep,
+ normalizeMaterial,
+ normalizeScope,
TRANSLUCENCY_MAX,
TRANSLUCENCY_MIN,
TRANSLUCENCY_STEP,
- type TranslucencyMode
+ type TranslucencyMode,
+ type TranslucencyState
} from '@hermes/shared/translucency'
import { atom } from 'nanostores'
import { isMacPlatform } from '@/lib/platform'
import { readJson, writeJson } from '@/lib/storage'
-export { TRANSLUCENCY_MAX, TRANSLUCENCY_MIN, TRANSLUCENCY_STEP, type TranslucencyMode }
+export {
+ DEFAULT_GLASS_MATERIAL,
+ DEFAULT_GLASS_SCOPE,
+ GLASS_MATERIALS,
+ GLASS_SCOPES,
+ type GlassMaterial,
+ type GlassScope,
+ glassSurfaceKeep,
+ TRANSLUCENCY_MAX,
+ TRANSLUCENCY_MIN,
+ TRANSLUCENCY_STEP,
+ type TranslucencyMode
+}
/** Glass rides on the macOS vibrancy material; other platforms only have Clear. */
export const GLASS_SUPPORTED = isMacPlatform()
const KEY = 'hermes.desktop.translucency.v1'
-interface PersistedTranslucency {
- intensity: number
- mode: TranslucencyMode
-}
-
// The v1 key used to hold a bare intensity (`"23"`). Anything without a mode
// predates glass and always behaved as clear, so it stays clear — a saved
// setting must not change how the window looks on update.
-const read = (): PersistedTranslucency => {
+const read = (): TranslucencyState => {
const stored = readJson<unknown>(KEY)
const record: Record<string, unknown> =
@@ -47,14 +63,18 @@ const read = (): PersistedTranslucency => {
return {
intensity: clampIntensity(record.intensity),
- mode: record.mode === 'glass' && GLASS_SUPPORTED ? 'glass' : 'clear'
+ mode: record.mode === 'glass' && GLASS_SUPPORTED ? 'glass' : 'clear',
+ material: normalizeMaterial(record.material),
+ scope: normalizeScope(record.scope)
}
}
-const initial: PersistedTranslucency =
- typeof window === 'undefined' ? { intensity: TRANSLUCENCY_MIN, mode: 'clear' } : read()
+const initial: TranslucencyState =
+ typeof window === 'undefined'
+ ? { intensity: TRANSLUCENCY_MIN, mode: 'clear', material: DEFAULT_GLASS_MATERIAL, scope: DEFAULT_GLASS_SCOPE }
+ : read()
-export const $translucency = atom<PersistedTranslucency>(initial)
+export const $translucency = atom<TranslucencyState>(initial)
export function setTranslucency(intensity: number): void {
$translucency.set({ ...$translucency.get(), intensity: clampIntensity(intensity) })
@@ -64,6 +84,14 @@ export function setTranslucencyMode(mode: TranslucencyMode): void {
$translucency.set({ ...$translucency.get(), mode: mode === 'glass' && GLASS_SUPPORTED ? 'glass' : 'clear' })
}
+export function setTranslucencyMaterial(material: GlassMaterial): void {
+ $translucency.set({ ...$translucency.get(), material: normalizeMaterial(material) })
+}
+
+export function setTranslucencyScope(scope: GlassScope): void {
+ $translucency.set({ ...$translucency.get(), scope: normalizeScope(scope) })
+}
+
// Glass thins surfaces only in real chat windows (the primary window and
// secondary session windows). The HUD, pet overlay, quick entry and wake
// indicator are transparent special-purpose windows that manage their own
@@ -78,7 +106,120 @@ export const isChatWindow = (search = typeof window === 'undefined' ? '' : windo
}
}
-const applyGlassSurfaces = ({ intensity, mode }: PersistedTranslucency): void => {
+/* Sidebar scope needs the rail's visual edge published on :root so <body>
+ can split its paint there (glass left of the seam, opaque chrome right of
+ it — the Finder shape). The rail is an in-flow div whose WIDTH animates
+ (components/ui/sidebar.tsx, collapsible='none' branch), so a
+ ResizeObserver sees every collapse/expand frame; a window resize listener
+ and a re-measure on every store sync cover the rest. RTL flips which side
+ the seam is measured from; styles.css picks the matching gradient
+ direction off html[dir]. */
+let railObserver: null | ResizeObserver = null
+let railTarget: Element | null = null
+let railTrackingOn = false
+
+const measureRailEdge = (): void => {
+ const root = document.documentElement
+ const rail = document.querySelector('[data-slot="sidebar"]')
+
+ if (rail !== railTarget) {
+ if (railObserver && railTarget) {
+ railObserver.unobserve(railTarget)
+ }
+
+ railTarget = rail
+
+ if (railObserver && rail) {
+ railObserver.observe(rail)
+ }
+ }
+
+ if (!rail) {
+ // No rail in this window (e.g. a pane-only layout): the seam sits at the
+ // window edge and the whole field stays opaque — glass simply waits for
+ // a rail to exist.
+ root.style.setProperty('--glass-rail-edge', '0px')
+
+ return
+ }
+
+ const rect = rail.getBoundingClientRect()
+ const rtl = getComputedStyle(root).direction === 'rtl'
+ const edge = rtl ? window.innerWidth - rect.left : rect.right
+
+ root.style.setProperty('--glass-rail-edge', `${Math.max(0, Math.round(edge))}px`)
+}
+
+const startRailTracking = (): void => {
+ if (railTrackingOn) {
+ measureRailEdge()
+
+ return
+ }
+
+ railTrackingOn = true
+
+ if (typeof ResizeObserver !== 'undefined' && !railObserver) {
+ railObserver = new ResizeObserver(() => measureRailEdge())
+ }
+
+ window.addEventListener('resize', measureRailEdge)
+ measureRailEdge()
+}
+
+const stopRailTracking = (): void => {
+ if (!railTrackingOn) {
+ return
+ }
+
+ railTrackingOn = false
+
+ if (railObserver && railTarget) {
+ railObserver.unobserve(railTarget)
+ }
+
+ railTarget = null
+ window.removeEventListener('resize', measureRailEdge)
+ document.documentElement.style.removeProperty('--glass-rail-edge')
+}
+
+/* Peek: while the user is actively adjusting translucency from Settings, the
+ overlay they stand in covers the very effect they're tuning — the scrim
+ plus a deliberately near-opaque card ([data-glass-raised]). A peek ghosts
+ the whole overlay layer so the live window IS the preview (see the
+ [data-hermes-translucency-peek] rules in styles.css). A counter rather
+ than a boolean: a held slider drag and a timed pulse from a picker click
+ can overlap. */
+const PEEK_ATTR = 'data-hermes-translucency-peek'
+
+export const $translucencyPeek = atom<number>(0)
+
+export function beginTranslucencyPeek(): void {
+ $translucencyPeek.set($translucencyPeek.get() + 1)
+}
+
+export function endTranslucencyPeek(): void {
+ $translucencyPeek.set(Math.max(0, $translucencyPeek.get() - 1))
+}
+
+/**
+ * Timed peek for one-shot changes (frost / area / mode clicks, keyboard
+ * slider steps): long enough to read the effect, short enough to hand the
+ * settings back without feeling stuck.
+ */
+export function pulseTranslucencyPeek(ms = 900): void {
+ beginTranslucencyPeek()
+
+ if (typeof window === 'undefined') {
+ endTranslucencyPeek()
+
+ return
+ }
+
+ window.setTimeout(endTranslucencyPeek, ms)
+}
+
+const applyGlassSurfaces = ({ intensity, mode, scope }: TranslucencyState): void => {
if (typeof document === 'undefined') {
return
}
@@ -95,10 +236,18 @@ const applyGlassSurfaces = ({ intensity, mode }: PersistedTranslucency): void =>
root.toggleAttribute('data-hermes-clear', clearOn)
if (glassOn) {
+ root.setAttribute('data-hermes-glass-scope', scope)
root.style.setProperty('--translucency-glass-keep', `${glassSurfaceKeep(intensity)}%`)
} else {
+ root.removeAttribute('data-hermes-glass-scope')
root.style.removeProperty('--translucency-glass-keep')
}
+
+ if (glassOn && scope === 'sidebar') {
+ startRailTracking()
+ } else {
+ stopRailTracking()
+ }
}
if (typeof window !== 'undefined') {
@@ -107,4 +256,12 @@ if (typeof window !== 'undefined') {
applyGlassSurfaces(state)
window.hermesDesktop?.setTranslucency?.(state)
})
+
+ $translucencyPeek.subscribe(count => {
+ if (typeof document === 'undefined') {
+ return
+ }
+
+ document.documentElement.toggleAttribute(PEEK_ATTR, count > 0)
+ })
}
diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.css
index c87d0327ab0..be7286e6f7d 100644
--- a/apps/desktop/src/styles.css
+++ b/apps/desktop/src/styles.css
@@ -587,6 +587,32 @@
background: color-mix(in srgb, var(--ui-bg-chrome) var(--translucency-glass-keep, 100%), transparent);
}
+ /* Sidebar scope (the Finder shape): glass rail, opaque content column.
+ <body> stays the one painter but splits at the rail's visual edge — the
+ store publishes it as --glass-rail-edge (live-tracked through collapse
+ animation and pane resizes). Left of the seam: the normal glass mix.
+ Right of it: the full opaque chrome. A hard gradient stop, so there is
+ no smear across the seam; RTL mirrors via html[dir='rtl']. The content
+ column's own surfaces stay transparent (they'd double-paint the tint
+ otherwise) — the body backdrop alone restores the opaque look. */
+ :root[data-hermes-glass][data-hermes-glass-scope='sidebar'] body {
+ background: linear-gradient(
+ to right,
+ color-mix(in srgb, var(--ui-bg-chrome) var(--translucency-glass-keep, 100%), transparent)
+ var(--glass-rail-edge, 0px),
+ var(--ui-bg-chrome) var(--glass-rail-edge, 0px)
+ );
+ }
+
+ :root[data-hermes-glass][data-hermes-glass-scope='sidebar'][dir='rtl'] body {
+ background: linear-gradient(
+ to left,
+ color-mix(in srgb, var(--ui-bg-chrome) var(--translucency-glass-keep, 100%), transparent)
+ var(--glass-rail-edge, 0px),
+ var(--ui-bg-chrome) var(--glass-rail-edge, 0px)
+ );
+ }
+
/* The app shell's two full-window opaque painters (the contrib controller
root and the SidebarProvider wrapper) sit between <body> and every
surface. Their fills are Tailwind utilities (bg-(--ui-bg-chrome) /
@@ -642,6 +668,30 @@
backdrop-filter: blur(0.5rem) !important;
}
+ /* Translucency peek: while the user holds the intensity slider (or for a
+ short pulse after a frost/area/mode click) the entire overlay layer —
+ scrim, blur and near-opaque card as ONE group — ghosts down so the live
+ window behind it becomes the preview. The layer keeps pointer events:
+ a held drag keeps delivering to the slider it started on. Opacity is
+ the one property that fades the scrim, its backdrop-blur and the card
+ together without relayout. Asymmetric easing: quick reveal while the
+ hand is on the control, unhurried return.
+
+ Both the peek and its return are scoped to a settings overlay that has
+ ARMED the interaction ([data-translucency-peek-scope], set by the
+ appearance row). An unscoped `[data-overlay-surface] { transition:
+ opacity … }` would tax every overlay in the app — command center, cron,
+ agents, model picker — with a 420ms opacity transition for the life of
+ the process, to serve one slider. */
+ :root [data-overlay-surface]:has([data-translucency-peek-scope]) {
+ transition: opacity 420ms cubic-bezier(0.22, 1, 0.36, 1);
+ }
+
+ :root[data-hermes-translucency-peek] [data-overlay-surface]:has([data-translucency-peek-scope]) {
+ opacity: 0.08;
+ transition: opacity 160ms cubic-bezier(0.32, 0.72, 0, 1);
+ }
+
* {
box-sizing: border-box;
border-color: var(--dt-border);
diff --git a/apps/shared/src/index.ts b/apps/shared/src/index.ts
index bd4edf5fff3..b4f6299ca22 100644
--- a/apps/shared/src/index.ts
+++ b/apps/shared/src/index.ts
@@ -64,9 +64,17 @@ export {
} from './skin'
export {
clampIntensity,
+ DEFAULT_GLASS_MATERIAL,
+ DEFAULT_GLASS_SCOPE,
+ GLASS_MATERIALS,
+ GLASS_SCOPES,
glassActive,
+ type GlassMaterial,
+ type GlassScope,
glassSurfaceKeep,
+ normalizeMaterial,
normalizeMode,
+ normalizeScope,
normalizeState,
TRANSLUCENCY_CURVE,
TRANSLUCENCY_MAX,
@@ -75,6 +83,7 @@ export {
TRANSLUCENCY_STEP,
type TranslucencyMode,
type TranslucencyState,
+ vibrancyFor,
windowOpacityFor
} from './translucency'
export {
diff --git a/apps/shared/src/translucency.ts b/apps/shared/src/translucency.ts
index 0bc825dcd72..c58730af54b 100644
--- a/apps/shared/src/translucency.ts
+++ b/apps/shared/src/translucency.ts
@@ -20,9 +20,44 @@
export type TranslucencyMode = 'clear' | 'glass'
+/**
+ * macOS vibrancy materials offered as glass "frost" levels, ordered sheer →
+ * heavy. macOS exposes no blur-radius knob (VibrancyOptions is only an
+ * animation duration), so the material IS the frost control: each maps to a
+ * different NSVisualEffectView material with its own luminance lift.
+ *
+ * Curated by pixel census on macOS 26 (one window, visualEffectState pinned
+ * to 'active', cycling all 14 materials over the same wallpaper): the 14
+ * collapse to 9 distinct looks (sidebar≡hud, window≡fullscreen-ui,
+ * tooltip≡content≡under-window≡under-page). These four are the ladder with
+ * the widest separations that stay distinct in BOTH appearances — dark lum
+ * 26/63/84/127, light lum 217/233/254/242. sidebar/hud sit 9 lum from
+ * under-window when focused and collapse INTO it when unfocused, which
+ * shipped as two indistinguishable picker options once — don't re-add them.
+ */
+export const GLASS_MATERIALS = ['under-window', 'popover', 'titlebar', 'header'] as const
+
+export type GlassMaterial = (typeof GLASS_MATERIALS)[number]
+
+export const DEFAULT_GLASS_MATERIAL: GlassMaterial = 'under-window'
+
+/**
+ * Where the glass field lives. 'window' thins every field surface; 'sidebar'
+ * is the Finder shape — glass rail, opaque content column. The scope is a
+ * renderer concern (which surfaces thin); the main process only persists and
+ * echoes it.
+ */
+export const GLASS_SCOPES = ['window', 'sidebar'] as const
+
+export type GlassScope = (typeof GLASS_SCOPES)[number]
+
+export const DEFAULT_GLASS_SCOPE: GlassScope = 'window'
+
export interface TranslucencyState {
intensity: number
mode: TranslucencyMode
+ material: GlassMaterial
+ scope: GlassScope
}
export const TRANSLUCENCY_MIN = 0
@@ -58,13 +93,25 @@ export function normalizeMode(value: unknown, isMac: boolean): TranslucencyMode
return value === 'glass' && isMac ? 'glass' : 'clear'
}
+/** Unknown or unsupported values fall back to the default material. */
+export function normalizeMaterial(value: unknown): GlassMaterial {
+ return GLASS_MATERIALS.includes(value as GlassMaterial) ? (value as GlassMaterial) : DEFAULT_GLASS_MATERIAL
+}
+
+/** Unknown or unsupported values fall back to whole-window glass. */
+export function normalizeScope(value: unknown): GlassScope {
+ return GLASS_SCOPES.includes(value as GlassScope) ? (value as GlassScope) : DEFAULT_GLASS_SCOPE
+}
+
/** Parse a persisted translucency.json / IPC payload into a safe state. */
export function normalizeState(payload: unknown, isMac: boolean): TranslucencyState {
const record = payload && typeof payload === 'object' ? (payload as Record<string, unknown>) : {}
return {
intensity: clampIntensity(record.intensity),
- mode: normalizeMode(record.mode, isMac)
+ mode: normalizeMode(record.mode, isMac),
+ material: normalizeMaterial(record.material),
+ scope: normalizeScope(record.scope)
}
}
@@ -91,10 +138,21 @@ export function glassActive({ intensity, mode }: TranslucencyState): boolean {
}
/**
- * Percent of the surface tint the renderer KEEPS at a given intensity. Mirrors
- * clear mode's opacity floor: at 100 the field still holds a 30% wash, so glass
- * reads as tinted blur rather than bare desktop.
+ * Percent of the surface tint the renderer KEEPS at a given intensity. Linear
+ * to zero: at 100 the tint is fully gone — bare vibrancy glass — so the slider
+ * spans the whole range from opaque theme to untinted blur. Text and cards
+ * keep their own opaque tokens for contrast; only the field surfaces thin.
*/
export function glassSurfaceKeep(intensity: number): number {
- return TRANSLUCENCY_MAX - clampIntensity(intensity) * (1 - TRANSLUCENCY_OPACITY_FLOOR)
+ return TRANSLUCENCY_MAX - clampIntensity(intensity)
+}
+
+/**
+ * The vibrancy material a chat window should carry. 'sidebar' is the
+ * long-standing default the titlebar band was designed against; glass mode
+ * swaps the whole window onto the user's chosen material (setVibrancy is
+ * cheap and animatable at runtime, unlike the backing).
+ */
+export function vibrancyFor(state: TranslucencyState): GlassMaterial | 'sidebar' {
+ return glassActive(state) ? state.material : 'sidebar'
}