diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index 6437fd1883c9ddbb256babbb88041b4c42293a95..e65ec23f107ea7caa9f7004d630f79d1c0c7409e 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -663,15 +663,18 @@ impl NativeAgent { return; }; - if let Some(title) = thread.read(cx).title() { - let acp_thread = session.acp_thread.downgrade(); - cx.spawn(async move |_, cx| { + let thread = thread.downgrade(); + let acp_thread = session.acp_thread.downgrade(); + cx.spawn(async move |_, cx| { + let title = thread.read_with(cx, |thread, _| thread.title())?; + if let Some(title) = title { let task = acp_thread.update(cx, |acp_thread, cx| acp_thread.set_title(title, cx))?; - task.await - }) - .detach_and_log_err(cx); - } + task.await?; + } + anyhow::Ok(()) + }) + .detach_and_log_err(cx); } fn handle_thread_token_usage_updated(