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