hermes-agent/apps/desktop/src/app/chat
joaomarcos 2afa92c74f fix(desktop): pin composer draft scope to the swap-effect owner, not the render ref
Fixes #54527 — a message typed into one TUI session could be silently
misrouted into (or overwritten by) another concurrently-open session.

Root cause: activeQueueSessionKeyRef is written on every render, but the
debounced draft-persist timer, the pagehide flush, and dispatchSubmit's
reject-restore path all read it lazily at async-resolve time instead of
capturing the scope that was active when the operation started. A session
switch landing between capture and resolve relabels one session's text
under the other session's key. A large paste widens the window (slower
synchronous render), which matches the original report.

Fix: introduce draftScopeRef, written only by the draft-swap effect (so it
always reflects the session whose text is actually loaded in the editor)
and read it instead of the render-time ref at both async write sites.
dispatchSubmit's restore() now uses the submittedScope already captured at
dispatch instead of re-reading the live ref.

Also adds isPendingDraftPersistCurrent as defense-in-depth: before the
debounce timer commits a write, it verifies its captured {scope, text}
pair is still the one on file. This is a no-op under the fix above (a
session swap or a newer keystroke already clears/replaces the pending
entry via clearTimeout), but turns any future regression that reintroduces
a stale/live-ref read at this call site into a dropped write instead of a
silent cross-session misroute.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-10 19:35:05 -07:00
..
composer fix(desktop): pin composer draft scope to the swap-effect owner, not the render ref 2026-07-10 19:35:05 -07:00
hooks refactor(desktop): adopt shared utils + app-wide cleanups 2026-07-03 13:48:44 -05:00
right-rail refactor(desktop): route preview-pane mermaid fences through shared embeds registry 2026-07-07 02:39:18 -07:00
sidebar refactor(desktop): adopt shared utils + app-wide cleanups 2026-07-03 13:48:44 -05:00
chat-drop-overlay.tsx Refactor desktop i18n field copy into nested structures 2026-06-06 07:51:44 -07:00
chat-swap-overlay.tsx Refactor desktop i18n field copy into nested structures 2026-06-06 07:51:44 -07:00
index.tsx chore(desktop): remove the DEV Shift+H heart preview 2026-07-10 16:09:23 -05:00
perf-probe.tsx chore(desktop): zero eslint/typecheck debt + prettier pass (#39100) 2026-06-04 14:10:38 +00:00
scroll-to-bottom-button.test.tsx fix(desktop): surface off-screen approvals via the jump-to-bottom control (#45853) 2026-06-13 23:07:22 +00:00
scroll-to-bottom-button.tsx fix(desktop): surface off-screen approvals via the jump-to-bottom control (#45853) 2026-06-13 23:07:22 +00:00
thread-loading.test.ts Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
thread-loading.ts perf(desktop): isolate streaming re-renders & cut layout thrash 2026-06-12 21:07:33 -05:00