Skip to content

fix: restore the Stop control when reconnecting to a session mid-turn - #508

Open
mittalpk wants to merge 1 commit into
andrewyng:mainfrom
mittalpk:fix/ws-ready-running-state-on-reconnect
Open

fix: restore the Stop control when reconnecting to a session mid-turn#508
mittalpk wants to merge 1 commit into
andrewyng:mainfrom
mittalpk:fix/ws-ready-running-state-on-reconnect

Conversation

@mittalpk

Copy link
Copy Markdown

Fixes #506.

selectSession() optimistically sets running=false on every switch, and the only thing that ever flips 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 (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 the ready event every connection gets on open, and the client now sets running=true when it says so.

Added a server-side test that opens a second connection to a session parked mid-turn and asserts ready reports running: true, then false once the turn ends. Confirmed it fails with a KeyError against unpatched code and passes after. Full pytest tests -q: 1171 passed, 1 pre-existing flaky timing test unrelated to this change (passes in isolation). GUI: tsc --noEmit clean, npm test: 111 passed.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][GUI] Stop button disappears (replaced by Send) after switching conversations while a turn is running — running turn becomes unstoppable

1 participant