title_bar.rs

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