assistant2: Add keybinding for "Remove All Context" action (#22783)
Ensuring all of the assistant 2 actions have keybindings. Release Notes: - N/A --------- Co-authored-by: Agus Zubiaga <hi@aguz.me> Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
parent
bb6e8053d3
commit
9d5ae516fd
5 changed files with 41 additions and 14 deletions
|
@ -227,7 +227,8 @@
|
||||||
"cmd-n": "assistant2::NewThread",
|
"cmd-n": "assistant2::NewThread",
|
||||||
"cmd-shift-h": "assistant2::OpenHistory",
|
"cmd-shift-h": "assistant2::OpenHistory",
|
||||||
"cmd-shift-m": "assistant2::ToggleModelSelector",
|
"cmd-shift-m": "assistant2::ToggleModelSelector",
|
||||||
"cmd-shift-a": "assistant2::ToggleContextPicker"
|
"cmd-shift-a": "assistant2::ToggleContextPicker",
|
||||||
|
"cmd-alt-e": "assistant2::RemoveAllContext"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -615,6 +616,7 @@
|
||||||
"use_key_equivalents": true,
|
"use_key_equivalents": true,
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"cmd-shift-a": "assistant2::ToggleContextPicker",
|
"cmd-shift-a": "assistant2::ToggleContextPicker",
|
||||||
|
"cmd-alt-e": "assistant2::RemoveAllContext",
|
||||||
"ctrl-[": "assistant::CyclePreviousInlineAssist",
|
"ctrl-[": "assistant::CyclePreviousInlineAssist",
|
||||||
"ctrl-]": "assistant::CycleNextInlineAssist"
|
"ctrl-]": "assistant::CycleNextInlineAssist"
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ actions!(
|
||||||
NewThread,
|
NewThread,
|
||||||
ToggleContextPicker,
|
ToggleContextPicker,
|
||||||
ToggleModelSelector,
|
ToggleModelSelector,
|
||||||
|
RemoveAllContext,
|
||||||
OpenHistory,
|
OpenHistory,
|
||||||
Chat,
|
Chat,
|
||||||
CycleNextInlineAssist,
|
CycleNextInlineAssist,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use crate::context_store::ContextStore;
|
||||||
use crate::thread::Thread;
|
use crate::thread::Thread;
|
||||||
use crate::thread_store::ThreadStore;
|
use crate::thread_store::ThreadStore;
|
||||||
use crate::ui::ContextPill;
|
use crate::ui::ContextPill;
|
||||||
use crate::{AssistantPanel, ToggleContextPicker};
|
use crate::{AssistantPanel, RemoveAllContext, ToggleContextPicker};
|
||||||
|
|
||||||
pub struct ContextStrip {
|
pub struct ContextStrip {
|
||||||
context_store: Model<ContextStore>,
|
context_store: Model<ContextStore>,
|
||||||
|
@ -226,14 +226,23 @@ impl Render for ContextStrip {
|
||||||
parent.child(
|
parent.child(
|
||||||
IconButton::new("remove-all-context", IconName::Eraser)
|
IconButton::new("remove-all-context", IconName::Eraser)
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.tooltip(move |cx| Tooltip::text("Remove All Context", cx))
|
.tooltip({
|
||||||
.on_click({
|
let focus_handle = focus_handle.clone();
|
||||||
let context_store = self.context_store.clone();
|
move |cx| {
|
||||||
cx.listener(move |_this, _event, cx| {
|
Tooltip::for_action_in(
|
||||||
context_store.update(cx, |this, _cx| this.clear());
|
"Remove All Context",
|
||||||
cx.notify();
|
&RemoveAllContext,
|
||||||
})
|
&focus_handle,
|
||||||
}),
|
cx,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on_click(cx.listener({
|
||||||
|
let focus_handle = focus_handle.clone();
|
||||||
|
move |_this, _event, cx| {
|
||||||
|
focus_handle.dispatch_action(&RemoveAllContext, cx);
|
||||||
|
}
|
||||||
|
})),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::context_strip::{ContextStrip, ContextStripEvent, SuggestContextKind};
|
||||||
use crate::terminal_codegen::TerminalCodegen;
|
use crate::terminal_codegen::TerminalCodegen;
|
||||||
use crate::thread_store::ThreadStore;
|
use crate::thread_store::ThreadStore;
|
||||||
use crate::{CycleNextInlineAssist, CyclePreviousInlineAssist};
|
use crate::{CycleNextInlineAssist, CyclePreviousInlineAssist};
|
||||||
use crate::{ToggleContextPicker, ToggleModelSelector};
|
use crate::{RemoveAllContext, ToggleContextPicker, ToggleModelSelector};
|
||||||
use client::ErrorExt;
|
use client::ErrorExt;
|
||||||
use collections::VecDeque;
|
use collections::VecDeque;
|
||||||
use editor::{
|
use editor::{
|
||||||
|
@ -37,6 +37,7 @@ use workspace::Workspace;
|
||||||
pub struct PromptEditor<T> {
|
pub struct PromptEditor<T> {
|
||||||
pub editor: View<Editor>,
|
pub editor: View<Editor>,
|
||||||
mode: PromptEditorMode,
|
mode: PromptEditorMode,
|
||||||
|
context_store: Model<ContextStore>,
|
||||||
context_strip: View<ContextStrip>,
|
context_strip: View<ContextStrip>,
|
||||||
context_picker_menu_handle: PopoverMenuHandle<ContextPicker>,
|
context_picker_menu_handle: PopoverMenuHandle<ContextPicker>,
|
||||||
model_selector: View<AssistantModelSelector>,
|
model_selector: View<AssistantModelSelector>,
|
||||||
|
@ -109,6 +110,7 @@ impl<T: 'static> Render for PromptEditor<T> {
|
||||||
.on_action(cx.listener(Self::cancel))
|
.on_action(cx.listener(Self::cancel))
|
||||||
.on_action(cx.listener(Self::move_up))
|
.on_action(cx.listener(Self::move_up))
|
||||||
.on_action(cx.listener(Self::move_down))
|
.on_action(cx.listener(Self::move_down))
|
||||||
|
.on_action(cx.listener(Self::remove_all_context))
|
||||||
.capture_action(cx.listener(Self::cycle_prev))
|
.capture_action(cx.listener(Self::cycle_prev))
|
||||||
.capture_action(cx.listener(Self::cycle_next))
|
.capture_action(cx.listener(Self::cycle_next))
|
||||||
.child(
|
.child(
|
||||||
|
@ -339,6 +341,11 @@ impl<T: 'static> PromptEditor<T> {
|
||||||
self.model_selector_menu_handle.toggle(cx);
|
self.model_selector_menu_handle.toggle(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove_all_context(&mut self, _: &RemoveAllContext, cx: &mut ViewContext<Self>) {
|
||||||
|
self.context_store.update(cx, |store, _cx| store.clear());
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
fn cancel(&mut self, _: &editor::actions::Cancel, cx: &mut ViewContext<Self>) {
|
fn cancel(&mut self, _: &editor::actions::Cancel, cx: &mut ViewContext<Self>) {
|
||||||
match self.codegen_status(cx) {
|
match self.codegen_status(cx) {
|
||||||
CodegenStatus::Idle | CodegenStatus::Done | CodegenStatus::Error(_) => {
|
CodegenStatus::Idle | CodegenStatus::Done | CodegenStatus::Error(_) => {
|
||||||
|
@ -816,7 +823,7 @@ impl PromptEditor<BufferCodegen> {
|
||||||
|
|
||||||
let context_strip = cx.new_view(|cx| {
|
let context_strip = cx.new_view(|cx| {
|
||||||
ContextStrip::new(
|
ContextStrip::new(
|
||||||
context_store,
|
context_store.clone(),
|
||||||
workspace.clone(),
|
workspace.clone(),
|
||||||
thread_store.clone(),
|
thread_store.clone(),
|
||||||
prompt_editor.focus_handle(cx),
|
prompt_editor.focus_handle(cx),
|
||||||
|
@ -831,6 +838,7 @@ impl PromptEditor<BufferCodegen> {
|
||||||
|
|
||||||
let mut this: PromptEditor<BufferCodegen> = PromptEditor {
|
let mut this: PromptEditor<BufferCodegen> = PromptEditor {
|
||||||
editor: prompt_editor.clone(),
|
editor: prompt_editor.clone(),
|
||||||
|
context_store,
|
||||||
context_strip,
|
context_strip,
|
||||||
context_picker_menu_handle,
|
context_picker_menu_handle,
|
||||||
model_selector: cx.new_view(|cx| {
|
model_selector: cx.new_view(|cx| {
|
||||||
|
@ -962,7 +970,7 @@ impl PromptEditor<TerminalCodegen> {
|
||||||
|
|
||||||
let context_strip = cx.new_view(|cx| {
|
let context_strip = cx.new_view(|cx| {
|
||||||
ContextStrip::new(
|
ContextStrip::new(
|
||||||
context_store,
|
context_store.clone(),
|
||||||
workspace.clone(),
|
workspace.clone(),
|
||||||
thread_store.clone(),
|
thread_store.clone(),
|
||||||
prompt_editor.focus_handle(cx),
|
prompt_editor.focus_handle(cx),
|
||||||
|
@ -977,6 +985,7 @@ impl PromptEditor<TerminalCodegen> {
|
||||||
|
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
editor: prompt_editor.clone(),
|
editor: prompt_editor.clone(),
|
||||||
|
context_store,
|
||||||
context_strip,
|
context_strip,
|
||||||
context_picker_menu_handle,
|
context_picker_menu_handle,
|
||||||
model_selector: cx.new_view(|cx| {
|
model_selector: cx.new_view(|cx| {
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::context_store::ContextStore;
|
||||||
use crate::context_strip::{ContextStrip, ContextStripEvent, SuggestContextKind};
|
use crate::context_strip::{ContextStrip, ContextStripEvent, SuggestContextKind};
|
||||||
use crate::thread::{RequestKind, Thread};
|
use crate::thread::{RequestKind, Thread};
|
||||||
use crate::thread_store::ThreadStore;
|
use crate::thread_store::ThreadStore;
|
||||||
use crate::{Chat, ToggleContextPicker, ToggleModelSelector};
|
use crate::{Chat, RemoveAllContext, ToggleContextPicker, ToggleModelSelector};
|
||||||
|
|
||||||
pub struct MessageEditor {
|
pub struct MessageEditor {
|
||||||
thread: Model<Thread>,
|
thread: Model<Thread>,
|
||||||
|
@ -116,6 +116,11 @@ impl MessageEditor {
|
||||||
self.context_picker_menu_handle.toggle(cx);
|
self.context_picker_menu_handle.toggle(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove_all_context(&mut self, _: &RemoveAllContext, cx: &mut ViewContext<Self>) {
|
||||||
|
self.context_store.update(cx, |store, _cx| store.clear());
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
fn chat(&mut self, _: &Chat, cx: &mut ViewContext<Self>) {
|
fn chat(&mut self, _: &Chat, cx: &mut ViewContext<Self>) {
|
||||||
self.send_to_model(RequestKind::Chat, cx);
|
self.send_to_model(RequestKind::Chat, cx);
|
||||||
}
|
}
|
||||||
|
@ -233,6 +238,7 @@ impl Render for MessageEditor {
|
||||||
.on_action(cx.listener(Self::chat))
|
.on_action(cx.listener(Self::chat))
|
||||||
.on_action(cx.listener(Self::toggle_model_selector))
|
.on_action(cx.listener(Self::toggle_model_selector))
|
||||||
.on_action(cx.listener(Self::toggle_context_picker))
|
.on_action(cx.listener(Self::toggle_context_picker))
|
||||||
|
.on_action(cx.listener(Self::remove_all_context))
|
||||||
.size_full()
|
.size_full()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.p_2()
|
.p_2()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue