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 ]
311 );
312}
313
314pub mod assistant {
315 use gpui::{Action, actions};
316 use schemars::JsonSchema;
317 use serde::Deserialize;
318 use uuid::Uuid;
319
320 actions!(
321 agent,
322 [
323 #[action(deprecated_aliases = ["assistant::ToggleFocus"])]
324 ToggleFocus
325 ]
326 );
327
328 actions!(
329 assistant,
330 [
331 /// Shows the assistant configuration panel.
332 ShowConfiguration
333 ]
334 );
335
336 /// Opens the rules library for managing agent rules and prompts.
337 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
338 #[action(namespace = agent, deprecated_aliases = ["assistant::OpenRulesLibrary", "assistant::DeployPromptLibrary"])]
339 #[serde(deny_unknown_fields)]
340 pub struct OpenRulesLibrary {
341 #[serde(skip)]
342 pub prompt_to_select: Option<Uuid>,
343 }
344
345 /// Deploys the assistant interface with the specified configuration.
346 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema, Action)]
347 #[action(namespace = assistant)]
348 #[serde(deny_unknown_fields)]
349 pub struct InlineAssist {
350 pub prompt: Option<String>,
351 }
352}
353
354pub mod debugger {
355 use gpui::actions;
356
357 actions!(
358 debugger,
359 [
360 /// Opens the debugger onboarding modal.
361 OpenOnboardingModal,
362 /// Resets the debugger onboarding state.
363 ResetOnboarding
364 ]
365 );
366}
367
368/// Opens the recent projects interface.
369#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
370#[action(namespace = projects)]
371#[serde(deny_unknown_fields)]
372pub struct OpenRecent {
373 #[serde(default)]
374 pub create_new_window: bool,
375}
376
377/// Creates a project from a selected template.
378#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
379#[action(namespace = projects)]
380#[serde(deny_unknown_fields)]
381pub struct OpenRemote {
382 #[serde(default)]
383 pub from_existing_connection: bool,
384 #[serde(default)]
385 pub create_new_window: bool,
386}
387
388/// Where to spawn the task in the UI.
389#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
390#[serde(rename_all = "snake_case")]
391pub enum RevealTarget {
392 /// In the central pane group, "main" editor area.
393 Center,
394 /// In the terminal dock, "regular" terminal items' place.
395 #[default]
396 Dock,
397}
398
399/// Spawns a task with name or opens tasks modal.
400#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema, Action)]
401#[action(namespace = task)]
402#[serde(untagged)]
403pub enum Spawn {
404 /// Spawns a task by the name given.
405 ByName {
406 task_name: String,
407 #[serde(default)]
408 reveal_target: Option<RevealTarget>,
409 },
410 /// Spawns a task by the name given.
411 ByTag {
412 task_tag: String,
413 #[serde(default)]
414 reveal_target: Option<RevealTarget>,
415 },
416 /// Spawns a task via modal's selection.
417 ViaModal {
418 /// Selected task's `reveal_target` property override.
419 #[serde(default)]
420 reveal_target: Option<RevealTarget>,
421 },
422}
423
424impl Spawn {
425 pub fn modal() -> Self {
426 Self::ViaModal {
427 reveal_target: None,
428 }
429 }
430}
431
432/// Reruns the last task.
433#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
434#[action(namespace = task)]
435#[serde(deny_unknown_fields)]
436pub struct Rerun {
437 /// Controls whether the task context is reevaluated prior to execution of a task.
438 /// 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
439 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
440 /// default: false
441 #[serde(default)]
442 pub reevaluate_context: bool,
443 /// Overrides `allow_concurrent_runs` property of the task being reran.
444 /// Default: null
445 #[serde(default)]
446 pub allow_concurrent_runs: Option<bool>,
447 /// Overrides `use_new_terminal` property of the task being reran.
448 /// Default: null
449 #[serde(default)]
450 pub use_new_terminal: Option<bool>,
451
452 /// If present, rerun the task with this ID, otherwise rerun the last task.
453 #[serde(skip)]
454 pub task_id: Option<String>,
455}
456
457pub mod outline {
458 use std::sync::OnceLock;
459
460 use gpui::{AnyView, App, Window, actions};
461
462 actions!(
463 outline,
464 [
465 #[action(name = "Toggle")]
466 ToggleOutline
467 ]
468 );
469 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
470 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
471}
472
473actions!(
474 zed_predict_onboarding,
475 [
476 /// Opens the Zed Predict onboarding modal.
477 OpenZedPredictOnboarding
478 ]
479);
480actions!(
481 git_onboarding,
482 [
483 /// Opens the git integration onboarding modal.
484 OpenGitIntegrationOnboarding
485 ]
486);
487
488actions!(
489 debug_panel,
490 [
491 /// Toggles focus on the debug panel.
492 ToggleFocus
493 ]
494);
495actions!(
496 debugger,
497 [
498 /// Toggles the enabled state of a breakpoint.
499 ToggleEnableBreakpoint,
500 /// Removes a breakpoint.
501 UnsetBreakpoint,
502 /// Opens the project debug tasks configuration.
503 OpenProjectDebugTasks,
504 ]
505);
506
507#[cfg(target_os = "windows")]
508pub mod wsl_actions {
509 use gpui::Action;
510 use schemars::JsonSchema;
511 use serde::Deserialize;
512
513 /// Opens a folder inside Wsl.
514 #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
515 #[action(namespace = projects)]
516 #[serde(deny_unknown_fields)]
517 pub struct OpenFolderInWsl {
518 #[serde(default)]
519 pub create_new_window: bool,
520 }
521
522 /// Open a wsl distro.
523 #[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
524 #[action(namespace = projects)]
525 #[serde(deny_unknown_fields)]
526 pub struct OpenWsl {
527 #[serde(default)]
528 pub create_new_window: bool,
529 }
530}