Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

agent: Remove selections as context once message is sent (#29030)

Bennet Bo Fenner87512d081415
diff --git a/crates/agent/src/message_editor.rs b/crates/agent/src/message_editor.rs
index df998b51026..73ca95888d1 100644
--- a/crates/agent/src/message_editor.rs
+++ b/crates/agent/src/message_editor.rs
@@ -2,7 +2,7 @@ use std::collections::BTreeMap;
use std::sync::Arc;
use crate::assistant_model_selector::ModelType;
-use crate::context::format_context_as_string;
+use crate::context::{AssistantContext, format_context_as_string};
use crate::tool_compatibility::{IncompatibleToolsState, IncompatibleToolsTooltip};
use buffer_diff::BufferDiff;
use collections::HashSet;
@@ -293,6 +293,21 @@ impl MessageEditor {
})
.log_err();
+ context_store
+ .update(cx, |context_store, cx| {
+ let excerpt_ids = context_store
+ .context()
+ .iter()
+ .filter(|ctx| matches!(ctx, AssistantContext::Excerpt(_)))
+ .map(|ctx| ctx.id())
+ .collect::<Vec<_>>();
+
+ for id in excerpt_ids {
+ context_store.remove_context(id, cx);
+ }
+ })
+ .log_err();
+
if let Some(wait_for_summaries) = context_store
.update(cx, |context_store, cx| context_store.wait_for_summaries(cx))
.log_err()