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
|
@ -38,7 +38,7 @@ use workspace::{
|
|||
dock::{DockPosition, Panel, PanelEvent},
|
||||
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) {
|
||||
workspace::FollowableViewRegistry::register::<ContextEditor>(cx);
|
||||
|
@ -259,7 +259,7 @@ impl AssistantPanel {
|
|||
menu.context(focus_handle.clone())
|
||||
.action("New Chat", Box::new(NewChat))
|
||||
.action("History", Box::new(DeployHistory))
|
||||
.action("Prompt Library", Box::new(DeployPromptLibrary))
|
||||
.action("Prompt Library", Box::new(OpenPromptLibrary))
|
||||
.action("Configure", Box::new(ShowConfiguration))
|
||||
.action(zoom_label, Box::new(ToggleZoom))
|
||||
}))
|
||||
|
@ -1028,7 +1028,7 @@ impl AssistantPanel {
|
|||
|
||||
fn deploy_prompt_library(
|
||||
&mut self,
|
||||
_: &DeployPromptLibrary,
|
||||
_: &OpenPromptLibrary,
|
||||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
|
|
|
@ -9,7 +9,7 @@ use ui::{
|
|||
prelude::*, Disclosure, Divider, DividerColor, ElevationIndex, Indicator, Switch, Tooltip,
|
||||
};
|
||||
use util::ResultExt as _;
|
||||
use zed_actions::assistant::DeployPromptLibrary;
|
||||
use zed_actions::assistant::OpenPromptLibrary;
|
||||
use zed_actions::ExtensionCategoryFilter;
|
||||
|
||||
pub struct AssistantConfiguration {
|
||||
|
@ -374,7 +374,7 @@ impl Render for AssistantConfiguration {
|
|||
.icon_size(IconSize::Small)
|
||||
.icon_position(IconPosition::Start)
|
||||
.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 fs::Fs;
|
||||
use gpui::{
|
||||
prelude::*, Action, AnyElement, App, AsyncWindowContext, Corner, Entity, EventEmitter,
|
||||
FocusHandle, Focusable, FontWeight, KeyContext, Pixels, Subscription, Task, UpdateGlobal,
|
||||
WeakEntity,
|
||||
action_with_deprecated_aliases, prelude::*, Action, AnyElement, App, AsyncWindowContext,
|
||||
Corner, Entity, EventEmitter, FocusHandle, Focusable, FontWeight, KeyContext, Pixels,
|
||||
Subscription, Task, UpdateGlobal, WeakEntity,
|
||||
};
|
||||
use language::LanguageRegistry;
|
||||
use language_model::{LanguageModelProviderTosView, LanguageModelRegistry};
|
||||
|
@ -29,7 +29,7 @@ use ui::{prelude::*, ContextMenu, KeyBinding, PopoverMenu, PopoverMenuHandle, Ta
|
|||
use util::ResultExt as _;
|
||||
use workspace::dock::{DockPosition, Panel, PanelEvent};
|
||||
use workspace::Workspace;
|
||||
use zed_actions::assistant::{DeployPromptLibrary, ToggleFocus};
|
||||
use zed_actions::assistant::ToggleFocus;
|
||||
|
||||
use crate::active_thread::ActiveThread;
|
||||
use crate::assistant_configuration::{AssistantConfiguration, AssistantConfigurationEvent};
|
||||
|
@ -43,6 +43,12 @@ use crate::{
|
|||
OpenHistory,
|
||||
};
|
||||
|
||||
action_with_deprecated_aliases!(
|
||||
assistant,
|
||||
OpenPromptLibrary,
|
||||
["assistant::DeployPromptLibrary"]
|
||||
);
|
||||
|
||||
pub fn init(cx: &mut App) {
|
||||
cx.observe_new(
|
||||
|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));
|
||||
}
|
||||
})
|
||||
.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| {
|
||||
if let Some(panel) = workspace.panel::<AssistantPanel>(cx) {
|
||||
workspace.focus_panel::<AssistantPanel>(window, cx);
|
||||
|
@ -303,7 +317,7 @@ impl AssistantPanel {
|
|||
|
||||
fn deploy_prompt_library(
|
||||
&mut self,
|
||||
_: &DeployPromptLibrary,
|
||||
_: &OpenPromptLibrary,
|
||||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
|
|
|
@ -188,7 +188,7 @@ pub mod assistant {
|
|||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
|
||||
actions!(assistant, [ToggleFocus, DeployPromptLibrary]);
|
||||
actions!(assistant, [ToggleFocus, OpenPromptLibrary]);
|
||||
|
||||
#[derive(Clone, Default, Deserialize, PartialEq, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue