Skip to content

fix(gui): preserve Stop button when returning to a running session - #630

Open
niranjannie wants to merge 1 commit into
andrewyng:mainfrom
niranjannie:fix/composer-running-state-survives-conversation-switch
Open

fix(gui): preserve Stop button when returning to a running session#630
niranjannie wants to merge 1 commit into
andrewyng:mainfrom
niranjannie:fix/composer-running-state-survives-conversation-switch

Conversation

@niranjannie

Copy link
Copy Markdown

Summary

When a user switches away from a conversation whose turn is still running and then switches back, the Stop button disappears (replaced by Send) — even though the backend turn is still executing. The user is left with no UI control to interrupt the running turn; sending a new message fails with This session is already running a turn. Wait for it to finish or stop it.

Root cause

selectSession in surfaces/gui/src/App.tsx eagerly called setRunning(false) before the new session's ready event had arrived. The case "ready" handler at the same site already restores d.running correctly (this was fixed previously for the reconnect-mid-turn case on 2026-08-24, recorded at the same site). The eager setRunning(false) raced with that restore and left the UI in the wrong state for any user who returned to a running session.

Fix

Remove the eager setRunning(false) in selectSession. The other state resets in selectSession are unchanged (todo, streaming, agent, workspace/branch/folder flags).

Why not just gate the reset?

A guarded reset (e.g. if (running) setRunning(false)) would still race with the ready event for sessions that are truly idle — the ready event arrives after the click and would overwrite correctly, but for any case where ready is delayed or lost, the gate would still incorrectly clear running. The cleanest, smallest fix is to delegate to ready entirely, matching the established pattern for initial session load.

Out of scope

Fixes #506

When a user switched away from a running conversation and back, the
Stop button disappeared (replaced by Send) even though the backend
turn was still executing. Sending a new message in that conversation
then failed with "This session is already running a turn. Wait for it
to finish or stop it." — leaving the user no way to interrupt the
turn from the UI.

Root cause: `selectSession` eagerly set `running` to false before
the new session's `ready` event had arrived, briefly hiding the
Stop button. The `case "ready"` handler already restores
`d.running` correctly (owner catch 2026-08-24, recorded at the same
site), so the eager reset is both unnecessary and harmful on
mid-turn reconnects.

Remove the eager `setRunning(false)` in `selectSession` and let the
`ready` event establish the truth. The other state resets in
`selectSession` are unchanged: `todo`, `streaming`, `agent`, and
the workspace/branch/folder flags are not affected.

Fixes andrewyng#506
@niranjannie

Copy link
Copy Markdown
Author

cc @cagdasyurekli — thanks for the early review on the issue thread. This is my first contribution to OpenWorker.

The fix removes the eager setRunning(false) in selectSession and relies on the ready event handler (already in place from your 2026-08-24 fix) to restore the truth on conversation switch.

I did not add an App.tsx-level test because no App.tsx test harness exists in the repo. Adding one felt like scope creep for a 1-line change. Happy to follow up with a harness in a separate PR if useful.

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