assistant2: Wire up basic @-mention interaction for context (#22197)
This PR adds an initial version of using `@` in the message editor to add context to the thread. We don't yet insert any sort of reference to it in the message body itself. Release Notes: - N/A
This commit is contained in:
parent
b79117c882
commit
8b2afab0d3
7 changed files with 182 additions and 34 deletions
|
@ -22,6 +22,12 @@ use crate::context_picker::thread_context_picker::ThreadContextPicker;
|
|||
use crate::context_store::ContextStore;
|
||||
use crate::thread_store::ThreadStore;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum ConfirmBehavior {
|
||||
KeepOpen,
|
||||
Close,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum ContextPickerMode {
|
||||
Default,
|
||||
|
@ -41,6 +47,7 @@ impl ContextPicker {
|
|||
workspace: WeakView<Workspace>,
|
||||
thread_store: Option<WeakModel<ThreadStore>>,
|
||||
context_store: WeakModel<ContextStore>,
|
||||
confirm_behavior: ConfirmBehavior,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
let mut entries = vec![
|
||||
|
@ -74,6 +81,7 @@ impl ContextPicker {
|
|||
workspace,
|
||||
thread_store,
|
||||
context_store,
|
||||
confirm_behavior,
|
||||
entries,
|
||||
selected_ix: 0,
|
||||
};
|
||||
|
@ -136,6 +144,7 @@ pub(crate) struct ContextPickerDelegate {
|
|||
workspace: WeakView<Workspace>,
|
||||
thread_store: Option<WeakModel<ThreadStore>>,
|
||||
context_store: WeakModel<ContextStore>,
|
||||
confirm_behavior: ConfirmBehavior,
|
||||
entries: Vec<ContextPickerEntry>,
|
||||
selected_ix: usize,
|
||||
}
|
||||
|
@ -175,6 +184,7 @@ impl PickerDelegate for ContextPickerDelegate {
|
|||
self.context_picker.clone(),
|
||||
self.workspace.clone(),
|
||||
self.context_store.clone(),
|
||||
self.confirm_behavior,
|
||||
cx,
|
||||
)
|
||||
}));
|
||||
|
@ -185,6 +195,7 @@ impl PickerDelegate for ContextPickerDelegate {
|
|||
self.context_picker.clone(),
|
||||
self.workspace.clone(),
|
||||
self.context_store.clone(),
|
||||
self.confirm_behavior,
|
||||
cx,
|
||||
)
|
||||
}));
|
||||
|
@ -195,6 +206,7 @@ impl PickerDelegate for ContextPickerDelegate {
|
|||
self.context_picker.clone(),
|
||||
self.workspace.clone(),
|
||||
self.context_store.clone(),
|
||||
self.confirm_behavior,
|
||||
cx,
|
||||
)
|
||||
}));
|
||||
|
@ -206,6 +218,7 @@ impl PickerDelegate for ContextPickerDelegate {
|
|||
thread_store.clone(),
|
||||
self.context_picker.clone(),
|
||||
self.context_store.clone(),
|
||||
self.confirm_behavior,
|
||||
cx,
|
||||
)
|
||||
}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue