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#[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
15#[action(namespace = zed)]
16#[serde(deny_unknown_fields)]
17pub struct OpenBrowser {
18 pub url: String,
19}
20
21#[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
22#[action(namespace = zed)]
23#[serde(deny_unknown_fields)]
24pub struct OpenZedUrl {
25 pub url: String,
26}
27
28actions!(
29 zed,
30 [
31 OpenSettings,
32 OpenDefaultKeymap,
33 OpenAccountSettings,
34 OpenServerSettings,
35 Quit,
36 OpenKeymap,
37 About,
38 OpenDocs,
39 OpenLicenses,
40 OpenTelemetryLog,
41 ]
42);
43
44#[derive(PartialEq, Clone, Copy, Debug, Deserialize, JsonSchema)]
45#[serde(rename_all = "snake_case")]
46pub enum ExtensionCategoryFilter {
47 Themes,
48 IconThemes,
49 Languages,
50 Grammars,
51 LanguageServers,
52 ContextServers,
53 SlashCommands,
54 IndexedDocsProviders,
55 Snippets,
56 DebugAdapters,
57}
58
59#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
60#[action(namespace = zed)]
61pub struct Extensions {
62 /// Filters the extensions page down to extensions that are in the specified category.
63 #[serde(default)]
64 pub category_filter: Option<ExtensionCategoryFilter>,
65}
66
67#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
68#[action(namespace = zed)]
69pub struct DecreaseBufferFontSize {
70 #[serde(default)]
71 pub persist: bool,
72}
73
74#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
75#[action(namespace = zed)]
76pub struct IncreaseBufferFontSize {
77 #[serde(default)]
78 pub persist: bool,
79}
80
81#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
82#[action(namespace = zed)]
83pub struct ResetBufferFontSize {
84 #[serde(default)]
85 pub persist: bool,
86}
87
88#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
89#[action(namespace = zed)]
90pub struct DecreaseUiFontSize {
91 #[serde(default)]
92 pub persist: bool,
93}
94
95#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
96#[action(namespace = zed)]
97pub struct IncreaseUiFontSize {
98 #[serde(default)]
99 pub persist: bool,
100}
101
102#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
103#[action(namespace = zed)]
104pub struct ResetUiFontSize {
105 #[serde(default)]
106 pub persist: bool,
107}
108
109pub mod dev {
110 use gpui::actions;
111
112 actions!(dev, [ToggleInspector]);
113}
114
115pub mod workspace {
116 use gpui::actions;
117
118 actions!(
119 workspace,
120 [
121 #[action(deprecated_aliases = ["editor::CopyPath", "outline_panel::CopyPath", "project_panel::CopyPath"])]
122 CopyPath,
123 #[action(deprecated_aliases = ["editor::CopyRelativePath", "outline_panel::CopyRelativePath", "project_panel::CopyRelativePath"])]
124 CopyRelativePath
125 ]
126 );
127}
128
129pub mod git {
130 use gpui::actions;
131
132 actions!(
133 git,
134 [
135 CheckoutBranch,
136 Switch,
137 SelectRepo,
138 #[action(deprecated_aliases = ["branches::OpenRecent"])]
139 Branch
140 ]
141 );
142}
143
144pub mod jj {
145 use gpui::actions;
146
147 actions!(jj, [BookmarkList]);
148}
149
150pub mod toast {
151 use gpui::actions;
152
153 actions!(toast, [RunAction]);
154}
155
156pub mod command_palette {
157 use gpui::actions;
158
159 actions!(command_palette, [Toggle]);
160}
161
162pub mod feedback {
163 use gpui::actions;
164
165 actions!(feedback, [FileBugReport, GiveFeedback]);
166}
167
168pub mod theme_selector {
169 use gpui::Action;
170 use schemars::JsonSchema;
171 use serde::Deserialize;
172
173 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
174 #[action(namespace = theme_selector)]
175 #[serde(deny_unknown_fields)]
176 pub struct Toggle {
177 /// A list of theme names to filter the theme selector down to.
178 pub themes_filter: Option<Vec<String>>,
179 }
180}
181
182pub mod icon_theme_selector {
183 use gpui::Action;
184 use schemars::JsonSchema;
185 use serde::Deserialize;
186
187 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
188 #[action(namespace = icon_theme_selector)]
189 #[serde(deny_unknown_fields)]
190 pub struct Toggle {
191 /// A list of icon theme names to filter the theme selector down to.
192 pub themes_filter: Option<Vec<String>>,
193 }
194}
195
196pub mod agent {
197 use gpui::actions;
198
199 actions!(
200 agent,
201 [
202 OpenConfiguration,
203 OpenOnboardingModal,
204 ResetOnboarding,
205 Chat
206 ]
207 );
208}
209
210pub mod assistant {
211 use gpui::{Action, actions};
212 use schemars::JsonSchema;
213 use serde::Deserialize;
214 use uuid::Uuid;
215
216 actions!(
217 agent,
218 [
219 #[action(deprecated_aliases = ["assistant::ToggleFocus"])]
220 ToggleFocus
221 ]
222 );
223
224 actions!(assistant, [ShowConfiguration]);
225
226 #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
227 #[action(namespace = agent, deprecated_aliases = ["assistant::OpenRulesLibrary", "assistant::DeployPromptLibrary"])]
228 #[serde(deny_unknown_fields)]
229 pub struct OpenRulesLibrary {
230 #[serde(skip)]
231 pub prompt_to_select: Option<Uuid>,
232 }
233
234 #[derive(Clone, Default, Deserialize, PartialEq, JsonSchema, Action)]
235 #[action(namespace = assistant)]
236 #[serde(deny_unknown_fields)]
237 pub struct InlineAssist {
238 pub prompt: Option<String>,
239 }
240}
241
242pub mod debugger {
243 use gpui::actions;
244
245 actions!(debugger, [OpenOnboardingModal, ResetOnboarding]);
246}
247
248#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
249#[action(namespace = projects)]
250#[serde(deny_unknown_fields)]
251pub struct OpenRecent {
252 #[serde(default)]
253 pub create_new_window: bool,
254}
255
256#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
257#[action(namespace = projects)]
258#[serde(deny_unknown_fields)]
259pub struct OpenRemote {
260 #[serde(default)]
261 pub from_existing_connection: bool,
262 #[serde(default)]
263 pub create_new_window: bool,
264}
265
266/// Where to spawn the task in the UI.
267#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
268#[serde(rename_all = "snake_case")]
269pub enum RevealTarget {
270 /// In the central pane group, "main" editor area.
271 Center,
272 /// In the terminal dock, "regular" terminal items' place.
273 #[default]
274 Dock,
275}
276
277/// Spawn a task with name or open tasks modal.
278#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema, Action)]
279#[action(namespace = task)]
280#[serde(untagged)]
281pub enum Spawn {
282 /// Spawns a task by the name given.
283 ByName {
284 task_name: String,
285 #[serde(default)]
286 reveal_target: Option<RevealTarget>,
287 },
288 /// Spawns a task by the name given.
289 ByTag {
290 task_tag: String,
291 #[serde(default)]
292 reveal_target: Option<RevealTarget>,
293 },
294 /// Spawns a task via modal's selection.
295 ViaModal {
296 /// Selected task's `reveal_target` property override.
297 #[serde(default)]
298 reveal_target: Option<RevealTarget>,
299 },
300}
301
302impl Spawn {
303 pub fn modal() -> Self {
304 Self::ViaModal {
305 reveal_target: None,
306 }
307 }
308}
309
310/// Rerun the last task.
311#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
312#[action(namespace = task)]
313#[serde(deny_unknown_fields)]
314pub struct Rerun {
315 /// Controls whether the task context is reevaluated prior to execution of a task.
316 /// 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
317 /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.
318 /// default: false
319 #[serde(default)]
320 pub reevaluate_context: bool,
321 /// Overrides `allow_concurrent_runs` property of the task being reran.
322 /// Default: null
323 #[serde(default)]
324 pub allow_concurrent_runs: Option<bool>,
325 /// Overrides `use_new_terminal` property of the task being reran.
326 /// Default: null
327 #[serde(default)]
328 pub use_new_terminal: Option<bool>,
329
330 /// If present, rerun the task with this ID, otherwise rerun the last task.
331 #[serde(skip)]
332 pub task_id: Option<String>,
333}
334
335pub mod outline {
336 use std::sync::OnceLock;
337
338 use gpui::{AnyView, App, Window, actions};
339
340 actions!(
341 outline,
342 [
343 #[action(name = "Toggle")]
344 ToggleOutline
345 ]
346 );
347 /// A pointer to outline::toggle function, exposed here to sewer the breadcrumbs <-> outline dependency.
348 pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
349}
350
351actions!(zed_predict_onboarding, [OpenZedPredictOnboarding]);
352actions!(git_onboarding, [OpenGitIntegrationOnboarding]);
353
354actions!(debug_panel, [ToggleFocus]);
355actions!(
356 debugger,
357 [
358 ToggleEnableBreakpoint,
359 UnsetBreakpoint,
360 OpenProjectDebugTasks,
361 ]
362);