Conversation
…resh session The selectProfile and newSessionInProfile functions called ensureGatewayProfile() with (fire-and-forget), then immediately called requestFreshSession() to navigate to a new chat. This races with the async gateway swap — the UI shows the new profile as active and creates a fresh chat draft, but the WebSocket connection to the target profile's backend may not be connected yet. When the user types a message, createBackendSessionForSend does await the gateway swap, but by then startFreshSessionDraft() has already cleared state and the session is created on whichever backend was still active. Fix: await ensureGatewayProfile(target) before calling requestFreshSession() when a real profile switch is happening. For the no-switch case (re-tapping the same profile), keep the fire-and-forget as a keepalive ping.
1 task
19 tasks
Collaborator
|
Thanks for the targeted profile-routing investigation. This is now redundant because current main fixes the wrong-profile behavior at the session-creation chokepoint rather than by delaying fresh-draft navigation.
Automated hermes-sweeper review. |
12 tasks
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.
Problem
When clicking a profile square in the desktop sidebar's ProfileRail, the profile pill highlights correctly but the chat continues talking to the old profile's agent. The user sees the new profile selected in the UI but their messages still go to the previous profile's backend.
Root cause
selectProfile()instore/profile.tscallsensureGatewayProfile(target)withvoid(fire-and-forget), then immediately callsrequestFreshSession()to navigate to a new chat. This creates a race condition:void ensureGatewayProfile(target)starts the async gateway swap (spawning a pooled backend, establishing WebSocket)requestFreshSession()runs synchronously — clears state, navigates to NEW_CHAT_ROUTE, shows a fresh draftcreateBackendSessionForSenddoes eventuallyawait ensureGatewayProfile(), but by then the session state is already cleared and the fresh chat is rendered as readyThe same bug exists in
newSessionInProfile().Fix
Make
selectProfileandnewSessionInProfileasync. When a real profile switch is happening (switching === true),awaitthe gateway swap before callingrequestFreshSession(). For the no-switch case (re-tapping the same profile), keep the fire-and-forget as a keepalive ping.Changes
Related
mainWindow?.reload())