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