Compare commits

..

1 Commits

Author SHA1 Message Date
Ben Brandt
4ee0fa561a agent: Add action to close agent panel
Adds an action to close the Agent panel, as well as binds it to cmd-w when focused on the panel.
2025-05-09 12:00:16 +02:00
6 changed files with 22 additions and 6 deletions

View File

@@ -242,6 +242,7 @@
"ctrl-i": "agent::ToggleProfileSelector",
"ctrl-alt-/": "agent::ToggleModelSelector",
"ctrl-shift-a": "agent::ToggleContextPicker",
"ctrl-w": "agent::Close",
"ctrl-shift-o": "agent::ToggleNavigationMenu",
"ctrl-shift-i": "agent::ToggleOptionsMenu",
"shift-escape": "agent::ExpandMessageEditor",

View File

@@ -288,6 +288,7 @@
"cmd-i": "agent::ToggleProfileSelector",
"cmd-alt-/": "agent::ToggleModelSelector",
"cmd-shift-a": "agent::ToggleContextPicker",
"cmd-w": "agent::Close",
"cmd-shift-o": "agent::ToggleNavigationMenu",
"cmd-shift-i": "agent::ToggleOptionsMenu",
"shift-escape": "agent::ExpandMessageEditor",

View File

@@ -1467,10 +1467,12 @@ impl ActiveThread {
cx.notify();
}
fn move_up(&mut self, _: &MoveUp, _window: &mut Window, cx: &mut Context<Self>) {
fn move_up(&mut self, _: &MoveUp, window: &mut Window, cx: &mut Context<Self>) {
if let Some((_, state)) = self.editing_message.as_mut() {
if state.context_picker_menu_handle.is_deployed() {
cx.propagate();
} else {
state.context_strip.focus_handle(cx).focus(window);
}
}
}

View File

@@ -85,6 +85,7 @@ actions!(
KeepAll,
Follow,
ResetTrialUpsell,
Close,
]
);

View File

@@ -62,10 +62,10 @@ use crate::thread_history::{EntryTimeFormat, PastContext, PastThread, ThreadHist
use crate::thread_store::ThreadStore;
use crate::ui::AgentOnboardingModal;
use crate::{
AddContextServer, AgentDiffPane, ContextStore, DeleteRecentlyOpenThread, ExpandMessageEditor,
Follow, InlineAssistant, NewTextThread, NewThread, OpenActiveThreadAsMarkdown, OpenAgentDiff,
OpenHistory, ResetTrialUpsell, TextThreadStore, ThreadEvent, ToggleContextPicker,
ToggleNavigationMenu, ToggleOptionsMenu,
AddContextServer, AgentDiffPane, Close, ContextStore, DeleteRecentlyOpenThread,
ExpandMessageEditor, Follow, InlineAssistant, NewTextThread, NewThread,
OpenActiveThreadAsMarkdown, OpenAgentDiff, OpenHistory, ResetTrialUpsell, TextThreadStore,
ThreadEvent, ToggleContextPicker, ToggleNavigationMenu, ToggleOptionsMenu,
};
const AGENT_PANEL_KEY: &str = "agent_panel";
@@ -156,6 +156,11 @@ pub fn init(cx: &mut App) {
})
.register_action(|_workspace, _: &ResetTrialUpsell, _window, cx| {
set_trial_upsell_dismissed(false, cx);
})
.register_action(|workspace, _: &Close, window, cx| {
if let Some(panel) = workspace.panel::<AgentPanel>(cx) {
panel.update(cx, |panel, cx| panel.close_panel(window, cx));
}
});
},
)
@@ -367,6 +372,10 @@ pub struct AgentPanel {
}
impl AgentPanel {
fn close_panel(&mut self, _window: &mut Window, cx: &mut Context<Self>) {
cx.emit(PanelEvent::Close);
}
fn serialize(&mut self, cx: &mut Context<Self>) {
let width = self.width;
self.pending_serialization = Some(cx.background_spawn(async move {

View File

@@ -392,9 +392,11 @@ impl MessageEditor {
}
}
fn move_up(&mut self, _: &MoveUp, _window: &mut Window, cx: &mut Context<Self>) {
fn move_up(&mut self, _: &MoveUp, window: &mut Window, cx: &mut Context<Self>) {
if self.context_picker_menu_handle.is_deployed() {
cx.propagate();
} else {
self.context_strip.focus_handle(cx).focus(window);
}
}