BlueGit

ict rusty-teams

Files

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

shell.rs

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