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