BlueGit

ict rusty-teams

Files

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

shell.rs

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