Skip to content

Fix stale turn steering fallback in tui_app_server#15714

Merged
etraut-openai merged 1 commit intomainfrom
etraut/steer-race
Mar 25, 2026
Merged

Fix stale turn steering fallback in tui_app_server#15714
etraut-openai merged 1 commit intomainfrom
etraut/steer-race

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented Mar 25, 2026

This PR adds code to recover from a narrow app-server timing race where a follow-up can be sent after the previous turn has already ended but before the TUI has observed that completion.

Instead of surfacing turn/steer failed: no active turn to steer, the client now treats that as a stale active-turn cache and falls back to starting a fresh turn, matching the intended submit behavior more closely. This is similar to the strategy employed by other app server clients (notably, the IDE extension and desktop app).

This race exists because the current app-server API makes the client choose between two separate RPCs, turn/steer and turn/start, based on its local view of whether a turn is still active. That view is replicated from asynchronous notifications, so it can be stale for a brief window. The server may already have ended the turn while the client still believes it is in progress. Since the choice is made client-side rather than atomically on the server, tui_app_server can occasionally send turn/steer for a turn that no longer exists.

let mut store = channel.store.lock().await;
store.clear_active_turn_id();
}
should_start_turn = true;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice graceful recovery

@etraut-openai etraut-openai merged commit c0ffd00 into main Mar 25, 2026
34 of 36 checks passed
@etraut-openai etraut-openai deleted the etraut/steer-race branch March 25, 2026 06:28
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants