assistant: Allow opening the Prompt Library via the command palette (#27368)
Also took the opportunity to rename the action to something that would be clearer in the command palette, from `DeployPromptLibrary` to `OpenPromptLibrary`. Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <git@maxdeviant.com>
This commit is contained in:
parent
c32dece1b8
commit
03102b4d7e
6 changed files with 27 additions and 13 deletions
|
@ -195,7 +195,7 @@
|
||||||
"ctrl-shift-g": "search::SelectPreviousMatch",
|
"ctrl-shift-g": "search::SelectPreviousMatch",
|
||||||
"ctrl-alt-/": "assistant::ToggleModelSelector",
|
"ctrl-alt-/": "assistant::ToggleModelSelector",
|
||||||
"ctrl-k h": "assistant::DeployHistory",
|
"ctrl-k h": "assistant::DeployHistory",
|
||||||
"ctrl-k l": "assistant::DeployPromptLibrary",
|
"ctrl-k l": "assistant::OpenPromptLibrary",
|
||||||
"new": "assistant::NewChat",
|
"new": "assistant::NewChat",
|
||||||
"ctrl-t": "assistant::NewChat",
|
"ctrl-t": "assistant::NewChat",
|
||||||
"ctrl-n": "assistant::NewChat"
|
"ctrl-n": "assistant::NewChat"
|
||||||
|
|
|
@ -241,7 +241,7 @@
|
||||||
"cmd-shift-g": "search::SelectPreviousMatch",
|
"cmd-shift-g": "search::SelectPreviousMatch",
|
||||||
"cmd-alt-/": "assistant::ToggleModelSelector",
|
"cmd-alt-/": "assistant::ToggleModelSelector",
|
||||||
"cmd-k h": "assistant::DeployHistory",
|
"cmd-k h": "assistant::DeployHistory",
|
||||||
"cmd-k l": "assistant::DeployPromptLibrary",
|
"cmd-k l": "assistant::OpenPromptLibrary",
|
||||||
"cmd-t": "assistant::NewChat",
|
"cmd-t": "assistant::NewChat",
|
||||||
"cmd-n": "assistant::NewChat"
|
"cmd-n": "assistant::NewChat"
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ use workspace::{
|
||||||
dock::{DockPosition, Panel, PanelEvent},
|
dock::{DockPosition, Panel, PanelEvent},
|
||||||
pane, DraggedSelection, Pane, ShowConfiguration, ToggleZoom, Workspace,
|
pane, DraggedSelection, Pane, ShowConfiguration, ToggleZoom, Workspace,
|
||||||
};
|
};
|
||||||
use zed_actions::assistant::{DeployPromptLibrary, InlineAssist, ToggleFocus};
|
use zed_actions::assistant::{InlineAssist, OpenPromptLibrary, ToggleFocus};
|
||||||
|
|
||||||
pub fn init(cx: &mut App) {
|
pub fn init(cx: &mut App) {
|
||||||
workspace::FollowableViewRegistry::register::<ContextEditor>(cx);
|
workspace::FollowableViewRegistry::register::<ContextEditor>(cx);
|
||||||
|
@ -259,7 +259,7 @@ impl AssistantPanel {
|
||||||
menu.context(focus_handle.clone())
|
menu.context(focus_handle.clone())
|
||||||
.action("New Chat", Box::new(NewChat))
|
.action("New Chat", Box::new(NewChat))
|
||||||
.action("History", Box::new(DeployHistory))
|
.action("History", Box::new(DeployHistory))
|
||||||
.action("Prompt Library", Box::new(DeployPromptLibrary))
|
.action("Prompt Library", Box::new(OpenPromptLibrary))
|
||||||
.action("Configure", Box::new(ShowConfiguration))
|
.action("Configure", Box::new(ShowConfiguration))
|
||||||
.action(zoom_label, Box::new(ToggleZoom))
|
.action(zoom_label, Box::new(ToggleZoom))
|
||||||
}))
|
}))
|
||||||
|
@ -1028,7 +1028,7 @@ impl AssistantPanel {
|
||||||
|
|
||||||
fn deploy_prompt_library(
|
fn deploy_prompt_library(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &DeployPromptLibrary,
|
_: &OpenPromptLibrary,
|
||||||
_window: &mut Window,
|
_window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ use ui::{
|
||||||
prelude::*, Disclosure, Divider, DividerColor, ElevationIndex, Indicator, Switch, Tooltip,
|
prelude::*, Disclosure, Divider, DividerColor, ElevationIndex, Indicator, Switch, Tooltip,
|
||||||
};
|
};
|
||||||
use util::ResultExt as _;
|
use util::ResultExt as _;
|
||||||
use zed_actions::assistant::DeployPromptLibrary;
|
use zed_actions::assistant::OpenPromptLibrary;
|
||||||
use zed_actions::ExtensionCategoryFilter;
|
use zed_actions::ExtensionCategoryFilter;
|
||||||
|
|
||||||
pub struct AssistantConfiguration {
|
pub struct AssistantConfiguration {
|
||||||
|
@ -374,7 +374,7 @@ impl Render for AssistantConfiguration {
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.icon_position(IconPosition::Start)
|
.icon_position(IconPosition::Start)
|
||||||
.on_click(|_event, window, cx| {
|
.on_click(|_event, window, cx| {
|
||||||
window.dispatch_action(DeployPromptLibrary.boxed_clone(), cx)
|
window.dispatch_action(OpenPromptLibrary.boxed_clone(), cx)
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,9 +14,9 @@ use client::zed_urls;
|
||||||
use editor::{Editor, MultiBuffer};
|
use editor::{Editor, MultiBuffer};
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
prelude::*, Action, AnyElement, App, AsyncWindowContext, Corner, Entity, EventEmitter,
|
action_with_deprecated_aliases, prelude::*, Action, AnyElement, App, AsyncWindowContext,
|
||||||
FocusHandle, Focusable, FontWeight, KeyContext, Pixels, Subscription, Task, UpdateGlobal,
|
Corner, Entity, EventEmitter, FocusHandle, Focusable, FontWeight, KeyContext, Pixels,
|
||||||
WeakEntity,
|
Subscription, Task, UpdateGlobal, WeakEntity,
|
||||||
};
|
};
|
||||||
use language::LanguageRegistry;
|
use language::LanguageRegistry;
|
||||||
use language_model::{LanguageModelProviderTosView, LanguageModelRegistry};
|
use language_model::{LanguageModelProviderTosView, LanguageModelRegistry};
|
||||||
|
@ -29,7 +29,7 @@ use ui::{prelude::*, ContextMenu, KeyBinding, PopoverMenu, PopoverMenuHandle, Ta
|
||||||
use util::ResultExt as _;
|
use util::ResultExt as _;
|
||||||
use workspace::dock::{DockPosition, Panel, PanelEvent};
|
use workspace::dock::{DockPosition, Panel, PanelEvent};
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
use zed_actions::assistant::{DeployPromptLibrary, ToggleFocus};
|
use zed_actions::assistant::ToggleFocus;
|
||||||
|
|
||||||
use crate::active_thread::ActiveThread;
|
use crate::active_thread::ActiveThread;
|
||||||
use crate::assistant_configuration::{AssistantConfiguration, AssistantConfigurationEvent};
|
use crate::assistant_configuration::{AssistantConfiguration, AssistantConfigurationEvent};
|
||||||
|
@ -43,6 +43,12 @@ use crate::{
|
||||||
OpenHistory,
|
OpenHistory,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
action_with_deprecated_aliases!(
|
||||||
|
assistant,
|
||||||
|
OpenPromptLibrary,
|
||||||
|
["assistant::DeployPromptLibrary"]
|
||||||
|
);
|
||||||
|
|
||||||
pub fn init(cx: &mut App) {
|
pub fn init(cx: &mut App) {
|
||||||
cx.observe_new(
|
cx.observe_new(
|
||||||
|workspace: &mut Workspace, _window, _cx: &mut Context<Workspace>| {
|
|workspace: &mut Workspace, _window, _cx: &mut Context<Workspace>| {
|
||||||
|
@ -65,6 +71,14 @@ pub fn init(cx: &mut App) {
|
||||||
panel.update(cx, |panel, cx| panel.new_prompt_editor(window, cx));
|
panel.update(cx, |panel, cx| panel.new_prompt_editor(window, cx));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.register_action(|workspace, _: &OpenPromptLibrary, window, cx| {
|
||||||
|
if let Some(panel) = workspace.panel::<AssistantPanel>(cx) {
|
||||||
|
workspace.focus_panel::<AssistantPanel>(window, cx);
|
||||||
|
panel.update(cx, |panel, cx| {
|
||||||
|
panel.deploy_prompt_library(&OpenPromptLibrary, window, cx)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
.register_action(|workspace, _: &OpenConfiguration, window, cx| {
|
.register_action(|workspace, _: &OpenConfiguration, window, cx| {
|
||||||
if let Some(panel) = workspace.panel::<AssistantPanel>(cx) {
|
if let Some(panel) = workspace.panel::<AssistantPanel>(cx) {
|
||||||
workspace.focus_panel::<AssistantPanel>(window, cx);
|
workspace.focus_panel::<AssistantPanel>(window, cx);
|
||||||
|
@ -303,7 +317,7 @@ impl AssistantPanel {
|
||||||
|
|
||||||
fn deploy_prompt_library(
|
fn deploy_prompt_library(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &DeployPromptLibrary,
|
_: &OpenPromptLibrary,
|
||||||
_window: &mut Window,
|
_window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -188,7 +188,7 @@ pub mod assistant {
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
actions!(assistant, [ToggleFocus, DeployPromptLibrary]);
|
actions!(assistant, [ToggleFocus, OpenPromptLibrary]);
|
||||||
|
|
||||||
#[derive(Clone, Default, Deserialize, PartialEq, JsonSchema)]
|
#[derive(Clone, Default, Deserialize, PartialEq, JsonSchema)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue