Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
acp_thread: Rename resume to retry (#47370)
Ben Brandt03a5f7b07fa7
diff --git a/crates/acp_thread/src/acp_thread.rs b/crates/acp_thread/src/acp_thread.rsindex 389b9ca3f8f..545f21b922c 100644--- a/crates/acp_thread/src/acp_thread.rs+++ b/crates/acp_thread/src/acp_thread.rs@@ -1911,18 +1911,18 @@ impl AcpThread {})}- pub fn can_resume(&self, cx: &App) -> bool {- self.connection.resume(&self.session_id, cx).is_some()+ pub fn can_retry(&self, cx: &App) -> bool {+ self.connection.retry(&self.session_id, cx).is_some()}- pub fn resume(&mut self, cx: &mut Context<Self>) -> BoxFuture<'static, Result<()>> {+ pub fn retry(&mut self, cx: &mut Context<Self>) -> BoxFuture<'static, Result<()>> {self.run_turn(cx, async move |this, cx| {this.update(cx, |this, cx| {this.connection- .resume(&this.session_id, cx)- .map(|resume| resume.run(cx))+ .retry(&this.session_id, cx)+ .map(|retry| retry.run(cx))})?- .context("resuming a session is not supported")?+ .context("retrying a session is not supported")?.await})}diff --git a/crates/acp_thread/src/connection.rs b/crates/acp_thread/src/connection.rsindex dd29293d8a3..c2d14eacc7f 100644--- a/crates/acp_thread/src/connection.rs+++ b/crates/acp_thread/src/connection.rs@@ -64,11 +64,7 @@ pub trait AgentConnection {cx: &mut App,) -> Task<Result<acp::PromptResponse>>;- fn resume(- &self,- _session_id: &acp::SessionId,- _cx: &App,- ) -> Option<Rc<dyn AgentSessionResume>> {+ fn retry(&self, _session_id: &acp::SessionId, _cx: &App) -> Option<Rc<dyn AgentSessionRetry>> {None}@@ -135,7 +131,7 @@ pub trait AgentSessionTruncate {fn run(&self, message_id: UserMessageId, cx: &mut App) -> Task<Result<()>>;}-pub trait AgentSessionResume {+pub trait AgentSessionRetry {fn run(&self, cx: &mut App) -> Task<Result<acp::PromptResponse>>;}diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rsindex 3d0f45d1c90..9aa7657f628 100644--- a/crates/agent/src/agent.rs+++ b/crates/agent/src/agent.rs@@ -1317,12 +1317,12 @@ impl acp_thread::AgentConnection for NativeAgentConnection {})}- fn resume(+ fn retry(&self,session_id: &acp::SessionId,_cx: &App,- ) -> Option<Rc<dyn acp_thread::AgentSessionResume>> {- Some(Rc::new(NativeAgentSessionResume {+ ) -> Option<Rc<dyn acp_thread::AgentSessionRetry>> {+ Some(Rc::new(NativeAgentSessionRetry {connection: self.clone(),session_id: session_id.clone(),}) as _)@@ -1496,12 +1496,12 @@ impl acp_thread::AgentSessionTruncate for NativeAgentSessionTruncate {}}-struct NativeAgentSessionResume {+struct NativeAgentSessionRetry {connection: NativeAgentConnection,session_id: acp::SessionId,}-impl acp_thread::AgentSessionResume for NativeAgentSessionResume {+impl acp_thread::AgentSessionRetry for NativeAgentSessionRetry {fn run(&self, cx: &mut App) -> Task<Result<acp::PromptResponse>> {self.connection.run_turn(self.session_id.clone(), cx, |thread, cx| {diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rsindex 4b994b61a88..7c204e9b0c4 100644--- a/crates/agent_ui/src/acp/thread_view.rs+++ b/crates/agent_ui/src/acp/thread_view.rs@@ -1355,16 +1355,16 @@ impl AcpThreadView {matches!(self.thread_state, ThreadState::Loading { .. })}- fn resume_chat(&mut self, cx: &mut Context<Self>) {+ fn retry_generation(&mut self, cx: &mut Context<Self>) {self.thread_error.take();let Some(thread) = self.thread() else {return;};- if !thread.read(cx).can_resume(cx) {+ if !thread.read(cx).can_retry(cx) {return;}- let task = thread.update(cx, |thread, cx| thread.resume(cx));+ let task = thread.update(cx, |thread, cx| thread.retry(cx));cx.spawn(async move |this, cx| {let result = task.await;@@ -7943,7 +7943,7 @@ impl AcpThreadView {) -> Callout {let can_resume = self.thread()- .map_or(false, |thread| thread.read(cx).can_resume(cx));+ .map_or(false, |thread| thread.read(cx).can_retry(cx));let markdown = if let Some(markdown) = &self.thread_error_markdown {markdown.clone()@@ -7972,7 +7972,7 @@ impl AcpThreadView {.icon_size(IconSize::Small).tooltip(Tooltip::text("Retry Generation")).on_click(cx.listener(|this, _, _window, cx| {- this.resume_chat(cx);+ this.retry_generation(cx);})),)})