BlueGit

ict rusty-teams

Files

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

shell.rs

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