Fix @-mentioning threads when their summary isn't ready yet (#36664)

Antonio Scandurra created

Release Notes:

- N/A

Change summary

crates/agent2/src/agent.rs                | 10 ++--------
crates/agent_ui/src/acp/message_editor.rs |  9 +++------
2 files changed, 5 insertions(+), 14 deletions(-)

Detailed changes

crates/agent2/src/agent.rs 🔗

@@ -1269,18 +1269,12 @@ mod tests {
         let model = Arc::new(FakeLanguageModel::default());
         let summary_model = Arc::new(FakeLanguageModel::default());
         thread.update(cx, |thread, cx| {
-            thread.set_model(model, cx);
-            thread.set_summarization_model(Some(summary_model), cx);
+            thread.set_model(model.clone(), cx);
+            thread.set_summarization_model(Some(summary_model.clone()), cx);
         });
         cx.run_until_parked();
         assert_eq!(history_entries(&history_store, cx), vec![]);
 
-        let model = thread.read_with(cx, |thread, _| thread.model().unwrap().clone());
-        let model = model.as_fake();
-        let summary_model = thread.read_with(cx, |thread, _| {
-            thread.summarization_model().unwrap().clone()
-        });
-        let summary_model = summary_model.as_fake();
         let send = acp_thread.update(cx, |thread, cx| {
             thread.send(
                 vec![

crates/agent_ui/src/acp/message_editor.rs 🔗

@@ -629,15 +629,11 @@ impl MessageEditor {
             .shared();
 
         self.mention_set.insert_thread(id.clone(), task.clone());
+        self.mention_set.insert_uri(crease_id, uri);
 
         let editor = self.editor.clone();
         cx.spawn_in(window, async move |this, cx| {
-            if task.await.notify_async_err(cx).is_some() {
-                this.update(cx, |this, _| {
-                    this.mention_set.insert_uri(crease_id, uri);
-                })
-                .ok();
-            } else {
+            if task.await.notify_async_err(cx).is_none() {
                 editor
                     .update(cx, |editor, cx| {
                         editor.display_map.update(cx, |display_map, cx| {
@@ -648,6 +644,7 @@ impl MessageEditor {
                     .ok();
                 this.update(cx, |this, _| {
                     this.mention_set.thread_summaries.remove(&id);
+                    this.mention_set.uri_by_crease_id.remove(&crease_id);
                 })
                 .ok();
             }