assistant2: Suggest current thread in inline assistant (#22586)

Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.com>
This commit is contained in:
Agus Zubiaga 2025-01-02 17:36:57 -03:00 committed by GitHub
parent 0e75ca8603
commit 374c298bd5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 161 additions and 114 deletions

View file

@ -1,7 +1,10 @@
use gpui::SharedString;
use project::ProjectEntryId;
use crate::context::{Context, ContextId, ContextKind};
use crate::{
context::{Context, ContextId, ContextKind},
thread::ThreadId,
};
pub struct ContextStore {
context: Vec<Context>,
@ -49,9 +52,14 @@ impl ContextStore {
pub fn contains_project_entry(&self, entry_id: ProjectEntryId) -> bool {
self.context.iter().any(|probe| match probe.kind {
ContextKind::File(probe_entry_id) => probe_entry_id == entry_id,
ContextKind::Directory => false,
ContextKind::FetchedUrl => false,
ContextKind::Thread => false,
ContextKind::Directory | ContextKind::FetchedUrl | ContextKind::Thread(_) => false,
})
}
pub fn contains_thread(&self, thread_id: &ThreadId) -> bool {
self.context.iter().any(|probe| match probe.kind {
ContextKind::Thread(ref probe_thread_id) => probe_thread_id == thread_id,
ContextKind::File(_) | ContextKind::Directory | ContextKind::FetchedUrl => false,
})
}
}