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/// Show call diagnostics and connection quality statistics.
114#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
115#[action(namespace = collab)]
116#[serde(deny_unknown_fields)]
117pub struct ShowCallStats;
118
119/// Decreases the font size in the editor buffer.
120#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
121#[action(namespace = zed)]
122#[serde(deny_unknown_fields)]
123pub struct DecreaseBufferFontSize {
124 #[serde(default)]
125 pub persist: bool,
126}
127
128/// Increases the font size in the editor buffer.
129#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
130#[action(namespace = zed)]
131#[serde(deny_unknown_fields)]
132pub struct IncreaseBufferFontSize {
133 #[serde(default)]
134 pub persist: bool,
135}
136
137/// Opens the settings editor at a specific path.
138#[derive(PartialEq, Clone, Debug, Deserialize, JsonSchema, Action)]
139#[action(namespace = zed)]
140#[serde(deny_unknown_fields)]
141pub struct OpenSettingsAt {
142 /// A path to a specific setting (e.g. `theme.mode`)
143 pub path: String,
144}
145
146/// Resets the buffer font size to the default value.
147#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
148#[action(namespace = zed)]
149#[serde(deny_unknown_fields)]
150pub struct ResetBufferFontSize {
151 #[serde(default)]
152 pub persist: bool,
153}
154
155/// Decreases the font size of the user interface.
156#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
157#[action(namespace = zed)]
158#[serde(deny_unknown_fields)]
159pub struct DecreaseUiFontSize {
160 #[serde(default)]
161 pub persist: bool,
162}
163
164/// Increases the font size of the user interface.
165#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
166#[action(namespace = zed)]
167#[serde(deny_unknown_fields)]
168pub struct IncreaseUiFontSize {
169 #[serde(default)]
170 pub persist: bool,
171}
172
173/// Resets the UI font size to the default value.
174#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
175#[action(namespace = zed)]
176#[serde(deny_unknown_fields)]
177pub struct ResetUiFontSize {
178 #[serde(default)]
179 pub persist: bool,
180}
181
182/// Resets all zoom levels (UI and buffer font sizes, including in the agent panel) to their default values.
183#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
184#[action(namespace = zed)]
185#[serde(deny_unknown_fields)]
186pub struct ResetAllZoom {
187 #[serde(default)]
188 pub persist: bool,
189}
190
191pub mod editor {
192 use gpui::actions;
193 actions!(
194 editor,
195 [
196 /// Moves cursor up.
197 MoveUp,
198 /// Moves cursor down.
199 MoveDown,
200 ]
201 );
202}
203
204pub mod dev {
205 use gpui::actions;
206
207 actions!(
208 dev,
209 [
210 /// Toggles the developer inspector for debugging UI elements.
211 ToggleInspector
212 ]
213 );
214}
215
216pub mod remote_debug {
217 use gpui::actions;
218
219 actions!(
220 remote_debug,
221 [
222 /// Simulates a disconnection from the remote server for testing purposes.
223 /// This will trigger the reconnection logic.
224 SimulateDisconnect,
225 /// Simulates a timeout/slow connection to the remote server for testing purposes.
226 /// This will cause heartbeat failures and trigger reconnection.
227 SimulateTimeout,
228 /// Simulates a timeout/slow connection to the remote server for testing purposes.
229 /// This will cause heartbeat failures and attempting a reconnection while having exhausted all attempts.
230 SimulateTimeoutExhausted,
231 ]
232 );
233}
234
235pub mod workspace {
236 use gpui::actions;
237
238 actions!(
239 workspace,
240 [
241 #[action(deprecated_aliases = ["editor::CopyPath", "outline_panel::CopyPath", "project_panel::CopyPath"])]
242 CopyPath,
243 #[action(deprecated_aliases = ["editor::CopyRelativePath", "outline_panel::CopyRelativePath", "project_panel::CopyRelativePath"])]
244 CopyRelativePath,
245 /// Opens the selected file with the system's default application.
246 #[action(deprecated_aliases = ["project_panel::OpenWithSystem"])]
247 OpenWithSystem,
248 ]
249 );
250}
251
252pub mod git {
253 use gpui::actions;
254
255 actions!(
256 git,
257 [
258 /// Checks out a different git branch.
259 CheckoutBranch,
260 /// Switches to a different git branch.
261 Switch,
262 /// Selects a different repository.
263 SelectRepo,
264 /// Filter remotes.
265 FilterRemotes,
266 /// Create a git remote.
267 CreateRemote,
268 /// Opens the git branch selector.
269 #[action(deprecated_aliases = ["branches::OpenRecent"])]
270 Branch,
271 /// Opens the git stash selector.
272 ViewStash,
273 /// Opens the git worktree selector.
274 Worktree,
275 /// Creates a pull request for the current branch.
276 CreatePullRequest
277 ]
278 );
279}
280
281pub mod toast {
282 use gpui::actions;
283
284 actions!(
285 toast,
286 [
287 /// Runs the action associated with a toast notification.
288 RunAction
289 ]
290 );
291}
292
293pub mod command_palette {
294 use gpui::actions;
295
296 actions!(
297 command_palette,
298 [
299 /// Toggles the command palette.
300 Toggle,
301 ]
302 );
303}
304
305pub mod project_panel {
306 use gpui::actions;
307
308 actions!(
309 project_panel,
310 [
311 /// Toggles the project panel.
312 Toggle,
313 /// Toggles focus on the project panel.
314 ToggleFocus
315 ]
316 );
317}
318pub mod feedback {
319 use gpui::actions;
320
321 actions!(
322 feedback,
323 [
324 /// Opens email client to send feedback to Zed support.
325 EmailZed,
326 /// Opens the bug report form.
327 FileBugReport,
328 /// Opens the feature request form.
329 RequestFeature
330 ]
331 );
332}
333
334pub mod theme {
335 use gpui::actions;
336
337 actions!(theme, [ToggleMode]);
338}
339
340pub mod theme_selector {
341 use gpui::Action;
342 use schemars::JsonSchema;
343 use serde::Deserialize;
344
345 /// Toggles the theme selector interface.
346 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
347 #[action(namespace = theme_selector)]
348 #[serde(deny_unknown_fields)]
349 pub struct Toggle {
350 /// A list of theme names to filter the theme selector down to.
351 pub themes_filter: Option<Vec<String>>,
352 }
353}
354
355pub mod icon_theme_selector {
356 use gpui::Action;
357 use schemars::JsonSchema;
358 use serde::Deserialize;
359
360 /// Toggles the icon theme selector interface.
361 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
362 #[action(namespace = icon_theme_selector)]
363 #[serde(deny_unknown_fields)]
364 pub struct Toggle {
365 /// A list of icon theme names to filter the theme selector down to.
366 pub themes_filter: Option<Vec<String>>,
367 }
368}
369
370pub mod search {
371 use gpui::actions;
372 actions!(
373 search,
374 [
375 /// Toggles searching in ignored files.
376 ToggleIncludeIgnored
377 ]
378 );
379}
380pub mod buffer_search {
381 use gpui::{Action, actions};
382 use schemars::JsonSchema;
383 use serde::Deserialize;
384
385 /// Opens the buffer search interface with the specified configuration.
386 #[derive(PartialEq, Clone, Deserialize, JsonSchema, Action)]
387 #[action(namespace = buffer_search)]
388 #[serde(deny_unknown_fields)]
389 pub struct Deploy {
390 #[serde(default = "util::serde::default_true")]
391 pub focus: bool,
392 #[serde(default)]
393 pub replace_enabled: bool,
394 #[serde(default)]
395 pub selection_search_enabled: bool,
396 }
397
398 impl Deploy {
399 pub fn find() -> Self {
400 Self {
401 focus: true,
402 replace_enabled: false,
403 selection_search_enabled: false,
404 }
405 }
406
407 pub fn replace() -> Self {
408 Self {
409 focus: true,
410 replace_enabled: true,
411 selection_search_enabled: false,
412 }
413 }
414 }
415
416 actions!(
417 buffer_search,
418 [
419 /// Deploys the search and replace interface.
420 DeployReplace,
421 /// Dismisses the search bar.
422 Dismiss,
423 /// Focuses back on the editor.
424 FocusEditor
425 ]
426 );
427}
428pub mod settings_profile_selector {
429 use gpui::Action;
430 use schemars::JsonSchema;
431 use serde::Deserialize;
432
433 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
434 #[action(namespace = settings_profile_selector)]
435 pub struct Toggle;
436}
437
438pub mod agent {
439 use gpui::{Action, SharedString, actions};
440 use schemars::JsonSchema;
441 use serde::Deserialize;
442
443 actions!(
444 agent,
445 [
446 /// Opens the agent settings panel.
447 #[action(deprecated_aliases = ["agent::OpenConfiguration"])]
448 OpenSettings,
449 /// Opens the agent onboarding modal.
450 OpenOnboardingModal,
451 /// Opens the ACP onboarding modal.
452 OpenAcpOnboardingModal,
453 /// Opens the Claude Agent onboarding modal.
454 OpenClaudeAgentOnboardingModal,
455 /// Resets the agent onboarding state.
456 ResetOnboarding,
457 /// Starts a chat conversation with the agent.
458 Chat,
459 /// Toggles the language model selector dropdown.
460 #[action(deprecated_aliases = ["assistant::ToggleModelSelector", "assistant2::ToggleModelSelector"])]
461 ToggleModelSelector,
462 /// Triggers re-authentication on Gemini
463 ReauthenticateAgent,
464 /// Add the current selection as context for threads in the agent panel.
465 #[action(deprecated_aliases = ["assistant::QuoteSelection", "agent::QuoteSelection"])]
466 AddSelectionToThread,
467 /// Resets the agent panel zoom levels (agent UI and buffer font sizes).
468 ResetAgentZoom,
469 /// Pastes clipboard content without any formatting.
470 PasteRaw,
471 ]
472 );
473
474 /// Opens a new agent thread with the provided branch diff for review.
475 #[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
476 #[action(namespace = agent)]
477 #[serde(deny_unknown_fields)]
478 pub struct ReviewBranchDiff {
479 /// The full text of the diff to review.
480 pub diff_text: SharedString,
481 /// The base ref that the diff was computed against (e.g. "main").
482 pub base_ref: SharedString,
483 }
484
485 /// A single merge conflict region extracted from a file.
486 #[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema)]
487 pub struct ConflictContent {
488 pub file_path: String,
489 pub conflict_text: String,
490 pub ours_branch_name: String,
491 pub theirs_branch_name: String,
492 }
493
494 /// Opens a new agent thread to resolve specific merge conflicts.
495 #[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
496 #[action(namespace = agent)]
497 #[serde(deny_unknown_fields)]
498 pub struct ResolveConflictsWithAgent {
499 /// Individual conflicts with their full text.
500 pub conflicts: Vec<ConflictContent>,
501 }
502
503 /// Opens a new agent thread to resolve merge conflicts in the given file paths.
504 #[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
505 #[action(namespace = agent)]
506 #[serde(deny_unknown_fields)]
507 pub struct ResolveConflictedFilesWithAgent {
508 /// File paths with unresolved conflicts (for project-wide resolution).
509 pub conflicted_file_paths: Vec<String>,
510 }
511}
512
513pub mod assistant {
514 use gpui::{Action, actions};
515 use schemars::JsonSchema;
516 use serde::Deserialize;
517 use uuid::Uuid;
518
519 actions!(
520 agent,
521 [
522 /// Toggles the agent panel.
523 Toggle,
524 #[action(deprecated_aliases = ["assistant::ToggleFocus"])]
525 ToggleFocus
526 ]
527 );
528
529 actions!(
530 assistant,
531 [
532 /// Shows the assistant configuration panel.
533 ShowConfiguration
534 ]
535 );
536
537 /// Opens the rules library for managing agent rules and prompts.
538 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
539 #[action(namespace = agent, deprecated_aliases = ["assistant::OpenRulesLibrary", "assistant::DeployPromptLibrary"])]
540 #[serde(deny_unknown_fields)]
541 pub struct OpenRulesLibrary {
542 #[serde(skip)]
543 pub prompt_to_select: Option<Uuid>,
544 }
545
546 /// Deploys the assistant interface with the specified configuration.
547 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema, Action)]
548 #[action(namespace = assistant)]
549 #[serde(deny_unknown_fields)]
550 pub struct InlineAssist {
551 pub prompt: Option<String>,
552 }
553}
554
555/// Opens the recent projects interface.
556#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
557#[action(namespace = projects)]
558#[serde(deny_unknown_fields)]
559pub struct OpenRecent {
560 #[serde(default)]
561 pub create_new_window: bool,
562}
563
564/// Creates a project from a selected template.
565#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
566#[action(namespace = projects)]
567#[serde(deny_unknown_fields)]
568pub struct OpenRemote {
569 #[serde(default)]
570 pub from_existing_connection: bool,
571 #[serde(default)]
572 pub create_new_window: bool,
573}
574
575/// Opens the dev container connection modal.
576#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
577#[action(namespace = projects)]
578#[serde(deny_unknown_fields)]
579pub struct OpenDevContainer;
580
581/// Where to spawn the task in the UI.
582#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
583#[serde(rename_all = "snake_case")]
584pub enum RevealTarget {
585 /// In the central pane group, "main" editor area.
586 Center,
587 /// In the terminal dock, "regular" terminal items' place.
588 #[default]
589 Dock,
590}
591
592/// Spawns a task with name or opens tasks modal.
593#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema, Action)]
594#[action(namespace = task)]
595#[serde(untagged)]
596pub enum Spawn {
597 /// Spawns a task by the name given.
598 ByName {
599 task_name: String,
600 #[serde(default)]
601 reveal_target: Option<RevealTarget>,
602 },
603 /// Spawns a task by the tag given.
604 ByTag {
605 task_tag: String,
606 #[serde(default)]
607 reveal_target: Option<RevealTarget>,
608 },
609 /// Spawns a task via modal's selection.
610 ViaModal {
611 /// Selected task's `reveal_target` property override.
612 #[serde(default)]
613 reveal_target: Option<RevealTarget>,
614 },
615}
616
617impl Spawn {
618 pub fn modal() -> Self {
619 Self::ViaModal {
620 reveal_target: None,
621 }
622 }
623}
624
625/// Reruns the last task.
626#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
627#[action(namespace = task)]
628#[serde(deny_unknown_fields)]
629pub struct Rerun {
630 /// Controls whether the task context is reevaluated prior to execution of a task.
631 /// 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
632 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
633 /// default: false
634 #[serde(default)]
635 pub reevaluate_context: bool,
636 /// Overrides `allow_concurrent_runs` property of the task being reran.
637 /// Default: null
638 #[serde(default)]
639 pub allow_concurrent_runs: Option<bool>,
640 /// Overrides `use_new_terminal` property of the task being reran.
641 /// Default: null
642 #[serde(default)]
643 pub use_new_terminal: Option<bool>,
644
645 /// If present, rerun the task with this ID, otherwise rerun the last task.
646 #[serde(skip)]
647 pub task_id: Option<String>,
648}
649
650pub mod outline {
651 use std::sync::OnceLock;
652
653 use gpui::{AnyView, App, Window, actions};
654
655 actions!(
656 outline,
657 [
658 #[action(name = "Toggle")]
659 ToggleOutline
660 ]
661 );
662 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
663 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
664}
665
666actions!(
667 zed_predict_onboarding,
668 [
669 /// Opens the Zed Predict onboarding modal.
670 OpenZedPredictOnboarding
671 ]
672);
673actions!(
674 git_onboarding,
675 [
676 /// Opens the git integration onboarding modal.
677 OpenGitIntegrationOnboarding
678 ]
679);
680
681pub mod debug_panel {
682 use gpui::actions;
683 actions!(
684 debug_panel,
685 [
686 /// Toggles the debug panel.
687 Toggle,
688 /// Toggles focus on the debug panel.
689 ToggleFocus
690 ]
691 );
692}
693
694actions!(
695 debugger,
696 [
697 /// Toggles the enabled state of a breakpoint.
698 ToggleEnableBreakpoint,
699 /// Removes a breakpoint.
700 UnsetBreakpoint,
701 /// Opens the project debug tasks configuration.
702 OpenProjectDebugTasks,
703 ]
704);
705
706pub mod vim {
707 use gpui::actions;
708
709 actions!(
710 vim,
711 [
712 /// Opens the default keymap file.
713 OpenDefaultKeymap
714 ]
715 );
716}
717
718#[derive(Debug, Clone, PartialEq, Eq, Hash)]
719pub struct WslConnectionOptions {
720 pub distro_name: String,
721 pub user: Option<String>,
722}
723
724#[cfg(target_os = "windows")]
725pub mod wsl_actions {
726 use gpui::Action;
727 use schemars::JsonSchema;
728 use serde::Deserialize;
729
730 /// Opens a folder inside Wsl.
731 #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
732 #[action(namespace = projects)]
733 #[serde(deny_unknown_fields)]
734 pub struct OpenFolderInWsl {
735 #[serde(default)]
736 pub create_new_window: bool,
737 }
738
739 /// Open a wsl distro.
740 #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
741 #[action(namespace = projects)]
742 #[serde(deny_unknown_fields)]
743 pub struct OpenWsl {
744 #[serde(default)]
745 pub create_new_window: bool,
746 }
747}
748
749pub mod preview {
750 pub mod markdown {
751 use gpui::actions;
752
753 actions!(
754 markdown,
755 [
756 /// Opens a markdown preview for the current file.
757 OpenPreview,
758 /// Opens a markdown preview in a split pane.
759 OpenPreviewToTheSide,
760 ]
761 );
762 }
763
764 pub mod svg {
765 use gpui::actions;
766
767 actions!(
768 svg,
769 [
770 /// Opens an SVG preview for the current file.
771 OpenPreview,
772 /// Opens an SVG preview in a split pane.
773 OpenPreviewToTheSide,
774 ]
775 );
776 }
777}
778
779pub mod agents_sidebar {
780 use gpui::actions;
781
782 actions!(
783 agents_sidebar,
784 [
785 /// Moves focus to the sidebar's search/filter editor.
786 FocusSidebarFilter,
787 ]
788 );
789}
790
791pub mod notebook {
792 use gpui::actions;
793
794 actions!(
795 notebook,
796 [
797 /// Move to down in cells
798 NotebookMoveDown,
799 /// Move to up in cells
800 NotebookMoveUp,
801 ]
802 );
803}