Files
hermes-agent/apps
Brooklyn Nicholson f3bfa9ae53 perf(desktop): stop the translucency slider thrashing the main process
Dragging the intensity slider was janky, and the four frost levels looked
nearly identical. Same cause.

At step=1 a drag emits ~100 updates, and every one of them did four
expensive things: a synchronous localStorage.setItem, an IPC wake, a
synchronous fs.writeFileSync in main, and setVibrancy + setBackgroundColor
on every open window. The vibrancy call is the one that also broke the
frost picker — it animates over 150ms, so re-issuing it per tick restarted
the animation before macOS could ever settle the material. The levels
weren't indistinguishable, they were never finishing.

The fix follows from a property the mode already has: under glass the
intensity is a pure renderer concern. windowOpacityFor returns 1 for the
whole range, so main has nothing to do on an intensity change at all.

- main diffs the incoming state against the current one and passes a
  `changed` set to applyWindowTranslucency. An intensity-only change under
  glass now touches zero native properties. Crossing zero still moves the
  backing, since that flips glass on and off.
- main's disk write is coalesced onto a 250ms trailing timer, flushed on
  before-quit. Only a cold launch reads that file.
- the renderer paints every tick (the field has to track the hand) but
  coalesces the localStorage write and the IPC send onto a 120ms trailing
  timer, flushed on pagehide.

Covered as contracts rather than timings: a table asserting exactly what
each kind of update changes natively (nothing, across the whole intensity
range under glass), and store tests that a six-tick drag produces one write
and one IPC call while every intermediate value still paints. Both
directions mutation-checked — restoring per-tick writes fails, and
debouncing the paint fails too.
2026-08-18 00:57:01 -05:00
..