agent: Add use_modifier_to_send
setting (#34709)
When `use_modifier_to_send` is turned on, holding `cmd`/`ctrl` is necessary to send a message in the agent panel. Text threads already use `cmd-enter` by default to submit a message, and it was done this way to have the usual text editing bindings not taken over when writing a prompt, sort of stimulating more thoughtful writing. While `enter` to send is still somewhat a huge pattern in chat-like LLM UIs, it still makes sense to allow this for the new agent panel... hence the existence of this setting now! Release Notes: - agent: Added the `use_modifier_to_send` setting, which makes holding a modifier (`cmd`/`ctrl`), together with `enter`, required to send a new message.
This commit is contained in:
parent
64ce696aae
commit
e1d28ff957
4 changed files with 66 additions and 4 deletions
|
@ -28,8 +28,8 @@ use fs::Fs;
|
|||
use futures::future::Shared;
|
||||
use futures::{FutureExt as _, future};
|
||||
use gpui::{
|
||||
Animation, AnimationExt, App, Entity, EventEmitter, Focusable, Subscription, Task, TextStyle,
|
||||
WeakEntity, linear_color_stop, linear_gradient, point, pulsating_between,
|
||||
Animation, AnimationExt, App, Entity, EventEmitter, Focusable, KeyContext, Subscription, Task,
|
||||
TextStyle, WeakEntity, linear_color_stop, linear_gradient, point, pulsating_between,
|
||||
};
|
||||
use language::{Buffer, Language, Point};
|
||||
use language_model::{
|
||||
|
@ -132,6 +132,7 @@ pub(crate) fn create_editor(
|
|||
placement: Some(ContextMenuPlacement::Above),
|
||||
});
|
||||
editor.register_addon(ContextCreasesAddon::new());
|
||||
editor.register_addon(MessageEditorAddon::new());
|
||||
editor
|
||||
});
|
||||
|
||||
|
@ -1494,6 +1495,31 @@ pub struct ContextCreasesAddon {
|
|||
_subscription: Option<Subscription>,
|
||||
}
|
||||
|
||||
pub struct MessageEditorAddon {}
|
||||
|
||||
impl MessageEditorAddon {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl Addon for MessageEditorAddon {
|
||||
fn to_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn to_any_mut(&mut self) -> Option<&mut dyn std::any::Any> {
|
||||
Some(self)
|
||||
}
|
||||
|
||||
fn extend_key_context(&self, key_context: &mut KeyContext, cx: &App) {
|
||||
let settings = agent_settings::AgentSettings::get_global(cx);
|
||||
if settings.use_modifier_to_send {
|
||||
key_context.add("use_modifier_to_send");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Addon for ContextCreasesAddon {
|
||||
fn to_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue