assistant2: Do not allow a context entry to be added multiple times (#22712)

https://github.com/user-attachments/assets/81674c88-031b-4d55-b362-43819492b93d


Release Notes:

- N/A
This commit is contained in:
Agus Zubiaga
2025-01-06 18:55:20 +00:00
committed by GitHub
parent c74e5f5de2
commit 3a061a91e7
9 changed files with 293 additions and 173 deletions
+4 -7
View File
@@ -1,11 +1,8 @@
use gpui::SharedString;
use language_model::{LanguageModelRequestMessage, MessageContent};
use project::ProjectEntryId;
use serde::{Deserialize, Serialize};
use util::post_inc;
use crate::thread::ThreadId;
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Serialize, Deserialize)]
pub struct ContextId(pub(crate) usize);
@@ -26,10 +23,10 @@ pub struct Context {
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ContextKind {
File(ProjectEntryId),
File,
Directory,
FetchedUrl,
Thread(ThreadId),
Thread,
}
pub fn attach_context_to_message(
@@ -43,7 +40,7 @@ pub fn attach_context_to_message(
for context in context.into_iter() {
match context.kind {
ContextKind::File(_) => {
ContextKind::File => {
file_context.push_str(&context.text);
file_context.push('\n');
}
@@ -57,7 +54,7 @@ pub fn attach_context_to_message(
fetch_context.push_str(&context.text);
fetch_context.push('\n');
}
ContextKind::Thread(_) => {
ContextKind::Thread => {
thread_context.push_str(&context.name);
thread_context.push('\n');
thread_context.push_str(&context.text);