BlueGit

ict rusty-teams

Files

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

shell.rs

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