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