BlueGit

ict rusty-teams

Files

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

shell.rs

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