BlueGit

ict rusty-teams

Files

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

shell.rs

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