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