Lightweight coding agent that runs in your terminal
Rust
Add the ability to interrupt and provide feedback to the model (#2381)
easong-openai09819d9b4755
diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rsindex 3f24a0176c..235280be9f 100644--- a/codex-rs/tui/src/chatwidget.rs+++ b/codex-rs/tui/src/chatwidget.rs@@ -26,6 +26,7 @@ use codex_core::protocol::PatchApplyBeginEvent;use codex_core::protocol::StreamErrorEvent;use codex_core::protocol::TaskCompleteEvent;use codex_core::protocol::TokenUsage;+use codex_core::protocol::TurnAbortReason;use codex_core::protocol::TurnDiffEvent;use codex_protocol::parse_command::ParsedCommand;use crossterm::event::KeyEvent;@@ -820,7 +821,14 @@ impl ChatWidget {EventMsg::TaskComplete(TaskCompleteEvent { .. }) => self.on_task_complete(),EventMsg::TokenCount(token_usage) => self.on_token_count(token_usage),EventMsg::Error(ErrorEvent { message }) => self.on_error(message),- EventMsg::TurnAborted(_) => self.on_error("Turn interrupted".to_owned()),+ EventMsg::TurnAborted(ev) => match ev.reason {+ TurnAbortReason::Interrupted => {+ self.on_error("Tell the model what to do differently".to_owned())+ }+ TurnAbortReason::Replaced => {+ self.on_error("Turn aborted: replaced by a new task".to_owned())+ }+ },EventMsg::PlanUpdate(update) => self.on_plan_update(update),EventMsg::ExecApprovalRequest(ev) => self.on_exec_approval_request(id, ev),EventMsg::ApplyPatchApprovalRequest(ev) => self.on_apply_patch_approval_request(id, ev),diff --git a/codex-rs/tui/src/user_approval_widget.rs b/codex-rs/tui/src/user_approval_widget.rsindex de22f12b7b..69ee3524e8 100644--- a/codex-rs/tui/src/user_approval_widget.rs+++ b/codex-rs/tui/src/user_approval_widget.rs@@ -74,6 +74,17 @@ static COMMAND_SELECT_OPTIONS: LazyLock<Vec<SelectOption>> = LazyLock::new(|| {key: KeyCode::Char('n'),decision: ReviewDecision::Denied,},+ SelectOption {+ label: Line::from(vec![+ "No, ".into(),+ "provide ".into(),+ "f".underlined(),+ "eedback".into(),+ ]),+ description: "Do not run the command; provide feedback",+ key: KeyCode::Char('f'),+ decision: ReviewDecision::Abort,+ },]});@@ -91,6 +102,17 @@ static PATCH_SELECT_OPTIONS: LazyLock<Vec<SelectOption>> = LazyLock::new(|| {key: KeyCode::Char('n'),decision: ReviewDecision::Denied,},+ SelectOption {+ label: Line::from(vec![+ "No, ".into(),+ "provide ".into(),+ "f".underlined(),+ "eedback".into(),+ ]),+ description: "Do not apply the changes; provide feedback",+ key: KeyCode::Char('f'),+ decision: ReviewDecision::Abort,+ },]});