assistant2: Suggest recent files and threads as context (#22959)
The context picker will now display up to 6 recent files/threads to add as a context: <img src="https://github.com/user-attachments/assets/80c87bf9-70ad-4e81-ba24-7a624378b991" width=400> Note: We decided to use a `ContextMenu` instead of `Picker` for the initial one since the latter didn't quite fit the design for the "Recent" section. Release Notes: - N/A --------- Co-authored-by: Danilo <danilo@zed.dev> Co-authored-by: Piotr <piotr@zed.dev> Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
49198a7961
commit
a267911e83
15 changed files with 649 additions and 350 deletions
|
@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};
|
|||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use collections::{BTreeMap, HashMap};
|
||||
use collections::{BTreeMap, HashMap, HashSet};
|
||||
use futures::{self, future, Future, FutureExt};
|
||||
use gpui::{AppContext, AsyncAppContext, Model, ModelContext, SharedString, Task, WeakView};
|
||||
use language::Buffer;
|
||||
|
@ -372,6 +372,23 @@ impl ContextStore {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn file_paths(&self, cx: &AppContext) -> HashSet<PathBuf> {
|
||||
self.context
|
||||
.iter()
|
||||
.filter_map(|context| match context {
|
||||
Context::File(file) => {
|
||||
let buffer = file.context_buffer.buffer.read(cx);
|
||||
buffer_path_log_err(buffer).map(|p| p.to_path_buf())
|
||||
}
|
||||
Context::Directory(_) | Context::FetchedUrl(_) | Context::Thread(_) => None,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn thread_ids(&self) -> HashSet<ThreadId> {
|
||||
self.threads.keys().cloned().collect()
|
||||
}
|
||||
}
|
||||
|
||||
pub enum FileInclusion {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue