BlueGit

ict rusty-teams

Files

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

shell.rs

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