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