The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): finer window translucency steps
Nicky Molina62beeeef8497
diff --git a/apps/desktop/src/app/settings/appearance-settings.tsx b/apps/desktop/src/app/settings/appearance-settings.tsxindex 425b8a86d12..fc7dda78cb7 100644--- a/apps/desktop/src/app/settings/appearance-settings.tsx+++ b/apps/desktop/src/app/settings/appearance-settings.tsx@@ -20,7 +20,13 @@ import { $reactionsEnabled, setReactionsEnabled } from '@/store/reactions-enableimport { $reasoningCollapsedByDefault, setReasoningCollapsedByDefault } from '@/store/reasoning-disclosure'import { $sessionListDensity, type SessionListDensity, setSessionListDensity } from '@/store/session-list-density'import { $toolViewMode, setToolViewMode } from '@/store/tool-view'-import { $translucency, setTranslucency } from '@/store/translucency'+import {+ $translucency,+ setTranslucency,+ TRANSLUCENCY_MAX,+ TRANSLUCENCY_MIN,+ TRANSLUCENCY_STEP+} from '@/store/translucency'import { $zoomPercent, setZoomPercent } from '@/store/zoom'import { getBaseColors, useTheme } from '@/themes/context'import { installVscodeThemeFromMarketplace } from '@/themes/install'@@ -466,13 +472,13 @@ export function AppearanceSettings() {<inputaria-label={a.translucencyTitle}className="h-1 w-40 cursor-pointer appearance-none rounded-full bg-(--ui-stroke-tertiary)"- max={100}- min={0}+ max={TRANSLUCENCY_MAX}+ min={TRANSLUCENCY_MIN}onChange={event => {triggerHaptic('selection')setTranslucency(Number(event.target.value))}}- step={5}+ step={TRANSLUCENCY_STEP}style={{ accentColor: 'var(--dt-primary)' }}type="range"value={translucency}diff --git a/apps/desktop/src/store/translucency.test.ts b/apps/desktop/src/store/translucency.test.tsnew file mode 100644index 00000000000..b3edc6da23f--- /dev/null+++ b/apps/desktop/src/store/translucency.test.ts@@ -0,0 +1,59 @@+import { beforeEach, describe, expect, it } from 'vitest'++import { onPersistenceEvent, type PersistenceEvent } from '@/lib/storage'++import { $translucency, setTranslucency, TRANSLUCENCY_MAX, TRANSLUCENCY_MIN, TRANSLUCENCY_STEP } from './translucency'++const KEY = 'hermes.desktop.translucency.v1'++describe('window translucency lever', () => {+ beforeEach(() => setTranslucency(TRANSLUCENCY_MIN))++ it('steps in single percent so the readable low end is reachable', () => {+ expect(TRANSLUCENCY_STEP).toBe(1)+ expect(TRANSLUCENCY_MIN).toBe(0)+ expect(TRANSLUCENCY_MAX).toBe(100)+ })++ it('defaults to off', () => {+ expect($translucency.get()).toBe(TRANSLUCENCY_MIN)+ })++ it('accepts every step the slider can emit', () => {+ for (let intensity = TRANSLUCENCY_MIN; intensity <= TRANSLUCENCY_MAX; intensity += TRANSLUCENCY_STEP) {+ setTranslucency(intensity)+ expect($translucency.get()).toBe(intensity)+ }+ })++ it('clamps out-of-range input to the lever bounds', () => {+ setTranslucency(-40)+ expect($translucency.get()).toBe(TRANSLUCENCY_MIN)++ setTranslucency(240)+ expect($translucency.get()).toBe(TRANSLUCENCY_MAX)+ })++ it('rounds fractional input to a whole percent', () => {+ setTranslucency(35.6)+ expect($translucency.get()).toBe(36)+ })++ it('persists under a stable key so a saved setting survives upgrades', () => {+ const writes: PersistenceEvent[] = []++ const stop = onPersistenceEvent(event => {+ if (event.op === 'write') {+ writes.push(event)+ }+ })++ try {+ setTranslucency(23)+ } finally {+ stop()+ }++ expect(writes).toContainEqual({ key: KEY, op: 'write', value: '23' })+ })+})diff --git a/apps/desktop/src/store/translucency.ts b/apps/desktop/src/store/translucency.tsindex 9038a0d2f74..b63c7c446eb 100644--- a/apps/desktop/src/store/translucency.ts+++ b/apps/desktop/src/store/translucency.ts@@ -16,7 +16,14 @@ import { persistString, storedString } from '@/lib/storage'const KEY = 'hermes.desktop.translucency.v1'-const clamp = (n: number): number => Math.min(100, Math.max(0, Math.round(n)))+// 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+// is renderer-only: the main process takes any integer in range.+export const TRANSLUCENCY_MIN = 0+export const TRANSLUCENCY_MAX = 100+export const TRANSLUCENCY_STEP = 1++const clamp = (n: number): number => Math.min(TRANSLUCENCY_MAX, Math.max(TRANSLUCENCY_MIN, Math.round(n)))const read = (): number => {const n = Number(storedString(KEY))