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