BlueGit

ict rusty-teams

Files

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

shell.rs

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