assistant2: Add ChatMode
action (#23243)
This PR makes the assistant 2 panel switch work with the keyboard via the `cmd-e` keybinding. Release Notes: - N/A --------- Co-authored-by: Agus Zubiaga <hi@aguz.me>
This commit is contained in:
parent
9ea8b14ac3
commit
8a0c22c3bf
4 changed files with 16 additions and 2 deletions
|
@ -574,6 +574,7 @@
|
||||||
"ctrl-shift-h": "assistant2::OpenHistory",
|
"ctrl-shift-h": "assistant2::OpenHistory",
|
||||||
"ctrl-alt-/": "assistant2::ToggleModelSelector",
|
"ctrl-alt-/": "assistant2::ToggleModelSelector",
|
||||||
"ctrl-shift-a": "assistant2::ToggleContextPicker",
|
"ctrl-shift-a": "assistant2::ToggleContextPicker",
|
||||||
|
"ctrl-e": "assistant2::ChatMode",
|
||||||
"ctrl-alt-e": "assistant2::RemoveAllContext"
|
"ctrl-alt-e": "assistant2::RemoveAllContext"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -229,6 +229,7 @@
|
||||||
"cmd-shift-h": "assistant2::OpenHistory",
|
"cmd-shift-h": "assistant2::OpenHistory",
|
||||||
"cmd-alt-/": "assistant2::ToggleModelSelector",
|
"cmd-alt-/": "assistant2::ToggleModelSelector",
|
||||||
"cmd-shift-a": "assistant2::ToggleContextPicker",
|
"cmd-shift-a": "assistant2::ToggleContextPicker",
|
||||||
|
"cmd-e": "assistant2::ChatMode",
|
||||||
"cmd-alt-e": "assistant2::RemoveAllContext"
|
"cmd-alt-e": "assistant2::RemoveAllContext"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -43,6 +43,7 @@ actions!(
|
||||||
RemoveAllContext,
|
RemoveAllContext,
|
||||||
OpenHistory,
|
OpenHistory,
|
||||||
Chat,
|
Chat,
|
||||||
|
ChatMode,
|
||||||
CycleNextInlineAssist,
|
CycleNextInlineAssist,
|
||||||
CyclePreviousInlineAssist,
|
CyclePreviousInlineAssist,
|
||||||
FocusUp,
|
FocusUp,
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::context_store::{refresh_context_store_text, 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, RemoveAllContext, ToggleContextPicker, ToggleModelSelector};
|
use crate::{Chat, ChatMode, RemoveAllContext, ToggleContextPicker, ToggleModelSelector};
|
||||||
|
|
||||||
pub struct MessageEditor {
|
pub struct MessageEditor {
|
||||||
thread: Model<Thread>,
|
thread: Model<Thread>,
|
||||||
|
@ -116,6 +116,11 @@ impl MessageEditor {
|
||||||
self.model_selector_menu_handle.toggle(cx)
|
self.model_selector_menu_handle.toggle(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn toggle_chat_mode(&mut self, _: &ChatMode, cx: &mut ViewContext<Self>) {
|
||||||
|
self.use_tools = !self.use_tools;
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
fn toggle_context_picker(&mut self, _: &ToggleContextPicker, cx: &mut ViewContext<Self>) {
|
fn toggle_context_picker(&mut self, _: &ToggleContextPicker, cx: &mut ViewContext<Self>) {
|
||||||
self.context_picker_menu_handle.toggle(cx);
|
self.context_picker_menu_handle.toggle(cx);
|
||||||
}
|
}
|
||||||
|
@ -264,6 +269,7 @@ impl Render for MessageEditor {
|
||||||
.on_action(cx.listener(Self::toggle_context_picker))
|
.on_action(cx.listener(Self::toggle_context_picker))
|
||||||
.on_action(cx.listener(Self::remove_all_context))
|
.on_action(cx.listener(Self::remove_all_context))
|
||||||
.on_action(cx.listener(Self::move_up))
|
.on_action(cx.listener(Self::move_up))
|
||||||
|
.on_action(cx.listener(Self::toggle_chat_mode))
|
||||||
.size_full()
|
.size_full()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.p_2()
|
.p_2()
|
||||||
|
@ -323,7 +329,12 @@ impl Render for MessageEditor {
|
||||||
ToggleState::Unselected
|
ToggleState::Unselected
|
||||||
| ToggleState::Indeterminate => false,
|
| ToggleState::Indeterminate => false,
|
||||||
};
|
};
|
||||||
})),
|
}))
|
||||||
|
.key_binding(KeyBinding::for_action_in(
|
||||||
|
&ChatMode,
|
||||||
|
&focus_handle,
|
||||||
|
cx,
|
||||||
|
)),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
h_flex().gap_1().child(self.model_selector.clone()).child(
|
h_flex().gap_1().child(self.model_selector.clone()).child(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue