fix(desktop): keep queued drains out of the foreground session on session switch - #73875
Merged
Merged
Conversation
…sion switch A queue drain pairs two identifiers from different clocks: the queue key (flips with the route) and the explicit runtime id (lags a resume behind). Mid-switch the composer can fire a drain with storedSessionId=B but sessionId=A-runtime, and prompt.submit then lands B's queued prompt — and its whole answer turn — inside session A. Make the central runtime binding authoritative for queued sends: when the explicit runtime id no longer matches the binding recorded for the target stored session, adopt the binding (or drop to the stored-id resume path when none exists yet). The identity pair (storedSessionId === sessionId) is the fresh-chat fallback and stays untouched. Tests: re-home-via-resume and rebind-to-central-runtime; existing background-drain and sleep/wake cases declare central bindings explicitly. Null-fallback guard already on main; this PR is the remaining half.
The binding check landed unscoped, so it fired for every caller passing a sessionId/storedSessionId pair — not just queue drains. A slash skill dispatch into a fresh ⌘T tab passes exactly that shape (sessionId=tab runtime, storedSessionId=tab stored) with no central binding recorded yet, so the check nulled the target and the kickoff dropped instead of landing in the tab. Only a drain pairs identifiers from two different clocks; every other explicit-target caller resolves both ids in the same tick and is authoritative by construction. Gate on fromQueue and add the scoping invariant as a test. Also refresh the two drain tests for `queued: true`, which prompt.submit started sending for queued drains in ab68c5e after this work branched. Co-authored-by: theone139344 <theone139344@users.noreply.github.com>
Contributor
૮ >ﻌ< ა ci reviewran on 8830f22 ℹ️ InfoDesktop E2E visual evidence · View test artifacts · View job1 visual diff. inline evidence upload failed. Failed to upload diff-665a0833239e-onboarding-overlay-diff.png with gh image (exit code 1): Error uploading /home/runner/work/_temp/e2e-evidence/diff-665a0833239e-onboarding-overlay-diff.png: step 0 (get upload token): uploadToken not found on repo page — do you have write access to NousResearch/hermes-agent? (or, if NousResearch enforces SAML SSO, authorize at https://github.com/orgs/NousResearch/sso) |
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
fix(desktop): keep queued drains out of the foreground session on session switch
33hodl
pushed a commit
to 33hodl/hermes-agent
that referenced
this pull request
Aug 12, 2026
fix(desktop): keep queued drains out of the foreground session on session switch
1 task
prmartinow
pushed a commit
to prmartinow/hermes-agent
that referenced
this pull request
Aug 26, 2026
fix(desktop): keep queued drains out of the foreground session on session switch
melon-xf
added a commit
to melon-xf/hermes-agent
that referenced
this pull request
Sep 3, 2026
fix(desktop): keep queued drains out of the foreground session on session switch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A queue drain pairs two identifiers that move on different clocks: the queue key flips with the route, while the explicit runtime id lags a resume behind. Mid-switch the composer can fire a drain carrying session B's queue key alongside session A's runtime id, and
prompt.submitthen lands B's queued prompt — and its entire answer turn — inside A. The existing guard only covered the case where the runtime id came through null; this closes the remaining case where it is non-null and stale.Supersedes #69049 by @theone139344, whose diagnosis and fix this builds on directly.
The fix
use-prompt-actions/submit.tstreated an explicitoptions.sessionIdas authoritative and never checked it againstgetRuntimeIdForStoredSession. Queued sends now verify the pair against the central runtime↔stored-session binding:storedSessionId === sessionId, a brand-new unsaved chat) pass through untouchedThe check is scoped to
fromQueue. Only a drain pairs ids from two clocks; every other explicit-target caller resolves both in the same tick and is authoritative by construction. A slash skill dispatch into a fresh ⌘T tab passes the same shape —sessionId=tab-runtime,storedSessionId=tab-stored, no binding recorded yet — so an unscoped check nulls the target and silently drops the kickoff.Changes from #69049
fromQueue, with the scoping invariant covered by a testqueued: true, whichprompt.submitstarted sending for queued drains in ab68c5e after that branch was cuttsc --noEmitis cleanVerification
use-prompt-actions,use-background-queue-drain,composer-queue, anduse-session-state-cache— 182 passing.tsc -p apps/desktop --noEmitclean.