hermes-agent/apps/desktop/src
brooklyn! e59dcf46f1
fix(desktop): end the #67603 model-switch dup, cross-profile session bleed, and [System:] bubble (#69861)
* fix(desktop): stop model-switch dup + route recovery resumes to the owning profile

Fixes two Desktop session-reconciliation symptoms from #67603.

Symptom 1 — duplicated user bubble after a model switch. The gateway
persists model-switch / personality notices as role=user `[System: …]`
rows (tui_gateway/server.py) so strict OpenAI-compatible providers don't
reject a non-leading system message (#48338). `preserveLocalPendingTurnMessages`
paired local optimistic rows with the stored transcript by user-role
ordinal, so a marker between two real user turns shifted every later
ordinal and the optimistic row was re-appended at the bottom. The single
trailing-marker case is already covered by the compression-era
`latestAuthoritativeUser` guard, but two switches around one turn (marker
before AND after the committed prompt) still duplicated it. Exclude
`[System:` bookkeeping markers from ordinal pairing on both sides.

Symptom 2 — a session appearing under two profiles. The main resume path
already resolves a session's owning profile via `resolveStoredSession`
(cache → active backend → cross-profile probe), but the recovery
`session.resume` calls (stale runtime id, session-not-found, wedged loop,
redirect) omitted `profile`, so the gateway fell back to the launch-profile
DB and forked the conversation into the wrong profile. Route every recovery
resume — and an uncached right-click branch — through the same resolver so
the profile is carried even for sessions outside the paginated sidebar
window (the cache-miss gap).

Tests: discriminating two-switch marker test (fails before, passes after);
cache-hit + cross-profile cache-miss coverage for the recovery resume and
for branching an uncached session.

Supersedes #68665 and #63590.
Closes #67603.

Co-authored-by: Dolverin <5910064+Dolverin@users.noreply.github.com>
Co-authored-by: oliviaaaa7788 <274182427+oliviaaaa7788@users.noreply.github.com>

* fix(desktop): scope the remembered session id per profile

A single global `hermes.desktop.lastSessionId` key remembered ONE session
across every profile, so a relaunch or cold start under profile B would try
to restore a session owned by profile A — reinforcing the impression that a
conversation had bled between profiles (#67603, second symptom).

Key the remembered id by the session's owning profile (resolved from the
session row's `profile`, falling back to the active gateway profile), read it
back for the active profile on restore, and clear an exhausted session under
its owner. The default profile keeps the original unsuffixed key so existing
installs' remembered session survives the upgrade.

Co-authored-by: oliviaaaa7788 <oliviaaaa7788@users.noreply.github.com>

* fix(gateway): hide [System:] bookkeeping markers from every transcript

Model-switch and personality notices are persisted as role=user `[System: …]`
rows so strict providers accept them mid-history, but they are model-facing
runtime metadata, not user turns. `_history_to_messages` — the single display
projection every client reads — passed them straight through, so on resume or
reload they rendered as a fake user bubble in the desktop, TUI, CLI, and web
transcripts.

Drop them in that projection. The raw marker stays in `session["history"]`
for the model, so nothing changes for inference; only the display loses a row
that never belonged to the user. This also removes the stored marker from the
payload the desktop reconciles against, killing the ordinal shift that
duplicated the optimistic prompt (#67603) at its source — the desktop-side
marker exclusion remains as a fallback for older backends.

Co-authored-by: Dolverin <Dolverin@users.noreply.github.com>

---------

Co-authored-by: Dolverin <5910064+Dolverin@users.noreply.github.com>
Co-authored-by: oliviaaaa7788 <274182427+oliviaaaa7788@users.noreply.github.com>
Co-authored-by: oliviaaaa7788 <oliviaaaa7788@users.noreply.github.com>
Co-authored-by: Dolverin <Dolverin@users.noreply.github.com>
2026-07-23 00:05:25 -05:00
..
app fix(desktop): end the #67603 model-switch dup, cross-profile session bleed, and [System:] bubble (#69861) 2026-07-23 00:05:25 -05:00
assets/tiers feat(desktop): Billing page revamp — current-plan card, in-app plans view, tier art (#68722) 2026-07-22 08:07:52 +05:30
components fix(desktop): let clarify choices and overlays keep their keys from type-to-focus (#69869) 2026-07-23 00:04:12 -05:00
contrib feat(desktop): expose ctx.i18n on the plugin SDK 2026-07-19 00:05:08 -04:00
fonts fix(desktop): crisp terminal text via opaque xterm canvas 2026-06-12 19:36:30 -05:00
hooks perf(desktop): kill the layout-thrash cascade on session switch (#66033) 2026-07-16 22:46:08 -04:00
i18n fix(desktop): split steer and queue keyboard shortcuts (#69797) 2026-07-23 00:13:58 -04:00
lib fix(desktop): let clarify choices and overlays keep their keys from type-to-focus (#69869) 2026-07-23 00:04:12 -05:00
plugins feat(desktop): plugin manager, runtime loader, and plugins settings 2026-07-13 17:57:53 -04:00
sdk feat(desktop): expose ctx.i18n on the plugin SDK 2026-07-19 00:05:08 -04:00
store fix(desktop): scope the remembered session id per profile 2026-07-22 23:53:59 -05:00
themes fix(themes): repaint the desktop on an in-place edit of the active skin 2026-07-22 15:07:03 -05:00
types Nous portal model pricing (#69579) 2026-07-22 16:47:06 -04:00
global.d.ts Merge pull request #68130 from NousResearch/feat/desktop-remote-ssh-current 2026-07-21 17:30:43 +02:00
hermes-cron-scope.test.ts fix(desktop): scope the cron jobs list to the active profile 2026-07-19 12:19:22 -07:00
hermes-parity.test.ts feat(desktop): CLI/dashboard parity — skills hub, MCP test/toggle/catalog, maintenance ops, log filters (#57441) 2026-07-03 01:02:47 -07:00
hermes-profile-scope.test.ts fix(memory): profile-scope the provider config endpoints 2026-07-07 10:53:43 -04:00
hermes.test.ts fix(desktop): extend read aloud + transcription timeouts (salvage of #39286) (#68056) 2026-07-20 09:51:31 -04:00
hermes.ts fmt(js): npm run fix on merge (#68681) 2026-07-21 14:28:28 +00:00
main.tsx bench(desktop): measure the full picture — prod build, cold-start, first-token (#67697) 2026-07-19 17:52:39 -05:00
styles.css refactor(desktop): extract shared Progress primitive; billing uses it 2026-07-22 18:53:26 -05:00
vite-env.d.ts