hermes-agent/apps/desktop/src/app/session/hooks
Brooklyn Nicholson fdc0d19566 fix(desktop): make draft persistence actually fire — new-chat sentinel, reload flush, session-switch clears
Manual testing of the salvaged draft persistence showed none of it worked
end-to-end. Three distinct bugs, all invisible to the store-level unit
tests:

1. New-chat drafts were never written. The skip-one-persist sentinel was
   reset to null after consuming, but null IS a real scope (the unsaved
   new-session draft) — so in a new chat every persist run matched the
   "consumed" sentinel and bailed. This silently killed the headline
   #38498 fix. Use undefined as the no-skip sentinel, which can never
   collide with a scope.

2. Cmd+R inside the debounce window dropped the trailing text. React does
   not run effect cleanups on a page reload, so the flush-on-unmount
   never fired; with the 400ms debounce that meant type-then-reload lost
   the draft every time. Flush pending writes on pagehide.

3. Session switch/new/resume/branch paths in use-session-actions cleared
   the composer stores synchronously with the session-id updates. React
   batches those, so by the time ChatBar's scope-change cleanup ran to
   stash the departing session's attachments, the store was already
   empty — the stash recorded [] and the chips were lost anyway. The
   composer's per-scope restore now owns composer contents wholesale on
   scope change, so drop the upstream clears (clearComposerDraft only
   touched the vestigial $composerDraft atom nothing reads).

Co-authored-by: mollusk <roger@roger.local>
Co-authored-by: Teknium <127238744+teknium1@users.noreply.github.com>
2026-06-10 22:58:50 -05:00
..
use-context-suggestions.ts Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
use-cwd-actions.ts Refactor desktop i18n field copy into nested structures 2026-06-06 07:51:44 -07:00
use-hermes-config.ts Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
use-message-stream.ts fix(desktop): keep model runtime state per session (#43702) 2026-06-10 18:16:50 +00:00
use-model-controls.test.tsx fix(desktop): keep model runtime state per session (#43702) 2026-06-10 18:16:50 +00:00
use-model-controls.ts fix(desktop): keep model runtime state per session (#43702) 2026-06-10 18:16:50 +00:00
use-preview-routing.test.tsx Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
use-preview-routing.ts Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
use-prompt-actions.test.tsx desktop: registry-driven slash commands + first-class /resume & /handoff (#42351) 2026-06-11 01:49:24 +00:00
use-prompt-actions.ts desktop: registry-driven slash commands + first-class /resume & /handoff (#42351) 2026-06-11 01:49:24 +00:00
use-route-resume.test.tsx fix(desktop): rebind sessions after websocket reconnect (salvage of #41740) (#43004) 2026-06-09 19:01:00 +00:00
use-route-resume.ts fix(desktop): rebind sessions after websocket reconnect (salvage of #41740) (#43004) 2026-06-09 19:01:00 +00:00
use-session-actions.ts fix(desktop): make draft persistence actually fire — new-chat sentinel, reload flush, session-switch clears 2026-06-10 22:58:50 -05:00
use-session-state-cache.test.tsx fix(desktop): make the running-turn timer per-session (#41182) 2026-06-07 04:29:05 -07:00
use-session-state-cache.ts fix(desktop): keep model runtime state per session (#43702) 2026-06-10 18:16:50 +00:00