mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
@@ -29936,7 +29936,30 @@ use code_core::protocol::OrderMeta;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn esc_router_prioritizes_agent_cancel_before_cli_interrupt() {
|
||||
fn esc_router_prioritizes_cli_interrupt_before_agent_cancel() {
|
||||
let mut harness = ChatWidgetHarness::new();
|
||||
let chat = harness.chat();
|
||||
|
||||
chat.active_agents.push(AgentInfo {
|
||||
id: "agent-1".to_string(),
|
||||
name: "Agent 1".to_string(),
|
||||
status: AgentStatus::Running,
|
||||
source_kind: None,
|
||||
batch_id: Some("batch-1".to_string()),
|
||||
model: None,
|
||||
result: None,
|
||||
error: None,
|
||||
last_progress: None,
|
||||
});
|
||||
chat.active_task_ids.insert("turn-1".to_string());
|
||||
chat.bottom_pane.set_task_running(true);
|
||||
|
||||
let route = chat.describe_esc_context();
|
||||
assert_eq!(route.intent, EscIntent::CancelTask);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn esc_router_cancels_agents_when_only_agents_running() {
|
||||
let mut harness = ChatWidgetHarness::new();
|
||||
let chat = harness.chat();
|
||||
|
||||
@@ -30667,6 +30690,7 @@ use code_core::protocol::OrderMeta;
|
||||
let mut harness = ChatWidgetHarness::new();
|
||||
let chat = harness.chat();
|
||||
|
||||
chat.active_task_ids.insert("turn-1".to_string());
|
||||
chat.bottom_pane.set_task_running(true);
|
||||
|
||||
let route = chat.describe_esc_context();
|
||||
|
||||
@@ -128,7 +128,7 @@ impl ChatWidget<'_> {
|
||||
return EscRoute::new(EscIntent::AutoPauseForEdit, true, false);
|
||||
}
|
||||
|
||||
if self.is_task_running() {
|
||||
if self.has_cancelable_task_activity() {
|
||||
return EscRoute::new(EscIntent::CancelTask, true, false);
|
||||
}
|
||||
|
||||
@@ -139,6 +139,10 @@ impl ChatWidget<'_> {
|
||||
return EscRoute::new(EscIntent::AutoStopActive, true, false);
|
||||
}
|
||||
|
||||
if self.has_cancelable_task_activity() {
|
||||
return EscRoute::new(EscIntent::CancelTask, true, false);
|
||||
}
|
||||
|
||||
if self.has_cancelable_agents() {
|
||||
return EscRoute::new(EscIntent::CancelAgents, true, false);
|
||||
}
|
||||
@@ -163,10 +167,6 @@ impl ChatWidget<'_> {
|
||||
return EscRoute::new(EscIntent::ClearComposer, true, false);
|
||||
}
|
||||
|
||||
if self.is_task_running() {
|
||||
return EscRoute::new(EscIntent::CancelTask, true, false);
|
||||
}
|
||||
|
||||
if !self.composer_is_empty() {
|
||||
return EscRoute::new(EscIntent::ClearComposer, true, false);
|
||||
}
|
||||
@@ -174,6 +174,17 @@ impl ChatWidget<'_> {
|
||||
EscRoute::new(EscIntent::ShowUndoHint, true, true)
|
||||
}
|
||||
|
||||
fn has_cancelable_task_activity(&self) -> bool {
|
||||
self.stream.is_write_cycle_active()
|
||||
|| !self.active_task_ids.is_empty()
|
||||
|| self.terminal_is_running()
|
||||
|| !self.exec.running_commands.is_empty()
|
||||
|| !self.tools_state.running_custom_tools.is_empty()
|
||||
|| !self.tools_state.web_search_sessions.is_empty()
|
||||
|| !self.tools_state.running_wait_tools.is_empty()
|
||||
|| !self.tools_state.running_kill_tools.is_empty()
|
||||
}
|
||||
|
||||
pub(crate) fn execute_esc_intent(&mut self, intent: EscIntent, key_event: KeyEvent) -> bool {
|
||||
match intent {
|
||||
EscIntent::DismissModal => {
|
||||
|
||||
Reference in New Issue
Block a user