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