BlueGit

ict rusty-teams

Files

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

shell.rs

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