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