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