fix: restore the Stop control when reconnecting to a session mid-turn - #508
Open
mittalpk wants to merge 1 commit into
Open
fix: restore the Stop control when reconnecting to a session mid-turn#508mittalpk wants to merge 1 commit into
mittalpk wants to merge 1 commit into
Conversation
Switching away from a running conversation and back loses the Stop button -- the composer shows Send instead, even though the backend turn is still executing (confirmed by a retry failing with "this session is already running a turn"). selectSession() optimistically resets running to false on every switch, and the only thing that ever sets it back to true is a turn_start event -- which only the connection that started the turn ever receives. A fresh WebSocket connecting mid-turn had no way to learn a turn was already in progress. The server already tracks this in manager.is_running(session_id) (it's what produces the "already running a turn" rejection), so include it in the ready event every connection gets on open, and have the client set running=true when it says so. Fixes andrewyng#506.
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.
Fixes #506.
selectSession()optimistically setsrunning=falseon every switch, and the only thing that ever flips it back to true is aturn_startevent — which only the connection that started the turn ever receives. A fresh WebSocket connecting mid-turn (e.g. switching back to that conversation) had no way to learn a turn was already running, so the composer showed Send even though the backend turn was still executing.The server already knows this via
manager.is_running(session_id)— it's what produces the "already running a turn" rejection on a stray send — so I added it to thereadyevent every connection gets on open, and the client now setsrunning=truewhen it says so.Added a server-side test that opens a second connection to a session parked mid-turn and asserts
readyreportsrunning: true, thenfalseonce the turn ends. Confirmed it fails with aKeyErroragainst unpatched code and passes after. Fullpytest tests -q: 1171 passed, 1 pre-existing flaky timing test unrelated to this change (passes in isolation). GUI:tsc --noEmitclean,npm test: 111 passed.