BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / views / shell.rs

shell.rs

shell.rs 51.7 KiB Download Raw
1mod team_keys;
2
3use std::sync::Arc;
4
5use gpui_kit::component::{elevation, h_flex, v_flex};
6use gpui_kit::*;
7
8use super::actions::{NewChat, OpenSwitcher, ReplyToHovered, ToggleCallMute};
9use super::activity_panel::{ActivityPanel, ActivityPanelEvent};
10use super::calendar_view::CalendarView;
11use super::call_pop_out::zoom_listener;
12use super::calls_page::CallsPage;
13use super::chat_pop_out;
14use super::connection_banner::render_connection_banner;
15use super::conversation::ConversationView;
16use super::dialog_overlay::render_task_dialog;
17use super::forward_dialog::{ForwardDialog, ForwardDialogEvent};
18use super::image_viewer::{ImageViewer, ImageViewerEvent};
19use super::manage_team_page::ManageTeamPage;
20use super::notice_toast::NoticeToasts;
21use super::profile_card::{ProfileCard, ProfileCardEvent};
22use super::quick_view_pane::{QuickViewEvent, QuickViewPane};
23use super::rail::RailView;
24use super::shortcuts::{
25 ClearChatFilters, DeclineCall, FilterMeetingChats, FilterMutedChats, FilterNonMeetingChats,
26 FilterUnreadChats, FindInChat, HangUpCall, JoinMeetingFromToast, JumpToLastReadOrNewest,
27 NextConversation, OpenActivity, OpenAgents, OpenCalendar, OpenCallsTab, OpenChannelsTab,
28 OpenChatFilter, OpenChatsTab, OpenLobbyList, OpenSaved, OpenSettings, PopOutSelectedChat,
29 PreviousConversation, PushToTalk, Scope, ShowShortcuts, StartAudioCall, StartVideoCall,
30 ToggleCallCamera, ToggleCallHand, ToggleCallShare, ZoomIn, ZoomOut, ZoomReset, ZoomShareIn,
31 ZoomShareOut, ZoomShareReset,
32};
33use super::shortcuts_dialog::{ShortcutsDialog, ShortcutsDialogEvent};
34use super::sidebar::{SidebarEvent, SidebarTab, SidebarView};
35use super::splash::{self, Phase, Splash, StartupFacts};
36use super::status_menu::{own_status_button, settings_more_button};
37use super::status_message_dialog::{StatusMessageDialog, StatusMessageDialogEvent};
38use super::switcher::{Switcher, SwitcherEvent, candidates_from};
39use super::title_bar::{mode_label, render_title_bar, update_button};
40use super::window_zoom::{WindowZoom, change_zoom};
41use crate::activity::ActivityCenter;
42use crate::agents::{AgentRunsEvent, StartDialog, StartDialogEvent, StartRequest};
43use crate::app_state::{AppEvent, AppState, QuickView, Selection, selection_for};
44use crate::call::{CallMedia, CallWindows, ZoomStep};
45use crate::chat_filter::ChatFilterPill;
46use crate::notice::NoticeAction;
47use crate::notify::NotificationCenter;
48use crate::settings::{SettingsDialog, SettingsDialogEvent};
49use crate::settings_section::SettingsSection;
50use crate::sidebar_model::Step;
51use crate::theme;
52use crate::updater::{self, IdleInputs, UpdateStatus};
53use crate::user_activity::{self, UserInput};
54use app_ui_kit::layout::{ISLAND_GAP, SIDEBAR_WIDTH};
55use app_ui_kit::render::hooks::RenderHooks;
56use gpui_kit::prelude::FluentBuilder as _;
57
58pub fn bind_keys(cx: &mut App) {
59 super::composer::bind_keys(cx);
60 super::shortcuts::bind_scopes(
61 cx,
62 &[
63 Scope::Global,
64 Scope::OutsideComposer,
65 Scope::GlobalOverTextFields,
66 Scope::OutsideTextFields,
67 ],
68 );
69}
70
71#[derive(Debug, Clone, Copy)]
72pub enum OpenTarget {
73 Chat(usize),
74 Channel(usize),
75}
76
77#[derive(Default)]
78pub struct Startup {
79 pub switcher_query: Option<String>,
80 pub composer_text: Option<String>,
81 pub reply_to_last: bool,
82 pub launched_by_autostart: bool,
83}
84
85pub struct UserInputHandle(pub Arc<UserInput>);
86
87impl Global for UserInputHandle {}
88
89pub fn install_globals(state: &Entity<AppState>, user_input: Arc<UserInput>, cx: &mut App) {
90 cx.set_global(crate::app_state::AppHandle(state.clone()));
91 cx.set_global(UserInputHandle(user_input));
92 cx.set_global(RenderHooks {
93 open_profile_link: super::profile_card::open_profile_link,
94 jump_to_quoted,
95 inline_image,
96 open_link,
97 });
98}
99
100fn open_link(url: &str, cx: &mut App) {
101 if let Some(handle) = cx.try_global::<crate::app_state::AppHandle>() {
102 let text = opening_link_text(url);
103 handle
104 .0
105 .clone()
106 .update(cx, |state, cx| state.raise_notice(text, None, cx));
107 }
108 cx.open_url(url);
109}
110
111fn opening_link_text(url: &str) -> String {
112 let host = url
113 .split_once("://")
114 .map_or(url, |(_, rest)| rest)
115 .split(['/', '?', '#'])
116 .next()
117 .unwrap_or_default();
118 if host.is_empty() {
119 "Opening link...".to_owned()
120 } else {
121 format!("Opening {host}...")
122 }
123}
124
125fn inline_image(url: &str, cx: &App) -> Option<std::path::PathBuf> {
126 let handle = cx.try_global::<crate::app_state::AppHandle>()?;
127 let entry = handle.0.read(cx).directory.image(url)?;
128 Some(entry.path.clone())
129}
130
131fn jump_to_quoted(message_id: String, cx: &mut App) {
132 let Some(handle) = cx.try_global::<crate::app_state::AppHandle>() else {
133 return;
134 };
135 handle.0.clone().update(cx, |state, cx| {
136 if let Some(selection) = state.selection.clone() {
137 state.jump_to_message(selection, message_id, cx);
138 }
139 });
140}
141
142#[cfg(windows)]
143fn watch_releases(running_tag: &'static str, cx: &mut App) {
144 use app_base::release_feed;
145 cx.spawn(async move |cx| {
146 cx.background_executor()
147 .timer(release_feed::FIRST_CHECK_DELAY)
148 .await;
149 loop {
150 let Some(paths) = updater::current_paths() else {
151 return;
152 };
153 let fetch = cx.update(|cx| release_feed::fetch_update(running_tag, paths, cx));
154 match fetch.await {
155 Ok(Some(tag)) => log::info!("release {tag} downloaded for the next restart"),
156 Ok(None) => {}
157 Err(error) => log::warn!("release check failed: {error}"),
158 }
159 cx.background_executor()
160 .timer(release_feed::CHECK_INTERVAL)
161 .await;
162 }
163 })
164 .detach();
165}
166
167const DEMO_UPDATE_VARIABLE: &str = "TEAMS_DEMO_UPDATE";
168
169/// Entities created with the first main window that a reopened one takes over.
170#[derive(Clone)]
171struct KeptParts {
172 activity: Entity<ActivityCenter>,
173 notifications: Entity<NotificationCenter>,
174 call_windows: Entity<CallWindows>,
175}
176
177impl Global for KeptParts {}
178
179pub struct AppShell {
180 state: Entity<AppState>,
181 rail: Entity<RailView>,
182 sidebar: Entity<SidebarView>,
183 calendar: Entity<CalendarView>,
184 quick_pane: Entity<QuickViewPane>,
185 manage_team_page: Entity<ManageTeamPage>,
186 calls_page: Entity<CallsPage>,
187 shown_quick_view: Option<QuickView>,
188 conversation: Entity<ConversationView>,
189 switcher: Option<Entity<Switcher>>,
190 notifications: Entity<NotificationCenter>,
191 _call_windows: Entity<CallWindows>,
192 forward_dialog: Option<Entity<ForwardDialog>>,
193 image_viewer: Option<Entity<ImageViewer>>,
194 status_dialog: Option<Entity<StatusMessageDialog>>,
195 shortcuts_dialog: Option<Entity<ShortcutsDialog>>,
196 agent_dialog: Option<Entity<StartDialog>>,
197 settings_dialog: Option<Entity<SettingsDialog>>,
198 profile_card: Option<Entity<ProfileCard>>,
199 focus_handle: FocusHandle,
200 open_target: Option<OpenTarget>,
201 update: UpdateStatus,
202 splash: Splash,
203 toasts: NoticeToasts,
204 user_input: Arc<UserInput>,
205 _subscription: Subscription,
206 _panel_subscriptions: [Subscription; 2],
207 _sidebar_subscription: Subscription,
208 _agents_subscription: Option<Subscription>,
209 _agent_subscription: Option<Subscription>,
210 _escape_observation: Subscription,
211 _activation_observation: Subscription,
212 _appearance_observation: Subscription,
213}
214
215impl AppShell {
216 #[cfg(test)]
217 pub(crate) fn set_update_status(&mut self, update: UpdateStatus, cx: &mut Context<Self>) {
218 self.update = update;
219 cx.notify();
220 }
221
222 fn focus_opened_quick_view(&mut self, window: &mut Window, cx: &mut Context<Self>) {
223 let quick_view = self.state.read(cx).quick_view;
224 if std::mem::replace(&mut self.shown_quick_view, quick_view) != quick_view
225 && quick_view.is_some()
226 {
227 self.restore_focus(window, cx);
228 }
229 }
230
231 fn leave_calendar_on_selection(&mut self, cx: &mut Context<Self>) {
232 if self.sidebar.read(cx).tab() != SidebarTab::Calendar {
233 return;
234 }
235 let selection = self.state.read(cx).selection.clone();
236 let sidebar = self.sidebar.clone();
237 cx.defer(move |cx| {
238 sidebar.update(cx, |sidebar, cx| match selection {
239 Some(Selection::Channel(_)) => sidebar.show_channels(cx),
240 Some(Selection::Chat(_)) => sidebar.show_chats(cx),
241 None => {}
242 })
243 });
244 }
245
246 pub fn new(
247 state: Entity<AppState>,
248 open_target: Option<OpenTarget>,
249 startup: Startup,
250 window: &mut Window,
251 cx: &mut Context<Self>,
252 ) -> Self {
253 let kept = cx.try_global::<KeptParts>().cloned();
254 let reopened = kept.is_some();
255 let activity = match &kept {
256 Some(kept) => {
257 kept.activity
258 .update(cx, |activity, _| activity.attach_main_window(window));
259 kept.activity.clone()
260 }
261 None => {
262 let call_media = cx.new(|_| CallMedia);
263 state.update(cx, |state, _| state.call_media = Some(call_media.clone()));
264 cx.new(|cx| ActivityCenter::new(state.clone(), window, cx))
265 }
266 };
267 let activity_panel = cx.new(|cx| ActivityPanel::new(state.clone(), activity.clone(), cx));
268 let quick_pane = cx.new(|cx| QuickViewPane::new(state.clone(), activity.clone(), cx));
269 let manage_team_page = cx.new(|cx| ManageTeamPage::new(state.clone(), window, cx));
270 let calls_page = cx.new(|cx| CallsPage::new(state.clone(), window, cx));
271 let agents_panel = crate::agents::runs_handle(cx)
272 .map(|runs| cx.new(|cx| crate::agents::AgentsPanel::new(runs, cx)));
273 let agents_subscription = agents_panel.as_ref().map(|panel| {
274 cx.subscribe(
275 panel,
276 |this, _, event: &crate::agents::AgentsPanelEvent, cx| {
277 let crate::agents::AgentsPanelEvent::Open {
278 conversation_id,
279 message_id,
280 } = event;
281 this.open_message(conversation_id, message_id, cx);
282 },
283 )
284 });
285 let panel_subscriptions = [
286 cx.subscribe(
287 &activity_panel,
288 |this, _, event: &ActivityPanelEvent, cx| match event {
289 ActivityPanelEvent::OpenSettings => this.state.update(cx, |state, cx| {
290 state.open_settings(SettingsSection::Notifications, cx)
291 }),
292 ActivityPanelEvent::Open {
293 conversation_id,
294 message_id,
295 link,
296 } => {
297 if !this.open_message(conversation_id, message_id, cx)
298 && let Some(link) = link
299 {
300 cx.open_url(link);
301 }
302 }
303 },
304 ),
305 cx.subscribe(&quick_pane, |this, _, event: &QuickViewEvent, cx| {
306 let QuickViewEvent::Open {
307 conversation_id,
308 message_id,
309 } = event;
310 this.state
311 .update(cx, |state, cx| state.close_quick_view(cx));
312 this.open_message(
313 conversation_id,
314 message_id.as_deref().unwrap_or_default(),
315 cx,
316 );
317 }),
318 ];
319 let agent_subscription = crate::agents::runs_handle(cx).map(|runs| {
320 cx.subscribe_in(
321 &runs,
322 window,
323 |this, _, event: &AgentRunsEvent, window, cx| match event {
324 AgentRunsEvent::StartRequested(request) => {
325 this.open_agent_dialog(request.clone(), window, cx)
326 }
327 AgentRunsEvent::OpenSettings => {
328 this.open_settings(SettingsSection::Agents, window, cx)
329 }
330 AgentRunsEvent::Finished(_) => {}
331 },
332 )
333 });
334 let sidebar =
335 cx.new(|cx| SidebarView::new(state.clone(), activity_panel, agents_panel, cx));
336 let sidebar_subscription = cx.subscribe_in(
337 &sidebar,
338 window,
339 |this, _, event: &SidebarEvent, window, cx| match event {
340 SidebarEvent::RestoreFocus => this.restore_focus(window, cx),
341 SidebarEvent::TabChanged => {
342 if this.sidebar.read(cx).tab() == SidebarTab::Calendar {
343 this.restore_focus(window, cx);
344 }
345 cx.notify();
346 }
347 SidebarEvent::NewChannelPost => this.conversation.update(cx, |conversation, cx| {
348 conversation.start_channel_post(window, cx)
349 }),
350 },
351 );
352 let calendar = cx.new(|cx| CalendarView::new(state.clone(), cx));
353 let rail = cx.new(|cx| RailView::new(state.clone(), activity.clone(), sidebar.clone(), cx));
354 let conversation = cx.new(|cx| ConversationView::new(state.clone(), window, cx));
355 let subscription =
356 cx.subscribe_in(&state, window, |this, _, event: &AppEvent, window, cx| {
357 if matches!(event, AppEvent::Sidebar | AppEvent::Status) {
358 this.apply_open_target(cx);
359 }
360 if matches!(event, AppEvent::Sidebar) {
361 this.focus_opened_quick_view(window, cx);
362 }
363 if matches!(event, AppEvent::Selection) {
364 this.leave_calendar_on_selection(cx);
365 }
366 if matches!(event, AppEvent::Forward) {
367 this.open_forward_dialog(window, cx);
368 }
369 if matches!(event, AppEvent::ImageViewer) {
370 this.open_image_viewer(window, cx);
371 }
372 if matches!(event, AppEvent::StatusMessage) {
373 this.open_status_dialog(window, cx);
374 }
375 if let AppEvent::Settings(section) = event {
376 this.open_settings(*section, window, cx);
377 }
378 if matches!(event, AppEvent::Profile) {
379 this.open_profile_card(window, cx);
380 }
381 cx.notify();
382 });
383 let focus_handle = cx.focus_handle();
384 window.focus(&focus_handle, cx);
385 // The tray, notifications and calls outlive a main window closed into the tray.
386 let (notifications, call_windows) = match kept {
387 Some(kept) => {
388 kept.notifications.update(cx, |notifications, _| {
389 notifications.attach_main_window(window)
390 });
391 kept.call_windows.update(cx, |call_windows, _| {
392 call_windows.attach_main_window(window)
393 });
394 (kept.notifications, kept.call_windows)
395 }
396 None => {
397 let notifications = cx
398 .new(|cx| NotificationCenter::new(state.clone(), activity.clone(), window, cx));
399 let call_windows = cx.new(|cx| CallWindows::new(state.clone(), window, cx));
400 cx.set_global(KeptParts {
401 activity: activity.clone(),
402 notifications: notifications.clone(),
403 call_windows: call_windows.clone(),
404 });
405 (notifications, call_windows)
406 }
407 };
408 let user_input = cx.global::<UserInputHandle>().0.clone();
409 let escape_observation = cx.observe_keystrokes(|this, event, _, cx| {
410 this.user_input.touch();
411 if event.keystroke.key == "escape" && event.action.is_none() {
412 this.state
413 .update(cx, |state, cx| state.escape_call_fullscreen(cx));
414 }
415 });
416 let appearance_observation = cx.observe_window_appearance(window, |_, window, cx| {
417 crate::active_appearance::system_appearance_changed(window.appearance(), cx);
418 });
419 let activation_observation = cx.observe_window_activation(window, |this, window, cx| {
420 if window.is_window_active() {
421 this.state
422 .update(cx, |state, cx| state.refresh_calendar(cx));
423 } else {
424 this.state
425 .update(cx, |state, cx| state.release_push_to_talk(cx));
426 }
427 });
428 let closing = notifications.clone();
429 window.on_window_should_close(cx, move |_, cx| {
430 !closing.update(cx, |notifications, cx| notifications.intercept_close(cx))
431 });
432 let mut shell = AppShell {
433 state,
434 rail,
435 sidebar,
436 calendar,
437 quick_pane,
438 manage_team_page,
439 calls_page,
440 shown_quick_view: None,
441 conversation,
442 switcher: None,
443 notifications,
444 _call_windows: call_windows,
445 forward_dialog: None,
446 image_viewer: None,
447 status_dialog: None,
448 shortcuts_dialog: None,
449 agent_dialog: None,
450 settings_dialog: None,
451 profile_card: None,
452 focus_handle,
453 open_target,
454 update: UpdateStatus::UpToDate,
455 splash: Splash::default(),
456 toasts: NoticeToasts::default(),
457 user_input,
458 _subscription: subscription,
459 _panel_subscriptions: panel_subscriptions,
460 _sidebar_subscription: sidebar_subscription,
461 _agents_subscription: agents_subscription,
462 _agent_subscription: agent_subscription,
463 _escape_observation: escape_observation,
464 _activation_observation: activation_observation,
465 _appearance_observation: appearance_observation,
466 };
467 shell.apply_open_target(cx);
468 shell
469 .state
470 .update(cx, |state, cx| state.refresh_connection_banner(cx));
471 if shell.state.read(cx).mode.demo && std::env::var_os(DEMO_UPDATE_VARIABLE).is_some() {
472 shell.update = UpdateStatus::Ready;
473 }
474 let Startup {
475 switcher_query,
476 composer_text,
477 reply_to_last,
478 launched_by_autostart,
479 } = startup;
480 if !reopened
481 && shell
482 .notifications
483 .read(cx)
484 .startup()
485 .starts_hidden(launched_by_autostart)
486 {
487 cx.defer_in(window, |this, window, cx| {
488 this.notifications.update(cx, |notifications, cx| {
489 notifications.start_in_background(window, cx)
490 })
491 });
492 }
493 if let Some(query) = switcher_query {
494 shell.toggle_switcher(&query, window, cx);
495 }
496 if composer_text.is_some() || reply_to_last {
497 cx.defer_in(window, move |this, window, cx| {
498 this.conversation.update(cx, |conversation, cx| {
499 if reply_to_last {
500 conversation.reply_to_latest_from_others(window, cx);
501 }
502 if let Some(text) = composer_text {
503 conversation.set_composer_text(&text, window, cx);
504 }
505 });
506 });
507 }
508 #[cfg(any(windows, target_os = "linux"))]
509 cx.spawn_in(window, async move |this, cx| {
510 loop {
511 cx.background_executor().timer(updater::POLL_INTERVAL).await;
512 if this
513 .update_in(cx, |this, window, cx| this.poll_update(window, cx))
514 .is_err()
515 {
516 break;
517 }
518 }
519 })
520 .detach();
521 // Linux asks before downloading (`linux_update`); Windows downloads quietly.
522 #[cfg(windows)]
523 if let Some(running_tag) = app_base::version::release_tag() {
524 watch_releases(running_tag, cx);
525 }
526 shell
527 }
528
529 #[cfg_attr(not(any(windows, target_os = "linux")), allow(dead_code))]
530 fn poll_update(&mut self, window: &mut Window, cx: &mut Context<Self>) {
531 if matches!(
532 self.update,
533 UpdateStatus::Failed(_) | UpdateStatus::Installing
534 ) {
535 return;
536 }
537 let Some(paths) = updater::current_paths() else {
538 return;
539 };
540 if self.update == UpdateStatus::UpToDate {
541 if !updater::check(&paths) {
542 return;
543 }
544 self.update = UpdateStatus::Ready;
545 let update_exe = paths.update_exe.clone();
546 cx.background_spawn(async move { updater::prescan(&update_exe) })
547 .detach();
548 }
549 let conversation = self.conversation.read(cx);
550 let idle = updater::is_idle(IdleInputs {
551 window_active: window.is_window_active(),
552 composer_empty: conversation.composer_is_empty(cx),
553 send_in_flight: conversation.send_in_flight(),
554 });
555 // On Linux only the user restarts: the update dialog or the title bar button.
556 if idle && cfg!(not(target_os = "linux")) {
557 self.restart_into_update(cx);
558 }
559 cx.notify();
560 }
561
562 fn restart_into_update(&mut self, cx: &mut Context<Self>) {
563 if self.update == UpdateStatus::Installing {
564 return;
565 }
566 let Some(paths) = updater::current_paths() else {
567 return;
568 };
569 self.update = UpdateStatus::Installing;
570 cx.notify();
571 cx.spawn(async move |this, cx| {
572 let result = cx
573 .background_spawn(async move { updater::install_and_relaunch(&paths) })
574 .await;
575 let _ = this.update(cx, |this, cx| {
576 match result {
577 Ok(()) => cx.quit(),
578 Err(message) => this.update = UpdateStatus::Failed(message),
579 }
580 cx.notify();
581 });
582 })
583 .detach();
584 }
585
586 fn apply_open_target(&mut self, cx: &mut Context<Self>) {
587 let Some(target) = self.open_target else {
588 return;
589 };
590 let sidebar = &self.state.read(cx).sidebar;
591 let selection = match target {
592 OpenTarget::Chat(index) => sidebar
593 .chats
594 .get(index)
595 .map(|chat| Selection::Chat(chat.id.clone())),
596 OpenTarget::Channel(index) => sidebar
597 .teams
598 .iter()
599 .flat_map(|team| team.channels.iter())
600 .nth(index)
601 .map(|channel| Selection::Channel(channel.id.clone())),
602 };
603 if let Some(selection) = selection {
604 self.open_target = None;
605 self.state
606 .update(cx, |state, cx| state.select(selection, cx));
607 }
608 }
609
610 fn toggle_switcher(
611 &mut self,
612 initial_query: &str,
613 window: &mut Window,
614 cx: &mut Context<Self>,
615 ) {
616 if self.switcher.take().is_some() {
617 self.restore_focus(window, cx);
618 cx.notify();
619 return;
620 }
621 self.close_image_viewer(window, cx);
622 let candidates = candidates_from(self.state.read(cx));
623 let app = self.state.clone();
624 let switcher = cx.new(|cx| Switcher::new(app, candidates, initial_query, window, cx));
625 cx.subscribe_in(
626 &switcher,
627 window,
628 |this, _, event: &SwitcherEvent, window, cx| {
629 match event {
630 SwitcherEvent::Pick(selection) => {
631 let selection = selection.clone();
632 this.state
633 .update(cx, |state, cx| state.select(selection, cx));
634 }
635 SwitcherEvent::PickMessage {
636 selection,
637 message_id,
638 } => {
639 let (selection, message_id) = (selection.clone(), message_id.clone());
640 this.state.update(cx, |state, cx| {
641 state.jump_to_message(selection, message_id, cx)
642 });
643 }
644 SwitcherEvent::PickPerson { user_id } => {
645 let user_id = user_id.clone();
646 this.state
647 .update(cx, |state, cx| state.open_chat_with(&user_id, cx));
648 }
649 SwitcherEvent::Close => {}
650 }
651 this.switcher = None;
652 this.restore_focus(window, cx);
653 cx.notify();
654 },
655 )
656 .detach();
657 self.switcher = Some(switcher);
658 cx.notify();
659 }
660
661 fn open_message(
662 &mut self,
663 conversation_id: &str,
664 message_id: &str,
665 cx: &mut Context<Self>,
666 ) -> bool {
667 let Some(selection) = selection_for(&self.state.read(cx).sidebar, conversation_id) else {
668 return false;
669 };
670 let message_id = message_id.to_owned();
671 self.state.update(cx, |state, cx| {
672 if message_id.is_empty() {
673 state.select(selection, cx)
674 } else {
675 state.jump_to_message(selection, message_id, cx)
676 }
677 });
678 true
679 }
680
681 fn open_status_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
682 if !self
683 .state
684 .update(cx, |state, _| state.take_status_message_request())
685 {
686 return;
687 }
688 self.close_image_viewer(window, cx);
689 self.switcher = None;
690 let app = self.state.clone();
691 let dialog = cx.new(|cx| StatusMessageDialog::new(app, window, cx));
692 cx.subscribe_in(
693 &dialog,
694 window,
695 |this, _, _: &StatusMessageDialogEvent, window, cx| {
696 this.status_dialog = None;
697 this.restore_focus(window, cx);
698 cx.notify();
699 },
700 )
701 .detach();
702 self.status_dialog = Some(dialog);
703 cx.notify();
704 }
705
706 fn open_agent_dialog(
707 &mut self,
708 request: StartRequest,
709 window: &mut Window,
710 cx: &mut Context<Self>,
711 ) {
712 let Some(runs) = crate::agents::runs_handle(cx) else {
713 return;
714 };
715 let settings = runs.read(cx).settings();
716 let Some(action) = settings
717 .actions
718 .iter()
719 .find(|action| action.id == request.action_id)
720 .cloned()
721 else {
722 return;
723 };
724 let agent_name = settings
725 .agents
726 .iter()
727 .find(|agent| agent.id == action.agent_id)
728 .map(|agent| agent.name.clone())
729 .unwrap_or_default();
730 self.switcher = None;
731 let app = self.state.clone();
732 let dialog = cx.new(|cx| StartDialog::new(app, request, action, &agent_name, window, cx));
733 cx.subscribe_in(
734 &dialog,
735 window,
736 |this, _, _: &StartDialogEvent, window, cx| {
737 this.agent_dialog = None;
738 window.focus(&this.focus_handle, cx);
739 cx.notify();
740 },
741 )
742 .detach();
743 self.agent_dialog = Some(dialog);
744 cx.notify();
745 }
746
747 fn open_settings(
748 &mut self,
749 section: SettingsSection,
750 window: &mut Window,
751 cx: &mut Context<Self>,
752 ) {
753 if let Some(dialog) = &self.settings_dialog {
754 dialog.update(cx, |dialog, cx| dialog.show(section, window, cx));
755 return;
756 }
757 self.close_image_viewer(window, cx);
758 self.switcher = None;
759 let (app, center) = (self.state.clone(), self.notifications.clone());
760 let dialog = cx.new(|cx| SettingsDialog::new(app, center, section, window, cx));
761 cx.subscribe_in(
762 &dialog,
763 window,
764 |this, _, _: &SettingsDialogEvent, window, cx| {
765 this.settings_dialog = None;
766 this.restore_focus(window, cx);
767 cx.notify();
768 },
769 )
770 .detach();
771 self.settings_dialog = Some(dialog);
772 cx.notify();
773 }
774
775 fn toggle_shortcuts_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
776 if self.shortcuts_dialog.take().is_some() {
777 self.restore_focus(window, cx);
778 cx.notify();
779 return;
780 }
781 self.close_image_viewer(window, cx);
782 self.switcher = None;
783 let dialog = cx.new(|cx| ShortcutsDialog::new(window, cx));
784 cx.subscribe_in(
785 &dialog,
786 window,
787 |this, _, _: &ShortcutsDialogEvent, window, cx| {
788 this.shortcuts_dialog = None;
789 this.restore_focus(window, cx);
790 cx.notify();
791 },
792 )
793 .detach();
794 self.shortcuts_dialog = Some(dialog);
795 cx.notify();
796 }
797
798 fn open_profile_card(&mut self, window: &mut Window, cx: &mut Context<Self>) {
799 let Some(request) = self
800 .state
801 .update(cx, |state, _| state.take_profile_request())
802 else {
803 return;
804 };
805 self.close_image_viewer(window, cx);
806 if let Some(card) = &self.profile_card {
807 card.update(cx, |card, cx| {
808 card.move_to(request.user_id, request.anchor, cx)
809 });
810 return;
811 }
812 let app = self.state.clone();
813 let card = cx.new(|cx| ProfileCard::new(app, request.user_id, request.anchor, window, cx));
814 cx.subscribe_in(
815 &card,
816 window,
817 |this, _, _: &ProfileCardEvent, window, cx| {
818 this.profile_card = None;
819 this.restore_focus(window, cx);
820 cx.notify();
821 },
822 )
823 .detach();
824 self.profile_card = Some(card);
825 cx.notify();
826 }
827
828 fn open_image_viewer(&mut self, window: &mut Window, cx: &mut Context<Self>) {
829 let Some(request) = self
830 .state
831 .update(cx, |state, _| state.take_image_viewer_request())
832 else {
833 return;
834 };
835 self.switcher = None;
836 let app = self.state.clone();
837 let viewer = cx.new(|cx| ImageViewer::new(app, request, window, cx));
838 cx.subscribe_in(
839 &viewer,
840 window,
841 |this, _, _: &ImageViewerEvent, window, cx| {
842 this.image_viewer = None;
843 window.focus(&this.focus_handle, cx);
844 cx.notify();
845 },
846 )
847 .detach();
848 self.image_viewer = Some(viewer);
849 cx.notify();
850 }
851
852 fn start_call_in_open_chat(&mut self, with_video: bool, cx: &mut Context<Self>) {
853 self.state.update(cx, |state, cx| {
854 if let Some(Selection::Chat(chat_id)) = state.selection.clone() {
855 if with_video {
856 state.start_chat_video_call(&chat_id, cx);
857 } else {
858 state.start_chat_call(&chat_id, cx);
859 }
860 }
861 });
862 }
863
864 fn close_image_viewer(&mut self, window: &mut Window, cx: &mut Context<Self>) {
865 if self.image_viewer.take().is_some() {
866 window.focus(&self.focus_handle, cx);
867 cx.notify();
868 }
869 }
870
871 fn restore_focus(&self, window: &mut Window, cx: &mut Context<Self>) {
872 match &self.image_viewer {
873 Some(viewer) => {
874 let handle = viewer.read(cx).focus_handle();
875 window.focus(&handle, cx)
876 }
877 None => window.focus(&self.focus_handle, cx),
878 }
879 }
880
881 fn open_forward_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
882 let Some(source) = self
883 .state
884 .update(cx, |state, _| state.take_forward_request())
885 else {
886 return;
887 };
888 self.switcher = None;
889 let candidates = candidates_from(self.state.read(cx));
890 let app = self.state.clone();
891 let dialog = cx.new(|cx| ForwardDialog::new(app, source, candidates, window, cx));
892 cx.subscribe_in(
893 &dialog,
894 window,
895 |this, _, event: &ForwardDialogEvent, window, cx| {
896 this.forward_dialog = None;
897 this.restore_focus(window, cx);
898 if let ForwardDialogEvent::Sent { target, title } = event {
899 let target = target.clone();
900 let open = NoticeAction::new("Open", move |state, cx| {
901 state.select(target.clone(), cx)
902 });
903 this.state.update(cx, |state, cx| {
904 state.cancel_forward_selection(cx);
905 state.raise_notice(format!("Forwarded to {title}"), Some(open), cx)
906 });
907 }
908 cx.notify();
909 },
910 )
911 .detach();
912 self.forward_dialog = Some(dialog);
913 cx.notify();
914 }
915}
916
917impl AppShell {
918 fn render_splash(&mut self, cx: &mut Context<Self>) -> Option<AnyElement> {
919 let phase = if self.splash.is_up() {
920 let opening = self.conversation.read(cx).opening_title();
921 let state = self.state.read(cx);
922 let phase = splash::phase(&StartupFacts {
923 elapsed: self.splash.elapsed(),
924 connection: &state.connection,
925 browser_sign_in: &state.browser_sign_in,
926 has_chats: !state.sidebar.chats.is_empty() || !state.sidebar.teams.is_empty(),
927 synced: state.last_sync.is_some(),
928 demo: state.mode.demo,
929 opening,
930 });
931 // Poll only when the progress bar is not already driving repaints
932 // (idle/stopped bar or reduced motion); otherwise the sweep animation
933 // wakes the splash often enough for BrowserSignIn status updates.
934 let needs_poll = match &phase {
935 Phase::Loading { running, .. } => !*running || cx.reduce_motion(),
936 Phase::Ready => false,
937 };
938 if needs_poll && !self.splash.recheck_scheduled {
939 self.splash.recheck_scheduled = true;
940 cx.spawn(async move |this, cx| {
941 cx.background_executor().timer(splash::STILL_RECHECK).await;
942 this.update(cx, |this, cx| {
943 this.splash.recheck_scheduled = false;
944 cx.notify();
945 })
946 .ok();
947 })
948 .detach();
949 }
950 if phase == Phase::Ready {
951 self.splash.hide();
952 cx.spawn(async move |this, cx| {
953 cx.background_executor().timer(splash::CONTENT_RISE).await;
954 this.update(cx, |_, cx| cx.notify()).ok();
955 })
956 .detach();
957 }
958 phase
959 } else {
960 Phase::Ready
961 };
962 self.splash.render(&phase, cx)
963 }
964
965 fn islands(
966 &self,
967 show_sidebar: bool,
968 calendar_open: bool,
969 quick_view_open: bool,
970 calls_open: bool,
971 manage_team_open: bool,
972 ) -> Div {
973 h_flex()
974 .debug_selector(|| "shell/islands".into())
975 .flex_1()
976 .min_h_0()
977 .w_full()
978 .when(show_sidebar, |islands| islands.gap(px(ISLAND_GAP)))
979 .pr(px(ISLAND_GAP))
980 .pb(px(ISLAND_GAP))
981 .child(h_flex().h_full().flex_none().child(self.rail.clone()).when(
982 show_sidebar,
983 |group| {
984 group.child(
985 self.sidebar.clone().cached(
986 StyleRefinement::default()
987 .w(px(SIDEBAR_WIDTH))
988 .h_full()
989 .flex_none(),
990 ),
991 )
992 },
993 ))
994 .child(match () {
995 _ if calls_open => self
996 .calls_page
997 .clone()
998 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
999 .into_any_element(),
1000 _ if manage_team_open => self
1001 .manage_team_page
1002 .clone()
1003 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
1004 .into_any_element(),
1005 _ if quick_view_open => self
1006 .quick_pane
1007 .clone()
1008 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
1009 .into_any_element(),
1010 _ if calendar_open => self
1011 .calendar
1012 .clone()
1013 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
1014 .into_any_element(),
1015 _ => self
1016 .conversation
1017 .clone()
1018 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
1019 .into_any_element(),
1020 })
1021 }
1022}
1023
1024impl Render for AppShell {
1025 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
1026 let open_dialogs = [
1027 self.state.read(cx).task_dialog.is_some(),
1028 self.forward_dialog.is_some(),
1029 self.status_dialog.is_some(),
1030 self.shortcuts_dialog.is_some(),
1031 self.agent_dialog.is_some(),
1032 self.settings_dialog.is_some(),
1033 ]
1034 .into_iter()
1035 .filter(|open| *open)
1036 .count();
1037 elevation::set_app_modal_layers(window, open_dialogs, cx);
1038 if open_dialogs > 0 {
1039 crate::inline_video::stop(cx);
1040 }
1041 if let Some(dialog) = self
1042 .state
1043 .read(cx)
1044 .task_dialog
1045 .as_ref()
1046 .map(|dialog| (dialog.scope.clone(), dialog.card.clone()))
1047 {
1048 self.state.update(cx, |state, cx| {
1049 state.ensure_card_inputs(&dialog.0, &dialog.1, window, cx)
1050 });
1051 }
1052 if let Some(me) = self.state.read(cx).directory.me.clone() {
1053 let app = self.state.clone();
1054 cx.defer(move |cx| {
1055 app.update(cx, |state, cx| {
1056 state.request_avatars(vec![me.user_id.clone()], cx);
1057 state.request_presence(vec![me.user_id], cx);
1058 });
1059 });
1060 }
1061 let notice = self.state.read(cx).notice.clone();
1062 self.toasts.sync(&self.state, notice.as_ref(), window, cx);
1063 let update_failure = match &self.update {
1064 UpdateStatus::Failed(message) => Some(message.clone()),
1065 _ => None,
1066 };
1067 self.toasts
1068 .update_failed(update_failure.as_deref(), window, cx);
1069 let calendar_tab = self.sidebar.read(cx).tab() == SidebarTab::Calendar;
1070 let chats_tab = self.sidebar.read(cx).tab() == SidebarTab::Chats;
1071 let calls_tab = self.sidebar.read(cx).tab() == SidebarTab::Calls;
1072 let splash = self.render_splash(cx);
1073 let state = self.state.read(cx);
1074 let calendar_open = calendar_tab;
1075 let quick_view_open = chats_tab && state.quick_view.is_some();
1076 let manage_team_open = !calendar_tab && !calls_tab && state.manage_team.is_some();
1077 let calls_open = calls_tab;
1078 let show_sidebar = !calendar_open && !calls_open;
1079 let banner = state
1080 .connection_banner_text()
1081 .filter(|_| !self.splash.is_up())
1082 .map(|banner| {
1083 render_connection_banner(
1084 banner,
1085 cx.listener(|this, _, _, cx| {
1086 this.state.update(cx, |state, _| state.retry_live())
1087 }),
1088 )
1089 });
1090 let title_bar = render_title_bar(
1091 crate::active_appearance::current(cx).app_icon,
1092 mode_label(state.mode),
1093 [
1094 update_button(
1095 &self.update,
1096 cx.listener(|this, _, _, cx| this.restart_into_update(cx)),
1097 ),
1098 Some(settings_more_button(&self.state)),
1099 own_status_button(&self.state, state),
1100 ]
1101 .into_iter()
1102 .flatten(),
1103 cx.listener(|this, _, window, cx| this.toggle_switcher("", window, cx)),
1104 );
1105 let shell = div()
1106 .id("app-shell")
1107 .key_context("AppShell")
1108 .track_focus(&self.focus_handle);
1109 self.team_keys(shell, cx)
1110 .on_action(cx.listener(|this, _: &OpenSwitcher, window, cx| {
1111 this.toggle_switcher("", window, cx);
1112 }))
1113 .on_action(cx.listener(|this, _: &NewChat, window, cx| {
1114 this.close_image_viewer(window, cx);
1115 this.state.update(cx, |state, cx| state.start_new_chat(cx));
1116 }))
1117 .on_action(cx.listener(|this, _: &ToggleCallMute, _, cx| {
1118 this.state
1119 .update(cx, |state, cx| state.toggle_call_mute(cx));
1120 }))
1121 .on_action(cx.listener(|this, _: &PushToTalk, _, cx| {
1122 this.state
1123 .update(cx, |state, cx| state.press_push_to_talk(cx));
1124 }))
1125 .on_key_up(cx.listener(|this, event: &KeyUpEvent, _, cx| {
1126 if event.keystroke.key == "space" {
1127 this.state
1128 .update(cx, |state, cx| state.release_push_to_talk(cx));
1129 }
1130 }))
1131 .on_modifiers_changed(cx.listener(|this, event: &ModifiersChangedEvent, _, cx| {
1132 if !event.modifiers.control {
1133 this.state
1134 .update(cx, |state, cx| state.release_push_to_talk(cx));
1135 }
1136 }))
1137 .on_action(cx.listener(|this, _: &OpenSettings, window, cx| {
1138 this.open_settings(SettingsSection::General, window, cx);
1139 }))
1140 .on_action(cx.listener(|this, _: &ShowShortcuts, window, cx| {
1141 this.toggle_shortcuts_dialog(window, cx);
1142 }))
1143 .on_action(cx.listener(|this, _: &OpenActivity, window, cx| {
1144 this.close_image_viewer(window, cx);
1145 this.sidebar
1146 .update(cx, |sidebar, cx| sidebar.show_activity(cx));
1147 }))
1148 .on_action(cx.listener(|this, _: &OpenSaved, window, cx| {
1149 this.close_image_viewer(window, cx);
1150 this.sidebar.update(cx, |sidebar, cx| {
1151 sidebar.open_quick_view(QuickView::Saved, cx)
1152 });
1153 }))
1154 .on_action(cx.listener(|this, _: &OpenCalendar, window, cx| {
1155 this.close_image_viewer(window, cx);
1156 this.sidebar
1157 .update(cx, |sidebar, cx| sidebar.show_calendar(cx));
1158 }))
1159 .on_action(cx.listener(|this, _: &OpenAgents, window, cx| {
1160 this.close_image_viewer(window, cx);
1161 this.sidebar
1162 .update(cx, |sidebar, cx| sidebar.show_agents(cx));
1163 }))
1164 .on_action(cx.listener(|this, _: &OpenChatsTab, window, cx| {
1165 this.close_image_viewer(window, cx);
1166 this.sidebar
1167 .update(cx, |sidebar, cx| sidebar.show_chats(cx));
1168 }))
1169 .on_action(cx.listener(|this, _: &FindInChat, window, cx| {
1170 this.close_image_viewer(window, cx);
1171 this.state
1172 .update(cx, |state, cx| state.close_quick_view(cx));
1173 this.conversation
1174 .update(cx, |conversation, cx| conversation.open_find(window, cx));
1175 }))
1176 .on_action(cx.listener(|this, _: &PopOutSelectedChat, _, cx| {
1177 let selected = this.state.read(cx).selection.clone();
1178 if let Some(Selection::Chat(chat_id)) = selected {
1179 chat_pop_out::pop_out_chat(&this.state, &chat_id, cx);
1180 }
1181 }))
1182 .on_action(cx.listener(|this, _: &OpenChatFilter, window, cx| {
1183 this.close_image_viewer(window, cx);
1184 this.sidebar
1185 .update(cx, |sidebar, cx| sidebar.toggle_filter_box(window, cx));
1186 }))
1187 .on_action(cx.listener(|this, _: &FilterUnreadChats, _, cx| {
1188 this.sidebar.update(cx, |sidebar, cx| {
1189 sidebar.toggle_pill(ChatFilterPill::Unread, cx)
1190 });
1191 }))
1192 .on_action(cx.listener(|this, _: &FilterNonMeetingChats, _, cx| {
1193 this.sidebar.update(cx, |sidebar, cx| {
1194 sidebar.toggle_pill(ChatFilterPill::Chats, cx)
1195 });
1196 }))
1197 .on_action(cx.listener(|this, _: &FilterMeetingChats, _, cx| {
1198 this.sidebar.update(cx, |sidebar, cx| {
1199 sidebar.toggle_pill(ChatFilterPill::Meetings, cx)
1200 });
1201 }))
1202 .on_action(cx.listener(|this, _: &FilterMutedChats, _, cx| {
1203 this.sidebar.update(cx, |sidebar, cx| {
1204 sidebar.toggle_pill(ChatFilterPill::Muted, cx)
1205 });
1206 }))
1207 .on_action(cx.listener(|this, _: &ClearChatFilters, window, cx| {
1208 this.sidebar
1209 .update(cx, |sidebar, cx| sidebar.clear_filters(window, cx));
1210 }))
1211 .on_action(cx.listener(|this, _: &OpenChannelsTab, window, cx| {
1212 this.close_image_viewer(window, cx);
1213 this.sidebar
1214 .update(cx, |sidebar, cx| sidebar.show_channels(cx));
1215 }))
1216 .on_action(cx.listener(|this, _: &OpenCallsTab, window, cx| {
1217 this.close_image_viewer(window, cx);
1218 this.sidebar
1219 .update(cx, |sidebar, cx| sidebar.show_calls(cx));
1220 }))
1221 .on_action(cx.listener(|this, _: &PreviousConversation, window, cx| {
1222 this.close_image_viewer(window, cx);
1223 this.sidebar.update(cx, |sidebar, cx| {
1224 sidebar.select_adjacent(Step::Previous, cx)
1225 });
1226 }))
1227 .on_action(cx.listener(|this, _: &NextConversation, window, cx| {
1228 this.close_image_viewer(window, cx);
1229 this.sidebar
1230 .update(cx, |sidebar, cx| sidebar.select_adjacent(Step::Next, cx));
1231 }))
1232 .on_action(cx.listener(|this, _: &DeclineCall, _, cx| {
1233 this.state
1234 .update(cx, |state, cx| state.decline_ringing_call(cx));
1235 }))
1236 .on_action(cx.listener(|this, _: &JoinMeetingFromToast, _, cx| {
1237 this.state
1238 .update(cx, |state, cx| state.join_latest_meeting_toast(cx));
1239 }))
1240 .on_action(cx.listener(|this, _: &HangUpCall, _, cx| {
1241 this.state.update(cx, |state, cx| state.leave_call(cx));
1242 }))
1243 .on_action(cx.listener(|this, _: &ToggleCallCamera, _, cx| {
1244 this.state
1245 .update(cx, |state, cx| state.toggle_call_camera(cx));
1246 }))
1247 .on_action(cx.listener(|this, _: &ToggleCallShare, _, cx| {
1248 this.state
1249 .update(cx, |state, cx| state.toggle_call_share(cx));
1250 }))
1251 .on_action(cx.listener(|this, _: &ToggleCallHand, _, cx| {
1252 this.state
1253 .update(cx, |state, cx| state.toggle_call_hand(cx));
1254 }))
1255 .on_action(cx.listener(|this, _: &OpenLobbyList, _, cx| {
1256 this.state
1257 .update(cx, |state, cx| state.open_call_lobby_list(cx));
1258 }))
1259 .on_action(cx.listener(|this, _: &StartAudioCall, _, cx| {
1260 this.start_call_in_open_chat(false, cx);
1261 }))
1262 .on_action(cx.listener(|this, _: &StartVideoCall, _, cx| {
1263 this.start_call_in_open_chat(true, cx);
1264 }))
1265 .on_action(
1266 cx.listener(|this, _: &ZoomIn, _, cx| change_zoom(&this.state, WindowZoom::In, cx)),
1267 )
1268 .on_action(
1269 cx.listener(|this, _: &ZoomOut, _, cx| {
1270 change_zoom(&this.state, WindowZoom::Out, cx)
1271 }),
1272 )
1273 .on_action(cx.listener(|this, _: &ZoomReset, _, cx| {
1274 change_zoom(&this.state, WindowZoom::Reset, cx)
1275 }))
1276 .on_action(zoom_listener::<ZoomShareIn>(&self.state, ZoomStep::In))
1277 .on_action(zoom_listener::<ZoomShareOut>(&self.state, ZoomStep::Out))
1278 .on_action(zoom_listener::<ZoomShareReset>(
1279 &self.state,
1280 ZoomStep::Reset,
1281 ))
1282 .on_action(cx.listener(|this, _: &JumpToLastReadOrNewest, _, cx| {
1283 if this.image_viewer.is_some() {
1284 cx.propagate();
1285 return;
1286 }
1287 this.conversation.update(cx, |conversation, cx| {
1288 conversation.jump_to_last_read_or_newest(cx)
1289 });
1290 }))
1291 .on_action(cx.listener(|this, _: &ReplyToHovered, window, cx| {
1292 this.close_image_viewer(window, cx);
1293 this.conversation.update(cx, |conversation, cx| {
1294 conversation.reply_to_hovered(window, cx)
1295 });
1296 }))
1297 .relative()
1298 .size_full()
1299 .bg(theme::background())
1300 .text_color(theme::text())
1301 .text_size(px(14.))
1302 .child(crate::frame_log::probe("first"))
1303 .child(user_activity::input_probe(self.user_input.clone()))
1304 .child(app_ui_kit::long_press::long_press_right_click())
1305 .child(
1306 v_flex()
1307 .debug_selector(|| "shell".into())
1308 .size_full()
1309 .child(title_bar)
1310 .children(banner)
1311 .child(rising_in(
1312 self.islands(
1313 show_sidebar,
1314 calendar_open,
1315 quick_view_open,
1316 calls_open,
1317 manage_team_open,
1318 ),
1319 &self.splash,
1320 cx,
1321 )),
1322 )
1323 .children(splash)
1324 .children(self.image_viewer.clone())
1325 .children(self.switcher.clone())
1326 .children(render_task_dialog(self.state.read(cx), cx))
1327 .children(self.forward_dialog.clone())
1328 .children(self.status_dialog.clone())
1329 .children(self.shortcuts_dialog.clone())
1330 .children(self.agent_dialog.clone())
1331 .children(self.settings_dialog.clone())
1332 .children(self.profile_card.clone())
1333 .child(crate::frame_log::probe("last"))
1334 }
1335}
1336
1337fn rising_in(islands: Div, splash: &Splash, cx: &App) -> AnyElement {
1338 if splash.content_rising().is_none() || cx.reduce_motion() {
1339 return islands.into_any_element();
1340 }
1341 islands
1342 .relative()
1343 .with_animation(
1344 "startup-content-rise",
1345 Animation::new(splash::CONTENT_RISE).with_easing(ease_out_quint()),
1346 |islands, delta| {
1347 islands
1348 .top(px(splash::CONTENT_RISE_OFFSET * (1. - delta)))
1349 .opacity(delta)
1350 },
1351 )
1352 .into_any_element()
1353}
1354
1355#[cfg(test)]
1356mod opening_link_tests {
1357 use super::opening_link_text;
1358
1359 #[test]
1360 fn the_notice_names_the_host() {
1361 assert_eq!(
1362 opening_link_text("https://example.com/a?b#c"),
1363 "Opening example.com..."
1364 );
1365 assert_eq!(opening_link_text("mailto:"), "Opening mailto:...");
1366 assert_eq!(opening_link_text(""), "Opening link...");
1367 }
1368}