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
30/// Opens the keymap to either add a keybinding or change an existing one
31#[derive(PartialEq, Clone, Default, Action, JsonSchema, Serialize, Deserialize)]
32#[action(namespace = zed, no_json, no_register)]
33pub struct ChangeKeybinding {
34 pub action: String,
35}
36
37actions!(
38 zed,
39 [
40 /// Opens the settings editor.
41 #[action(deprecated_aliases = ["zed_actions::OpenSettingsEditor"])]
42 OpenSettings,
43 /// Opens the settings JSON file.
44 #[action(deprecated_aliases = ["zed_actions::OpenSettings"])]
45 OpenSettingsFile,
46 /// Opens project-specific settings.
47 #[action(deprecated_aliases = ["zed_actions::OpenProjectSettings"])]
48 OpenProjectSettings,
49 /// Opens the default keymap file.
50 OpenDefaultKeymap,
51 /// Opens the user keymap file.
52 #[action(deprecated_aliases = ["zed_actions::OpenKeymap"])]
53 OpenKeymapFile,
54 /// Opens the keymap editor.
55 #[action(deprecated_aliases = ["zed_actions::OpenKeymapEditor"])]
56 OpenKeymap,
57 /// Opens account settings.
58 OpenAccountSettings,
59 /// Opens server settings.
60 OpenServerSettings,
61 /// Quits the application.
62 Quit,
63 /// Shows information about Zed.
64 About,
65 /// Opens the documentation website.
66 OpenDocs,
67 /// Views open source licenses.
68 OpenLicenses,
69 /// Opens the telemetry log.
70 OpenTelemetryLog,
71 /// Opens the performance profiler.
72 OpenPerformanceProfiler,
73 /// Opens the onboarding view.
74 OpenOnboarding,
75 ]
76);
77
78#[derive(PartialEq, Clone, Copy, Debug, Deserialize, JsonSchema)]
79#[serde(rename_all = "snake_case")]
80pub enum ExtensionCategoryFilter {
81 Themes,
82 IconThemes,
83 Languages,
84 Grammars,
85 LanguageServers,
86 ContextServers,
87 AgentServers,
88 SlashCommands,
89 IndexedDocsProviders,
90 Snippets,
91 DebugAdapters,
92}
93
94/// Opens the extensions management interface.
95#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
96#[action(namespace = zed)]
97#[serde(deny_unknown_fields)]
98pub struct Extensions {
99 /// Filters the extensions page down to extensions that are in the specified category.
100 #[serde(default)]
101 pub category_filter: Option<ExtensionCategoryFilter>,
102 /// Focuses just the extension with the specified ID.
103 #[serde(default)]
104 pub id: Option<String>,
105}
106
107/// Opens the ACP registry.
108#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
109#[action(namespace = zed)]
110#[serde(deny_unknown_fields)]
111pub struct AcpRegistry;
112
113/// Decreases the font size in the editor buffer.
114#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
115#[action(namespace = zed)]
116#[serde(deny_unknown_fields)]
117pub struct DecreaseBufferFontSize {
118 #[serde(default)]
119 pub persist: bool,
120}
121
122/// Increases the font size in the editor buffer.
123#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
124#[action(namespace = zed)]
125#[serde(deny_unknown_fields)]
126pub struct IncreaseBufferFontSize {
127 #[serde(default)]
128 pub persist: bool,
129}
130
131/// Opens the settings editor at a specific path.
132#[derive(PartialEq, Clone, Debug, Deserialize, JsonSchema, Action)]
133#[action(namespace = zed)]
134#[serde(deny_unknown_fields)]
135pub struct OpenSettingsAt {
136 /// A path to a specific setting (e.g. `theme.mode`)
137 pub path: String,
138}
139
140/// Resets the buffer font size to the default value.
141#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
142#[action(namespace = zed)]
143#[serde(deny_unknown_fields)]
144pub struct ResetBufferFontSize {
145 #[serde(default)]
146 pub persist: bool,
147}
148
149/// Decreases the font size of the user interface.
150#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
151#[action(namespace = zed)]
152#[serde(deny_unknown_fields)]
153pub struct DecreaseUiFontSize {
154 #[serde(default)]
155 pub persist: bool,
156}
157
158/// Increases the font size of the user interface.
159#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
160#[action(namespace = zed)]
161#[serde(deny_unknown_fields)]
162pub struct IncreaseUiFontSize {
163 #[serde(default)]
164 pub persist: bool,
165}
166
167/// Resets the UI font size to the default value.
168#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
169#[action(namespace = zed)]
170#[serde(deny_unknown_fields)]
171pub struct ResetUiFontSize {
172 #[serde(default)]
173 pub persist: bool,
174}
175
176/// Resets all zoom levels (UI and buffer font sizes, including in the agent panel) to their default values.
177#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
178#[action(namespace = zed)]
179#[serde(deny_unknown_fields)]
180pub struct ResetAllZoom {
181 #[serde(default)]
182 pub persist: bool,
183}
184
185pub mod editor {
186 use gpui::actions;
187 actions!(
188 editor,
189 [
190 /// Moves cursor up.
191 MoveUp,
192 /// Moves cursor down.
193 MoveDown,
194 ]
195 );
196}
197
198pub mod dev {
199 use gpui::actions;
200
201 actions!(
202 dev,
203 [
204 /// Toggles the developer inspector for debugging UI elements.
205 ToggleInspector
206 ]
207 );
208}
209
210pub mod remote_debug {
211 use gpui::actions;
212
213 actions!(
214 remote_debug,
215 [
216 /// Simulates a disconnection from the remote server for testing purposes.
217 /// This will trigger the reconnection logic.
218 SimulateDisconnect,
219 /// Simulates a timeout/slow connection to the remote server for testing purposes.
220 /// This will cause heartbeat failures and trigger reconnection.
221 SimulateTimeout,
222 /// Simulates a timeout/slow connection to the remote server for testing purposes.
223 /// This will cause heartbeat failures and attempting a reconnection while having exhausted all attempts.
224 SimulateTimeoutExhausted,
225 ]
226 );
227}
228
229pub mod workspace {
230 use gpui::actions;
231
232 actions!(
233 workspace,
234 [
235 #[action(deprecated_aliases = ["editor::CopyPath", "outline_panel::CopyPath", "project_panel::CopyPath"])]
236 CopyPath,
237 #[action(deprecated_aliases = ["editor::CopyRelativePath", "outline_panel::CopyRelativePath", "project_panel::CopyRelativePath"])]
238 CopyRelativePath,
239 /// Opens the selected file with the system's default application.
240 #[action(deprecated_aliases = ["project_panel::OpenWithSystem"])]
241 OpenWithSystem,
242 ]
243 );
244}
245
246pub mod git {
247 use gpui::actions;
248
249 actions!(
250 git,
251 [
252 /// Checks out a different git branch.
253 CheckoutBranch,
254 /// Switches to a different git branch.
255 Switch,
256 /// Selects a different repository.
257 SelectRepo,
258 /// Filter remotes.
259 FilterRemotes,
260 /// Create a git remote.
261 CreateRemote,
262 /// Opens the git branch selector.
263 #[action(deprecated_aliases = ["branches::OpenRecent"])]
264 Branch,
265 /// Opens the git stash selector.
266 ViewStash,
267 /// Opens the git worktree selector.
268 Worktree,
269 /// Creates a pull request for the current branch.
270 CreatePullRequest
271 ]
272 );
273}
274
275pub mod toast {
276 use gpui::actions;
277
278 actions!(
279 toast,
280 [
281 /// Runs the action associated with a toast notification.
282 RunAction
283 ]
284 );
285}
286
287pub mod command_palette {
288 use gpui::actions;
289
290 actions!(
291 command_palette,
292 [
293 /// Toggles the command palette.
294 Toggle,
295 ]
296 );
297}
298
299pub mod project_panel {
300 use gpui::actions;
301
302 actions!(
303 project_panel,
304 [
305 /// Toggles focus on the project panel.
306 ToggleFocus
307 ]
308 );
309}
310pub mod feedback {
311 use gpui::actions;
312
313 actions!(
314 feedback,
315 [
316 /// Opens email client to send feedback to Zed support.
317 EmailZed,
318 /// Opens the bug report form.
319 FileBugReport,
320 /// Opens the feature request form.
321 RequestFeature
322 ]
323 );
324}
325
326pub mod theme_selector {
327 use gpui::Action;
328 use schemars::JsonSchema;
329 use serde::Deserialize;
330
331 /// Toggles the theme selector interface.
332 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
333 #[action(namespace = theme_selector)]
334 #[serde(deny_unknown_fields)]
335 pub struct Toggle {
336 /// A list of theme names to filter the theme selector down to.
337 pub themes_filter: Option<Vec<String>>,
338 }
339}
340
341pub mod icon_theme_selector {
342 use gpui::Action;
343 use schemars::JsonSchema;
344 use serde::Deserialize;
345
346 /// Toggles the icon theme selector interface.
347 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
348 #[action(namespace = icon_theme_selector)]
349 #[serde(deny_unknown_fields)]
350 pub struct Toggle {
351 /// A list of icon theme names to filter the theme selector down to.
352 pub themes_filter: Option<Vec<String>>,
353 }
354}
355
356pub mod search {
357 use gpui::actions;
358 actions!(
359 search,
360 [
361 /// Toggles searching in ignored files.
362 ToggleIncludeIgnored
363 ]
364 );
365}
366pub mod buffer_search {
367 use gpui::{Action, actions};
368 use schemars::JsonSchema;
369 use serde::Deserialize;
370
371 /// Opens the buffer search interface with the specified configuration.
372 #[derive(PartialEq, Clone, Deserialize, JsonSchema, Action)]
373 #[action(namespace = buffer_search)]
374 #[serde(deny_unknown_fields)]
375 pub struct Deploy {
376 #[serde(default = "util::serde::default_true")]
377 pub focus: bool,
378 #[serde(default)]
379 pub replace_enabled: bool,
380 #[serde(default)]
381 pub selection_search_enabled: bool,
382 }
383
384 impl Deploy {
385 pub fn find() -> Self {
386 Self {
387 focus: true,
388 replace_enabled: false,
389 selection_search_enabled: false,
390 }
391 }
392
393 pub fn replace() -> Self {
394 Self {
395 focus: true,
396 replace_enabled: true,
397 selection_search_enabled: false,
398 }
399 }
400 }
401
402 actions!(
403 buffer_search,
404 [
405 /// Deploys the search and replace interface.
406 DeployReplace,
407 /// Dismisses the search bar.
408 Dismiss,
409 /// Focuses back on the editor.
410 FocusEditor
411 ]
412 );
413}
414pub mod settings_profile_selector {
415 use gpui::Action;
416 use schemars::JsonSchema;
417 use serde::Deserialize;
418
419 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
420 #[action(namespace = settings_profile_selector)]
421 pub struct Toggle;
422}
423
424pub mod agent {
425 use gpui::actions;
426
427 actions!(
428 agent,
429 [
430 /// Opens the agent settings panel.
431 #[action(deprecated_aliases = ["agent::OpenConfiguration"])]
432 OpenSettings,
433 /// Opens the agent onboarding modal.
434 OpenOnboardingModal,
435 /// Opens the ACP onboarding modal.
436 OpenAcpOnboardingModal,
437 /// Opens the Claude Code onboarding modal.
438 OpenClaudeCodeOnboardingModal,
439 /// Resets the agent onboarding state.
440 ResetOnboarding,
441 /// Starts a chat conversation with the agent.
442 Chat,
443 /// Toggles the language model selector dropdown.
444 #[action(deprecated_aliases = ["assistant::ToggleModelSelector", "assistant2::ToggleModelSelector"])]
445 ToggleModelSelector,
446 /// Triggers re-authentication on Gemini
447 ReauthenticateAgent,
448 /// Add the current selection as context for threads in the agent panel.
449 #[action(deprecated_aliases = ["assistant::QuoteSelection", "agent::QuoteSelection"])]
450 AddSelectionToThread,
451 /// Resets the agent panel zoom levels (agent UI and buffer font sizes).
452 ResetAgentZoom,
453 /// Pastes clipboard content without any formatting.
454 PasteRaw,
455 ]
456 );
457}
458
459pub mod assistant {
460 use gpui::{Action, actions};
461 use schemars::JsonSchema;
462 use serde::Deserialize;
463 use uuid::Uuid;
464
465 actions!(
466 agent,
467 [
468 #[action(deprecated_aliases = ["assistant::ToggleFocus"])]
469 ToggleFocus
470 ]
471 );
472
473 actions!(
474 assistant,
475 [
476 /// Shows the assistant configuration panel.
477 ShowConfiguration
478 ]
479 );
480
481 /// Opens the rules library for managing agent rules and prompts.
482 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
483 #[action(namespace = agent, deprecated_aliases = ["assistant::OpenRulesLibrary", "assistant::DeployPromptLibrary"])]
484 #[serde(deny_unknown_fields)]
485 pub struct OpenRulesLibrary {
486 #[serde(skip)]
487 pub prompt_to_select: Option<Uuid>,
488 }
489
490 /// Deploys the assistant interface with the specified configuration.
491 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema, Action)]
492 #[action(namespace = assistant)]
493 #[serde(deny_unknown_fields)]
494 pub struct InlineAssist {
495 pub prompt: Option<String>,
496 }
497}
498
499pub mod debugger {
500 use gpui::actions;
501
502 actions!(
503 debugger,
504 [
505 /// Opens the debugger onboarding modal.
506 OpenOnboardingModal,
507 /// Resets the debugger onboarding state.
508 ResetOnboarding
509 ]
510 );
511}
512
513/// Opens the recent projects interface.
514#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
515#[action(namespace = projects)]
516#[serde(deny_unknown_fields)]
517pub struct OpenRecent {
518 #[serde(default)]
519 pub create_new_window: bool,
520}
521
522/// Creates a project from a selected template.
523#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
524#[action(namespace = projects)]
525#[serde(deny_unknown_fields)]
526pub struct OpenRemote {
527 #[serde(default)]
528 pub from_existing_connection: bool,
529 #[serde(default)]
530 pub create_new_window: bool,
531}
532
533/// Opens the dev container connection modal.
534#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
535#[action(namespace = projects)]
536#[serde(deny_unknown_fields)]
537pub struct OpenDevContainer;
538
539/// Where to spawn the task in the UI.
540#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
541#[serde(rename_all = "snake_case")]
542pub enum RevealTarget {
543 /// In the central pane group, "main" editor area.
544 Center,
545 /// In the terminal dock, "regular" terminal items' place.
546 #[default]
547 Dock,
548}
549
550/// Spawns a task with name or opens tasks modal.
551#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema, Action)]
552#[action(namespace = task)]
553#[serde(untagged)]
554pub enum Spawn {
555 /// Spawns a task by the name given.
556 ByName {
557 task_name: String,
558 #[serde(default)]
559 reveal_target: Option<RevealTarget>,
560 },
561 /// Spawns a task by the tag given.
562 ByTag {
563 task_tag: String,
564 #[serde(default)]
565 reveal_target: Option<RevealTarget>,
566 },
567 /// Spawns a task via modal's selection.
568 ViaModal {
569 /// Selected task's `reveal_target` property override.
570 #[serde(default)]
571 reveal_target: Option<RevealTarget>,
572 },
573}
574
575impl Spawn {
576 pub fn modal() -> Self {
577 Self::ViaModal {
578 reveal_target: None,
579 }
580 }
581}
582
583/// Reruns the last task.
584#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
585#[action(namespace = task)]
586#[serde(deny_unknown_fields)]
587pub struct Rerun {
588 /// Controls whether the task context is reevaluated prior to execution of a task.
589 /// 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
590 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
591 /// default: false
592 #[serde(default)]
593 pub reevaluate_context: bool,
594 /// Overrides `allow_concurrent_runs` property of the task being reran.
595 /// Default: null
596 #[serde(default)]
597 pub allow_concurrent_runs: Option<bool>,
598 /// Overrides `use_new_terminal` property of the task being reran.
599 /// Default: null
600 #[serde(default)]
601 pub use_new_terminal: Option<bool>,
602
603 /// If present, rerun the task with this ID, otherwise rerun the last task.
604 #[serde(skip)]
605 pub task_id: Option<String>,
606}
607
608pub mod outline {
609 use std::sync::OnceLock;
610
611 use gpui::{AnyView, App, Window, actions};
612
613 actions!(
614 outline,
615 [
616 #[action(name = "Toggle")]
617 ToggleOutline
618 ]
619 );
620 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
621 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
622}
623
624actions!(
625 zed_predict_onboarding,
626 [
627 /// Opens the Zed Predict onboarding modal.
628 OpenZedPredictOnboarding
629 ]
630);
631actions!(
632 git_onboarding,
633 [
634 /// Opens the git integration onboarding modal.
635 OpenGitIntegrationOnboarding
636 ]
637);
638
639actions!(
640 debug_panel,
641 [
642 /// Toggles focus on the debug panel.
643 ToggleFocus
644 ]
645);
646actions!(
647 debugger,
648 [
649 /// Toggles the enabled state of a breakpoint.
650 ToggleEnableBreakpoint,
651 /// Removes a breakpoint.
652 UnsetBreakpoint,
653 /// Opens the project debug tasks configuration.
654 OpenProjectDebugTasks,
655 ]
656);
657
658pub mod vim {
659 use gpui::actions;
660
661 actions!(
662 vim,
663 [
664 /// Opens the default keymap file.
665 OpenDefaultKeymap
666 ]
667 );
668}
669
670#[derive(Debug, Clone, PartialEq, Eq, Hash)]
671pub struct WslConnectionOptions {
672 pub distro_name: String,
673 pub user: Option<String>,
674}
675
676#[cfg(target_os = "windows")]
677pub mod wsl_actions {
678 use gpui::Action;
679 use schemars::JsonSchema;
680 use serde::Deserialize;
681
682 /// Opens a folder inside Wsl.
683 #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
684 #[action(namespace = projects)]
685 #[serde(deny_unknown_fields)]
686 pub struct OpenFolderInWsl {
687 #[serde(default)]
688 pub create_new_window: bool,
689 }
690
691 /// Open a wsl distro.
692 #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
693 #[action(namespace = projects)]
694 #[serde(deny_unknown_fields)]
695 pub struct OpenWsl {
696 #[serde(default)]
697 pub create_new_window: bool,
698 }
699}
700
701pub mod preview {
702 pub mod markdown {
703 use gpui::actions;
704
705 actions!(
706 markdown,
707 [
708 /// Opens a markdown preview for the current file.
709 OpenPreview,
710 /// Opens a markdown preview in a split pane.
711 OpenPreviewToTheSide,
712 ]
713 );
714 }
715
716 pub mod svg {
717 use gpui::actions;
718
719 actions!(
720 svg,
721 [
722 /// Opens an SVG preview for the current file.
723 OpenPreview,
724 /// Opens an SVG preview in a split pane.
725 OpenPreviewToTheSide,
726 ]
727 );
728 }
729}