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