Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Add setting for controlling terminal tool stop button behavior (#47521)
Danilo Leal19b4e432d968
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex b30eee96211..ad331dbb79a 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -1112,6 +1112,11 @@//// Default: true"expand_terminal_card": true,+ // Whether clicking the stop button on a running terminal tool should also cancel the agent's generation.+ // Note that this only applies to the stop button, not to ctrl+c inside the terminal.+ //+ // Default: true+ "cancel_generation_on_terminal_stop": true,// Whether to always use cmd-enter (or ctrl-enter on Linux or Windows) to send messages in the agent panel.//// Default: falsediff --git a/crates/agent_settings/src/agent_settings.rs b/crates/agent_settings/src/agent_settings.rsindex 7d466a2be69..9b5960eed27 100644--- a/crates/agent_settings/src/agent_settings.rs+++ b/crates/agent_settings/src/agent_settings.rs@@ -46,6 +46,7 @@ pub struct AgentSettings {pub enable_feedback: bool,pub expand_edit_card: bool,pub expand_terminal_card: bool,+ pub cancel_generation_on_terminal_stop: bool,pub use_modifier_to_send: bool,pub message_editor_min_lines: usize,pub show_turn_stats: bool,@@ -256,6 +257,7 @@ impl Settings for AgentSettings {enable_feedback: agent.enable_feedback.unwrap(),expand_edit_card: agent.expand_edit_card.unwrap(),expand_terminal_card: agent.expand_terminal_card.unwrap(),+ cancel_generation_on_terminal_stop: agent.cancel_generation_on_terminal_stop.unwrap(),use_modifier_to_send: agent.use_modifier_to_send.unwrap(),message_editor_min_lines: agent.message_editor_min_lines.unwrap(),show_turn_stats: agent.show_turn_stats.unwrap(),diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rsindex 75bb3716d8a..b38348ed3f2 100644--- a/crates/agent_ui/src/acp/thread_view.rs+++ b/crates/agent_ui/src/acp/thread_view.rs@@ -4633,7 +4633,9 @@ impl AcpThreadView {terminal.update(cx, |terminal, cx| {terminal.stop_by_user(cx);});- this.cancel_generation(cx);+ if AgentSettings::get_global(cx).cancel_generation_on_terminal_stop {+ this.cancel_generation(cx);+ }})}),)diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rsindex 5da5bababb6..6ed8f73f223 100644--- a/crates/agent_ui/src/agent_ui.rs+++ b/crates/agent_ui/src/agent_ui.rs@@ -538,6 +538,7 @@ mod tests {enable_feedback: false,expand_edit_card: true,expand_terminal_card: true,+ cancel_generation_on_terminal_stop: true,use_modifier_to_send: true,message_editor_min_lines: 1,tool_permissions: Default::default(),diff --git a/crates/settings_content/src/agent.rs b/crates/settings_content/src/agent.rsindex 8d8331ec262..56a7efaa6eb 100644--- a/crates/settings_content/src/agent.rs+++ b/crates/settings_content/src/agent.rs@@ -109,6 +109,11 @@ pub struct AgentSettingsContent {////// Default: truepub expand_terminal_card: Option<bool>,+ /// Whether clicking the stop button on a running terminal tool should also cancel the agent's generation.+ /// Note that this only applies to the stop button, not to ctrl+c inside the terminal.+ ///+ /// Default: true+ pub cancel_generation_on_terminal_stop: Option<bool>,/// Whether to always use cmd-enter (or ctrl-enter on Linux or Windows) to send messages in the agent panel.////// Default: falsediff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rsindex dc9d1d81aed..d82fdf338a9 100644--- a/crates/settings_ui/src/page_data.rs+++ b/crates/settings_ui/src/page_data.rs@@ -6830,7 +6830,7 @@ fn ai_page() -> SettingsPage {]}- fn agent_configuration_section() -> [SettingsPageItem; 11] {+ fn agent_configuration_section() -> [SettingsPageItem; 12] {[SettingsPageItem::SectionHeader("Agent Configuration"),SettingsPageItem::SettingItem(SettingItem {@@ -6975,6 +6975,28 @@ fn ai_page() -> SettingsPage {metadata: None,files: USER,}),+ SettingsPageItem::SettingItem(SettingItem {+ title: "Cancel Generation On Terminal Stop",+ description: "Whether clicking the stop button on a running terminal tool should also cancel the agent's generation. Note that this only applies to the stop button, not to ctrl+c inside the terminal.",+ field: Box::new(SettingField {+ json_path: Some("agent.cancel_generation_on_terminal_stop"),+ pick: |settings_content| {+ settings_content+ .agent+ .as_ref()?+ .cancel_generation_on_terminal_stop+ .as_ref()+ },+ write: |settings_content, value| {+ settings_content+ .agent+ .get_or_insert_default()+ .cancel_generation_on_terminal_stop = value;+ },+ }),+ metadata: None,+ files: USER,+ }),SettingsPageItem::SettingItem(SettingItem {title: "Use Modifier To Send",description: "Whether to always use cmd-enter (or ctrl-enter on Linux or Windows) to send messages.",