Standardize on canceled instead of cancelled (#36385)

Release Notes:

- N/A
This commit is contained in:
Ben Brandt 2025-08-18 06:07:32 +02:00 committed by GitHub
parent 7dc4adbd40
commit b3969ed427
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 28 additions and 29 deletions

4
Cargo.lock generated
View file

@ -172,9 +172,9 @@ dependencies = [
[[package]] [[package]]
name = "agent-client-protocol" name = "agent-client-protocol"
version = "0.0.25" version = "0.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ab66add8be8d6a963f5bf4070045c1bbf36472837654c73e2298dd16bda5bf7" checksum = "160971bb53ca0b2e70ebc857c21e24eb448745f1396371015f4c59e9a9e51ed0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures 0.3.31", "futures 0.3.31",

View file

@ -423,7 +423,7 @@ zlog_settings = { path = "crates/zlog_settings" }
# #
agentic-coding-protocol = "0.0.10" agentic-coding-protocol = "0.0.10"
agent-client-protocol = "0.0.25" agent-client-protocol = "0.0.26"
aho-corasick = "1.1" aho-corasick = "1.1"
alacritty_terminal = { git = "https://github.com/zed-industries/alacritty.git", branch = "add-hush-login-flag" } alacritty_terminal = { git = "https://github.com/zed-industries/alacritty.git", branch = "add-hush-login-flag" }
any_vec = "0.14" any_vec = "0.14"

View file

@ -360,7 +360,7 @@ pub enum ToolCallStatus {
Failed, Failed,
/// The user rejected the tool call. /// The user rejected the tool call.
Rejected, Rejected,
/// The user cancelled generation so the tool call was cancelled. /// The user canceled generation so the tool call was canceled.
Canceled, Canceled,
} }
@ -1269,19 +1269,19 @@ impl AcpThread {
Err(e) Err(e)
} }
result => { result => {
let cancelled = matches!( let canceled = matches!(
result, result,
Ok(Ok(acp::PromptResponse { Ok(Ok(acp::PromptResponse {
stop_reason: acp::StopReason::Cancelled stop_reason: acp::StopReason::Canceled
})) }))
); );
// We only take the task if the current prompt wasn't cancelled. // We only take the task if the current prompt wasn't canceled.
// //
// This prompt may have been cancelled because another one was sent // This prompt may have been canceled because another one was sent
// while it was still generating. In these cases, dropping `send_task` // while it was still generating. In these cases, dropping `send_task`
// would cause the next generation to be cancelled. // would cause the next generation to be canceled.
if !cancelled { if !canceled {
this.send_task.take(); this.send_task.take();
} }

View file

@ -5337,7 +5337,7 @@ fn main() {{
} }
#[gpui::test] #[gpui::test]
async fn test_retry_cancelled_on_stop(cx: &mut TestAppContext) { async fn test_retry_canceled_on_stop(cx: &mut TestAppContext) {
init_test_settings(cx); init_test_settings(cx);
let project = create_test_project(cx, json!({})).await; let project = create_test_project(cx, json!({})).await;
@ -5393,7 +5393,7 @@ fn main() {{
"Should have no pending completions after cancellation" "Should have no pending completions after cancellation"
); );
// Verify the retry was cancelled by checking retry state // Verify the retry was canceled by checking retry state
thread.read_with(cx, |thread, _| { thread.read_with(cx, |thread, _| {
if let Some(retry_state) = &thread.retry_state { if let Some(retry_state) = &thread.retry_state {
panic!( panic!(

View file

@ -137,7 +137,7 @@ impl ToolUseState {
} }
pub fn cancel_pending(&mut self) -> Vec<PendingToolUse> { pub fn cancel_pending(&mut self) -> Vec<PendingToolUse> {
let mut cancelled_tool_uses = Vec::new(); let mut canceled_tool_uses = Vec::new();
self.pending_tool_uses_by_id self.pending_tool_uses_by_id
.retain(|tool_use_id, tool_use| { .retain(|tool_use_id, tool_use| {
if matches!(tool_use.status, PendingToolUseStatus::Error { .. }) { if matches!(tool_use.status, PendingToolUseStatus::Error { .. }) {
@ -155,10 +155,10 @@ impl ToolUseState {
is_error: true, is_error: true,
}, },
); );
cancelled_tool_uses.push(tool_use.clone()); canceled_tool_uses.push(tool_use.clone());
false false
}); });
cancelled_tool_uses canceled_tool_uses
} }
pub fn pending_tool_uses(&self) -> Vec<&PendingToolUse> { pub fn pending_tool_uses(&self) -> Vec<&PendingToolUse> {

View file

@ -237,7 +237,7 @@ impl acp::Client for ClientDelegate {
let outcome = match result { let outcome = match result {
Ok(option) => acp::RequestPermissionOutcome::Selected { option_id: option }, Ok(option) => acp::RequestPermissionOutcome::Selected { option_id: option },
Err(oneshot::Canceled) => acp::RequestPermissionOutcome::Cancelled, Err(oneshot::Canceled) => acp::RequestPermissionOutcome::Canceled,
}; };
Ok(acp::RequestPermissionResponse { outcome }) Ok(acp::RequestPermissionResponse { outcome })

View file

@ -285,7 +285,7 @@ impl AgentConnection for ClaudeAgentConnection {
let turn_state = session.turn_state.take(); let turn_state = session.turn_state.take();
let TurnState::InProgress { end_tx } = turn_state else { let TurnState::InProgress { end_tx } = turn_state else {
// Already cancelled or idle, put it back // Already canceled or idle, put it back
session.turn_state.replace(turn_state); session.turn_state.replace(turn_state);
return; return;
}; };
@ -389,7 +389,7 @@ enum TurnState {
} }
impl TurnState { impl TurnState {
fn is_cancelled(&self) -> bool { fn is_canceled(&self) -> bool {
matches!(self, TurnState::CancelConfirmed { .. }) matches!(self, TurnState::CancelConfirmed { .. })
} }
@ -439,7 +439,7 @@ impl ClaudeAgentSession {
for chunk in message.content.chunks() { for chunk in message.content.chunks() {
match chunk { match chunk {
ContentChunk::Text { text } | ContentChunk::UntaggedText(text) => { ContentChunk::Text { text } | ContentChunk::UntaggedText(text) => {
if !turn_state.borrow().is_cancelled() { if !turn_state.borrow().is_canceled() {
thread thread
.update(cx, |thread, cx| { .update(cx, |thread, cx| {
thread.push_user_content_block(None, text.into(), cx) thread.push_user_content_block(None, text.into(), cx)
@ -458,8 +458,8 @@ impl ClaudeAgentSession {
acp::ToolCallUpdate { acp::ToolCallUpdate {
id: acp::ToolCallId(tool_use_id.into()), id: acp::ToolCallId(tool_use_id.into()),
fields: acp::ToolCallUpdateFields { fields: acp::ToolCallUpdateFields {
status: if turn_state.borrow().is_cancelled() { status: if turn_state.borrow().is_canceled() {
// Do not set to completed if turn was cancelled // Do not set to completed if turn was canceled
None None
} else { } else {
Some(acp::ToolCallStatus::Completed) Some(acp::ToolCallStatus::Completed)
@ -592,14 +592,13 @@ impl ClaudeAgentSession {
.. ..
} => { } => {
let turn_state = turn_state.take(); let turn_state = turn_state.take();
let was_cancelled = turn_state.is_cancelled(); let was_canceled = turn_state.is_canceled();
let Some(end_turn_tx) = turn_state.end_tx() else { let Some(end_turn_tx) = turn_state.end_tx() else {
debug_panic!("Received `SdkMessage::Result` but there wasn't an active turn"); debug_panic!("Received `SdkMessage::Result` but there wasn't an active turn");
return; return;
}; };
if is_error || (!was_cancelled && subtype == ResultErrorType::ErrorDuringExecution) if is_error || (!was_canceled && subtype == ResultErrorType::ErrorDuringExecution) {
{
end_turn_tx end_turn_tx
.send(Err(anyhow!( .send(Err(anyhow!(
"Error: {}", "Error: {}",
@ -610,7 +609,7 @@ impl ClaudeAgentSession {
let stop_reason = match subtype { let stop_reason = match subtype {
ResultErrorType::Success => acp::StopReason::EndTurn, ResultErrorType::Success => acp::StopReason::EndTurn,
ResultErrorType::ErrorMaxTurns => acp::StopReason::MaxTurnRequests, ResultErrorType::ErrorMaxTurns => acp::StopReason::MaxTurnRequests,
ResultErrorType::ErrorDuringExecution => acp::StopReason::Cancelled, ResultErrorType::ErrorDuringExecution => acp::StopReason::Canceled,
}; };
end_turn_tx end_turn_tx
.send(Ok(acp::PromptResponse { stop_reason })) .send(Ok(acp::PromptResponse { stop_reason }))

View file

@ -4020,7 +4020,7 @@ mod tests {
cx.run_until_parked(); cx.run_until_parked();
// Verify that the previous completion was cancelled // Verify that the previous completion was canceled
assert_eq!(cancellation_events.lock().unwrap().len(), 1); assert_eq!(cancellation_events.lock().unwrap().len(), 1);
// Verify that a new request was started after cancellation // Verify that a new request was started after cancellation

View file

@ -441,11 +441,11 @@ impl MessageEditor {
thread.cancel_editing(cx); thread.cancel_editing(cx);
}); });
let cancelled = self.thread.update(cx, |thread, cx| { let canceled = self.thread.update(cx, |thread, cx| {
thread.cancel_last_completion(Some(window.window_handle()), cx) thread.cancel_last_completion(Some(window.window_handle()), cx)
}); });
if cancelled { if canceled {
self.set_editor_is_expanded(false, cx); self.set_editor_is_expanded(false, cx);
self.send_to_model(window, cx); self.send_to_model(window, cx);
} }
@ -1404,7 +1404,7 @@ impl MessageEditor {
}) })
.ok(); .ok();
}); });
// Replace existing load task, if any, causing it to be cancelled. // Replace existing load task, if any, causing it to be canceled.
let load_task = load_task.shared(); let load_task = load_task.shared();
self.load_context_task = Some(load_task.clone()); self.load_context_task = Some(load_task.clone());
cx.spawn(async move |this, cx| { cx.spawn(async move |this, cx| {