Skip to content

The agent that grows with you

refactor(desktop): trim the glass surface

Brooklyn Nicholson7a81dd9efdaa
diff --git a/apps/desktop/electron/translucency.ts b/apps/desktop/electron/translucency.ts
index 30c12970826..cb9b2f28bfe 100644
--- a/apps/desktop/electron/translucency.ts
+++ b/apps/desktop/electron/translucency.ts
@@ -21,7 +21,6 @@ export {
GLASS_SCOPES,
glassActive,
type GlassMaterial,
- type GlassScope,
glassSurfaceKeep,
normalizeMaterial,
normalizeMode,
@@ -31,8 +30,6 @@ export {
TRANSLUCENCY_MAX,
TRANSLUCENCY_MIN,
TRANSLUCENCY_OPACITY_FLOOR,
- TRANSLUCENCY_STEP,
- type TranslucencyMode,
type TranslucencyState,
vibrancyFor,
windowOpacityFor
diff --git a/apps/desktop/src/app/settings/appearance-settings.tsx b/apps/desktop/src/app/settings/appearance-settings.tsx
index 84951d8bbdc..0fd8fd5e38e 100644
--- a/apps/desktop/src/app/settings/appearance-settings.tsx
+++ b/apps/desktop/src/app/settings/appearance-settings.tsx
@@ -300,6 +300,20 @@ export function AppearanceSettings() {
// every outstanding hold.
useEffect(() => resetTranslucencyPeek, [])
+ // Shared by the mode/frost/area pickers: apply the choice, then show it
+ // through the overlay it just altered (a pulse, not a hold — see the peek
+ // notes on the slider itself).
+ const pickTranslucency =
+ <T,>(set: (value: T) => void) =>
+ (value: T) => {
+ triggerHaptic('selection')
+ set(value)
+
+ if (translucency.intensity > 0) {
+ pulseTranslucencyPeek()
+ }
+ }
+
const [query, setQuery] = useState('')
// One box does double duty: filter installed themes live (below), and run a
@@ -506,15 +520,7 @@ export function AppearanceSettings() {
>
{GLASS_SUPPORTED && (
<SegmentedControl
- onChange={id => {
- triggerHaptic('selection')
- setTranslucencyMode(id)
-
- // Show the change through the overlay it just altered.
- if (translucency.intensity > 0) {
- pulseTranslucencyPeek()
- }
- }}
+ onChange={pickTranslucency(setTranslucencyMode)}
options={[
{ id: 'clear' as const, label: a.translucencyModeClear },
{ id: 'glass' as const, label: a.translucencyModeGlass }
@@ -563,14 +569,7 @@ export function AppearanceSettings() {
{a.translucencyFrostTitle}
</span>
<SegmentedControl
- onChange={id => {
- triggerHaptic('selection')
- setTranslucencyMaterial(id)
-
- if (translucency.intensity > 0) {
- pulseTranslucencyPeek()
- }
- }}
+ onChange={pickTranslucency(setTranslucencyMaterial)}
options={GLASS_MATERIALS.map(material => ({
id: material,
label: a.translucencyFrost[material]
@@ -583,14 +582,7 @@ export function AppearanceSettings() {
{a.translucencyScopeTitle}
</span>
<SegmentedControl
- onChange={id => {
- triggerHaptic('selection')
- setTranslucencyScope(id)
-
- if (translucency.intensity > 0) {
- pulseTranslucencyPeek()
- }
- }}
+ onChange={pickTranslucency(setTranslucencyScope)}
options={GLASS_SCOPES.map(scope => ({
id: scope,
label: a.translucencyScope[scope]
diff --git a/apps/desktop/src/store/translucency.test.ts b/apps/desktop/src/store/translucency.test.ts
index d09744a7a22..3ddaa39fcf8 100644
--- a/apps/desktop/src/store/translucency.test.ts
+++ b/apps/desktop/src/store/translucency.test.ts
@@ -10,14 +10,14 @@ vi.hoisted(() => {
Object.defineProperty(globalThis.navigator, 'platform', { configurable: true, value: 'MacIntel' })
})
+import { DEFAULT_GLASS_MATERIAL, DEFAULT_GLASS_SCOPE } from '@hermes/shared/translucency'
+
import { onPersistenceEvent, type PersistenceEvent } from '@/lib/storage'
import {
$translucency,
$translucencyPeek,
beginTranslucencyPeek,
- DEFAULT_GLASS_MATERIAL,
- DEFAULT_GLASS_SCOPE,
endTranslucencyPeek,
GLASS_SUPPORTED,
isChatWindow,
diff --git a/apps/desktop/src/store/translucency.ts b/apps/desktop/src/store/translucency.ts
index 2b2960c257b..a5e0cd6efa9 100644
--- a/apps/desktop/src/store/translucency.ts
+++ b/apps/desktop/src/store/translucency.ts
@@ -33,19 +33,7 @@ import { atom } from 'nanostores'
import { isMacPlatform } from '@/lib/platform'
import { readJson, writeJson } from '@/lib/storage'
-export {
- DEFAULT_GLASS_MATERIAL,
- DEFAULT_GLASS_SCOPE,
- GLASS_MATERIALS,
- GLASS_SCOPES,
- type GlassMaterial,
- type GlassScope,
- glassSurfaceKeep,
- TRANSLUCENCY_MAX,
- TRANSLUCENCY_MIN,
- TRANSLUCENCY_STEP,
- type TranslucencyMode
-}
+export { GLASS_MATERIALS, GLASS_SCOPES, TRANSLUCENCY_MAX, TRANSLUCENCY_MIN, TRANSLUCENCY_STEP }
/** Glass rides on the macOS vibrancy material; other platforms only have Clear. */
export const GLASS_SUPPORTED = isMacPlatform()