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:
Agus Zubiaga 2025-01-10 11:26:53 -03:00 committed by GitHub
parent 49198a7961
commit a267911e83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 649 additions and 350 deletions

View file

@ -23,7 +23,7 @@ use crate::{AssistantPanel, RemoveAllContext, ToggleContextPicker};
pub struct ContextStrip {
context_store: Model<ContextStore>,
context_picker: View<ContextPicker>,
pub context_picker: View<ContextPicker>,
context_picker_menu_handle: PopoverMenuHandle<ContextPicker>,
focus_handle: FocusHandle,
suggest_context_kind: SuggestContextKind,
@ -126,7 +126,7 @@ impl ContextStrip {
}
Some(SuggestedContext::Thread {
name: active_thread.summary().unwrap_or("New Thread".into()),
name: active_thread.summary_or_default(),
thread: weak_active_thread,
})
}
@ -168,7 +168,13 @@ impl Render for ContextStrip {
.gap_1()
.child(
PopoverMenu::new("context-picker")
.menu(move |_cx| Some(context_picker.clone()))
.menu(move |cx| {
context_picker.update(cx, |this, cx| {
this.reset_mode(cx);
});
Some(context_picker.clone())
})
.trigger(
IconButton::new("add-context", IconName::Plus)
.icon_size(IconSize::Small)