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