hermes-agent/apps
ethernet 210e6b5643 fix(desktop): replace atom-mirrored refs with synchronous writes + direct reads
The atom-mirrored-ref antipattern (useEffect syncing a ref from a store
value) lags the atom by one render. Callbacks that read the ref after an
await or through a stable-ref bag get stale values. This fixes all 11
sites identified in the audit:

Confirmed bugs (PR #66485 class):
- use-session-state-cache.ts: activeSessionIdRef, busyRef,
  selectedStoredSessionIdRef — now synced synchronously during render
  instead of via useEffect. Fixes the one-render lag that caused
  cancelRun to interrupt the wrong session.

Latent bugs:
- use-gateway-request.ts: gatewayStateRef → $gatewayState.get() in
  ensureGatewayOpen (deps=[]), removed mirroring effect entirely
- use-voice-conversation.ts: enabledRef, mutedRef, busyRef, statusRef
  → synced synchronously during render (same pattern as session-state-cache)
- model-settings.tsx: moaRef → setMoa(updater) with functional update,
  removed mirroring effect
- i18n/context.tsx: localeRef → locale captured directly in setLocale
  callback, added to dep array
- user-edit-composer.tsx: draftRef mirror removed, appendExternalText
  reads draft from closure (added to deps)

The remaining eslint-disable comments on useEffect ref writes are
legitimate non-mirror patterns: prev-value tracking, staging buffers,
state flags, and direct ref writes paired with atom setters.
2026-07-17 16:35:43 -04:00
..
bootstrap-installer fmt(js): npm run fix on merge (#65229) 2026-07-15 21:40:56 +00:00
desktop fix(desktop): replace atom-mirrored refs with synchronous writes + direct reads 2026-07-17 16:35:43 -04:00
shared fmt(js): npm run fix on merge (#65229) 2026-07-15 21:40:56 +00:00