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                "Debugger Onboarding",
279                IconName::Debug,
280                "The Debugger",
281                None,
282                zed_actions::debugger::OpenOnboardingModal.boxed_clone(),
283                cx,
284            )
285        });
286
287        let platform_titlebar = cx.new(|_| PlatformTitleBar::new(id));
288
289        Self {
290            platform_titlebar,
291            application_menu,
292            workspace: workspace.weak_handle(),
293            project,
294            user_store,
295            client,
296            _subscriptions: subscriptions,
297            banner,
298            screen_share_popover_handle: Default::default(),
299        }
300    }
301
302    fn render_ssh_project_host(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
303        let options = self.project.read(cx).ssh_connection_options(cx)?;
304        let host: SharedString = options.connection_string().into();
305
306        let nickname = options
307            .nickname
308            .clone()
309            .map(|nick| nick.into())
310            .unwrap_or_else(|| host.clone());
311
312        let (indicator_color, meta) = match self.project.read(cx).ssh_connection_state(cx)? {
313            remote::ConnectionState::Connecting => (Color::Info, format!("Connecting to: {host}")),
314            remote::ConnectionState::Connected => (Color::Success, format!("Connected to: {host}")),
315            remote::ConnectionState::HeartbeatMissed => (
316                Color::Warning,
317                format!("Connection attempt to {host} missed. Retrying..."),
318            ),
319            remote::ConnectionState::Reconnecting => (
320                Color::Warning,
321                format!("Lost connection to {host}. Reconnecting..."),
322            ),
323            remote::ConnectionState::Disconnected => {
324                (Color::Error, format!("Disconnected from {host}"))
325            }
326        };
327
328        let icon_color = match self.project.read(cx).ssh_connection_state(cx)? {
329            remote::ConnectionState::Connecting => Color::Info,
330            remote::ConnectionState::Connected => Color::Default,
331            remote::ConnectionState::HeartbeatMissed => Color::Warning,
332            remote::ConnectionState::Reconnecting => Color::Warning,
333            remote::ConnectionState::Disconnected => Color::Error,
334        };
335
336        let meta = SharedString::from(meta);
337
338        Some(
339            ButtonLike::new("ssh-server-icon")
340                .child(
341                    h_flex()
342                        .gap_2()
343                        .max_w_32()
344                        .child(
345                            IconWithIndicator::new(
346                                Icon::new(IconName::Server)
347                                    .size(IconSize::Small)
348                                    .color(icon_color),
349                                Some(Indicator::dot().color(indicator_color)),
350                            )
351                            .indicator_border_color(Some(cx.theme().colors().title_bar_background))
352                            .into_any_element(),
353                        )
354                        .child(
355                            Label::new(nickname.clone())
356                                .size(LabelSize::Small)
357                                .truncate(),
358                        ),
359                )
360                .tooltip(move |window, cx| {
361                    Tooltip::with_meta(
362                        "Remote Project",
363                        Some(&OpenRemote {
364                            from_existing_connection: false,
365                            create_new_window: false,
366                        }),
367                        meta.clone(),
368                        window,
369                        cx,
370                    )
371                })
372                .on_click(|_, window, cx| {
373                    window.dispatch_action(
374                        OpenRemote {
375                            from_existing_connection: false,
376                            create_new_window: false,
377                        }
378                        .boxed_clone(),
379                        cx,
380                    );
381                })
382                .into_any_element(),
383        )
384    }
385
386    pub fn render_project_host(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
387        if self.project.read(cx).is_via_ssh() {
388            return self.render_ssh_project_host(cx);
389        }
390
391        if self.project.read(cx).is_disconnected(cx) {
392            return Some(
393                Button::new("disconnected", "Disconnected")
394                    .disabled(true)
395                    .color(Color::Disabled)
396                    .style(ButtonStyle::Subtle)
397                    .label_size(LabelSize::Small)
398                    .into_any_element(),
399            );
400        }
401
402        let host = self.project.read(cx).host()?;
403        let host_user = self.user_store.read(cx).get_cached_user(host.user_id)?;
404        let participant_index = self
405            .user_store
406            .read(cx)
407            .participant_indices()
408            .get(&host_user.id)?;
409        Some(
410            Button::new("project_owner_trigger", host_user.github_login.clone())
411                .color(Color::Player(participant_index.0))
412                .style(ButtonStyle::Subtle)
413                .label_size(LabelSize::Small)
414                .tooltip(Tooltip::text(format!(
415                    "{} is sharing this project. Click to follow.",
416                    host_user.github_login
417                )))
418                .on_click({
419                    let host_peer_id = host.peer_id;
420                    cx.listener(move |this, _, window, cx| {
421                        this.workspace
422                            .update(cx, |workspace, cx| {
423                                workspace.follow(host_peer_id, window, cx);
424                            })
425                            .log_err();
426                    })
427                })
428                .into_any_element(),
429        )
430    }
431
432    pub fn render_project_name(&self, cx: &mut Context<Self>) -> impl IntoElement {
433        let name = {
434            let mut names = self.project.read(cx).visible_worktrees(cx).map(|worktree| {
435                let worktree = worktree.read(cx);
436                worktree.root_name()
437            });
438
439            names.next()
440        };
441        let is_project_selected = name.is_some();
442        let name = if let Some(name) = name {
443            util::truncate_and_trailoff(name, MAX_PROJECT_NAME_LENGTH)
444        } else {
445            "Open recent project".to_string()
446        };
447
448        Button::new("project_name_trigger", name)
449            .when(!is_project_selected, |b| b.color(Color::Muted))
450            .style(ButtonStyle::Subtle)
451            .label_size(LabelSize::Small)
452            .tooltip(move |window, cx| {
453                Tooltip::for_action(
454                    "Recent Projects",
455                    &zed_actions::OpenRecent {
456                        create_new_window: false,
457                    },
458                    window,
459                    cx,
460                )
461            })
462            .on_click(cx.listener(move |_, _, window, cx| {
463                window.dispatch_action(
464                    OpenRecent {
465                        create_new_window: false,
466                    }
467                    .boxed_clone(),
468                    cx,
469                );
470            }))
471    }
472
473    pub fn render_project_branch(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
474        let repository = self.project.read(cx).active_repository(cx)?;
475        let workspace = self.workspace.upgrade()?;
476        let branch_name = {
477            let repo = repository.read(cx);
478            repo.branch
479                .as_ref()
480                .map(|branch| branch.name())
481                .map(|name| util::truncate_and_trailoff(name, MAX_BRANCH_NAME_LENGTH))
482                .or_else(|| {
483                    repo.head_commit.as_ref().map(|commit| {
484                        commit
485                            .sha
486                            .chars()
487                            .take(MAX_SHORT_SHA_LENGTH)
488                            .collect::<String>()
489                    })
490                })
491        }?;
492
493        Some(
494            Button::new("project_branch_trigger", branch_name)
495                .color(Color::Muted)
496                .style(ButtonStyle::Subtle)
497                .label_size(LabelSize::Small)
498                .tooltip(move |window, cx| {
499                    Tooltip::with_meta(
500                        "Recent Branches",
501                        Some(&zed_actions::git::Branch),
502                        "Local branches only",
503                        window,
504                        cx,
505                    )
506                })
507                .on_click(move |_, window, cx| {
508                    let _ = workspace.update(cx, |this, cx| {
509                        window.focus(&this.active_pane().focus_handle(cx));
510                        window.dispatch_action(zed_actions::git::Branch.boxed_clone(), cx);
511                    });
512                })
513                .when(
514                    TitleBarSettings::get_global(cx).show_branch_icon,
515                    |branch_button| {
516                        branch_button
517                            .icon(IconName::GitBranch)
518                            .icon_position(IconPosition::Start)
519                            .icon_color(Color::Muted)
520                            .icon_size(IconSize::Indicator)
521                    },
522                ),
523        )
524    }
525
526    fn window_activation_changed(&mut self, window: &mut Window, cx: &mut Context<Self>) {
527        if window.is_window_active() {
528            ActiveCall::global(cx)
529                .update(cx, |call, cx| call.set_location(Some(&self.project), cx))
530                .detach_and_log_err(cx);
531        } else if cx.active_window().is_none() {
532            ActiveCall::global(cx)
533                .update(cx, |call, cx| call.set_location(None, cx))
534                .detach_and_log_err(cx);
535        }
536        self.workspace
537            .update(cx, |workspace, cx| {
538                workspace.update_active_view_for_followers(window, cx);
539            })
540            .ok();
541    }
542
543    fn active_call_changed(&mut self, cx: &mut Context<Self>) {
544        cx.notify();
545    }
546
547    fn share_project(&mut self, cx: &mut Context<Self>) {
548        let active_call = ActiveCall::global(cx);
549        let project = self.project.clone();
550        active_call
551            .update(cx, |call, cx| call.share_project(project, cx))
552            .detach_and_log_err(cx);
553    }
554
555    fn unshare_project(&mut self, _: &mut Window, cx: &mut Context<Self>) {
556        let active_call = ActiveCall::global(cx);
557        let project = self.project.clone();
558        active_call
559            .update(cx, |call, cx| call.unshare_project(project, cx))
560            .log_err();
561    }
562
563    fn render_connection_status(
564        &self,
565        status: &client::Status,
566        cx: &mut Context<Self>,
567    ) -> Option<AnyElement> {
568        match status {
569            client::Status::ConnectionError
570            | client::Status::ConnectionLost
571            | client::Status::Reauthenticating { .. }
572            | client::Status::Reconnecting { .. }
573            | client::Status::ReconnectionError { .. } => Some(
574                div()
575                    .id("disconnected")
576                    .child(Icon::new(IconName::Disconnected).size(IconSize::Small))
577                    .tooltip(Tooltip::text("Disconnected"))
578                    .into_any_element(),
579            ),
580            client::Status::UpgradeRequired => {
581                let auto_updater = auto_update::AutoUpdater::get(cx);
582                let label = match auto_updater.map(|auto_update| auto_update.read(cx).status()) {
583                    Some(AutoUpdateStatus::Updated { .. }) => "Please restart Zed to Collaborate",
584                    Some(AutoUpdateStatus::Installing { .. })
585                    | Some(AutoUpdateStatus::Downloading { .. })
586                    | Some(AutoUpdateStatus::Checking) => "Updating...",
587                    Some(AutoUpdateStatus::Idle) | Some(AutoUpdateStatus::Errored) | None => {
588                        "Please update Zed to Collaborate"
589                    }
590                };
591
592                Some(
593                    Button::new("connection-status", label)
594                        .label_size(LabelSize::Small)
595                        .on_click(|_, window, cx| {
596                            if let Some(auto_updater) = auto_update::AutoUpdater::get(cx) {
597                                if auto_updater.read(cx).status().is_updated() {
598                                    workspace::reload(cx);
599                                    return;
600                                }
601                            }
602                            auto_update::check(&Default::default(), window, cx);
603                        })
604                        .into_any_element(),
605                )
606            }
607            _ => None,
608        }
609    }
610
611    pub fn render_sign_in_button(&mut self, _: &mut Context<Self>) -> Button {
612        let client = self.client.clone();
613        Button::new("sign_in", "Sign in")
614            .label_size(LabelSize::Small)
615            .on_click(move |_, window, cx| {
616                let client = client.clone();
617                window
618                    .spawn(cx, async move |cx| {
619                        client
620                            .sign_in_with_optional_connect(true, cx)
621                            .await
622                            .notify_async_err(cx);
623                    })
624                    .detach();
625            })
626    }
627
628    pub fn render_user_menu_button(&mut self, cx: &mut Context<Self>) -> impl Element {
629        let user_store = self.user_store.read(cx);
630        if let Some(user) = user_store.current_user() {
631            let has_subscription_period = user_store.subscription_period().is_some();
632            let plan = user_store.plan().filter(|_| {
633                // Since the user might be on the legacy free plan we filter based on whether we have a subscription period.
634                has_subscription_period
635            });
636
637            let user_avatar = user.avatar_uri.clone();
638            let free_chip_bg = cx
639                .theme()
640                .colors()
641                .editor_background
642                .opacity(0.5)
643                .blend(cx.theme().colors().text_accent.opacity(0.05));
644
645            let pro_chip_bg = cx
646                .theme()
647                .colors()
648                .editor_background
649                .opacity(0.5)
650                .blend(cx.theme().colors().text_accent.opacity(0.2));
651
652            PopoverMenu::new("user-menu")
653                .anchor(Corner::TopRight)
654                .menu(move |window, cx| {
655                    ContextMenu::build(window, cx, |menu, _, _cx| {
656                        let user_login = user.github_login.clone();
657
658                        let (plan_name, label_color, bg_color) = match plan {
659                            None | Some(Plan::ZedFree) => ("Free", Color::Default, free_chip_bg),
660                            Some(Plan::ZedProTrial) => ("Pro Trial", Color::Accent, pro_chip_bg),
661                            Some(Plan::ZedPro) => ("Pro", Color::Accent, pro_chip_bg),
662                        };
663
664                        menu.custom_entry(
665                            move |_window, _cx| {
666                                let user_login = user_login.clone();
667
668                                h_flex()
669                                    .w_full()
670                                    .justify_between()
671                                    .child(Label::new(user_login))
672                                    .child(
673                                        Chip::new(plan_name.to_string())
674                                            .bg_color(bg_color)
675                                            .label_color(label_color),
676                                    )
677                                    .into_any_element()
678                            },
679                            move |_, cx| {
680                                cx.open_url(&zed_urls::account_url(cx));
681                            },
682                        )
683                        .separator()
684                        .action("Settings", zed_actions::OpenSettings.boxed_clone())
685                        .action(
686                            "Settings Profiles",
687                            zed_actions::settings_profile_selector::Toggle.boxed_clone(),
688                        )
689                        .action("Key Bindings", Box::new(keybindings::OpenKeymapEditor))
690                        .action(
691                            "Themes…",
692                            zed_actions::theme_selector::Toggle::default().boxed_clone(),
693                        )
694                        .action(
695                            "Icon Themes…",
696                            zed_actions::icon_theme_selector::Toggle::default().boxed_clone(),
697                        )
698                        .action(
699                            "Extensions",
700                            zed_actions::Extensions::default().boxed_clone(),
701                        )
702                        .separator()
703                        .action("Sign Out", client::SignOut.boxed_clone())
704                    })
705                    .into()
706                })
707                .trigger_with_tooltip(
708                    ButtonLike::new("user-menu")
709                        .child(
710                            h_flex()
711                                .gap_0p5()
712                                .children(
713                                    TitleBarSettings::get_global(cx)
714                                        .show_user_picture
715                                        .then(|| Avatar::new(user_avatar)),
716                                )
717                                .child(
718                                    Icon::new(IconName::ChevronDown)
719                                        .size(IconSize::Small)
720                                        .color(Color::Muted),
721                                ),
722                        )
723                        .style(ButtonStyle::Subtle),
724                    Tooltip::text("Toggle User Menu"),
725                )
726                .anchor(gpui::Corner::TopRight)
727        } else {
728            PopoverMenu::new("user-menu")
729                .anchor(Corner::TopRight)
730                .menu(|window, cx| {
731                    ContextMenu::build(window, cx, |menu, _, _| {
732                        menu.action("Settings", zed_actions::OpenSettings.boxed_clone())
733                            .action(
734                                "Settings Profiles",
735                                zed_actions::settings_profile_selector::Toggle.boxed_clone(),
736                            )
737                            .action("Key Bindings", Box::new(keybindings::OpenKeymapEditor))
738                            .action(
739                                "Themes…",
740                                zed_actions::theme_selector::Toggle::default().boxed_clone(),
741                            )
742                            .action(
743                                "Icon Themes…",
744                                zed_actions::icon_theme_selector::Toggle::default().boxed_clone(),
745                            )
746                            .action(
747                                "Extensions",
748                                zed_actions::Extensions::default().boxed_clone(),
749                            )
750                    })
751                    .into()
752                })
753                .trigger_with_tooltip(
754                    IconButton::new("user-menu", IconName::ChevronDown).icon_size(IconSize::Small),
755                    Tooltip::text("Toggle User Menu"),
756                )
757        }
758    }
759}