Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent_ui: Allow opening thread as markdown in remote projects (#42182)
Bennet Bo Fenner61c263fcf031
diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rsindex 5907076fb9e..13cd3988ae6 100644--- a/crates/agent_ui/src/acp/thread_view.rs+++ b/crates/agent_ui/src/acp/thread_view.rs@@ -9,7 +9,7 @@ use agent::{DbThreadMetadata, HistoryEntry, HistoryEntryId, HistoryStore, Nativeuse agent_client_protocol::{self as acp, PromptCapabilities};use agent_servers::{AgentServer, AgentServerDelegate};use agent_settings::{AgentProfileId, AgentSettings, CompletionMode};-use anyhow::{Result, anyhow, bail};+use anyhow::{Result, anyhow};use arrayvec::ArrayVec;use audio::{Audio, Sound};use buffer_diff::BufferDiff;@@ -4709,35 +4709,36 @@ impl AcpThreadView {.languages.language_for_name("Markdown");- let (thread_summary, markdown) = if let Some(thread) = self.thread() {+ let (thread_title, markdown) = if let Some(thread) = self.thread() {let thread = thread.read(cx);(thread.title().to_string(), thread.to_markdown(cx))} else {return Task::ready(Ok(()));};+ let project = workspace.read(cx).project().clone();window.spawn(cx, async move |cx| {let markdown_language = markdown_language_task.await?;- workspace.update_in(cx, |workspace, window, cx| {- let project = workspace.project().clone();+ let buffer = project+ .update(cx, |project, cx| project.create_buffer(false, cx))?+ .await?;- if !project.read(cx).is_local() {- bail!("failed to open active thread as markdown in remote project");- }+ buffer.update(cx, |buffer, cx| {+ buffer.set_text(markdown, cx);+ buffer.set_language(Some(markdown_language), cx);+ buffer.set_capability(language::Capability::ReadOnly, cx);+ })?;- let buffer = project.update(cx, |project, cx| {- project.create_local_buffer(&markdown, Some(markdown_language), true, cx)- });- let buffer = cx.new(|cx| {- MultiBuffer::singleton(buffer, cx).with_title(thread_summary.clone())- });+ workspace.update_in(cx, |workspace, window, cx| {+ let buffer = cx+ .new(|cx| MultiBuffer::singleton(buffer, cx).with_title(thread_title.clone()));workspace.add_item_to_active_pane(Box::new(cx.new(|cx| {let mut editor =Editor::for_multibuffer(buffer, Some(project.clone()), window, cx);- editor.set_breadcrumb_header(thread_summary);+ editor.set_breadcrumb_header(thread_title);editor})),None,@@ -4745,9 +4746,7 @@ impl AcpThreadView {window,cx,);-- anyhow::Ok(())- })??;+ })?;anyhow::Ok(())})}