mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
Document async interrupt state transitions
Add terse comments around aborting-turn ownership and event ordering. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -4164,6 +4164,8 @@ impl Session {
|
||||
let Some(active_turn) = active.as_mut() else {
|
||||
return Err(SteerInputError::NoActiveTurn(input));
|
||||
};
|
||||
// An aborting turn still owns the session until cleanup finishes, but it can no longer
|
||||
// accept same-turn input.
|
||||
if active_turn.is_aborting() {
|
||||
return Err(SteerInputError::TurnAbortInProgress(input));
|
||||
}
|
||||
|
||||
@@ -409,6 +409,9 @@ impl Session {
|
||||
let Some(active_turn) = active.as_mut() else {
|
||||
return;
|
||||
};
|
||||
// Async abort keeps the turn installed until cleanup completes so the session does
|
||||
// not look idle to other callers while the old turn is still unwinding. Mark it as
|
||||
// aborting before we cancel tasks so the turn remains non-steerable during that gap.
|
||||
let Some(tasks) = active_turn.begin_abort() else {
|
||||
return;
|
||||
};
|
||||
@@ -662,6 +665,8 @@ impl Session {
|
||||
}
|
||||
|
||||
if clear_active_turn_before_event {
|
||||
// The final async-aborted task clears the installed aborting turn before emitting the
|
||||
// client-visible abort event so immediate follow-up actions observe an idle session.
|
||||
let mut active = self.active_turn.lock().await;
|
||||
if active.as_ref().is_some_and(ActiveTurn::is_aborting) {
|
||||
*active = None;
|
||||
|
||||
Reference in New Issue
Block a user