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/// Opens a URL in the system's default web browser.
15#[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
16#[action(namespace = zed)]
17#[serde(deny_unknown_fields)]
18pub struct OpenBrowser {
19 pub url: String,
20}
21
22/// Opens a zed:// URL within the application.
23#[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
24#[action(namespace = zed)]
25#[serde(deny_unknown_fields)]
26pub struct OpenZedUrl {
27 pub url: String,
28}
29
30actions!(
31 zed,
32 [
33 /// Opens the settings editor.
34 OpenSettings,
35 /// Opens the default keymap file.
36 OpenDefaultKeymap,
37 /// Opens account settings.
38 OpenAccountSettings,
39 /// Opens server settings.
40 OpenServerSettings,
41 /// Quits the application.
42 Quit,
43 /// Opens the user keymap file.
44 OpenKeymap,
45 /// Shows information about Zed.
46 About,
47 /// Opens the documentation website.
48 OpenDocs,
49 /// Views open source licenses.
50 OpenLicenses,
51 /// Opens the telemetry log.
52 OpenTelemetryLog,
53 ]
54);
55
56#[derive(PartialEq, Clone, Copy, Debug, Deserialize, JsonSchema)]
57#[serde(rename_all = "snake_case")]
58pub enum ExtensionCategoryFilter {
59 Themes,
60 IconThemes,
61 Languages,
62 Grammars,
63 LanguageServers,
64 ContextServers,
65 SlashCommands,
66 IndexedDocsProviders,
67 Snippets,
68 DebugAdapters,
69}
70
71/// Opens the extensions management interface.
72#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
73#[action(namespace = zed)]
74#[serde(deny_unknown_fields)]
75pub struct Extensions {
76 /// Filters the extensions page down to extensions that are in the specified category.
77 #[serde(default)]
78 pub category_filter: Option<ExtensionCategoryFilter>,
79}
80
81/// Decreases the font size in the editor buffer.
82#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
83#[action(namespace = zed)]
84#[serde(deny_unknown_fields)]
85pub struct DecreaseBufferFontSize {
86 #[serde(default)]
87 pub persist: bool,
88}
89
90/// Increases the font size in the editor buffer.
91#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
92#[action(namespace = zed)]
93#[serde(deny_unknown_fields)]
94pub struct IncreaseBufferFontSize {
95 #[serde(default)]
96 pub persist: bool,
97}
98
99/// Resets the buffer font size to the default value.
100#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
101#[action(namespace = zed)]
102#[serde(deny_unknown_fields)]
103pub struct ResetBufferFontSize {
104 #[serde(default)]
105 pub persist: bool,
106}
107
108/// Decreases the font size of the user interface.
109#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
110#[action(namespace = zed)]
111#[serde(deny_unknown_fields)]
112pub struct DecreaseUiFontSize {
113 #[serde(default)]
114 pub persist: bool,
115}
116
117/// Increases the font size of the user interface.
118#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
119#[action(namespace = zed)]
120#[serde(deny_unknown_fields)]
121pub struct IncreaseUiFontSize {
122 #[serde(default)]
123 pub persist: bool,
124}
125
126/// Resets the UI font size to the default value.
127#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
128#[action(namespace = zed)]
129#[serde(deny_unknown_fields)]
130pub struct ResetUiFontSize {
131 #[serde(default)]
132 pub persist: bool,
133}
134
135pub mod dev {
136 use gpui::actions;
137
138 actions!(
139 dev,
140 [
141 /// Toggles the developer inspector for debugging UI elements.
142 ToggleInspector
143 ]
144 );
145}
146
147pub mod workspace {
148 use gpui::actions;
149
150 actions!(
151 workspace,
152 [
153 #[action(deprecated_aliases = ["editor::CopyPath", "outline_panel::CopyPath", "project_panel::CopyPath"])]
154 CopyPath,
155 #[action(deprecated_aliases = ["editor::CopyRelativePath", "outline_panel::CopyRelativePath", "project_panel::CopyRelativePath"])]
156 CopyRelativePath
157 ]
158 );
159}
160
161pub mod git {
162 use gpui::actions;
163
164 actions!(
165 git,
166 [
167 /// Checks out a different git branch.
168 CheckoutBranch,
169 /// Switches to a different git branch.
170 Switch,
171 /// Selects a different repository.
172 SelectRepo,
173 /// Opens the git branch selector.
174 #[action(deprecated_aliases = ["branches::OpenRecent"])]
175 Branch
176 ]
177 );
178}
179
180pub mod jj {
181 use gpui::actions;
182
183 actions!(
184 jj,
185 [
186 /// Opens the Jujutsu bookmark list.
187 BookmarkList
188 ]
189 );
190}
191
192pub mod toast {
193 use gpui::actions;
194
195 actions!(
196 toast,
197 [
198 /// Runs the action associated with a toast notification.
199 RunAction
200 ]
201 );
202}
203
204pub mod command_palette {
205 use gpui::actions;
206
207 actions!(
208 command_palette,
209 [
210 /// Toggles the command palette.
211 Toggle
212 ]
213 );
214}
215
216pub mod feedback {
217 use gpui::actions;
218
219 actions!(
220 feedback,
221 [
222 /// Opens the bug report form.
223 FileBugReport,
224 /// Opens the feedback form.
225 GiveFeedback
226 ]
227 );
228}
229
230pub mod theme_selector {
231 use gpui::Action;
232 use schemars::JsonSchema;
233 use serde::Deserialize;
234
235 /// Toggles the theme selector interface.
236 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
237 #[action(namespace = theme_selector)]
238 #[serde(deny_unknown_fields)]
239 pub struct Toggle {
240 /// A list of theme names to filter the theme selector down to.
241 pub themes_filter: Option<Vec<String>>,
242 }
243}
244
245pub mod icon_theme_selector {
246 use gpui::Action;
247 use schemars::JsonSchema;
248 use serde::Deserialize;
249
250 /// Toggles the icon theme selector interface.
251 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
252 #[action(namespace = icon_theme_selector)]
253 #[serde(deny_unknown_fields)]
254 pub struct Toggle {
255 /// A list of icon theme names to filter the theme selector down to.
256 pub themes_filter: Option<Vec<String>>,
257 }
258}
259
260pub mod agent {
261 use gpui::actions;
262
263 actions!(
264 agent,
265 [
266 /// Opens the agent configuration panel.
267 OpenConfiguration,
268 /// Opens the agent onboarding modal.
269 OpenOnboardingModal,
270 /// Resets the agent onboarding state.
271 ResetOnboarding
272 ]
273 );
274}
275
276pub mod assistant {
277 use gpui::{Action, actions};
278 use schemars::JsonSchema;
279 use serde::Deserialize;
280 use uuid::Uuid;
281
282 actions!(
283 agent,
284 [
285 #[action(deprecated_aliases = ["assistant::ToggleFocus"])]
286 ToggleFocus
287 ]
288 );
289
290 actions!(
291 assistant,
292 [
293 /// Shows the assistant configuration panel.
294 ShowConfiguration
295 ]
296 );
297
298 /// Opens the rules library for managing agent rules and prompts.
299 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
300 #[action(namespace = agent, deprecated_aliases = ["assistant::OpenRulesLibrary", "assistant::DeployPromptLibrary"])]
301 #[serde(deny_unknown_fields)]
302 pub struct OpenRulesLibrary {
303 #[serde(skip)]
304 pub prompt_to_select: Option<Uuid>,
305 }
306
307 /// Deploys the assistant interface with the specified configuration.
308 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema, Action)]
309 #[action(namespace = assistant)]
310 #[serde(deny_unknown_fields)]
311 pub struct InlineAssist {
312 pub prompt: Option<String>,
313 }
314}
315
316pub mod debugger {
317 use gpui::actions;
318
319 actions!(
320 debugger,
321 [
322 /// Opens the debugger onboarding modal.
323 OpenOnboardingModal,
324 /// Resets the debugger onboarding state.
325 ResetOnboarding
326 ]
327 );
328}
329
330/// Opens the recent projects interface.
331#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
332#[action(namespace = projects)]
333#[serde(deny_unknown_fields)]
334pub struct OpenRecent {
335 #[serde(default)]
336 pub create_new_window: bool,
337}
338
339/// Creates a project from a selected template.
340#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
341#[action(namespace = projects)]
342#[serde(deny_unknown_fields)]
343pub struct OpenRemote {
344 #[serde(default)]
345 pub from_existing_connection: bool,
346 #[serde(default)]
347 pub create_new_window: bool,
348}
349
350/// Where to spawn the task in the UI.
351#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
352#[serde(rename_all = "snake_case")]
353pub enum RevealTarget {
354 /// In the central pane group, "main" editor area.
355 Center,
356 /// In the terminal dock, "regular" terminal items' place.
357 #[default]
358 Dock,
359}
360
361/// Spawns a task with name or opens tasks modal.
362#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema, Action)]
363#[action(namespace = task)]
364#[serde(untagged)]
365pub enum Spawn {
366 /// Spawns a task by the name given.
367 ByName {
368 task_name: String,
369 #[serde(default)]
370 reveal_target: Option<RevealTarget>,
371 },
372 /// Spawns a task by the name given.
373 ByTag {
374 task_tag: String,
375 #[serde(default)]
376 reveal_target: Option<RevealTarget>,
377 },
378 /// Spawns a task via modal's selection.
379 ViaModal {
380 /// Selected task's `reveal_target` property override.
381 #[serde(default)]
382 reveal_target: Option<RevealTarget>,
383 },
384}
385
386impl Spawn {
387 pub fn modal() -> Self {
388 Self::ViaModal {
389 reveal_target: None,
390 }
391 }
392}
393
394/// Reruns the last task.
395#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
396#[action(namespace = task)]
397#[serde(deny_unknown_fields)]
398pub struct Rerun {
399 /// Controls whether the task context is reevaluated prior to execution of a task.
400 /// 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
401 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
402 /// default: false
403 #[serde(default)]
404 pub reevaluate_context: bool,
405 /// Overrides `allow_concurrent_runs` property of the task being reran.
406 /// Default: null
407 #[serde(default)]
408 pub allow_concurrent_runs: Option<bool>,
409 /// Overrides `use_new_terminal` property of the task being reran.
410 /// Default: null
411 #[serde(default)]
412 pub use_new_terminal: Option<bool>,
413
414 /// If present, rerun the task with this ID, otherwise rerun the last task.
415 #[serde(skip)]
416 pub task_id: Option<String>,
417}
418
419pub mod outline {
420 use std::sync::OnceLock;
421
422 use gpui::{AnyView, App, Window, actions};
423
424 actions!(
425 outline,
426 [
427 #[action(name = "Toggle")]
428 ToggleOutline
429 ]
430 );
431 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
432 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
433}
434
435actions!(
436 zed_predict_onboarding,
437 [
438 /// Opens the Zed Predict onboarding modal.
439 OpenZedPredictOnboarding
440 ]
441);
442actions!(
443 git_onboarding,
444 [
445 /// Opens the git integration onboarding modal.
446 OpenGitIntegrationOnboarding
447 ]
448);
449
450actions!(
451 debug_panel,
452 [
453 /// Toggles focus on the debug panel.
454 ToggleFocus
455 ]
456);
457actions!(
458 debugger,
459 [
460 /// Toggles the enabled state of a breakpoint.
461 ToggleEnableBreakpoint,
462 /// Removes a breakpoint.
463 UnsetBreakpoint,
464 /// Opens the project debug tasks configuration.
465 OpenProjectDebugTasks,
466 ]
467);