title_bar.rs

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