hermes-agent/apps/desktop/src
Brooklyn Nicholson f7bf740640 fix(desktop): reject cross-wired runtime-id cache on session resume
resumeSession's warm-cache fast-path trusted the
storedSessionId -> runtimeId -> ClientSessionState mapping without
checking the cached state still BELONGS to the session being resumed.
A pooled profile backend that gets idle-reaped and respawned
(pruneSecondaryGateways) re-mints runtime ids, so a recycled id can
resolve to a live-but-DIFFERENT session's cache entry. The only
existing guard was a session.usage 404 -- that catches a fully-dead
runtime id, but a recycled id still 200s, so the fast-path happily
painted the wrong transcript under the current route (open chat A,
chat B loads).

Fold the belongs-to check into a single takeWarmCache() helper used at
BOTH cache reads -- the early transcript-keep decision and the fast-path
itself -- so a cross-wired entry can't even briefly flash a stale
transcript before the full resume repaints. On a mismatch the helper
purges both stale map entries and reports a miss, falling through to a
full resume that rebinds a correct runtime id. The full-resume path
already guards its final paint with isCurrentResume(), so only the
cached fast-path was missing the belongs-to check.

Pre-existing bug from the initial desktop app (#20059); not introduced
by the session-switch perf work (#49807), which left these lines
untouched.

Tests: two cases in use-session-actions.test.tsx driven through a
harness that owns the two cache maps -- a cross-wired mapping is
rejected + purged (the bug), and a correctly-wired cache still serves
from memory with no needless refetch (no perf regression).

Supersedes #50464 by @professorpalmer, reimplemented to also guard the
early transcript-keep read (whole-class fix, not just the fast-path).

Co-authored-by: professorpalmer <professorpalmer@users.noreply.github.com>
2026-06-25 16:11:18 -05:00
..
app fix(desktop): reject cross-wired runtime-id cache on session resume 2026-06-25 16:11:18 -05:00
components fix(ui): share compact tool previews across clients 2026-06-25 00:47:14 -05:00
fonts fix(desktop): crisp terminal text via opaque xterm canvas 2026-06-12 19:36:30 -05:00
hooks fix(desktop): keep generated images in the tool slot, not inline 2026-06-13 02:42:15 -05:00
i18n feat(pets): remix a draft into a fresh round 2026-06-25 01:09:19 -05:00
lib fix(desktop): compact tool row titles 2026-06-25 00:01:11 -05:00
store feat(pets): remix a draft into a fresh round 2026-06-25 01:09:19 -05:00
themes feat(desktop): composer status stack, live subagent windows, editable prompts (#44630) 2026-06-12 08:30:06 -05:00
types feat(moa): expose MoA presets as selectable virtual models (#46081) 2026-06-25 13:52:06 -07:00
global.d.ts Merge remote-tracking branch 'origin/main' into bb/pets-merge 2026-06-23 19:05:22 -05:00
hermes-profile-scope.test.ts fix(desktop): route gateway restart / status / update to the active profile 2026-06-24 19:16:26 -05:00
hermes.test.ts fix(desktop): route profile session reads 2026-06-11 18:09:24 -05:00
hermes.ts feat(moa): expose MoA presets as selectable virtual models (#46081) 2026-06-25 13:52:06 -07:00
main.tsx feat(desktop): floating pet, pop-out overlay + Cmd+K picker 2026-06-20 14:18:40 -05:00
styles.css feat(pets): polish generate flow and reduce hatch CPU pressure 2026-06-24 19:08:06 -05:00
vite-env.d.ts Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00