1mod application_menu;
2mod collab;
3mod onboarding_banner;
4pub mod platform_title_bar;
5mod platforms;
6mod system_window_tabs;
7mod title_bar_settings;
8
9#[cfg(feature = "stories")]
10mod stories;
11
12use crate::{
13 application_menu::{ApplicationMenu, show_menus},
14 platform_title_bar::PlatformTitleBar,
15 system_window_tabs::SystemWindowTabs,
16};
17
18#[cfg(not(target_os = "macos"))]
19use crate::application_menu::{
20 ActivateDirection, ActivateMenuLeft, ActivateMenuRight, OpenApplicationMenu,
21};
22
23use auto_update::AutoUpdateStatus;
24use call::ActiveCall;
25use client::{Client, UserStore, zed_urls};
26use cloud_llm_client::{Plan, PlanV1, PlanV2};
27use gpui::{
28 Action, AnyElement, App, Context, Corner, Element, Entity, Focusable, InteractiveElement,
29 IntoElement, MouseButton, ParentElement, Render, StatefulInteractiveElement, Styled,
30 Subscription, WeakEntity, Window, actions, div,
31};
32use onboarding_banner::OnboardingBanner;
33use project::{Project, WorktreeSettings};
34use remote::RemoteConnectionOptions;
35use settings::{Settings, SettingsLocation};
36use std::sync::Arc;
37use theme::ActiveTheme;
38use title_bar_settings::TitleBarSettings;
39use ui::{
40 Avatar, Button, ButtonLike, ButtonStyle, Chip, ContextMenu, Icon, IconName, IconSize,
41 IconWithIndicator, Indicator, PopoverMenu, PopoverMenuHandle, Tooltip, h_flex, prelude::*,
42};
43use util::{ResultExt, rel_path::RelPath};
44use workspace::{Workspace, notifications::NotifyResultExt};
45use zed_actions::{OpenRecent, OpenRemote};
46
47pub use onboarding_banner::restore_banner;
48
49#[cfg(feature = "stories")]
50pub use stories::*;
51
52const MAX_PROJECT_NAME_LENGTH: usize = 40;
53const MAX_BRANCH_NAME_LENGTH: usize = 40;
54const MAX_SHORT_SHA_LENGTH: usize = 8;
55
56actions!(
57 collab,
58 [
59 /// Toggles the user menu dropdown.
60 ToggleUserMenu,
61 /// Toggles the project menu dropdown.
62 ToggleProjectMenu,
63 /// Switches to a different git branch.
64 SwitchBranch
65 ]
66);
67
68pub fn init(cx: &mut App) {
69 TitleBarSettings::register(cx);
70 SystemWindowTabs::init(cx);
71
72 cx.observe_new(|workspace: &mut Workspace, window, cx| {
73 let Some(window) = window else {
74 return;
75 };
76 let item = cx.new(|cx| TitleBar::new("title-bar", workspace, window, cx));
77 workspace.set_titlebar_item(item.into(), window, cx);
78
79 #[cfg(not(target_os = "macos"))]
80 workspace.register_action(|workspace, action: &OpenApplicationMenu, window, cx| {
81 if let Some(titlebar) = workspace
82 .titlebar_item()
83 .and_then(|item| item.downcast::<TitleBar>().ok())
84 {
85 titlebar.update(cx, |titlebar, cx| {
86 if let Some(ref menu) = titlebar.application_menu {
87 menu.update(cx, |menu, cx| menu.open_menu(action, window, cx));
88 }
89 });
90 }
91 });
92
93 #[cfg(not(target_os = "macos"))]
94 workspace.register_action(|workspace, _: &ActivateMenuRight, window, cx| {
95 if let Some(titlebar) = workspace
96 .titlebar_item()
97 .and_then(|item| item.downcast::<TitleBar>().ok())
98 {
99 titlebar.update(cx, |titlebar, cx| {
100 if let Some(ref menu) = titlebar.application_menu {
101 menu.update(cx, |menu, cx| {
102 menu.navigate_menus_in_direction(ActivateDirection::Right, window, cx)
103 });
104 }
105 });
106 }
107 });
108
109 #[cfg(not(target_os = "macos"))]
110 workspace.register_action(|workspace, _: &ActivateMenuLeft, window, cx| {
111 if let Some(titlebar) = workspace
112 .titlebar_item()
113 .and_then(|item| item.downcast::<TitleBar>().ok())
114 {
115 titlebar.update(cx, |titlebar, cx| {
116 if let Some(ref menu) = titlebar.application_menu {
117 menu.update(cx, |menu, cx| {
118 menu.navigate_menus_in_direction(ActivateDirection::Left, window, cx)
119 });
120 }
121 });
122 }
123 });
124 })
125 .detach();
126}
127
128pub struct TitleBar {
129 platform_titlebar: Entity<PlatformTitleBar>,
130 project: Entity<Project>,
131 user_store: Entity<UserStore>,
132 client: Arc<Client>,
133 workspace: WeakEntity<Workspace>,
134 application_menu: Option<Entity<ApplicationMenu>>,
135 _subscriptions: Vec<Subscription>,
136 banner: Entity<OnboardingBanner>,
137 screen_share_popover_handle: PopoverMenuHandle<ContextMenu>,
138}
139
140impl Render for TitleBar {
141 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
142 let title_bar_settings = *TitleBarSettings::get_global(cx);
143
144 let show_menus = show_menus(cx);
145
146 let mut children = Vec::new();
147
148 children.push(
149 h_flex()
150 .gap_1()
151 .map(|title_bar| {
152 let mut render_project_items = title_bar_settings.show_branch_name
153 || title_bar_settings.show_project_items;
154 title_bar
155 .when_some(
156 self.application_menu.clone().filter(|_| !show_menus),
157 |title_bar, menu| {
158 render_project_items &=
159 !menu.update(cx, |menu, cx| menu.all_menus_shown(cx));
160 title_bar.child(menu)
161 },
162 )
163 .when(render_project_items, |title_bar| {
164 title_bar
165 .when(title_bar_settings.show_project_items, |title_bar| {
166 title_bar
167 .children(self.render_project_host(cx))
168 .child(self.render_project_name(cx))
169 })
170 .when(title_bar_settings.show_branch_name, |title_bar| {
171 title_bar.children(self.render_project_branch(cx))
172 })
173 })
174 })
175 .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
176 .into_any_element(),
177 );
178
179 children.push(self.render_collaborator_list(window, cx).into_any_element());
180
181 if title_bar_settings.show_onboarding_banner {
182 children.push(self.banner.clone().into_any_element())
183 }
184
185 let status = self.client.status();
186 let status = &*status.borrow();
187 let user = self.user_store.read(cx).current_user();
188
189 children.push(
190 h_flex()
191 .gap_1()
192 .pr_1()
193 .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
194 .children(self.render_call_controls(window, cx))
195 .children(self.render_connection_status(status, cx))
196 .when(
197 user.is_none() && TitleBarSettings::get_global(cx).show_sign_in,
198 |el| el.child(self.render_sign_in_button(cx)),
199 )
200 .when(user.is_some(), |parent| {
201 parent.child(self.render_user_menu_button(cx))
202 })
203 .into_any_element(),
204 );
205
206 if show_menus {
207 self.platform_titlebar.update(cx, |this, _| {
208 this.set_children(
209 self.application_menu
210 .clone()
211 .map(|menu| menu.into_any_element()),
212 );
213 });
214
215 let height = PlatformTitleBar::height(window);
216 let title_bar_color = self.platform_titlebar.update(cx, |platform_titlebar, cx| {
217 platform_titlebar.title_bar_color(window, cx)
218 });
219
220 v_flex()
221 .w_full()
222 .child(self.platform_titlebar.clone().into_any_element())
223 .child(
224 h_flex()
225 .bg(title_bar_color)
226 .h(height)
227 .pl_2()
228 .justify_between()
229 .w_full()
230 .children(children),
231 )
232 .into_any_element()
233 } else {
234 self.platform_titlebar.update(cx, |this, _| {
235 this.set_children(children);
236 });
237 self.platform_titlebar.clone().into_any_element()
238 }
239 }
240}
241
242impl TitleBar {
243 pub fn new(
244 id: impl Into<ElementId>,
245 workspace: &Workspace,
246 window: &mut Window,
247 cx: &mut Context<Self>,
248 ) -> Self {
249 let project = workspace.project().clone();
250 let user_store = workspace.app_state().user_store.clone();
251 let client = workspace.app_state().client.clone();
252 let active_call = ActiveCall::global(cx);
253
254 let platform_style = PlatformStyle::platform();
255 let application_menu = match platform_style {
256 PlatformStyle::Mac => {
257 if option_env!("ZED_USE_CROSS_PLATFORM_MENU").is_some() {
258 Some(cx.new(|cx| ApplicationMenu::new(window, cx)))
259 } else {
260 None
261 }
262 }
263 PlatformStyle::Linux | PlatformStyle::Windows => {
264 Some(cx.new(|cx| ApplicationMenu::new(window, cx)))
265 }
266 };
267
268 let mut subscriptions = Vec::new();
269 subscriptions.push(
270 cx.observe(&workspace.weak_handle().upgrade().unwrap(), |_, _, cx| {
271 cx.notify()
272 }),
273 );
274 subscriptions.push(cx.subscribe(&project, |_, _, _: &project::Event, cx| cx.notify()));
275 subscriptions.push(cx.observe(&active_call, |this, _, cx| this.active_call_changed(cx)));
276 subscriptions.push(cx.observe_window_activation(window, Self::window_activation_changed));
277 subscriptions.push(cx.observe(&user_store, |_, _, cx| cx.notify()));
278
279 let banner = cx.new(|cx| {
280 OnboardingBanner::new(
281 "ACP Claude Code Onboarding",
282 IconName::AiClaude,
283 "Claude Code",
284 Some("Introducing:".into()),
285 zed_actions::agent::OpenClaudeCodeOnboardingModal.boxed_clone(),
286 cx,
287 )
288 // When updating this to a non-AI feature release, remove this line.
289 .visible_when(|cx| !project::DisableAiSettings::get_global(cx).disable_ai)
290 });
291
292 let platform_titlebar = cx.new(|cx| PlatformTitleBar::new(id, cx));
293
294 Self {
295 platform_titlebar,
296 application_menu,
297 workspace: workspace.weak_handle(),
298 project,
299 user_store,
300 client,
301 _subscriptions: subscriptions,
302 banner,
303 screen_share_popover_handle: Default::default(),
304 }
305 }
306
307 fn render_remote_project_connection(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
308 let options = self.project.read(cx).remote_connection_options(cx)?;
309 let host: SharedString = options.display_name().into();
310
311 let (nickname, icon) = match options {
312 RemoteConnectionOptions::Ssh(options) => {
313 (options.nickname.map(|nick| nick.into()), IconName::Server)
314 }
315 RemoteConnectionOptions::Wsl(_) => (None, IconName::Linux),
316 };
317 let nickname = nickname.unwrap_or_else(|| host.clone());
318
319 let (indicator_color, meta) = match self.project.read(cx).remote_connection_state(cx)? {
320 remote::ConnectionState::Connecting => (Color::Info, format!("Connecting to: {host}")),
321 remote::ConnectionState::Connected => (Color::Success, format!("Connected to: {host}")),
322 remote::ConnectionState::HeartbeatMissed => (
323 Color::Warning,
324 format!("Connection attempt to {host} missed. Retrying..."),
325 ),
326 remote::ConnectionState::Reconnecting => (
327 Color::Warning,
328 format!("Lost connection to {host}. Reconnecting..."),
329 ),
330 remote::ConnectionState::Disconnected => {
331 (Color::Error, format!("Disconnected from {host}"))
332 }
333 };
334
335 let icon_color = match self.project.read(cx).remote_connection_state(cx)? {
336 remote::ConnectionState::Connecting => Color::Info,
337 remote::ConnectionState::Connected => Color::Default,
338 remote::ConnectionState::HeartbeatMissed => Color::Warning,
339 remote::ConnectionState::Reconnecting => Color::Warning,
340 remote::ConnectionState::Disconnected => Color::Error,
341 };
342
343 let meta = SharedString::from(meta);
344
345 Some(
346 ButtonLike::new("ssh-server-icon")
347 .child(
348 h_flex()
349 .gap_2()
350 .max_w_32()
351 .child(
352 IconWithIndicator::new(
353 Icon::new(icon).size(IconSize::Small).color(icon_color),
354 Some(Indicator::dot().color(indicator_color)),
355 )
356 .indicator_border_color(Some(cx.theme().colors().title_bar_background))
357 .into_any_element(),
358 )
359 .child(Label::new(nickname).size(LabelSize::Small).truncate()),
360 )
361 .tooltip(move |window, cx| {
362 Tooltip::with_meta(
363 "Remote Project",
364 Some(&OpenRemote {
365 from_existing_connection: false,
366 create_new_window: false,
367 }),
368 meta.clone(),
369 window,
370 cx,
371 )
372 })
373 .on_click(|_, window, cx| {
374 window.dispatch_action(
375 OpenRemote {
376 from_existing_connection: false,
377 create_new_window: false,
378 }
379 .boxed_clone(),
380 cx,
381 );
382 })
383 .into_any_element(),
384 )
385 }
386
387 pub fn render_project_host(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
388 if self.project.read(cx).is_via_remote_server() {
389 return self.render_remote_project_connection(cx);
390 }
391
392 if self.project.read(cx).is_disconnected(cx) {
393 return Some(
394 Button::new("disconnected", "Disconnected")
395 .disabled(true)
396 .color(Color::Disabled)
397 .style(ButtonStyle::Subtle)
398 .label_size(LabelSize::Small)
399 .into_any_element(),
400 );
401 }
402
403 let host = self.project.read(cx).host()?;
404 let host_user = self.user_store.read(cx).get_cached_user(host.user_id)?;
405 let participant_index = self
406 .user_store
407 .read(cx)
408 .participant_indices()
409 .get(&host_user.id)?;
410 Some(
411 Button::new("project_owner_trigger", host_user.github_login.clone())
412 .color(Color::Player(participant_index.0))
413 .style(ButtonStyle::Subtle)
414 .label_size(LabelSize::Small)
415 .tooltip(Tooltip::text(format!(
416 "{} is sharing this project. Click to follow.",
417 host_user.github_login
418 )))
419 .on_click({
420 let host_peer_id = host.peer_id;
421 cx.listener(move |this, _, window, cx| {
422 this.workspace
423 .update(cx, |workspace, cx| {
424 workspace.follow(host_peer_id, window, cx);
425 })
426 .log_err();
427 })
428 })
429 .into_any_element(),
430 )
431 }
432
433 pub fn render_project_name(&self, cx: &mut Context<Self>) -> impl IntoElement {
434 let name = self
435 .project
436 .read(cx)
437 .visible_worktrees(cx)
438 .map(|worktree| {
439 let worktree = worktree.read(cx);
440 let settings_location = SettingsLocation {
441 worktree_id: worktree.id(),
442 path: RelPath::empty(),
443 };
444
445 let settings = WorktreeSettings::get(Some(settings_location), cx);
446 match &settings.project_name {
447 Some(name) => name.as_str(),
448 None => worktree.root_name_str(),
449 }
450 })
451 .next();
452 let is_project_selected = name.is_some();
453 let name = if let Some(name) = name {
454 util::truncate_and_trailoff(name, MAX_PROJECT_NAME_LENGTH)
455 } else {
456 "Open recent project".to_string()
457 };
458
459 Button::new("project_name_trigger", name)
460 .when(!is_project_selected, |b| b.color(Color::Muted))
461 .style(ButtonStyle::Subtle)
462 .label_size(LabelSize::Small)
463 .tooltip(move |window, cx| {
464 Tooltip::for_action(
465 "Recent Projects",
466 &zed_actions::OpenRecent {
467 create_new_window: false,
468 },
469 window,
470 cx,
471 )
472 })
473 .on_click(cx.listener(move |_, _, window, cx| {
474 window.dispatch_action(
475 OpenRecent {
476 create_new_window: false,
477 }
478 .boxed_clone(),
479 cx,
480 );
481 }))
482 }
483
484 pub fn render_project_branch(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
485 let repository = self.project.read(cx).active_repository(cx)?;
486 let workspace = self.workspace.upgrade()?;
487 let branch_name = {
488 let repo = repository.read(cx);
489 repo.branch
490 .as_ref()
491 .map(|branch| branch.name())
492 .map(|name| util::truncate_and_trailoff(name, MAX_BRANCH_NAME_LENGTH))
493 .or_else(|| {
494 repo.head_commit.as_ref().map(|commit| {
495 commit
496 .sha
497 .chars()
498 .take(MAX_SHORT_SHA_LENGTH)
499 .collect::<String>()
500 })
501 })
502 }?;
503
504 Some(
505 Button::new("project_branch_trigger", branch_name)
506 .color(Color::Muted)
507 .style(ButtonStyle::Subtle)
508 .label_size(LabelSize::Small)
509 .tooltip(move |window, cx| {
510 Tooltip::with_meta(
511 "Recent Branches",
512 Some(&zed_actions::git::Branch),
513 "Local branches only",
514 window,
515 cx,
516 )
517 })
518 .on_click(move |_, window, cx| {
519 let _ = workspace.update(cx, |this, cx| {
520 window.focus(&this.active_pane().focus_handle(cx));
521 window.dispatch_action(zed_actions::git::Branch.boxed_clone(), cx);
522 });
523 })
524 .when(
525 TitleBarSettings::get_global(cx).show_branch_icon,
526 |branch_button| {
527 branch_button
528 .icon(IconName::GitBranch)
529 .icon_position(IconPosition::Start)
530 .icon_color(Color::Muted)
531 .icon_size(IconSize::Indicator)
532 },
533 ),
534 )
535 }
536
537 fn window_activation_changed(&mut self, window: &mut Window, cx: &mut Context<Self>) {
538 if window.is_window_active() {
539 ActiveCall::global(cx)
540 .update(cx, |call, cx| call.set_location(Some(&self.project), cx))
541 .detach_and_log_err(cx);
542 } else if cx.active_window().is_none() {
543 ActiveCall::global(cx)
544 .update(cx, |call, cx| call.set_location(None, cx))
545 .detach_and_log_err(cx);
546 }
547 self.workspace
548 .update(cx, |workspace, cx| {
549 workspace.update_active_view_for_followers(window, cx);
550 })
551 .ok();
552 }
553
554 fn active_call_changed(&mut self, cx: &mut Context<Self>) {
555 cx.notify();
556 }
557
558 fn share_project(&mut self, cx: &mut Context<Self>) {
559 let active_call = ActiveCall::global(cx);
560 let project = self.project.clone();
561 active_call
562 .update(cx, |call, cx| call.share_project(project, cx))
563 .detach_and_log_err(cx);
564 }
565
566 fn unshare_project(&mut self, _: &mut Window, cx: &mut Context<Self>) {
567 let active_call = ActiveCall::global(cx);
568 let project = self.project.clone();
569 active_call
570 .update(cx, |call, cx| call.unshare_project(project, cx))
571 .log_err();
572 }
573
574 fn render_connection_status(
575 &self,
576 status: &client::Status,
577 cx: &mut Context<Self>,
578 ) -> Option<AnyElement> {
579 match status {
580 client::Status::ConnectionError
581 | client::Status::ConnectionLost
582 | client::Status::Reauthenticating
583 | client::Status::Reconnecting
584 | client::Status::ReconnectionError { .. } => Some(
585 div()
586 .id("disconnected")
587 .child(Icon::new(IconName::Disconnected).size(IconSize::Small))
588 .tooltip(Tooltip::text("Disconnected"))
589 .into_any_element(),
590 ),
591 client::Status::UpgradeRequired => {
592 let auto_updater = auto_update::AutoUpdater::get(cx);
593 let label = match auto_updater.map(|auto_update| auto_update.read(cx).status()) {
594 Some(AutoUpdateStatus::Updated { .. }) => "Please restart Zed to Collaborate",
595 Some(AutoUpdateStatus::Installing { .. })
596 | Some(AutoUpdateStatus::Downloading { .. })
597 | Some(AutoUpdateStatus::Checking) => "Updating...",
598 Some(AutoUpdateStatus::Idle)
599 | Some(AutoUpdateStatus::Errored { .. })
600 | None => "Please update Zed to Collaborate",
601 };
602
603 Some(
604 Button::new("connection-status", label)
605 .label_size(LabelSize::Small)
606 .on_click(|_, window, cx| {
607 if let Some(auto_updater) = auto_update::AutoUpdater::get(cx)
608 && auto_updater.read(cx).status().is_updated()
609 {
610 workspace::reload(cx);
611 return;
612 }
613 auto_update::check(&Default::default(), window, cx);
614 })
615 .into_any_element(),
616 )
617 }
618 _ => None,
619 }
620 }
621
622 pub fn render_sign_in_button(&mut self, _: &mut Context<Self>) -> Button {
623 let client = self.client.clone();
624 Button::new("sign_in", "Sign in")
625 .label_size(LabelSize::Small)
626 .on_click(move |_, window, cx| {
627 let client = client.clone();
628 window
629 .spawn(cx, async move |cx| {
630 client
631 .sign_in_with_optional_connect(true, cx)
632 .await
633 .notify_async_err(cx);
634 })
635 .detach();
636 })
637 }
638
639 pub fn render_user_menu_button(&mut self, cx: &mut Context<Self>) -> impl Element {
640 let user_store = self.user_store.read(cx);
641 if let Some(user) = user_store.current_user() {
642 let has_subscription_period = user_store.subscription_period().is_some();
643 let plan = user_store.plan().filter(|_| {
644 // Since the user might be on the legacy free plan we filter based on whether we have a subscription period.
645 has_subscription_period
646 });
647
648 let user_avatar = user.avatar_uri.clone();
649 let free_chip_bg = cx
650 .theme()
651 .colors()
652 .editor_background
653 .opacity(0.5)
654 .blend(cx.theme().colors().text_accent.opacity(0.05));
655
656 let pro_chip_bg = cx
657 .theme()
658 .colors()
659 .editor_background
660 .opacity(0.5)
661 .blend(cx.theme().colors().text_accent.opacity(0.2));
662
663 PopoverMenu::new("user-menu")
664 .anchor(Corner::TopRight)
665 .menu(move |window, cx| {
666 ContextMenu::build(window, cx, |menu, _, _cx| {
667 let user_login = user.github_login.clone();
668
669 let (plan_name, label_color, bg_color) = match plan {
670 None | Some(Plan::V1(PlanV1::ZedFree) | Plan::V2(PlanV2::ZedFree)) => {
671 ("Free", Color::Default, free_chip_bg)
672 }
673 Some(Plan::V1(PlanV1::ZedProTrial) | Plan::V2(PlanV2::ZedProTrial)) => {
674 ("Pro Trial", Color::Accent, pro_chip_bg)
675 }
676 Some(Plan::V1(PlanV1::ZedPro) | Plan::V2(PlanV2::ZedPro)) => {
677 ("Pro", Color::Accent, pro_chip_bg)
678 }
679 };
680
681 menu.custom_entry(
682 move |_window, _cx| {
683 let user_login = user_login.clone();
684
685 h_flex()
686 .w_full()
687 .justify_between()
688 .child(Label::new(user_login))
689 .child(
690 Chip::new(plan_name.to_string())
691 .bg_color(bg_color)
692 .label_color(label_color),
693 )
694 .into_any_element()
695 },
696 move |_, cx| {
697 cx.open_url(&zed_urls::account_url(cx));
698 },
699 )
700 .separator()
701 .action("Settings", zed_actions::OpenSettings.boxed_clone())
702 .action(
703 "Settings Profiles",
704 zed_actions::settings_profile_selector::Toggle.boxed_clone(),
705 )
706 .action("Keymap Editor", Box::new(zed_actions::OpenKeymapEditor))
707 .action(
708 "Themes…",
709 zed_actions::theme_selector::Toggle::default().boxed_clone(),
710 )
711 .action(
712 "Icon Themes…",
713 zed_actions::icon_theme_selector::Toggle::default().boxed_clone(),
714 )
715 .action(
716 "Extensions",
717 zed_actions::Extensions::default().boxed_clone(),
718 )
719 .separator()
720 .action("Sign Out", client::SignOut.boxed_clone())
721 })
722 .into()
723 })
724 .trigger_with_tooltip(
725 ButtonLike::new("user-menu")
726 .child(
727 h_flex()
728 .gap_0p5()
729 .children(
730 TitleBarSettings::get_global(cx)
731 .show_user_picture
732 .then(|| Avatar::new(user_avatar)),
733 )
734 .child(
735 Icon::new(IconName::ChevronDown)
736 .size(IconSize::Small)
737 .color(Color::Muted),
738 ),
739 )
740 .style(ButtonStyle::Subtle),
741 Tooltip::text("Toggle User Menu"),
742 )
743 .anchor(gpui::Corner::TopRight)
744 } else {
745 PopoverMenu::new("user-menu")
746 .anchor(Corner::TopRight)
747 .menu(|window, cx| {
748 ContextMenu::build(window, cx, |menu, _, _| {
749 menu.action("Settings", zed_actions::OpenSettings.boxed_clone())
750 .action(
751 "Settings Profiles",
752 zed_actions::settings_profile_selector::Toggle.boxed_clone(),
753 )
754 .action("Key Bindings", Box::new(zed_actions::OpenKeymapEditor))
755 .action(
756 "Themes…",
757 zed_actions::theme_selector::Toggle::default().boxed_clone(),
758 )
759 .action(
760 "Icon Themes…",
761 zed_actions::icon_theme_selector::Toggle::default().boxed_clone(),
762 )
763 .action(
764 "Extensions",
765 zed_actions::Extensions::default().boxed_clone(),
766 )
767 })
768 .into()
769 })
770 .trigger_with_tooltip(
771 IconButton::new("user-menu", IconName::ChevronDown).icon_size(IconSize::Small),
772 Tooltip::text("Toggle User Menu"),
773 )
774 }
775 }
776}