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