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