mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Make TUI turn interrupts nonblocking (#35000)
## What changed - Dispatch app-server turn interrupts in the background so the TUI can keep processing thread events while an interrupt is pending. - Coalesce repeated interrupt requests for the same active turn and clear the pending state when the turn completes or the thread closes. - Preserve the retry for stale active-turn IDs, surface interrupt failures as warning notifications instead of exiting the TUI, and reset backtrack state whenever an interrupt is handled. ## Testing - Add an app-server integration test covering nonblocking event handling, repeated-request coalescing, and pending-state cleanup. - Verify that interrupting without an active turn clears backtrack state. GitOrigin-RevId: 9ada247a739e2e0a63b425f75ebd6d054167d825
This commit is contained in:
1 parent
2c92af09cf
commit
62ba648136
5 files changed
+192
-36
No files matched your search
@@ -45,6 +45,7 @@ pub(super) struct ThreadEventStore {
|
||||
pub(super) buffer: VecDeque<ThreadBufferedEvent>,
|
||||
pub(super) pending_interactive_replay: PendingInteractiveReplayState,
|
||||
pub(super) active_turn_id: Option<String>,
|
||||
pub(super) pending_interrupt_turn_id: Option<String>,
|
||||
pub(super) input_state: Option<ThreadInputState>,
|
||||
pub(super) capacity: usize,
|
||||
pub(super) active: bool,
|
||||
@@ -69,6 +70,7 @@ impl ThreadEventStore {
|
||||
buffer: VecDeque::new(),
|
||||
pending_interactive_replay: PendingInteractiveReplayState::default(),
|
||||
active_turn_id: None,
|
||||
pending_interrupt_turn_id: None,
|
||||
input_state: None,
|
||||
capacity,
|
||||
active: false,
|
||||
@@ -120,13 +122,17 @@ impl ThreadEventStore {
|
||||
ServerNotification::TurnStarted(turn) => {
|
||||
self.active_turn_id = Some(turn.turn.id.clone());
|
||||
}
|
||||
ServerNotification::TurnCompleted(turn)
|
||||
if self.active_turn_id.as_deref() == Some(turn.turn.id.as_str()) =>
|
||||
{
|
||||
self.active_turn_id = None;
|
||||
ServerNotification::TurnCompleted(turn) => {
|
||||
if self.active_turn_id.as_deref() == Some(turn.turn.id.as_str()) {
|
||||
self.active_turn_id = None;
|
||||
}
|
||||
if self.pending_interrupt_turn_id.as_deref() == Some(turn.turn.id.as_str()) {
|
||||
self.pending_interrupt_turn_id = None;
|
||||
}
|
||||
}
|
||||
ServerNotification::ThreadClosed(_) => {
|
||||
self.active_turn_id = None;
|
||||
self.pending_interrupt_turn_id = None;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user