Fix stale background terminal poll events#23231
Merged
Merged
Conversation
jif-oai
approved these changes
May 18, 2026
| // still a live process for the UI to wait on. Non-empty stdin is a real | ||
| // terminal interaction and should remain visible even if it completes | ||
| // the process before the response returns. | ||
| if !args.chars.is_empty() || response.process_id.is_some() { |
Collaborator
There was a problem hiding this comment.
This still seems racy for the adjacent ordering: if the process is alive when write_stdin builds the response but exits before this event is delivered, the exit watcher can clear the process first and then this empty interaction sets the stale “Waiting for background terminal” status again
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Why
Issue #23214 reports
/psshowing no background terminals while the status line still says it is waiting for a background terminal. The race is in core:write_stdincan poll a process that exits before the response returns. The process manager correctly returnsprocess_id: None, but the handler still emitted aTerminalInteractionevent using the requested session id, causing clients to believe a dead process was still being polled.Fixes #23214.
What changed
TerminalInteractionevents for emptywrite_stdinpolls onceresponse.process_idisNone.Verification
cargo test -p codex-core --test all unified_exec_emits_one_begin_and_one_end_eventcargo test -p codex-core --test all unified_exec_emits_terminal_interaction_for_write_stdincargo test -p codex-corecurrently aborts in unrelatedagent::control::tests::resume_agent_from_rollout_uses_edge_data_when_descendant_metadata_source_is_stalewith a reproducible stack overflow.