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