1use gpui::{Action, 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, Action)]
15#[action(namespace = zed)]
16#[serde(deny_unknown_fields)]
17pub struct OpenBrowser {
18 pub url: String,
19}
20
21#[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
22#[action(namespace = zed)]
23#[serde(deny_unknown_fields)]
24pub struct OpenZedUrl {
25 pub url: String,
26}
27
28actions!(
29 zed,
30 [
31 OpenSettings,
32 OpenDefaultKeymap,
33 OpenAccountSettings,
34 OpenServerSettings,
35 Quit,
36 OpenKeymap,
37 About,
38 OpenDocs,
39 OpenLicenses,
40 OpenTelemetryLog,
41 ]
42);
43
44#[derive(PartialEq, Clone, Copy, Debug, Deserialize, JsonSchema)]
45#[serde(rename_all = "snake_case")]
46pub enum ExtensionCategoryFilter {
47 Themes,
48 IconThemes,
49 Languages,
50 Grammars,
51 LanguageServers,
52 ContextServers,
53 SlashCommands,
54 IndexedDocsProviders,
55 Snippets,
56 DebugAdapters,
57}
58
59#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
60#[action(namespace = zed)]
61#[serde(deny_unknown_fields)]
62pub struct Extensions {
63 /// Filters the extensions page down to extensions that are in the specified category.
64 #[serde(default)]
65 pub category_filter: Option<ExtensionCategoryFilter>,
66}
67
68#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
69#[action(namespace = zed)]
70#[serde(deny_unknown_fields)]
71pub struct DecreaseBufferFontSize {
72 #[serde(default)]
73 pub persist: bool,
74}
75
76#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
77#[action(namespace = zed)]
78#[serde(deny_unknown_fields)]
79pub struct IncreaseBufferFontSize {
80 #[serde(default)]
81 pub persist: bool,
82}
83
84#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
85#[action(namespace = zed)]
86#[serde(deny_unknown_fields)]
87pub struct ResetBufferFontSize {
88 #[serde(default)]
89 pub persist: bool,
90}
91
92#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
93#[action(namespace = zed)]
94#[serde(deny_unknown_fields)]
95pub struct DecreaseUiFontSize {
96 #[serde(default)]
97 pub persist: bool,
98}
99
100#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
101#[action(namespace = zed)]
102#[serde(deny_unknown_fields)]
103pub struct IncreaseUiFontSize {
104 #[serde(default)]
105 pub persist: bool,
106}
107
108#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
109#[action(namespace = zed)]
110#[serde(deny_unknown_fields)]
111pub struct ResetUiFontSize {
112 #[serde(default)]
113 pub persist: bool,
114}
115
116pub mod dev {
117 use gpui::actions;
118
119 actions!(dev, [ToggleInspector]);
120}
121
122pub mod workspace {
123 use gpui::actions;
124
125 actions!(
126 workspace,
127 [
128 #[action(deprecated_aliases = ["editor::CopyPath", "outline_panel::CopyPath", "project_panel::CopyPath"])]
129 CopyPath,
130 #[action(deprecated_aliases = ["editor::CopyRelativePath", "outline_panel::CopyRelativePath", "project_panel::CopyRelativePath"])]
131 CopyRelativePath
132 ]
133 );
134}
135
136pub mod git {
137 use gpui::actions;
138
139 actions!(
140 git,
141 [
142 CheckoutBranch,
143 Switch,
144 SelectRepo,
145 #[action(deprecated_aliases = ["branches::OpenRecent"])]
146 Branch
147 ]
148 );
149}
150
151pub mod jj {
152 use gpui::actions;
153
154 actions!(jj, [BookmarkList]);
155}
156
157pub mod toast {
158 use gpui::actions;
159
160 actions!(toast, [RunAction]);
161}
162
163pub mod command_palette {
164 use gpui::actions;
165
166 actions!(command_palette, [Toggle]);
167}
168
169pub mod feedback {
170 use gpui::actions;
171
172 actions!(feedback, [FileBugReport, GiveFeedback]);
173}
174
175pub mod theme_selector {
176 use gpui::Action;
177 use schemars::JsonSchema;
178 use serde::Deserialize;
179
180 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
181 #[action(namespace = theme_selector)]
182 #[serde(deny_unknown_fields)]
183 pub struct Toggle {
184 /// A list of theme names to filter the theme selector down to.
185 pub themes_filter: Option<Vec<String>>,
186 }
187}
188
189pub mod icon_theme_selector {
190 use gpui::Action;
191 use schemars::JsonSchema;
192 use serde::Deserialize;
193
194 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
195 #[action(namespace = icon_theme_selector)]
196 #[serde(deny_unknown_fields)]
197 pub struct Toggle {
198 /// A list of icon theme names to filter the theme selector down to.
199 pub themes_filter: Option<Vec<String>>,
200 }
201}
202
203pub mod agent {
204 use gpui::actions;
205
206 actions!(
207 agent,
208 [
209 OpenConfiguration,
210 OpenOnboardingModal,
211 ResetOnboarding,
212 Chat
213 ]
214 );
215}
216
217pub mod assistant {
218 use gpui::{Action, actions};
219 use schemars::JsonSchema;
220 use serde::Deserialize;
221 use uuid::Uuid;
222
223 actions!(
224 agent,
225 [
226 #[action(deprecated_aliases = ["assistant::ToggleFocus"])]
227 ToggleFocus
228 ]
229 );
230
231 actions!(assistant, [ShowConfiguration]);
232
233 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
234 #[action(namespace = agent, deprecated_aliases = ["assistant::OpenRulesLibrary", "assistant::DeployPromptLibrary"])]
235 #[serde(deny_unknown_fields)]
236 pub struct OpenRulesLibrary {
237 #[serde(skip)]
238 pub prompt_to_select: Option<Uuid>,
239 }
240
241 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema, Action)]
242 #[action(namespace = assistant)]
243 #[serde(deny_unknown_fields)]
244 pub struct InlineAssist {
245 pub prompt: Option<String>,
246 }
247}
248
249pub mod debugger {
250 use gpui::actions;
251
252 actions!(debugger, [OpenOnboardingModal, ResetOnboarding]);
253}
254
255#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
256#[action(namespace = projects)]
257#[serde(deny_unknown_fields)]
258pub struct OpenRecent {
259 #[serde(default)]
260 pub create_new_window: bool,
261}
262
263#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
264#[action(namespace = projects)]
265#[serde(deny_unknown_fields)]
266pub struct OpenRemote {
267 #[serde(default)]
268 pub from_existing_connection: bool,
269 #[serde(default)]
270 pub create_new_window: bool,
271}
272
273/// Where to spawn the task in the UI.
274#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
275#[serde(rename_all = "snake_case")]
276pub enum RevealTarget {
277 /// In the central pane group, "main" editor area.
278 Center,
279 /// In the terminal dock, "regular" terminal items' place.
280 #[default]
281 Dock,
282}
283
284/// Spawn a task with name or open tasks modal.
285#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema, Action)]
286#[action(namespace = task)]
287#[serde(untagged)]
288pub enum Spawn {
289 /// Spawns a task by the name given.
290 ByName {
291 task_name: String,
292 #[serde(default)]
293 reveal_target: Option<RevealTarget>,
294 },
295 /// Spawns a task by the name given.
296 ByTag {
297 task_tag: String,
298 #[serde(default)]
299 reveal_target: Option<RevealTarget>,
300 },
301 /// Spawns a task via modal's selection.
302 ViaModal {
303 /// Selected task's `reveal_target` property override.
304 #[serde(default)]
305 reveal_target: Option<RevealTarget>,
306 },
307}
308
309impl Spawn {
310 pub fn modal() -> Self {
311 Self::ViaModal {
312 reveal_target: None,
313 }
314 }
315}
316
317/// Rerun the last task.
318#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
319#[action(namespace = task)]
320#[serde(deny_unknown_fields)]
321pub struct Rerun {
322 /// Controls whether the task context is reevaluated prior to execution of a task.
323 /// 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
324 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
325 /// default: false
326 #[serde(default)]
327 pub reevaluate_context: bool,
328 /// Overrides `allow_concurrent_runs` property of the task being reran.
329 /// Default: null
330 #[serde(default)]
331 pub allow_concurrent_runs: Option<bool>,
332 /// Overrides `use_new_terminal` property of the task being reran.
333 /// Default: null
334 #[serde(default)]
335 pub use_new_terminal: Option<bool>,
336
337 /// If present, rerun the task with this ID, otherwise rerun the last task.
338 #[serde(skip)]
339 pub task_id: Option<String>,
340}
341
342pub mod outline {
343 use std::sync::OnceLock;
344
345 use gpui::{AnyView, App, Window, actions};
346
347 actions!(
348 outline,
349 [
350 #[action(name = "Toggle")]
351 ToggleOutline
352 ]
353 );
354 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
355 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
356}
357
358actions!(zed_predict_onboarding, [OpenZedPredictOnboarding]);
359actions!(git_onboarding, [OpenGitIntegrationOnboarding]);
360
361actions!(debug_panel, [ToggleFocus]);
362actions!(
363 debugger,
364 [
365 ToggleEnableBreakpoint,
366 UnsetBreakpoint,
367 OpenProjectDebugTasks,
368 ]
369);