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        ]
232    );
233}
234
235pub mod toast {
236    use gpui::actions;
237
238    actions!(
239        toast,
240        [
241            /// Runs the action associated with a toast notification.
242            RunAction
243        ]
244    );
245}
246
247pub mod command_palette {
248    use gpui::actions;
249
250    actions!(
251        command_palette,
252        [
253            /// Toggles the command palette.
254            Toggle,
255        ]
256    );
257}
258
259pub mod project_panel {
260    use gpui::actions;
261
262    actions!(
263        project_panel,
264        [
265            /// Toggles focus on the project panel.
266            ToggleFocus
267        ]
268    );
269}
270pub mod feedback {
271    use gpui::actions;
272
273    actions!(
274        feedback,
275        [
276            /// Opens email client to send feedback to Zed support.
277            EmailZed,
278            /// Opens the bug report form.
279            FileBugReport,
280            /// Opens the feature request form.
281            RequestFeature
282        ]
283    );
284}
285
286pub mod theme_selector {
287    use gpui::Action;
288    use schemars::JsonSchema;
289    use serde::Deserialize;
290
291    /// Toggles the theme selector interface.
292    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
293    #[action(namespace = theme_selector)]
294    #[serde(deny_unknown_fields)]
295    pub struct Toggle {
296        /// A list of theme names to filter the theme selector down to.
297        pub themes_filter: Option<Vec<String>>,
298    }
299}
300
301pub mod icon_theme_selector {
302    use gpui::Action;
303    use schemars::JsonSchema;
304    use serde::Deserialize;
305
306    /// Toggles the icon theme selector interface.
307    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
308    #[action(namespace = icon_theme_selector)]
309    #[serde(deny_unknown_fields)]
310    pub struct Toggle {
311        /// A list of icon theme names to filter the theme selector down to.
312        pub themes_filter: Option<Vec<String>>,
313    }
314}
315
316pub mod settings_profile_selector {
317    use gpui::Action;
318    use schemars::JsonSchema;
319    use serde::Deserialize;
320
321    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
322    #[action(namespace = settings_profile_selector)]
323    pub struct Toggle;
324}
325
326pub mod agent {
327    use gpui::actions;
328
329    actions!(
330        agent,
331        [
332            /// Opens the agent settings panel.
333            #[action(deprecated_aliases = ["agent::OpenConfiguration"])]
334            OpenSettings,
335            /// Opens the agent onboarding modal.
336            OpenOnboardingModal,
337            /// Opens the ACP onboarding modal.
338            OpenAcpOnboardingModal,
339            /// Opens the Claude Code onboarding modal.
340            OpenClaudeCodeOnboardingModal,
341            /// Resets the agent onboarding state.
342            ResetOnboarding,
343            /// Starts a chat conversation with the agent.
344            Chat,
345            /// Toggles the language model selector dropdown.
346            #[action(deprecated_aliases = ["assistant::ToggleModelSelector", "assistant2::ToggleModelSelector"])]
347            ToggleModelSelector,
348            /// Triggers re-authentication on Gemini
349            ReauthenticateAgent,
350            /// Add the current selection as context for threads in the agent panel.
351            #[action(deprecated_aliases = ["assistant::QuoteSelection", "agent::QuoteSelection"])]
352            AddSelectionToThread,
353            /// Resets the agent panel zoom levels (agent UI and buffer font sizes).
354            ResetAgentZoom,
355            /// Toggles the utility/agent pane open/closed state.
356            ToggleAgentPane,
357        ]
358    );
359}
360
361pub mod assistant {
362    use gpui::{Action, actions};
363    use schemars::JsonSchema;
364    use serde::Deserialize;
365    use uuid::Uuid;
366
367    actions!(
368        agent,
369        [
370            #[action(deprecated_aliases = ["assistant::ToggleFocus"])]
371            ToggleFocus
372        ]
373    );
374
375    actions!(
376        assistant,
377        [
378            /// Shows the assistant configuration panel.
379            ShowConfiguration
380        ]
381    );
382
383    /// Opens the rules library for managing agent rules and prompts.
384    #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
385    #[action(namespace = agent, deprecated_aliases = ["assistant::OpenRulesLibrary", "assistant::DeployPromptLibrary"])]
386    #[serde(deny_unknown_fields)]
387    pub struct OpenRulesLibrary {
388        #[serde(skip)]
389        pub prompt_to_select: Option<Uuid>,
390    }
391
392    /// Deploys the assistant interface with the specified configuration.
393    #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema, Action)]
394    #[action(namespace = assistant)]
395    #[serde(deny_unknown_fields)]
396    pub struct InlineAssist {
397        pub prompt: Option<String>,
398    }
399}
400
401pub mod debugger {
402    use gpui::actions;
403
404    actions!(
405        debugger,
406        [
407            /// Opens the debugger onboarding modal.
408            OpenOnboardingModal,
409            /// Resets the debugger onboarding state.
410            ResetOnboarding
411        ]
412    );
413}
414
415/// Opens the recent projects interface.
416#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
417#[action(namespace = projects)]
418#[serde(deny_unknown_fields)]
419pub struct OpenRecent {
420    #[serde(default)]
421    pub create_new_window: bool,
422}
423
424/// Creates a project from a selected template.
425#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
426#[action(namespace = projects)]
427#[serde(deny_unknown_fields)]
428pub struct OpenRemote {
429    #[serde(default)]
430    pub from_existing_connection: bool,
431    #[serde(default)]
432    pub create_new_window: bool,
433}
434
435/// Opens the dev container connection modal.
436#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
437#[action(namespace = projects)]
438#[serde(deny_unknown_fields)]
439pub struct OpenDevContainer;
440
441/// Where to spawn the task in the UI.
442#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
443#[serde(rename_all = "snake_case")]
444pub enum RevealTarget {
445    /// In the central pane group, "main" editor area.
446    Center,
447    /// In the terminal dock, "regular" terminal items' place.
448    #[default]
449    Dock,
450}
451
452/// Spawns a task with name or opens tasks modal.
453#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema, Action)]
454#[action(namespace = task)]
455#[serde(untagged)]
456pub enum Spawn {
457    /// Spawns a task by the name given.
458    ByName {
459        task_name: String,
460        #[serde(default)]
461        reveal_target: Option<RevealTarget>,
462    },
463    /// Spawns a task by the name given.
464    ByTag {
465        task_tag: String,
466        #[serde(default)]
467        reveal_target: Option<RevealTarget>,
468    },
469    /// Spawns a task via modal's selection.
470    ViaModal {
471        /// Selected task's `reveal_target` property override.
472        #[serde(default)]
473        reveal_target: Option<RevealTarget>,
474    },
475}
476
477impl Spawn {
478    pub fn modal() -> Self {
479        Self::ViaModal {
480            reveal_target: None,
481        }
482    }
483}
484
485/// Reruns the last task.
486#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
487#[action(namespace = task)]
488#[serde(deny_unknown_fields)]
489pub struct Rerun {
490    /// Controls whether the task context is reevaluated prior to execution of a task.
491    /// 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
492    /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
493    /// default: false
494    #[serde(default)]
495    pub reevaluate_context: bool,
496    /// Overrides `allow_concurrent_runs` property of the task being reran.
497    /// Default: null
498    #[serde(default)]
499    pub allow_concurrent_runs: Option<bool>,
500    /// Overrides `use_new_terminal` property of the task being reran.
501    /// Default: null
502    #[serde(default)]
503    pub use_new_terminal: Option<bool>,
504
505    /// If present, rerun the task with this ID, otherwise rerun the last task.
506    #[serde(skip)]
507    pub task_id: Option<String>,
508}
509
510pub mod outline {
511    use std::sync::OnceLock;
512
513    use gpui::{AnyView, App, Window, actions};
514
515    actions!(
516        outline,
517        [
518            #[action(name = "Toggle")]
519            ToggleOutline
520        ]
521    );
522    /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
523    pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
524}
525
526actions!(
527    zed_predict_onboarding,
528    [
529        /// Opens the Zed Predict onboarding modal.
530        OpenZedPredictOnboarding
531    ]
532);
533actions!(
534    git_onboarding,
535    [
536        /// Opens the git integration onboarding modal.
537        OpenGitIntegrationOnboarding
538    ]
539);
540
541actions!(
542    debug_panel,
543    [
544        /// Toggles focus on the debug panel.
545        ToggleFocus
546    ]
547);
548actions!(
549    debugger,
550    [
551        /// Toggles the enabled state of a breakpoint.
552        ToggleEnableBreakpoint,
553        /// Removes a breakpoint.
554        UnsetBreakpoint,
555        /// Opens the project debug tasks configuration.
556        OpenProjectDebugTasks,
557    ]
558);
559
560pub mod vim {
561    use gpui::actions;
562
563    actions!(
564        vim,
565        [
566            /// Opens the default keymap file.
567            OpenDefaultKeymap
568        ]
569    );
570}
571
572#[derive(Debug, Clone, PartialEq, Eq, Hash)]
573pub struct WslConnectionOptions {
574    pub distro_name: String,
575    pub user: Option<String>,
576}
577
578#[cfg(target_os = "windows")]
579pub mod wsl_actions {
580    use gpui::Action;
581    use schemars::JsonSchema;
582    use serde::Deserialize;
583
584    /// Opens a folder inside Wsl.
585    #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
586    #[action(namespace = projects)]
587    #[serde(deny_unknown_fields)]
588    pub struct OpenFolderInWsl {
589        #[serde(default)]
590        pub create_new_window: bool,
591    }
592
593    /// Open a wsl distro.
594    #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
595    #[action(namespace = projects)]
596    #[serde(deny_unknown_fields)]
597    pub struct OpenWsl {
598        #[serde(default)]
599        pub create_new_window: bool,
600    }
601}