Skip to content

fix(desktop): bind submits to activated session - #73282

Closed
CryptoDombili wants to merge 1 commit into
NousResearch:mainfrom
CryptoDombili:fix/desktop-session-submit-race
Closed

CryptoDombili wants to merge 1 commit into
NousResearch:mainfrom
CryptoDombili:fix/desktop-session-submit-race

Conversation

@CryptoDombili

Copy link
Copy Markdown
Contributor

What does this PR do?

Prevents Desktop prompt submissions from being routed to a stale runtime session during asynchronous session switches.

The submit path now waits for the latest session.activate or session.resume acknowledgement and re-reads the active runtime session immediately before prompt.submit.

Related issue

Fixes #72971

Related to #66661, but this PR addresses the stale activation and submit-routing path rather than rejected-submit composer restoration.

Type of change

  • Bug fix
  • Tests
  • New feature
  • Security fix
  • Documentation update
  • Refactor

Changes made

  • add a monotonic session activation barrier shared by session and prompt actions
  • block prompt submission while the selected session activation is unacknowledged
  • re-read the active runtime session immediately before prompt.submit
  • fail closed when stored-session and runtime-session mappings disagree
  • prevent stale activation responses from clearing a newer pending activation
  • restore the composer text when submission is rejected by the session barrier
  • add regression coverage for pending activation and runtime changes during asynchronous attachment upload

How to test

  1. Start a response in one Desktop session.
  2. Switch to or branch into another session while the response is still active.
  3. Submit a message immediately in the newly selected session.
  4. Verify that submission is blocked until the latest session activation is acknowledged.
  5. Verify that the message is then submitted with the newly active runtime session ID.
  6. Run the focused Desktop session-action and prompt-action tests.

Checklist

  • The change is scoped to the Desktop session-switch and prompt-submit paths
  • Regression tests were added
  • Existing credential, backend, and persistence behavior is unchanged
  • No unrelated files were modified

Prevent prompt submissions from using stale runtime session IDs during asynchronous session switches and add regression coverage.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/desktop Electron desktop app (apps/desktop/*) area/sessions Session lifecycle, resume, persistence, history sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jul 28, 2026
@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for the focused investigation and regression coverage. This automated hermes-sweeper review found that current main already protects this routing path.

  • apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts:244 detects a stale or incomplete durable-session/runtime binding rather than trusting the active runtime ref.
  • apps/desktop/src/app/session/hooks/use-prompt-actions/submit.ts:430 resumes the durable routed session and verifies the active runtime, durable mapping, and selected session agree before submission.
  • apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsx:3195 covers replacement of a stale selected/runtime pair and asserts submission to the recovered runtime.
  • This behavior was introduced by f0ff8d50970c35b67484056af9e913a6e6ba7e49 and is included in v2026.7.20; it is already an ancestor of this PR's base.

@teknium1 teknium1 closed this Jul 30, 2026
@teknium1 teknium1 added sweeper:implemented-on-main Sweeper: behavior already present on current main sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/desktop Electron desktop app (apps/desktop/*) P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:implemented-on-main Sweeper: behavior already present on current main sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop GUI: prompt.submit sends to wrong session after session switch while model response is slow

3 participants