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 in_call: self.state.read(cx).call.is_some(),
561 });
562 // On Linux only the user restarts: the update dialog or the title bar button.
563 if idle && cfg!(not(target_os = "linux")) {
564 self.restart_into_update(cx);
565 }
566 cx.notify();
567 }
568
569 fn restart_into_update(&mut self, cx: &mut Context<Self>) {
570 if self.update == UpdateStatus::Installing {
571 return;
572 }
573 let Some(paths) = updater::current_paths() else {
574 return;
575 };
576 self.update = UpdateStatus::Installing;
577 cx.notify();
578 cx.spawn(async move |this, cx| {
579 let result = cx
580 .background_spawn(async move { updater::install_and_relaunch(&paths) })
581 .await;
582 let _ = this.update(cx, |this, cx| {
583 match result {
584 Ok(()) => cx.quit(),
585 Err(message) => this.update = UpdateStatus::Failed(message),
586 }
587 cx.notify();
588 });
589 })
590 .detach();
591 }
592
593 fn apply_open_target(&mut self, cx: &mut Context<Self>) {
594 let Some(target) = self.open_target else {
595 return;
596 };
597 let sidebar = &self.state.read(cx).sidebar;
598 let selection = match target {
599 OpenTarget::Chat(index) => sidebar
600 .chats
601 .get(index)
602 .map(|chat| Selection::Chat(chat.id.clone())),
603 OpenTarget::Channel(index) => sidebar
604 .teams
605 .iter()
606 .flat_map(|team| team.channels.iter())
607 .nth(index)
608 .map(|channel| Selection::Channel(channel.id.clone())),
609 };
610 if let Some(selection) = selection {
611 self.open_target = None;
612 self.state
613 .update(cx, |state, cx| state.select(selection, cx));
614 }
615 }
616
617 fn toggle_switcher(
618 &mut self,
619 initial_query: &str,
620 window: &mut Window,
621 cx: &mut Context<Self>,
622 ) {
623 if self.switcher.take().is_some() {
624 self.restore_focus(window, cx);
625 cx.notify();
626 return;
627 }
628 self.close_image_viewer(window, cx);
629 let candidates = candidates_from(self.state.read(cx));
630 let app = self.state.clone();
631 let switcher = cx.new(|cx| Switcher::new(app, candidates, initial_query, window, cx));
632 cx.subscribe_in(
633 &switcher,
634 window,
635 |this, _, event: &SwitcherEvent, window, cx| {
636 match event {
637 SwitcherEvent::Pick(selection) => {
638 let selection = selection.clone();
639 this.state
640 .update(cx, |state, cx| state.select(selection, cx));
641 }
642 SwitcherEvent::PickMessage {
643 selection,
644 message_id,
645 } => {
646 let (selection, message_id) = (selection.clone(), message_id.clone());
647 this.state.update(cx, |state, cx| {
648 state.jump_to_message(selection, message_id, cx)
649 });
650 }
651 SwitcherEvent::PickPerson { user_id } => {
652 let user_id = user_id.clone();
653 this.state
654 .update(cx, |state, cx| state.open_chat_with(&user_id, cx));
655 }
656 SwitcherEvent::Close => {}
657 }
658 this.switcher = None;
659 this.restore_focus(window, cx);
660 cx.notify();
661 },
662 )
663 .detach();
664 self.switcher = Some(switcher);
665 cx.notify();
666 }
667
668 fn open_message(
669 &mut self,
670 conversation_id: &str,
671 message_id: &str,
672 cx: &mut Context<Self>,
673 ) -> bool {
674 let Some(selection) = selection_for(&self.state.read(cx).sidebar, conversation_id) else {
675 return false;
676 };
677 let message_id = message_id.to_owned();
678 self.state.update(cx, |state, cx| {
679 if message_id.is_empty() {
680 state.select(selection, cx)
681 } else {
682 state.jump_to_message(selection, message_id, cx)
683 }
684 });
685 true
686 }
687
688 fn open_status_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
689 if !self
690 .state
691 .update(cx, |state, _| state.take_status_message_request())
692 {
693 return;
694 }
695 self.close_image_viewer(window, cx);
696 self.switcher = None;
697 let app = self.state.clone();
698 let dialog = cx.new(|cx| StatusMessageDialog::new(app, window, cx));
699 cx.subscribe_in(
700 &dialog,
701 window,
702 |this, _, _: &StatusMessageDialogEvent, window, cx| {
703 this.status_dialog = None;
704 this.restore_focus(window, cx);
705 cx.notify();
706 },
707 )
708 .detach();
709 self.status_dialog = Some(dialog);
710 cx.notify();
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(&peek, window, |this, _, _: &EventPeekEvent, window, cx| {
724 this.calendar_event_peek = None;
725 this.restore_focus(window, cx);
726 cx.notify();
727 })
728 .detach();
729 self.calendar_event_peek = Some(peek);
730 cx.notify();
731 }
732
733 fn open_agent_dialog(
734 &mut self,
735 request: StartRequest,
736 window: &mut Window,
737 cx: &mut Context<Self>,
738 ) {
739 let Some(runs) = crate::agents::runs_handle(cx) else {
740 return;
741 };
742 let settings = runs.read(cx).settings();
743 let Some(action) = settings
744 .actions
745 .iter()
746 .find(|action| action.id == request.action_id)
747 .cloned()
748 else {
749 return;
750 };
751 let agent_name = settings
752 .agents
753 .iter()
754 .find(|agent| agent.id == action.agent_id)
755 .map(|agent| agent.name.clone())
756 .unwrap_or_default();
757 self.switcher = None;
758 let app = self.state.clone();
759 let dialog = cx.new(|cx| StartDialog::new(app, request, action, &agent_name, window, cx));
760 cx.subscribe_in(
761 &dialog,
762 window,
763 |this, _, _: &StartDialogEvent, window, cx| {
764 this.agent_dialog = None;
765 window.focus(&this.focus_handle, cx);
766 cx.notify();
767 },
768 )
769 .detach();
770 self.agent_dialog = Some(dialog);
771 cx.notify();
772 }
773
774 fn open_settings(
775 &mut self,
776 section: SettingsSection,
777 window: &mut Window,
778 cx: &mut Context<Self>,
779 ) {
780 if let Some(dialog) = &self.settings_dialog {
781 dialog.update(cx, |dialog, cx| dialog.show(section, window, cx));
782 return;
783 }
784 self.close_image_viewer(window, cx);
785 self.switcher = None;
786 let (app, center) = (self.state.clone(), self.notifications.clone());
787 let dialog = cx.new(|cx| SettingsDialog::new(app, center, section, window, cx));
788 cx.subscribe_in(
789 &dialog,
790 window,
791 |this, _, _: &SettingsDialogEvent, window, cx| {
792 this.settings_dialog = None;
793 this.restore_focus(window, cx);
794 cx.notify();
795 },
796 )
797 .detach();
798 self.settings_dialog = Some(dialog);
799 cx.notify();
800 }
801
802 fn toggle_shortcuts_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
803 if self.shortcuts_dialog.take().is_some() {
804 self.restore_focus(window, cx);
805 cx.notify();
806 return;
807 }
808 self.close_image_viewer(window, cx);
809 self.switcher = None;
810 let dialog = cx.new(|cx| ShortcutsDialog::new(window, cx));
811 cx.subscribe_in(
812 &dialog,
813 window,
814 |this, _, _: &ShortcutsDialogEvent, window, cx| {
815 this.shortcuts_dialog = None;
816 this.restore_focus(window, cx);
817 cx.notify();
818 },
819 )
820 .detach();
821 self.shortcuts_dialog = Some(dialog);
822 cx.notify();
823 }
824
825 fn open_profile_card(&mut self, window: &mut Window, cx: &mut Context<Self>) {
826 let Some(request) = self
827 .state
828 .update(cx, |state, _| state.take_profile_request())
829 else {
830 return;
831 };
832 self.close_image_viewer(window, cx);
833 if let Some(card) = &self.profile_card {
834 card.update(cx, |card, cx| {
835 card.move_to(request.user_id, request.anchor, cx)
836 });
837 return;
838 }
839 let app = self.state.clone();
840 let card = cx.new(|cx| ProfileCard::new(app, request.user_id, request.anchor, window, cx));
841 cx.subscribe_in(
842 &card,
843 window,
844 |this, _, _: &ProfileCardEvent, window, cx| {
845 this.profile_card = None;
846 this.restore_focus(window, cx);
847 cx.notify();
848 },
849 )
850 .detach();
851 self.profile_card = Some(card);
852 cx.notify();
853 }
854
855 fn open_image_viewer(&mut self, window: &mut Window, cx: &mut Context<Self>) {
856 let Some(request) = self
857 .state
858 .update(cx, |state, _| state.take_image_viewer_request())
859 else {
860 return;
861 };
862 self.switcher = None;
863 let app = self.state.clone();
864 let viewer = cx.new(|cx| ImageViewer::new(app, request, window, cx));
865 cx.subscribe_in(
866 &viewer,
867 window,
868 |this, _, _: &ImageViewerEvent, window, cx| {
869 this.image_viewer = None;
870 window.focus(&this.focus_handle, cx);
871 cx.notify();
872 },
873 )
874 .detach();
875 self.image_viewer = Some(viewer);
876 cx.notify();
877 }
878
879 fn start_call_in_open_chat(&mut self, with_video: bool, cx: &mut Context<Self>) {
880 self.state.update(cx, |state, cx| {
881 if let Some(Selection::Chat(chat_id)) = state.selection.clone() {
882 if with_video {
883 state.start_chat_video_call(&chat_id, cx);
884 } else {
885 state.start_chat_call(&chat_id, cx);
886 }
887 }
888 });
889 }
890
891 fn close_image_viewer(&mut self, window: &mut Window, cx: &mut Context<Self>) {
892 if self.image_viewer.take().is_some() {
893 window.focus(&self.focus_handle, cx);
894 cx.notify();
895 }
896 }
897
898 fn restore_focus(&self, window: &mut Window, cx: &mut Context<Self>) {
899 match &self.image_viewer {
900 Some(viewer) => {
901 let handle = viewer.read(cx).focus_handle();
902 window.focus(&handle, cx)
903 }
904 None => window.focus(&self.focus_handle, cx),
905 }
906 }
907
908 fn open_forward_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
909 let Some(source) = self
910 .state
911 .update(cx, |state, _| state.take_forward_request())
912 else {
913 return;
914 };
915 self.switcher = None;
916 let candidates = candidates_from(self.state.read(cx));
917 let app = self.state.clone();
918 let dialog = cx.new(|cx| ForwardDialog::new(app, source, candidates, window, cx));
919 cx.subscribe_in(
920 &dialog,
921 window,
922 |this, _, event: &ForwardDialogEvent, window, cx| {
923 this.forward_dialog = None;
924 this.restore_focus(window, cx);
925 if let ForwardDialogEvent::Sent { target, title } = event {
926 let target = target.clone();
927 let open = NoticeAction::new("Open", move |state, cx| {
928 state.select(target.clone(), cx)
929 });
930 this.state.update(cx, |state, cx| {
931 state.cancel_forward_selection(cx);
932 state.raise_notice(format!("Forwarded to {title}"), Some(open), cx)
933 });
934 }
935 cx.notify();
936 },
937 )
938 .detach();
939 self.forward_dialog = Some(dialog);
940 cx.notify();
941 }
942}
943
944impl AppShell {
945 fn render_splash(&mut self, cx: &mut Context<Self>) -> Option<AnyElement> {
946 let phase = if self.splash.is_up() {
947 let opening = self.conversation.read(cx).opening_title();
948 let state = self.state.read(cx);
949 let phase = splash::phase(&StartupFacts {
950 elapsed: self.splash.elapsed(),
951 connection: &state.connection,
952 browser_sign_in: &state.browser_sign_in,
953 has_chats: !state.sidebar.chats.is_empty() || !state.sidebar.teams.is_empty(),
954 synced: state.last_sync.is_some(),
955 demo: state.mode.demo,
956 opening,
957 });
958 // Poll only when the progress bar is not already driving repaints
959 // (idle/stopped bar or reduced motion); otherwise the sweep animation
960 // wakes the splash often enough for BrowserSignIn status updates.
961 let needs_poll = match &phase {
962 Phase::Loading { running, .. } => !*running || cx.reduce_motion(),
963 Phase::Ready => false,
964 };
965 if needs_poll && !self.splash.recheck_scheduled {
966 self.splash.recheck_scheduled = true;
967 cx.spawn(async move |this, cx| {
968 cx.background_executor().timer(splash::STILL_RECHECK).await;
969 this.update(cx, |this, cx| {
970 this.splash.recheck_scheduled = false;
971 cx.notify();
972 })
973 .ok();
974 })
975 .detach();
976 }
977 if phase == Phase::Ready {
978 self.splash.hide();
979 cx.spawn(async move |this, cx| {
980 cx.background_executor().timer(splash::CONTENT_RISE).await;
981 this.update(cx, |_, cx| cx.notify()).ok();
982 })
983 .detach();
984 }
985 phase
986 } else {
987 Phase::Ready
988 };
989 self.splash.render(&phase, cx)
990 }
991
992 fn islands(
993 &self,
994 show_sidebar: bool,
995 calendar_open: bool,
996 quick_view_open: bool,
997 calls_open: bool,
998 manage_team_open: bool,
999 ) -> Div {
1000 h_flex()
1001 .debug_selector(|| "shell/islands".into())
1002 .flex_1()
1003 .min_h_0()
1004 .w_full()
1005 .when(show_sidebar, |islands| islands.gap(px(ISLAND_GAP)))
1006 .pr(px(ISLAND_GAP))
1007 .pb(px(ISLAND_GAP))
1008 .child(h_flex().h_full().flex_none().child(self.rail.clone()).when(
1009 show_sidebar,
1010 |group| {
1011 group.child(
1012 self.sidebar.clone().cached(
1013 StyleRefinement::default()
1014 .w(px(SIDEBAR_WIDTH))
1015 .h_full()
1016 .flex_none(),
1017 ),
1018 )
1019 },
1020 ))
1021 .child(match () {
1022 _ if calls_open => self
1023 .calls_page
1024 .clone()
1025 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
1026 .into_any_element(),
1027 _ if manage_team_open => self
1028 .manage_team_page
1029 .clone()
1030 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
1031 .into_any_element(),
1032 _ if quick_view_open => self
1033 .quick_pane
1034 .clone()
1035 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
1036 .into_any_element(),
1037 _ if calendar_open => self
1038 .calendar
1039 .clone()
1040 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
1041 .into_any_element(),
1042 _ => self
1043 .conversation
1044 .clone()
1045 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
1046 .into_any_element(),
1047 })
1048 }
1049}
1050
1051impl Render for AppShell {
1052 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
1053 let open_dialogs = [
1054 self.state.read(cx).task_dialog.is_some(),
1055 self.forward_dialog.is_some(),
1056 self.status_dialog.is_some(),
1057 self.shortcuts_dialog.is_some(),
1058 self.agent_dialog.is_some(),
1059 self.settings_dialog.is_some(),
1060 ]
1061 .into_iter()
1062 .filter(|open| *open)
1063 .count();
1064 elevation::set_app_modal_layers(window, open_dialogs, cx);
1065 if open_dialogs > 0 {
1066 crate::inline_video::stop(cx);
1067 }
1068 if let Some(dialog) = self
1069 .state
1070 .read(cx)
1071 .task_dialog
1072 .as_ref()
1073 .map(|dialog| (dialog.scope.clone(), dialog.card.clone()))
1074 {
1075 self.state.update(cx, |state, cx| {
1076 state.ensure_card_inputs(&dialog.0, &dialog.1, window, cx)
1077 });
1078 }
1079 if let Some(me) = self.state.read(cx).directory.me.clone() {
1080 let app = self.state.clone();
1081 cx.defer(move |cx| {
1082 app.update(cx, |state, cx| {
1083 state.request_avatars(vec![me.user_id.clone()], cx);
1084 state.request_presence(vec![me.user_id], cx);
1085 });
1086 });
1087 }
1088 let notice = self.state.read(cx).notice.clone();
1089 self.toasts.sync(&self.state, notice.as_ref(), window, cx);
1090 let update_failure = match &self.update {
1091 UpdateStatus::Failed(message) => Some(message.clone()),
1092 _ => None,
1093 };
1094 self.toasts
1095 .update_failed(update_failure.as_deref(), window, cx);
1096 let calendar_tab = self.sidebar.read(cx).tab() == SidebarTab::Calendar;
1097 let chats_tab = self.sidebar.read(cx).tab() == SidebarTab::Chats;
1098 let calls_tab = self.sidebar.read(cx).tab() == SidebarTab::Calls;
1099 let splash = self.render_splash(cx);
1100 let state = self.state.read(cx);
1101 let calendar_open = calendar_tab;
1102 let quick_view_open = chats_tab && state.quick_view.is_some();
1103 let manage_team_open = !calendar_tab && !calls_tab && state.manage_team.is_some();
1104 let calls_open = calls_tab;
1105 let show_sidebar = !calendar_open && !calls_open;
1106 let banner = state
1107 .connection_banner_text()
1108 .filter(|_| !self.splash.is_up())
1109 .map(|banner| {
1110 render_connection_banner(
1111 banner,
1112 cx.listener(|this, _, _, cx| {
1113 this.state.update(cx, |state, _| state.retry_live())
1114 }),
1115 )
1116 });
1117 let title_bar = render_title_bar(
1118 crate::active_appearance::current(cx).app_icon,
1119 mode_label(state.mode),
1120 [
1121 update_button(
1122 &self.update,
1123 cx.listener(|this, _, _, cx| this.restart_into_update(cx)),
1124 ),
1125 Some(settings_more_button(&self.state)),
1126 own_status_button(&self.state, state),
1127 ]
1128 .into_iter()
1129 .flatten(),
1130 cx.listener(|this, _, window, cx| this.toggle_switcher("", window, cx)),
1131 );
1132 let shell = div()
1133 .id("app-shell")
1134 .key_context("AppShell")
1135 .track_focus(&self.focus_handle);
1136 self.team_keys(shell, cx)
1137 .on_action(cx.listener(|this, _: &OpenSwitcher, window, cx| {
1138 this.toggle_switcher("", window, cx);
1139 }))
1140 .on_action(cx.listener(|this, _: &NewChat, window, cx| {
1141 this.close_image_viewer(window, cx);
1142 this.state.update(cx, |state, cx| state.start_new_chat(cx));
1143 }))
1144 .on_action(cx.listener(|this, _: &ToggleCallMute, _, cx| {
1145 this.state
1146 .update(cx, |state, cx| state.toggle_call_mute(cx));
1147 }))
1148 .on_action(cx.listener(|this, _: &PushToTalk, _, cx| {
1149 this.state
1150 .update(cx, |state, cx| state.press_push_to_talk(cx));
1151 }))
1152 .on_key_up(cx.listener(|this, event: &KeyUpEvent, _, cx| {
1153 if event.keystroke.key == "space" {
1154 this.state
1155 .update(cx, |state, cx| state.release_push_to_talk(cx));
1156 }
1157 }))
1158 .on_modifiers_changed(cx.listener(|this, event: &ModifiersChangedEvent, _, cx| {
1159 if !event.modifiers.control {
1160 this.state
1161 .update(cx, |state, cx| state.release_push_to_talk(cx));
1162 }
1163 }))
1164 .on_action(cx.listener(|this, _: &OpenSettings, window, cx| {
1165 this.open_settings(SettingsSection::General, window, cx);
1166 }))
1167 .on_action(cx.listener(|this, _: &ShowShortcuts, window, cx| {
1168 this.toggle_shortcuts_dialog(window, cx);
1169 }))
1170 .on_action(cx.listener(|this, _: &OpenActivity, window, cx| {
1171 this.close_image_viewer(window, cx);
1172 this.sidebar
1173 .update(cx, |sidebar, cx| sidebar.show_activity(cx));
1174 }))
1175 .on_action(cx.listener(|this, _: &OpenSaved, window, cx| {
1176 this.close_image_viewer(window, cx);
1177 this.sidebar.update(cx, |sidebar, cx| {
1178 sidebar.open_quick_view(QuickView::Saved, cx)
1179 });
1180 }))
1181 .on_action(cx.listener(|this, _: &OpenCalendar, window, cx| {
1182 this.close_image_viewer(window, cx);
1183 this.sidebar
1184 .update(cx, |sidebar, cx| sidebar.show_calendar(cx));
1185 }))
1186 .on_action(cx.listener(|this, _: &OpenAgents, window, cx| {
1187 this.close_image_viewer(window, cx);
1188 this.sidebar
1189 .update(cx, |sidebar, cx| sidebar.show_agents(cx));
1190 }))
1191 .on_action(cx.listener(|this, _: &OpenChatsTab, window, cx| {
1192 this.close_image_viewer(window, cx);
1193 this.sidebar
1194 .update(cx, |sidebar, cx| sidebar.show_chats(cx));
1195 }))
1196 .on_action(cx.listener(|this, _: &FindInChat, window, cx| {
1197 this.close_image_viewer(window, cx);
1198 this.state
1199 .update(cx, |state, cx| state.close_quick_view(cx));
1200 this.conversation
1201 .update(cx, |conversation, cx| conversation.open_find(window, cx));
1202 }))
1203 .on_action(cx.listener(|this, _: &PopOutSelectedChat, _, cx| {
1204 let selected = this.state.read(cx).selection.clone();
1205 if let Some(Selection::Chat(chat_id)) = selected {
1206 chat_pop_out::pop_out_chat(&this.state, &chat_id, cx);
1207 }
1208 }))
1209 .on_action(cx.listener(|this, _: &OpenChatFilter, window, cx| {
1210 this.close_image_viewer(window, cx);
1211 this.sidebar
1212 .update(cx, |sidebar, cx| sidebar.toggle_filter_box(window, cx));
1213 }))
1214 .on_action(cx.listener(|this, _: &FilterUnreadChats, _, cx| {
1215 this.sidebar.update(cx, |sidebar, cx| {
1216 sidebar.toggle_pill(ChatFilterPill::Unread, cx)
1217 });
1218 }))
1219 .on_action(cx.listener(|this, _: &FilterNonMeetingChats, _, cx| {
1220 this.sidebar.update(cx, |sidebar, cx| {
1221 sidebar.toggle_pill(ChatFilterPill::Chats, cx)
1222 });
1223 }))
1224 .on_action(cx.listener(|this, _: &FilterMeetingChats, _, cx| {
1225 this.sidebar.update(cx, |sidebar, cx| {
1226 sidebar.toggle_pill(ChatFilterPill::Meetings, cx)
1227 });
1228 }))
1229 .on_action(cx.listener(|this, _: &FilterMutedChats, _, cx| {
1230 this.sidebar.update(cx, |sidebar, cx| {
1231 sidebar.toggle_pill(ChatFilterPill::Muted, cx)
1232 });
1233 }))
1234 .on_action(cx.listener(|this, _: &ClearChatFilters, window, cx| {
1235 this.sidebar
1236 .update(cx, |sidebar, cx| sidebar.clear_filters(window, cx));
1237 }))
1238 .on_action(cx.listener(|this, _: &OpenChannelsTab, window, cx| {
1239 this.close_image_viewer(window, cx);
1240 this.sidebar
1241 .update(cx, |sidebar, cx| sidebar.show_channels(cx));
1242 }))
1243 .on_action(cx.listener(|this, _: &OpenCallsTab, window, cx| {
1244 this.close_image_viewer(window, cx);
1245 this.sidebar
1246 .update(cx, |sidebar, cx| sidebar.show_calls(cx));
1247 }))
1248 .on_action(cx.listener(|this, _: &PreviousConversation, window, cx| {
1249 this.close_image_viewer(window, cx);
1250 this.sidebar.update(cx, |sidebar, cx| {
1251 sidebar.select_adjacent(Step::Previous, cx)
1252 });
1253 }))
1254 .on_action(cx.listener(|this, _: &NextConversation, window, cx| {
1255 this.close_image_viewer(window, cx);
1256 this.sidebar
1257 .update(cx, |sidebar, cx| sidebar.select_adjacent(Step::Next, cx));
1258 }))
1259 .on_action(cx.listener(|this, _: &DeclineCall, _, cx| {
1260 this.state
1261 .update(cx, |state, cx| state.decline_ringing_call(cx));
1262 }))
1263 .on_action(cx.listener(|this, _: &JoinMeetingFromToast, _, cx| {
1264 this.state
1265 .update(cx, |state, cx| state.join_latest_meeting_toast(cx));
1266 }))
1267 .on_action(cx.listener(|this, _: &HangUpCall, _, cx| {
1268 this.state.update(cx, |state, cx| state.leave_call(cx));
1269 }))
1270 .on_action(cx.listener(|this, _: &ToggleCallCamera, _, cx| {
1271 this.state
1272 .update(cx, |state, cx| state.toggle_call_camera(cx));
1273 }))
1274 .on_action(cx.listener(|this, _: &ToggleCallShare, _, cx| {
1275 this.state
1276 .update(cx, |state, cx| state.toggle_call_share(cx));
1277 }))
1278 .on_action(cx.listener(|this, _: &ToggleCallHand, _, cx| {
1279 this.state
1280 .update(cx, |state, cx| state.toggle_call_hand(cx));
1281 }))
1282 .on_action(cx.listener(|this, _: &OpenLobbyList, _, cx| {
1283 this.state
1284 .update(cx, |state, cx| state.open_call_lobby_list(cx));
1285 }))
1286 .on_action(cx.listener(|this, _: &StartAudioCall, _, cx| {
1287 this.start_call_in_open_chat(false, cx);
1288 }))
1289 .on_action(cx.listener(|this, _: &StartVideoCall, _, cx| {
1290 this.start_call_in_open_chat(true, cx);
1291 }))
1292 .on_action(
1293 cx.listener(|this, _: &ZoomIn, _, cx| change_zoom(&this.state, WindowZoom::In, cx)),
1294 )
1295 .on_action(
1296 cx.listener(|this, _: &ZoomOut, _, cx| {
1297 change_zoom(&this.state, WindowZoom::Out, cx)
1298 }),
1299 )
1300 .on_action(cx.listener(|this, _: &ZoomReset, _, cx| {
1301 change_zoom(&this.state, WindowZoom::Reset, cx)
1302 }))
1303 .on_action(zoom_listener::<ZoomShareIn>(&self.state, ZoomStep::In))
1304 .on_action(zoom_listener::<ZoomShareOut>(&self.state, ZoomStep::Out))
1305 .on_action(zoom_listener::<ZoomShareReset>(
1306 &self.state,
1307 ZoomStep::Reset,
1308 ))
1309 .on_action(cx.listener(|this, _: &JumpToLastReadOrNewest, _, cx| {
1310 if this.image_viewer.is_some() {
1311 cx.propagate();
1312 return;
1313 }
1314 this.conversation.update(cx, |conversation, cx| {
1315 conversation.jump_to_last_read_or_newest(cx)
1316 });
1317 }))
1318 .on_action(cx.listener(|this, _: &ReplyToHovered, window, cx| {
1319 this.close_image_viewer(window, cx);
1320 this.conversation.update(cx, |conversation, cx| {
1321 conversation.reply_to_hovered(window, cx)
1322 });
1323 }))
1324 .relative()
1325 .size_full()
1326 .bg(theme::background())
1327 .text_color(theme::text())
1328 .text_size(px(14.))
1329 .child(crate::frame_log::probe("first"))
1330 .child(user_activity::input_probe(self.user_input.clone()))
1331 .child(app_ui_kit::long_press::long_press_right_click())
1332 .child(
1333 v_flex()
1334 .debug_selector(|| "shell".into())
1335 .size_full()
1336 .child(title_bar)
1337 .children(banner)
1338 .child(rising_in(
1339 self.islands(
1340 show_sidebar,
1341 calendar_open,
1342 quick_view_open,
1343 calls_open,
1344 manage_team_open,
1345 ),
1346 &self.splash,
1347 cx,
1348 )),
1349 )
1350 .children(splash)
1351 .children(self.image_viewer.clone())
1352 .children(self.switcher.clone())
1353 .children(render_task_dialog(self.state.read(cx), cx))
1354 .children(self.forward_dialog.clone())
1355 .children(self.status_dialog.clone())
1356 .children(self.calendar_event_peek.clone())
1357 .children(self.shortcuts_dialog.clone())
1358 .children(self.agent_dialog.clone())
1359 .children(self.settings_dialog.clone())
1360 .children(self.profile_card.clone())
1361 .child(crate::frame_log::probe("last"))
1362 }
1363}
1364
1365fn rising_in(islands: Div, splash: &Splash, cx: &App) -> AnyElement {
1366 if splash.content_rising().is_none() || cx.reduce_motion() {
1367 return islands.into_any_element();
1368 }
1369 islands
1370 .relative()
1371 .with_animation(
1372 "startup-content-rise",
1373 Animation::new(splash::CONTENT_RISE).with_easing(ease_out_quint()),
1374 |islands, delta| {
1375 islands
1376 .top(px(splash::CONTENT_RISE_OFFSET * (1. - delta)))
1377 .opacity(delta)
1378 },
1379 )
1380 .into_any_element()
1381}
1382
1383#[cfg(test)]
1384mod opening_link_tests {
1385 use super::opening_link_text;
1386
1387 #[test]
1388 fn the_notice_names_the_host() {
1389 assert_eq!(
1390 opening_link_text("https://example.com/a?b#c"),
1391 "Opening example.com..."
1392 );
1393 assert_eq!(opening_link_text("mailto:"), "Opening mailto:...");
1394 assert_eq!(opening_link_text(""), "Opening link...");
1395 }
1396}