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 the project panel.
306 Toggle,
307 /// Toggles focus on the project panel.
308 ToggleFocus
309 ]
310 );
311}
312pub mod feedback {
313 use gpui::actions;
314
315 actions!(
316 feedback,
317 [
318 /// Opens email client to send feedback to Zed support.
319 EmailZed,
320 /// Opens the bug report form.
321 FileBugReport,
322 /// Opens the feature request form.
323 RequestFeature
324 ]
325 );
326}
327
328pub mod theme {
329 use gpui::actions;
330
331 actions!(theme, [ToggleMode]);
332}
333
334pub mod theme_selector {
335 use gpui::Action;
336 use schemars::JsonSchema;
337 use serde::Deserialize;
338
339 /// Toggles the theme selector interface.
340 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
341 #[action(namespace = theme_selector)]
342 #[serde(deny_unknown_fields)]
343 pub struct Toggle {
344 /// A list of theme names to filter the theme selector down to.
345 pub themes_filter: Option<Vec<String>>,
346 }
347}
348
349pub mod icon_theme_selector {
350 use gpui::Action;
351 use schemars::JsonSchema;
352 use serde::Deserialize;
353
354 /// Toggles the icon theme selector interface.
355 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
356 #[action(namespace = icon_theme_selector)]
357 #[serde(deny_unknown_fields)]
358 pub struct Toggle {
359 /// A list of icon theme names to filter the theme selector down to.
360 pub themes_filter: Option<Vec<String>>,
361 }
362}
363
364pub mod search {
365 use gpui::actions;
366 actions!(
367 search,
368 [
369 /// Toggles searching in ignored files.
370 ToggleIncludeIgnored
371 ]
372 );
373}
374pub mod buffer_search {
375 use gpui::{Action, actions};
376 use schemars::JsonSchema;
377 use serde::Deserialize;
378
379 /// Opens the buffer search interface with the specified configuration.
380 #[derive(PartialEq, Clone, Deserialize, JsonSchema, Action)]
381 #[action(namespace = buffer_search)]
382 #[serde(deny_unknown_fields)]
383 pub struct Deploy {
384 #[serde(default = "util::serde::default_true")]
385 pub focus: bool,
386 #[serde(default)]
387 pub replace_enabled: bool,
388 #[serde(default)]
389 pub selection_search_enabled: bool,
390 }
391
392 impl Deploy {
393 pub fn find() -> Self {
394 Self {
395 focus: true,
396 replace_enabled: false,
397 selection_search_enabled: false,
398 }
399 }
400
401 pub fn replace() -> Self {
402 Self {
403 focus: true,
404 replace_enabled: true,
405 selection_search_enabled: false,
406 }
407 }
408 }
409
410 actions!(
411 buffer_search,
412 [
413 /// Deploys the search and replace interface.
414 DeployReplace,
415 /// Dismisses the search bar.
416 Dismiss,
417 /// Focuses back on the editor.
418 FocusEditor
419 ]
420 );
421}
422pub mod settings_profile_selector {
423 use gpui::Action;
424 use schemars::JsonSchema;
425 use serde::Deserialize;
426
427 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
428 #[action(namespace = settings_profile_selector)]
429 pub struct Toggle;
430}
431
432pub mod agent {
433 use gpui::{Action, SharedString, actions};
434 use schemars::JsonSchema;
435 use serde::Deserialize;
436
437 actions!(
438 agent,
439 [
440 /// Opens the agent settings panel.
441 #[action(deprecated_aliases = ["agent::OpenConfiguration"])]
442 OpenSettings,
443 /// Opens the agent onboarding modal.
444 OpenOnboardingModal,
445 /// Opens the ACP onboarding modal.
446 OpenAcpOnboardingModal,
447 /// Opens the Claude Agent onboarding modal.
448 OpenClaudeAgentOnboardingModal,
449 /// Resets the agent onboarding state.
450 ResetOnboarding,
451 /// Starts a chat conversation with the agent.
452 Chat,
453 /// Toggles the language model selector dropdown.
454 #[action(deprecated_aliases = ["assistant::ToggleModelSelector", "assistant2::ToggleModelSelector"])]
455 ToggleModelSelector,
456 /// Triggers re-authentication on Gemini
457 ReauthenticateAgent,
458 /// Add the current selection as context for threads in the agent panel.
459 #[action(deprecated_aliases = ["assistant::QuoteSelection", "agent::QuoteSelection"])]
460 AddSelectionToThread,
461 /// Resets the agent panel zoom levels (agent UI and buffer font sizes).
462 ResetAgentZoom,
463 /// Pastes clipboard content without any formatting.
464 PasteRaw,
465 ]
466 );
467
468 /// Opens a new agent thread with the provided branch diff for review.
469 #[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
470 #[action(namespace = agent)]
471 #[serde(deny_unknown_fields)]
472 pub struct ReviewBranchDiff {
473 /// The full text of the diff to review.
474 pub diff_text: SharedString,
475 /// The base ref that the diff was computed against (e.g. "main").
476 pub base_ref: SharedString,
477 }
478
479 /// A single merge conflict region extracted from a file.
480 #[derive(Clone, Debug, PartialEq, Deserialize, JsonSchema)]
481 pub struct ConflictContent {
482 pub file_path: String,
483 pub conflict_text: String,
484 pub ours_branch_name: String,
485 pub theirs_branch_name: String,
486 }
487
488 /// Opens a new agent thread to resolve specific merge conflicts.
489 #[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
490 #[action(namespace = agent)]
491 #[serde(deny_unknown_fields)]
492 pub struct ResolveConflictsWithAgent {
493 /// Individual conflicts with their full text.
494 pub conflicts: Vec<ConflictContent>,
495 }
496
497 /// Opens a new agent thread to resolve merge conflicts in the given file paths.
498 #[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
499 #[action(namespace = agent)]
500 #[serde(deny_unknown_fields)]
501 pub struct ResolveConflictedFilesWithAgent {
502 /// File paths with unresolved conflicts (for project-wide resolution).
503 pub conflicted_file_paths: Vec<String>,
504 }
505}
506
507pub mod assistant {
508 use gpui::{Action, actions};
509 use schemars::JsonSchema;
510 use serde::Deserialize;
511 use uuid::Uuid;
512
513 actions!(
514 agent,
515 [
516 /// Toggles the agent panel.
517 Toggle,
518 #[action(deprecated_aliases = ["assistant::ToggleFocus"])]
519 ToggleFocus
520 ]
521 );
522
523 actions!(
524 assistant,
525 [
526 /// Shows the assistant configuration panel.
527 ShowConfiguration
528 ]
529 );
530
531 /// Opens the rules library for managing agent rules and prompts.
532 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
533 #[action(namespace = agent, deprecated_aliases = ["assistant::OpenRulesLibrary", "assistant::DeployPromptLibrary"])]
534 #[serde(deny_unknown_fields)]
535 pub struct OpenRulesLibrary {
536 #[serde(skip)]
537 pub prompt_to_select: Option<Uuid>,
538 }
539
540 /// Deploys the assistant interface with the specified configuration.
541 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema, Action)]
542 #[action(namespace = assistant)]
543 #[serde(deny_unknown_fields)]
544 pub struct InlineAssist {
545 pub prompt: Option<String>,
546 }
547}
548
549/// Opens the recent projects interface.
550#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
551#[action(namespace = projects)]
552#[serde(deny_unknown_fields)]
553pub struct OpenRecent {
554 #[serde(default)]
555 pub create_new_window: bool,
556}
557
558/// Creates a project from a selected template.
559#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
560#[action(namespace = projects)]
561#[serde(deny_unknown_fields)]
562pub struct OpenRemote {
563 #[serde(default)]
564 pub from_existing_connection: bool,
565 #[serde(default)]
566 pub create_new_window: bool,
567}
568
569/// Opens the dev container connection modal.
570#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
571#[action(namespace = projects)]
572#[serde(deny_unknown_fields)]
573pub struct OpenDevContainer;
574
575/// Where to spawn the task in the UI.
576#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
577#[serde(rename_all = "snake_case")]
578pub enum RevealTarget {
579 /// In the central pane group, "main" editor area.
580 Center,
581 /// In the terminal dock, "regular" terminal items' place.
582 #[default]
583 Dock,
584}
585
586/// Spawns a task with name or opens tasks modal.
587#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema, Action)]
588#[action(namespace = task)]
589#[serde(untagged)]
590pub enum Spawn {
591 /// Spawns a task by the name given.
592 ByName {
593 task_name: String,
594 #[serde(default)]
595 reveal_target: Option<RevealTarget>,
596 },
597 /// Spawns a task by the tag given.
598 ByTag {
599 task_tag: String,
600 #[serde(default)]
601 reveal_target: Option<RevealTarget>,
602 },
603 /// Spawns a task via modal's selection.
604 ViaModal {
605 /// Selected task's `reveal_target` property override.
606 #[serde(default)]
607 reveal_target: Option<RevealTarget>,
608 },
609}
610
611impl Spawn {
612 pub fn modal() -> Self {
613 Self::ViaModal {
614 reveal_target: None,
615 }
616 }
617}
618
619/// Reruns the last task.
620#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
621#[action(namespace = task)]
622#[serde(deny_unknown_fields)]
623pub struct Rerun {
624 /// Controls whether the task context is reevaluated prior to execution of a task.
625 /// 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
626 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
627 /// default: false
628 #[serde(default)]
629 pub reevaluate_context: bool,
630 /// Overrides `allow_concurrent_runs` property of the task being reran.
631 /// Default: null
632 #[serde(default)]
633 pub allow_concurrent_runs: Option<bool>,
634 /// Overrides `use_new_terminal` property of the task being reran.
635 /// Default: null
636 #[serde(default)]
637 pub use_new_terminal: Option<bool>,
638
639 /// If present, rerun the task with this ID, otherwise rerun the last task.
640 #[serde(skip)]
641 pub task_id: Option<String>,
642}
643
644pub mod outline {
645 use std::sync::OnceLock;
646
647 use gpui::{AnyView, App, Window, actions};
648
649 actions!(
650 outline,
651 [
652 #[action(name = "Toggle")]
653 ToggleOutline
654 ]
655 );
656 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
657 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
658}
659
660actions!(
661 zed_predict_onboarding,
662 [
663 /// Opens the Zed Predict onboarding modal.
664 OpenZedPredictOnboarding
665 ]
666);
667actions!(
668 git_onboarding,
669 [
670 /// Opens the git integration onboarding modal.
671 OpenGitIntegrationOnboarding
672 ]
673);
674
675pub mod debug_panel {
676 use gpui::actions;
677 actions!(
678 debug_panel,
679 [
680 /// Toggles the debug panel.
681 Toggle,
682 /// Toggles focus on the debug panel.
683 ToggleFocus
684 ]
685 );
686}
687
688actions!(
689 debugger,
690 [
691 /// Toggles the enabled state of a breakpoint.
692 ToggleEnableBreakpoint,
693 /// Removes a breakpoint.
694 UnsetBreakpoint,
695 /// Opens the project debug tasks configuration.
696 OpenProjectDebugTasks,
697 ]
698);
699
700pub mod vim {
701 use gpui::actions;
702
703 actions!(
704 vim,
705 [
706 /// Opens the default keymap file.
707 OpenDefaultKeymap
708 ]
709 );
710}
711
712#[derive(Debug, Clone, PartialEq, Eq, Hash)]
713pub struct WslConnectionOptions {
714 pub distro_name: String,
715 pub user: Option<String>,
716}
717
718#[cfg(target_os = "windows")]
719pub mod wsl_actions {
720 use gpui::Action;
721 use schemars::JsonSchema;
722 use serde::Deserialize;
723
724 /// Opens a folder inside Wsl.
725 #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
726 #[action(namespace = projects)]
727 #[serde(deny_unknown_fields)]
728 pub struct OpenFolderInWsl {
729 #[serde(default)]
730 pub create_new_window: bool,
731 }
732
733 /// Open a wsl distro.
734 #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
735 #[action(namespace = projects)]
736 #[serde(deny_unknown_fields)]
737 pub struct OpenWsl {
738 #[serde(default)]
739 pub create_new_window: bool,
740 }
741}
742
743pub mod preview {
744 pub mod markdown {
745 use gpui::actions;
746
747 actions!(
748 markdown,
749 [
750 /// Opens a markdown preview for the current file.
751 OpenPreview,
752 /// Opens a markdown preview in a split pane.
753 OpenPreviewToTheSide,
754 ]
755 );
756 }
757
758 pub mod svg {
759 use gpui::actions;
760
761 actions!(
762 svg,
763 [
764 /// Opens an SVG preview for the current file.
765 OpenPreview,
766 /// Opens an SVG preview in a split pane.
767 OpenPreviewToTheSide,
768 ]
769 );
770 }
771}
772
773pub mod notebook {
774 use gpui::actions;
775
776 actions!(
777 notebook,
778 [
779 /// Move to down in cells
780 NotebookMoveDown,
781 /// Move to up in cells
782 NotebookMoveUp,
783 ]
784 );
785}