Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Fix thread summary generation (#28143)
Agus Zubiagaec7d28648a84
diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rsindex 2f49d5ad713..cd88c5e4830 100644--- a/crates/agent/src/thread.rs+++ b/crates/agent/src/thread.rs@@ -391,17 +391,20 @@ impl Thread {self.summary.clone().unwrap_or(Self::DEFAULT_SUMMARY)}- pub fn set_summary(&mut self, summary: impl Into<SharedString>, cx: &mut Context<Self>) {- let summary = summary.into();- let old_summary = self.summary_or_default();-- self.summary = if summary.is_empty() {- Some(Self::DEFAULT_SUMMARY)- } else {- Some(summary)+ pub fn set_summary(&mut self, new_summary: impl Into<SharedString>, cx: &mut Context<Self>) {+ let Some(current_summary) = &self.summary else {+ // Don't allow setting summary until generated+ return;};- if Some(old_summary) != self.summary {+ let mut new_summary = new_summary.into();++ if new_summary.is_empty() {+ new_summary = Self::DEFAULT_SUMMARY;+ }++ if current_summary != &new_summary {+ self.summary = Some(new_summary);cx.emit(ThreadEvent::SummaryChanged);}}