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