mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
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. |
||
|---|---|---|
| .. | ||
| bootstrap-installer | ||
| desktop | ||
| shared | ||