assistant2: Add live context type and use in message editor (#22865)
Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com> Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
parent
5d8ef94c86
commit
a0fca24e3f
15 changed files with 359 additions and 182 deletions
|
@ -240,7 +240,7 @@ impl PickerDelegate for DirectoryContextPickerDelegate {
|
|||
let added = self.context_store.upgrade().map_or(false, |context_store| {
|
||||
context_store
|
||||
.read(cx)
|
||||
.included_directory(&path_match.path)
|
||||
.includes_directory(&path_match.path)
|
||||
.is_some()
|
||||
});
|
||||
|
||||
|
|
|
@ -82,10 +82,12 @@ impl FetchContextPickerDelegate {
|
|||
}
|
||||
|
||||
async fn build_message(http_client: Arc<HttpClientWithUrl>, url: &str) -> Result<String> {
|
||||
let mut url = url.to_owned();
|
||||
if !url.starts_with("https://") && !url.starts_with("http://") {
|
||||
url = format!("https://{url}");
|
||||
}
|
||||
let prefixed_url = if !url.starts_with("https://") && !url.starts_with("http://") {
|
||||
Some(format!("https://{url}"))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let url = prefixed_url.as_deref().unwrap_or(url);
|
||||
|
||||
let mut response = http_client.get(&url, AsyncBody::default(), true).await?;
|
||||
|
||||
|
@ -200,7 +202,7 @@ impl PickerDelegate for FetchContextPickerDelegate {
|
|||
this.delegate
|
||||
.context_store
|
||||
.update(cx, |context_store, _cx| {
|
||||
if context_store.included_url(&url).is_none() {
|
||||
if context_store.includes_url(&url).is_none() {
|
||||
context_store.insert_fetched_url(url, text);
|
||||
}
|
||||
})?;
|
||||
|
@ -234,7 +236,7 @@ impl PickerDelegate for FetchContextPickerDelegate {
|
|||
cx: &mut ViewContext<Picker<Self>>,
|
||||
) -> Option<Self::ListItem> {
|
||||
let added = self.context_store.upgrade().map_or(false, |context_store| {
|
||||
context_store.read(cx).included_url(&self.url).is_some()
|
||||
context_store.read(cx).includes_url(&self.url).is_some()
|
||||
});
|
||||
|
||||
Some(
|
||||
|
|
|
@ -11,7 +11,7 @@ use util::ResultExt as _;
|
|||
use workspace::Workspace;
|
||||
|
||||
use crate::context_picker::{ConfirmBehavior, ContextPicker};
|
||||
use crate::context_store::{ContextStore, IncludedFile};
|
||||
use crate::context_store::{ContextStore, FileInclusion};
|
||||
|
||||
pub struct FileContextPicker {
|
||||
picker: View<Picker<FileContextPickerDelegate>>,
|
||||
|
@ -275,10 +275,11 @@ impl PickerDelegate for FileContextPickerDelegate {
|
|||
(file_name, Some(directory))
|
||||
};
|
||||
|
||||
let added = self
|
||||
.context_store
|
||||
.upgrade()
|
||||
.and_then(|context_store| context_store.read(cx).included_file(&path_match.path));
|
||||
let added = self.context_store.upgrade().and_then(|context_store| {
|
||||
context_store
|
||||
.read(cx)
|
||||
.will_include_file_path(&path_match.path, cx)
|
||||
});
|
||||
|
||||
Some(
|
||||
ListItem::new(ix)
|
||||
|
@ -295,7 +296,7 @@ impl PickerDelegate for FileContextPickerDelegate {
|
|||
})),
|
||||
)
|
||||
.when_some(added, |el, added| match added {
|
||||
IncludedFile::Direct(_) => el.end_slot(
|
||||
FileInclusion::Direct(_) => el.end_slot(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.child(
|
||||
|
@ -305,7 +306,7 @@ impl PickerDelegate for FileContextPickerDelegate {
|
|||
)
|
||||
.child(Label::new("Added").size(LabelSize::Small)),
|
||||
),
|
||||
IncludedFile::InDirectory(dir_name) => {
|
||||
FileInclusion::InDirectory(dir_name) => {
|
||||
let dir_name = dir_name.to_string_lossy().into_owned();
|
||||
|
||||
el.end_slot(
|
||||
|
|
|
@ -194,7 +194,7 @@ impl PickerDelegate for ThreadContextPickerDelegate {
|
|||
let thread = &self.matches[ix];
|
||||
|
||||
let added = self.context_store.upgrade().map_or(false, |context_store| {
|
||||
context_store.read(cx).included_thread(&thread.id).is_some()
|
||||
context_store.read(cx).includes_thread(&thread.id).is_some()
|
||||
});
|
||||
|
||||
Some(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue