1use gpui::{actions, impl_actions};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5// If the zed binary doesn't use anything in this crate, it will be optimized away
6// and the actions won't initialize. So we just provide an empty initialization function
7// to be called from main.
8//
9// These may provide relevant context:
10// https://github.com/rust-lang/rust/issues/47384
11// https://github.com/mmastrac/rust-ctor/issues/280
12pub fn init() {}
13
14#[derive(Clone, PartialEq, Deserialize, JsonSchema)]
15#[serde(deny_unknown_fields)]
16pub struct OpenBrowser {
17 pub url: String,
18}
19
20#[derive(Clone, PartialEq, Deserialize, JsonSchema)]
21#[serde(deny_unknown_fields)]
22pub struct OpenZedUrl {
23 pub url: String,
24}
25
26impl_actions!(zed, [OpenBrowser, OpenZedUrl]);
27
28actions!(
29 zed,
30 [
31 OpenSettings,
32 OpenDefaultKeymap,
33 OpenAccountSettings,
34 OpenServerSettings,
35 Quit,
36 OpenKeymap,
37 About,
38 Extensions,
39 OpenLicenses,
40 OpenTelemetryLog,
41 DecreaseBufferFontSize,
42 IncreaseBufferFontSize,
43 ResetBufferFontSize,
44 DecreaseUiFontSize,
45 IncreaseUiFontSize,
46 ResetUiFontSize
47 ]
48);
49
50pub mod git {
51 use gpui::action_with_deprecated_aliases;
52
53 action_with_deprecated_aliases!(git, Branch, ["branches::OpenRecent"]);
54}
55
56pub mod command_palette {
57 use gpui::actions;
58
59 actions!(command_palette, [Toggle]);
60}
61
62pub mod feedback {
63 use gpui::actions;
64
65 actions!(feedback, [GiveFeedback]);
66}
67
68pub mod theme_selector {
69 use gpui::impl_actions;
70 use schemars::JsonSchema;
71 use serde::Deserialize;
72
73 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
74 #[serde(deny_unknown_fields)]
75 pub struct Toggle {
76 /// A list of theme names to filter the theme selector down to.
77 pub themes_filter: Option<Vec<String>>,
78 }
79
80 impl_actions!(theme_selector, [Toggle]);
81}
82
83pub mod icon_theme_selector {
84 use gpui::impl_actions;
85 use schemars::JsonSchema;
86 use serde::Deserialize;
87
88 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
89 #[serde(deny_unknown_fields)]
90 pub struct Toggle {
91 /// A list of icon theme names to filter the theme selector down to.
92 pub themes_filter: Option<Vec<String>>,
93 }
94
95 impl_actions!(icon_theme_selector, [Toggle]);
96}
97
98pub mod assistant {
99 use gpui::{actions, impl_actions};
100 use schemars::JsonSchema;
101 use serde::Deserialize;
102
103 actions!(assistant, [ToggleFocus, DeployPromptLibrary]);
104
105 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema)]
106 #[serde(deny_unknown_fields)]
107 pub struct InlineAssist {
108 pub prompt: Option<String>,
109 }
110
111 impl_actions!(assistant, [InlineAssist]);
112}
113
114#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
115#[serde(deny_unknown_fields)]
116pub struct OpenRecent {
117 #[serde(default)]
118 pub create_new_window: bool,
119}
120
121impl_actions!(projects, [OpenRecent]);
122actions!(projects, [OpenRemote]);
123
124/// Where to spawn the task in the UI.
125#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
126#[serde(rename_all = "snake_case")]
127pub enum RevealTarget {
128 /// In the central pane group, "main" editor area.
129 Center,
130 /// In the terminal dock, "regular" terminal items' place.
131 #[default]
132 Dock,
133}
134
135/// Spawn a task with name or open tasks modal.
136#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema)]
137#[serde(untagged)]
138pub enum Spawn {
139 /// Spawns a task by the name given.
140 ByName {
141 task_name: String,
142 #[serde(default)]
143 reveal_target: Option<RevealTarget>,
144 },
145 /// Spawns a task via modal's selection.
146 ViaModal {
147 /// Selected task's `reveal_target` property override.
148 #[serde(default)]
149 reveal_target: Option<RevealTarget>,
150 },
151}
152
153impl Spawn {
154 pub fn modal() -> Self {
155 Self::ViaModal {
156 reveal_target: None,
157 }
158 }
159}
160
161/// Rerun the last task.
162#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema)]
163#[serde(deny_unknown_fields)]
164pub struct Rerun {
165 /// Controls whether the task context is reevaluated prior to execution of a task.
166 /// If it is not, environment variables such as ZED_COLUMN, ZED_FILE are gonna be the same as in the last execution of a task
167 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
168 /// default: false
169 #[serde(default)]
170 pub reevaluate_context: bool,
171 /// Overrides `allow_concurrent_runs` property of the task being reran.
172 /// Default: null
173 #[serde(default)]
174 pub allow_concurrent_runs: Option<bool>,
175 /// Overrides `use_new_terminal` property of the task being reran.
176 /// Default: null
177 #[serde(default)]
178 pub use_new_terminal: Option<bool>,
179
180 /// If present, rerun the task with this ID, otherwise rerun the last task.
181 #[serde(skip)]
182 pub task_id: Option<String>,
183}
184
185impl_actions!(task, [Spawn, Rerun]);
186
187pub mod outline {
188 use std::sync::OnceLock;
189
190 use gpui::{action_as, AnyView, App, Window};
191
192 action_as!(outline, ToggleOutline as Toggle);
193 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
194 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
195}
196
197actions!(zed_predict_onboarding, [OpenZedPredictOnboarding]);