fix(tui): queue steer Enter while final answer is still streaming to prevent dead state#12569
Conversation
…is being streamed and the only solution is to quit and relaunch with a resume
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
FWIW I think we should always queue steer at least until the end of a currently-generating assistant message or in-progress toolcall (because it weirdly breaks up the UI) |
I believe that's what Claude Code does - if you enter a prompt while it's working, it'll queue your request till it's at least finished with its ongoing stream / message. That would fix this and the oddities reported with Steer in other issues #11062 |
|
Some other issues may also be related to this PR: #11047 |
|
Thanks for the contribution @guidedways! |
Summary
This fixes a TUI race (#11008) where pressing Enter with Steer enabled while the assistant is still streaming the final answer could put Codex into a non-recoverable “running” state (no further prompts handled until exiting and resuming).
Root Cause
In steer mode,
InputResult::Submittedcould submit immediately even while a final-answer stream was active. That immediate submission races with turn completion and can strand turn state.Fix
When handling
InputResult::Submitted, we now queue instead of immediate-submit if a final-answer stream is active (stream_controller.is_some()).This keeps behavior deterministic:
on_task_complete()drains queued input throughmaybe_send_next_queued_input().Why this resolves the “dead mode”
The problematic timing window is now converted into queueing, so prompts entered during final streaming are not lost and are processed after the current output ends. The model continues handling prompts normally without requiring
/quit+resume.Tests
Added regression coverage in
tui/src/chatwidget/tests.rs:steer_enter_queues_while_final_answer_stream_is_activesteer_enter_during_final_stream_preserves_follow_up_prompts_in_orderBoth fail on old behavior and pass with this fix.