lib.rs

  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/// Decreases the font size in the editor buffer.
108#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
109#[action(namespace = zed)]
110#[serde(deny_unknown_fields)]
111pub struct DecreaseBufferFontSize {
112    #[serde(default)]
113    pub persist: bool,
114}
115
116/// Increases the font size in the editor buffer.
117#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
118#[action(namespace = zed)]
119#[serde(deny_unknown_fields)]
120pub struct IncreaseBufferFontSize {
121    #[serde(default)]
122    pub persist: bool,
123}
124
125/// Increases the font size in the editor buffer.
126#[derive(PartialEq, Clone, Debug, Deserialize, JsonSchema, Action)]
127#[action(namespace = zed)]
128#[serde(deny_unknown_fields)]
129pub struct OpenSettingsAt {
130    /// A path to a specific setting (e.g. `theme.mode`)
131    pub path: String,
132}
133
134/// Resets the buffer font size to the default value.
135#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
136#[action(namespace = zed)]
137#[serde(deny_unknown_fields)]
138pub struct ResetBufferFontSize {
139    #[serde(default)]
140    pub persist: bool,
141}
142
143/// Decreases the font size of the user interface.
144#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
145#[action(namespace = zed)]
146#[serde(deny_unknown_fields)]
147pub struct DecreaseUiFontSize {
148    #[serde(default)]
149    pub persist: bool,
150}
151
152/// Increases the font size of the user interface.
153#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
154#[action(namespace = zed)]
155#[serde(deny_unknown_fields)]
156pub struct IncreaseUiFontSize {
157    #[serde(default)]
158    pub persist: bool,
159}
160
161/// Resets the UI font size to the default value.
162#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
163#[action(namespace = zed)]
164#[serde(deny_unknown_fields)]
165pub struct ResetUiFontSize {
166    #[serde(default)]
167    pub persist: bool,
168}
169
170/// Resets all zoom levels (UI and buffer font sizes, including in the agent panel) to their default values.
171#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
172#[action(namespace = zed)]
173#[serde(deny_unknown_fields)]
174pub struct ResetAllZoom {
175    #[serde(default)]
176    pub persist: bool,
177}
178
179pub mod dev {
180    use gpui::actions;
181
182    actions!(
183        dev,
184        [
185            /// Toggles the developer inspector for debugging UI elements.
186            ToggleInspector
187        ]
188    );
189}
190
191pub mod workspace {
192    use gpui::actions;
193
194    actions!(
195        workspace,
196        [
197            #[action(deprecated_aliases = ["editor::CopyPath", "outline_panel::CopyPath", "project_panel::CopyPath"])]
198            CopyPath,
199            #[action(deprecated_aliases = ["editor::CopyRelativePath", "outline_panel::CopyRelativePath", "project_panel::CopyRelativePath"])]
200            CopyRelativePath,
201            /// Opens the selected file with the system's default application.
202            #[action(deprecated_aliases = ["project_panel::OpenWithSystem"])]
203            OpenWithSystem,
204        ]
205    );
206}
207
208pub mod git {
209    use gpui::actions;
210
211    actions!(
212        git,
213        [
214            /// Checks out a different git branch.
215            CheckoutBranch,
216            /// Switches to a different git branch.
217            Switch,
218            /// Selects a different repository.
219            SelectRepo,
220            /// Filter remotes.
221            FilterRemotes,
222            /// Create a git remote.
223            CreateRemote,
224            /// Opens the git branch selector.
225            #[action(deprecated_aliases = ["branches::OpenRecent"])]
226            Branch,
227            /// Opens the git stash selector.
228            ViewStash,
229            /// Opens the git worktree selector.
230            Worktree,
231            /// Creates a pull request for the current branch.
232            CreatePullRequest
233        ]
234    );
235}
236
237pub mod toast {
238    use gpui::actions;
239
240    actions!(
241        toast,
242        [
243            /// Runs the action associated with a toast notification.
244            RunAction
245        ]
246    );
247}
248
249pub mod command_palette {
250    use gpui::actions;
251
252    actions!(
253        command_palette,
254        [
255            /// Toggles the command palette.
256            Toggle,
257        ]
258    );
259}
260
261pub mod project_panel {
262    use gpui::actions;
263
264    actions!(
265        project_panel,
266        [
267            /// Toggles focus on the project panel.
268            ToggleFocus
269        ]
270    );
271}
272pub mod feedback {
273    use gpui::actions;
274
275    actions!(
276        feedback,
277        [
278            /// Opens email client to send feedback to Zed support.
279            EmailZed,
280            /// Opens the bug report form.
281            FileBugReport,
282            /// Opens the feature request form.
283            RequestFeature
284        ]
285    );
286}
287
288pub mod theme_selector {
289    use gpui::Action;
290    use schemars::JsonSchema;
291    use serde::Deserialize;
292
293    /// Toggles the theme selector interface.
294    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
295    #[action(namespace = theme_selector)]
296    #[serde(deny_unknown_fields)]
297    pub struct Toggle {
298        /// A list of theme names to filter the theme selector down to.
299        pub themes_filter: Option<Vec<String>>,
300    }
301}
302
303pub mod icon_theme_selector {
304    use gpui::Action;
305    use schemars::JsonSchema;
306    use serde::Deserialize;
307
308    /// Toggles the icon theme selector interface.
309    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
310    #[action(namespace = icon_theme_selector)]
311    #[serde(deny_unknown_fields)]
312    pub struct Toggle {
313        /// A list of icon theme names to filter the theme selector down to.
314        pub themes_filter: Option<Vec<String>>,
315    }
316}
317
318pub mod settings_profile_selector {
319    use gpui::Action;
320    use schemars::JsonSchema;
321    use serde::Deserialize;
322
323    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
324    #[action(namespace = settings_profile_selector)]
325    pub struct Toggle;
326}
327
328pub mod agent {
329    use gpui::actions;
330
331    actions!(
332        agent,
333        [
334            /// Opens the agent settings panel.
335            #[action(deprecated_aliases = ["agent::OpenConfiguration"])]
336            OpenSettings,
337            /// Opens the agent onboarding modal.
338            OpenOnboardingModal,
339            /// Opens the ACP onboarding modal.
340            OpenAcpOnboardingModal,
341            /// Opens the Claude Code onboarding modal.
342            OpenClaudeCodeOnboardingModal,
343            /// Resets the agent onboarding state.
344            ResetOnboarding,
345            /// Starts a chat conversation with the agent.
346            Chat,
347            /// Toggles the language model selector dropdown.
348            #[action(deprecated_aliases = ["assistant::ToggleModelSelector", "assistant2::ToggleModelSelector"])]
349            ToggleModelSelector,
350            /// Triggers re-authentication on Gemini
351            ReauthenticateAgent,
352            /// Add the current selection as context for threads in the agent panel.
353            #[action(deprecated_aliases = ["assistant::QuoteSelection", "agent::QuoteSelection"])]
354            AddSelectionToThread,
355            /// Resets the agent panel zoom levels (agent UI and buffer font sizes).
356            ResetAgentZoom,
357            /// Toggles the utility/agent pane open/closed state.
358            ToggleAgentPane,
359            /// Pastes clipboard content without any formatting.
360            PasteRaw,
361        ]
362    );
363}
364
365pub mod assistant {
366    use gpui::{Action, actions};
367    use schemars::JsonSchema;
368    use serde::Deserialize;
369    use uuid::Uuid;
370
371    actions!(
372        agent,
373        [
374            #[action(deprecated_aliases = ["assistant::ToggleFocus"])]
375            ToggleFocus
376        ]
377    );
378
379    actions!(
380        assistant,
381        [
382            /// Shows the assistant configuration panel.
383            ShowConfiguration
384        ]
385    );
386
387    /// Opens the rules library for managing agent rules and prompts.
388    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
389    #[action(namespace = agent, deprecated_aliases = ["assistant::OpenRulesLibrary", "assistant::DeployPromptLibrary"])]
390    #[serde(deny_unknown_fields)]
391    pub struct OpenRulesLibrary {
392        #[serde(skip)]
393        pub prompt_to_select: Option<Uuid>,
394    }
395
396    /// Deploys the assistant interface with the specified configuration.
397    #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema, Action)]
398    #[action(namespace = assistant)]
399    #[serde(deny_unknown_fields)]
400    pub struct InlineAssist {
401        pub prompt: Option<String>,
402    }
403}
404
405pub mod debugger {
406    use gpui::actions;
407
408    actions!(
409        debugger,
410        [
411            /// Opens the debugger onboarding modal.
412            OpenOnboardingModal,
413            /// Resets the debugger onboarding state.
414            ResetOnboarding
415        ]
416    );
417}
418
419/// Opens the recent projects interface.
420#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
421#[action(namespace = projects)]
422#[serde(deny_unknown_fields)]
423pub struct OpenRecent {
424    #[serde(default)]
425    pub create_new_window: bool,
426}
427
428/// Creates a project from a selected template.
429#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
430#[action(namespace = projects)]
431#[serde(deny_unknown_fields)]
432pub struct OpenRemote {
433    #[serde(default)]
434    pub from_existing_connection: bool,
435    #[serde(default)]
436    pub create_new_window: bool,
437}
438
439/// Opens the dev container connection modal.
440#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
441#[action(namespace = projects)]
442#[serde(deny_unknown_fields)]
443pub struct OpenDevContainer;
444
445/// Where to spawn the task in the UI.
446#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
447#[serde(rename_all = "snake_case")]
448pub enum RevealTarget {
449    /// In the central pane group, "main" editor area.
450    Center,
451    /// In the terminal dock, "regular" terminal items' place.
452    #[default]
453    Dock,
454}
455
456/// Spawns a task with name or opens tasks modal.
457#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema, Action)]
458#[action(namespace = task)]
459#[serde(untagged)]
460pub enum Spawn {
461    /// Spawns a task by the name given.
462    ByName {
463        task_name: String,
464        #[serde(default)]
465        reveal_target: Option<RevealTarget>,
466    },
467    /// Spawns a task by the name given.
468    ByTag {
469        task_tag: String,
470        #[serde(default)]
471        reveal_target: Option<RevealTarget>,
472    },
473    /// Spawns a task via modal's selection.
474    ViaModal {
475        /// Selected task's `reveal_target` property override.
476        #[serde(default)]
477        reveal_target: Option<RevealTarget>,
478    },
479}
480
481impl Spawn {
482    pub fn modal() -> Self {
483        Self::ViaModal {
484            reveal_target: None,
485        }
486    }
487}
488
489/// Reruns the last task.
490#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
491#[action(namespace = task)]
492#[serde(deny_unknown_fields)]
493pub struct Rerun {
494    /// Controls whether the task context is reevaluated prior to execution of a task.
495    /// 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
496    /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
497    /// default: false
498    #[serde(default)]
499    pub reevaluate_context: bool,
500    /// Overrides `allow_concurrent_runs` property of the task being reran.
501    /// Default: null
502    #[serde(default)]
503    pub allow_concurrent_runs: Option<bool>,
504    /// Overrides `use_new_terminal` property of the task being reran.
505    /// Default: null
506    #[serde(default)]
507    pub use_new_terminal: Option<bool>,
508
509    /// If present, rerun the task with this ID, otherwise rerun the last task.
510    #[serde(skip)]
511    pub task_id: Option<String>,
512}
513
514pub mod outline {
515    use std::sync::OnceLock;
516
517    use gpui::{AnyView, App, Window, actions};
518
519    actions!(
520        outline,
521        [
522            #[action(name = "Toggle")]
523            ToggleOutline
524        ]
525    );
526    /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
527    pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
528}
529
530actions!(
531    zed_predict_onboarding,
532    [
533        /// Opens the Zed Predict onboarding modal.
534        OpenZedPredictOnboarding
535    ]
536);
537actions!(
538    git_onboarding,
539    [
540        /// Opens the git integration onboarding modal.
541        OpenGitIntegrationOnboarding
542    ]
543);
544
545actions!(
546    debug_panel,
547    [
548        /// Toggles focus on the debug panel.
549        ToggleFocus
550    ]
551);
552actions!(
553    debugger,
554    [
555        /// Toggles the enabled state of a breakpoint.
556        ToggleEnableBreakpoint,
557        /// Removes a breakpoint.
558        UnsetBreakpoint,
559        /// Opens the project debug tasks configuration.
560        OpenProjectDebugTasks,
561    ]
562);
563
564pub mod vim {
565    use gpui::actions;
566
567    actions!(
568        vim,
569        [
570            /// Opens the default keymap file.
571            OpenDefaultKeymap
572        ]
573    );
574}
575
576#[derive(Debug, Clone, PartialEq, Eq, Hash)]
577pub struct WslConnectionOptions {
578    pub distro_name: String,
579    pub user: Option<String>,
580}
581
582#[cfg(target_os = "windows")]
583pub mod wsl_actions {
584    use gpui::Action;
585    use schemars::JsonSchema;
586    use serde::Deserialize;
587
588    /// Opens a folder inside Wsl.
589    #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
590    #[action(namespace = projects)]
591    #[serde(deny_unknown_fields)]
592    pub struct OpenFolderInWsl {
593        #[serde(default)]
594        pub create_new_window: bool,
595    }
596
597    /// Open a wsl distro.
598    #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
599    #[action(namespace = projects)]
600    #[serde(deny_unknown_fields)]
601    pub struct OpenWsl {
602        #[serde(default)]
603        pub create_new_window: bool,
604    }
605}