BlueGit

ict rusty-teams

Files

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

shell.rs

shell.rs 30.9 KiB Download Raw
1use std::sync::Arc;
2
3use gpui_kit::component::{h_flex, v_flex};
4use gpui_kit::*;
5
6use super::activity_panel::{ActivityPanel, ActivityPanelEvent};
7use super::call_mini::render_call_mini;
8use super::call_stage::render_stage_overlay;
9use super::call_view::render_call_view;
10use super::conversation::{ConversationView, ReplyToHovered};
11use super::dialog_overlay::render_task_dialog;
12use super::forward_dialog::{ForwardDialog, ForwardDialogEvent};
13use super::image_viewer::{ImageViewer, ImageViewerEvent};
14use super::prejoin_view::PrejoinView;
15use super::profile_card::{ProfileCard, ProfileCardEvent};
16use super::rail::RailView;
17use super::saved_panel::{SavedPanel, SavedPanelEvent};
18use super::shortcuts::{
19 AcceptCall, DeclineCall, HangUpCall, JoinMeetingFromToast, NextConversation, OpenActivity,
20 OpenCallsTab, OpenChannelsTab, OpenChatsTab, OpenSaved, PreviousConversation, Scope,
21 ShowShortcuts, ToggleCallCamera, ToggleCallShare,
22};
23use super::shortcuts_dialog::{ShortcutsDialog, ShortcutsDialogEvent};
24use super::sidebar::{SIDEBAR_WIDTH, SidebarView};
25use super::status_bar::render_status_bar;
26use super::status_menu::own_status_button;
27use super::status_message_dialog::{StatusMessageDialog, StatusMessageDialogEvent};
28use super::switcher::{Switcher, SwitcherEvent, candidates_from};
29use super::title_bar::render_title_bar;
30use crate::activity::ActivityCenter;
31use crate::agents::{AgentRunsEvent, StartDialog, StartDialogEvent, StartRequest};
32use crate::app_state::{AppEvent, AppState, Selection};
33use crate::call::{CallMedia, CallWindows};
34use crate::notice::NoticeAction;
35use crate::notify::{NotificationCenter, selection_for};
36use crate::sidebar_model::Step;
37use crate::theme;
38use crate::updater::{self, IdleInputs, UpdateStatus};
39use crate::user_activity::{self, UserInput};
40
41actions!(teams, [OpenSwitcher, NewChat, ToggleCallMute]);
42
43pub fn bind_keys(cx: &mut App) {
44 super::composer::bind_keys(cx);
45 super::shortcuts::bind_scopes(
46 cx,
47 &[
48 Scope::Global,
49 Scope::OutsideComposer,
50 Scope::GlobalOverTextFields,
51 ],
52 );
53}
54
55#[derive(Debug, Clone, Copy)]
56pub enum OpenTarget {
57 Chat(usize),
58 Channel(usize),
59}
60
61#[derive(Default)]
62pub struct Startup {
63 pub switcher_query: Option<String>,
64 pub composer_text: Option<String>,
65 pub reply_to_last: bool,
66}
67
68pub const ISLAND_GAP: f32 = 6.;
69
70pub struct UserInputHandle(pub Arc<UserInput>);
71
72impl Global for UserInputHandle {}
73
74pub fn install_globals(state: &Entity<AppState>, user_input: Arc<UserInput>, cx: &mut App) {
75 cx.set_global(crate::app_state::AppHandle(state.clone()));
76 cx.set_global(UserInputHandle(user_input));
77}
78
79pub struct AppShell {
80 state: Entity<AppState>,
81 rail: Entity<RailView>,
82 sidebar: Entity<SidebarView>,
83 conversation: Entity<ConversationView>,
84 call_chat: Option<(String, Entity<ConversationView>)>,
85 prejoin: Option<Entity<PrejoinView>>,
86 switcher: Option<Entity<Switcher>>,
87 notifications: Entity<NotificationCenter>,
88 _call_windows: Entity<CallWindows>,
89 forward_dialog: Option<Entity<ForwardDialog>>,
90 image_viewer: Option<Entity<ImageViewer>>,
91 status_dialog: Option<Entity<StatusMessageDialog>>,
92 shortcuts_dialog: Option<Entity<ShortcutsDialog>>,
93 agent_dialog: Option<Entity<StartDialog>>,
94 profile_card: Option<Entity<ProfileCard>>,
95 focus_handle: FocusHandle,
96 open_target: Option<OpenTarget>,
97 update: UpdateStatus,
98 user_input: Arc<UserInput>,
99 _subscription: Subscription,
100 _call_media_observation: Subscription,
101 _panel_subscriptions: [Subscription; 2],
102 _agent_subscription: Option<Subscription>,
103 _escape_observation: Subscription,
104 _activation_observation: Subscription,
105}
106
107impl AppShell {
108 fn sync_call_chat(
109 &mut self,
110 thread: Option<String>,
111 window: &mut Window,
112 cx: &mut Context<Self>,
113 ) {
114 match (thread, &self.call_chat) {
115 (Some(wanted), Some((open, _))) if &wanted == open => {}
116 (Some(wanted), _) => {
117 let app = self.state.clone();
118 let selection = Selection::Chat(wanted.clone());
119 let view = cx.new(|cx| ConversationView::pinned_to(app, selection, window, cx));
120 self.call_chat = Some((wanted, view));
121 }
122 (None, _) => self.call_chat = None,
123 }
124 }
125
126 fn sync_prejoin(&mut self, window: &mut Window, cx: &mut Context<Self>) {
127 let wanted = self.state.read(cx).prejoin.clone();
128 let open = self.prejoin.as_ref().map(|view| view.read(cx).pending_id());
129 match (wanted, open) {
130 (Some(pending), Some(id)) if pending.id == id => {}
131 (Some(pending), _) => {
132 let app = self.state.clone();
133 self.prejoin = Some(cx.new(|cx| PrejoinView::new(app, &pending, window, cx)));
134 }
135 (None, _) => self.prejoin = None,
136 }
137 }
138
139 pub fn new(
140 state: Entity<AppState>,
141 open_target: Option<OpenTarget>,
142 startup: Startup,
143 window: &mut Window,
144 cx: &mut Context<Self>,
145 ) -> Self {
146 let call_media = cx.new(|_| CallMedia);
147 state.update(cx, |state, _| state.call_media = Some(call_media.clone()));
148 let call_media_observation = cx.observe(&call_media, |_, _, cx| cx.notify());
149 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
150 let activity_panel = cx.new(|cx| ActivityPanel::new(state.clone(), activity.clone(), cx));
151 let saved_panel = cx.new(|cx| SavedPanel::new(state.clone(), cx));
152 let panel_subscriptions = [
153 cx.subscribe(
154 &activity_panel,
155 |this, _, event: &ActivityPanelEvent, cx| match event {
156 ActivityPanelEvent::OpenSettings => this
157 .notifications
158 .update(cx, |center, cx| center.open_settings(cx)),
159 ActivityPanelEvent::Open {
160 conversation_id,
161 message_id,
162 } => this.open_message(conversation_id, message_id, cx),
163 },
164 ),
165 cx.subscribe(&saved_panel, |this, _, event: &SavedPanelEvent, cx| {
166 let SavedPanelEvent::Open {
167 conversation_id,
168 message_id,
169 } = event;
170 this.open_message(conversation_id, message_id, cx);
171 }),
172 ];
173 let agent_subscription = crate::agents::runs_handle(cx).map(|runs| {
174 cx.subscribe_in(
175 &runs,
176 window,
177 |this, _, event: &AgentRunsEvent, window, cx| match event {
178 AgentRunsEvent::StartRequested(request) => {
179 this.open_agent_dialog(request.clone(), window, cx)
180 }
181 AgentRunsEvent::OpenSettings => this
182 .notifications
183 .update(cx, |center, cx| center.open_agent_settings(cx)),
184 AgentRunsEvent::Finished(_) => {}
185 },
186 )
187 });
188 let sidebar = cx.new(|cx| SidebarView::new(state.clone(), activity_panel, saved_panel, cx));
189 let rail = cx.new(|cx| RailView::new(state.clone(), activity.clone(), sidebar.clone(), cx));
190 let conversation = cx.new(|cx| ConversationView::new(state.clone(), window, cx));
191 let subscription =
192 cx.subscribe_in(&state, window, |this, _, event: &AppEvent, window, cx| {
193 if matches!(event, AppEvent::Sidebar | AppEvent::Status) {
194 this.apply_open_target(cx);
195 }
196 if matches!(event, AppEvent::Forward) {
197 this.open_forward_dialog(window, cx);
198 }
199 if matches!(event, AppEvent::ImageViewer) {
200 this.open_image_viewer(window, cx);
201 }
202 if matches!(event, AppEvent::StatusMessage) {
203 this.open_status_dialog(window, cx);
204 }
205 if matches!(event, AppEvent::NotificationSettings) {
206 this.notifications
207 .update(cx, |center, cx| center.open_settings(cx));
208 }
209 if matches!(event, AppEvent::Profile) {
210 this.open_profile_card(window, cx);
211 }
212 cx.notify();
213 });
214 let focus_handle = cx.focus_handle();
215 window.focus(&focus_handle, cx);
216 let notifications = cx.new(|cx| NotificationCenter::new(state.clone(), window, cx));
217 let call_windows = cx.new(|cx| CallWindows::new(state.clone(), window, cx));
218 let user_input = cx.global::<UserInputHandle>().0.clone();
219 let escape_observation = cx.observe_keystrokes(|this, event, _, cx| {
220 this.user_input.touch();
221 if event.keystroke.key == "escape" {
222 this.state
223 .update(cx, |state, cx| state.leave_stage_fullscreen(cx));
224 }
225 });
226 let activation_observation = cx.observe_window_activation(window, |this, window, cx| {
227 if window.is_window_active() {
228 this.state
229 .update(cx, |state, cx| state.refresh_calendar(cx));
230 }
231 });
232 let closing = notifications.clone();
233 window.on_window_should_close(cx, move |_, cx| !closing.read(cx).intercept_close(cx));
234 let mut shell = AppShell {
235 state,
236 rail,
237 sidebar,
238 conversation,
239 call_chat: None,
240 prejoin: None,
241 switcher: None,
242 notifications,
243 _call_windows: call_windows,
244 forward_dialog: None,
245 image_viewer: None,
246 status_dialog: None,
247 shortcuts_dialog: None,
248 agent_dialog: None,
249 profile_card: None,
250 focus_handle,
251 open_target,
252 update: UpdateStatus::UpToDate,
253 user_input,
254 _subscription: subscription,
255 _call_media_observation: call_media_observation,
256 _panel_subscriptions: panel_subscriptions,
257 _agent_subscription: agent_subscription,
258 _escape_observation: escape_observation,
259 _activation_observation: activation_observation,
260 };
261 shell.apply_open_target(cx);
262 let Startup {
263 switcher_query,
264 composer_text,
265 reply_to_last,
266 } = startup;
267 if let Some(query) = switcher_query {
268 shell.toggle_switcher(&query, window, cx);
269 }
270 if composer_text.is_some() || reply_to_last {
271 cx.defer_in(window, move |this, window, cx| {
272 this.conversation.update(cx, |conversation, cx| {
273 if reply_to_last {
274 conversation.reply_to_latest_from_others(window, cx);
275 }
276 if let Some(text) = composer_text {
277 conversation.set_composer_text(&text, window, cx);
278 }
279 });
280 });
281 }
282 #[cfg(windows)]
283 cx.spawn_in(window, async move |this, cx| {
284 loop {
285 cx.background_executor().timer(updater::POLL_INTERVAL).await;
286 if this
287 .update_in(cx, |this, window, cx| this.poll_update(window, cx))
288 .is_err()
289 {
290 break;
291 }
292 }
293 })
294 .detach();
295 shell
296 }
297
298 #[cfg_attr(not(windows), allow(dead_code))]
299 fn poll_update(&mut self, window: &mut Window, cx: &mut Context<Self>) {
300 if matches!(
301 self.update,
302 UpdateStatus::Failed(_) | UpdateStatus::Installing
303 ) {
304 return;
305 }
306 let Some(paths) = updater::current_paths() else {
307 return;
308 };
309 if self.update == UpdateStatus::UpToDate {
310 if !updater::check(&paths) {
311 return;
312 }
313 self.update = UpdateStatus::Ready;
314 let update_exe = paths.update_exe.clone();
315 cx.background_spawn(async move { updater::prescan(&update_exe) })
316 .detach();
317 }
318 let conversation = self.conversation.read(cx);
319 let idle = updater::is_idle(IdleInputs {
320 window_active: window.is_window_active(),
321 composer_empty: conversation.composer_is_empty(cx),
322 send_in_flight: conversation.send_in_flight(),
323 });
324 if idle {
325 self.restart_into_update(cx);
326 }
327 cx.notify();
328 }
329
330 fn restart_into_update(&mut self, cx: &mut Context<Self>) {
331 if self.update == UpdateStatus::Installing {
332 return;
333 }
334 let Some(paths) = updater::current_paths() else {
335 return;
336 };
337 self.update = UpdateStatus::Installing;
338 cx.notify();
339 cx.spawn(async move |this, cx| {
340 let result = cx
341 .background_spawn(async move { updater::install_and_relaunch(&paths) })
342 .await;
343 let _ = this.update(cx, |this, cx| {
344 match result {
345 Ok(()) => cx.quit(),
346 Err(message) => this.update = UpdateStatus::Failed(message),
347 }
348 cx.notify();
349 });
350 })
351 .detach();
352 }
353
354 fn apply_open_target(&mut self, cx: &mut Context<Self>) {
355 let Some(target) = self.open_target else {
356 return;
357 };
358 let sidebar = &self.state.read(cx).sidebar;
359 let selection = match target {
360 OpenTarget::Chat(index) => sidebar
361 .chats
362 .get(index)
363 .map(|chat| Selection::Chat(chat.id.clone())),
364 OpenTarget::Channel(index) => sidebar
365 .teams
366 .iter()
367 .flat_map(|team| team.channels.iter())
368 .nth(index)
369 .map(|channel| Selection::Channel(channel.id.clone())),
370 };
371 if let Some(selection) = selection {
372 self.open_target = None;
373 self.state
374 .update(cx, |state, cx| state.select(selection, cx));
375 }
376 }
377
378 fn toggle_switcher(
379 &mut self,
380 initial_query: &str,
381 window: &mut Window,
382 cx: &mut Context<Self>,
383 ) {
384 if self.switcher.take().is_some() {
385 self.restore_focus(window, cx);
386 cx.notify();
387 return;
388 }
389 self.close_image_viewer(window, cx);
390 let candidates = candidates_from(self.state.read(cx));
391 let app = self.state.clone();
392 let switcher = cx.new(|cx| Switcher::new(app, candidates, initial_query, window, cx));
393 cx.subscribe_in(
394 &switcher,
395 window,
396 |this, _, event: &SwitcherEvent, window, cx| {
397 match event {
398 SwitcherEvent::Pick(selection) => {
399 let selection = selection.clone();
400 this.state
401 .update(cx, |state, cx| state.select(selection, cx));
402 }
403 SwitcherEvent::PickMessage {
404 selection,
405 message_id,
406 } => {
407 let (selection, message_id) = (selection.clone(), message_id.clone());
408 this.state.update(cx, |state, cx| {
409 state.jump_to_message(selection, message_id, cx)
410 });
411 }
412 SwitcherEvent::Close => {}
413 }
414 this.switcher = None;
415 this.restore_focus(window, cx);
416 cx.notify();
417 },
418 )
419 .detach();
420 self.switcher = Some(switcher);
421 cx.notify();
422 }
423
424 fn open_message(&mut self, conversation_id: &str, message_id: &str, cx: &mut Context<Self>) {
425 let Some(selection) = selection_for(&self.state.read(cx).sidebar, conversation_id) else {
426 return;
427 };
428 let message_id = message_id.to_owned();
429 self.state.update(cx, |state, cx| {
430 if message_id.is_empty() {
431 state.select(selection, cx)
432 } else {
433 state.jump_to_message(selection, message_id, cx)
434 }
435 });
436 }
437
438 fn open_status_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
439 if !self
440 .state
441 .update(cx, |state, _| state.take_status_message_request())
442 {
443 return;
444 }
445 self.close_image_viewer(window, cx);
446 self.switcher = None;
447 let app = self.state.clone();
448 let dialog = cx.new(|cx| StatusMessageDialog::new(app, window, cx));
449 cx.subscribe_in(
450 &dialog,
451 window,
452 |this, _, _: &StatusMessageDialogEvent, window, cx| {
453 this.status_dialog = None;
454 this.restore_focus(window, cx);
455 cx.notify();
456 },
457 )
458 .detach();
459 self.status_dialog = Some(dialog);
460 cx.notify();
461 }
462
463 fn open_agent_dialog(
464 &mut self,
465 request: StartRequest,
466 window: &mut Window,
467 cx: &mut Context<Self>,
468 ) {
469 let Some(runs) = crate::agents::runs_handle(cx) else {
470 return;
471 };
472 let settings = runs.read(cx).settings();
473 let Some(action) = settings
474 .actions
475 .iter()
476 .find(|action| action.id == request.action_id)
477 .cloned()
478 else {
479 return;
480 };
481 let agent_name = settings
482 .agents
483 .iter()
484 .find(|agent| agent.id == action.agent_id)
485 .map(|agent| agent.name.clone())
486 .unwrap_or_default();
487 self.switcher = None;
488 let app = self.state.clone();
489 let dialog = cx.new(|cx| StartDialog::new(app, request, action, &agent_name, window, cx));
490 cx.subscribe_in(
491 &dialog,
492 window,
493 |this, _, _: &StartDialogEvent, window, cx| {
494 this.agent_dialog = None;
495 window.focus(&this.focus_handle, cx);
496 cx.notify();
497 },
498 )
499 .detach();
500 self.agent_dialog = Some(dialog);
501 cx.notify();
502 }
503
504 fn toggle_shortcuts_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
505 if self.shortcuts_dialog.take().is_some() {
506 self.restore_focus(window, cx);
507 cx.notify();
508 return;
509 }
510 self.close_image_viewer(window, cx);
511 self.switcher = None;
512 let dialog = cx.new(|cx| ShortcutsDialog::new(window, cx));
513 cx.subscribe_in(
514 &dialog,
515 window,
516 |this, _, _: &ShortcutsDialogEvent, window, cx| {
517 this.shortcuts_dialog = None;
518 this.restore_focus(window, cx);
519 cx.notify();
520 },
521 )
522 .detach();
523 self.shortcuts_dialog = Some(dialog);
524 cx.notify();
525 }
526
527 fn open_profile_card(&mut self, window: &mut Window, cx: &mut Context<Self>) {
528 let Some(request) = self
529 .state
530 .update(cx, |state, _| state.take_profile_request())
531 else {
532 return;
533 };
534 self.close_image_viewer(window, cx);
535 if let Some(card) = &self.profile_card {
536 card.update(cx, |card, cx| {
537 card.move_to(request.user_id, request.anchor, cx)
538 });
539 return;
540 }
541 let app = self.state.clone();
542 let card = cx.new(|cx| ProfileCard::new(app, request.user_id, request.anchor, window, cx));
543 cx.subscribe_in(
544 &card,
545 window,
546 |this, _, _: &ProfileCardEvent, window, cx| {
547 this.profile_card = None;
548 this.restore_focus(window, cx);
549 cx.notify();
550 },
551 )
552 .detach();
553 self.profile_card = Some(card);
554 cx.notify();
555 }
556
557 fn open_image_viewer(&mut self, window: &mut Window, cx: &mut Context<Self>) {
558 let Some(request) = self
559 .state
560 .update(cx, |state, _| state.take_image_viewer_request())
561 else {
562 return;
563 };
564 self.switcher = None;
565 let app = self.state.clone();
566 let viewer = cx.new(|cx| ImageViewer::new(app, request, window, cx));
567 cx.subscribe_in(
568 &viewer,
569 window,
570 |this, _, _: &ImageViewerEvent, window, cx| {
571 this.image_viewer = None;
572 window.focus(&this.focus_handle, cx);
573 cx.notify();
574 },
575 )
576 .detach();
577 self.image_viewer = Some(viewer);
578 cx.notify();
579 }
580
581 fn close_image_viewer(&mut self, window: &mut Window, cx: &mut Context<Self>) {
582 if self.image_viewer.take().is_some() {
583 window.focus(&self.focus_handle, cx);
584 cx.notify();
585 }
586 }
587
588 fn restore_focus(&self, window: &mut Window, cx: &mut Context<Self>) {
589 match &self.image_viewer {
590 Some(viewer) => {
591 let handle = viewer.read(cx).focus_handle();
592 window.focus(&handle, cx)
593 }
594 None => window.focus(&self.focus_handle, cx),
595 }
596 }
597
598 fn open_forward_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
599 let Some(source) = self
600 .state
601 .update(cx, |state, _| state.take_forward_request())
602 else {
603 return;
604 };
605 self.switcher = None;
606 let candidates = candidates_from(self.state.read(cx));
607 let app = self.state.clone();
608 let dialog = cx.new(|cx| ForwardDialog::new(app, source, candidates, window, cx));
609 cx.subscribe_in(
610 &dialog,
611 window,
612 |this, _, event: &ForwardDialogEvent, window, cx| {
613 this.forward_dialog = None;
614 this.restore_focus(window, cx);
615 if let ForwardDialogEvent::Sent { target, title } = event {
616 let target = target.clone();
617 let open = NoticeAction::new("Open", move |state, cx| {
618 state.select(target.clone(), cx)
619 });
620 this.state.update(cx, |state, cx| {
621 state.raise_notice(format!("Forwarded to {title}"), Some(open), cx)
622 });
623 }
624 cx.notify();
625 },
626 )
627 .detach();
628 self.forward_dialog = Some(dialog);
629 cx.notify();
630 }
631}
632
633impl AppShell {
634 fn islands(&self, call_view: Option<AnyElement>) -> impl IntoElement {
635 h_flex()
636 .debug_selector(|| "shell/islands".into())
637 .flex_1()
638 .min_h_0()
639 .w_full()
640 .gap(px(ISLAND_GAP))
641 .pr(px(ISLAND_GAP))
642 .py(px(ISLAND_GAP))
643 .child(
644 h_flex()
645 .h_full()
646 .flex_none()
647 .child(self.rail.clone())
648 .child(
649 self.sidebar.clone().cached(
650 StyleRefinement::default()
651 .w(px(SIDEBAR_WIDTH))
652 .h_full()
653 .flex_none(),
654 ),
655 ),
656 )
657 .child(match (call_view, self.prejoin.clone()) {
658 (Some(call_view), _) => call_view,
659 (None, Some(prejoin)) => prejoin
660 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
661 .into_any_element(),
662 (None, None) => self
663 .conversation
664 .clone()
665 .cached(
666 StyleRefinement::default()
667 .flex_1()
668 .min_w_0()
669 .h_full()
670 .rounded(px(10.))
671 .bg(theme::surface())
672 .overflow_hidden(),
673 )
674 .into_any_element(),
675 })
676 }
677}
678
679impl Render for AppShell {
680 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
681 if let Some(dialog) = self
682 .state
683 .read(cx)
684 .task_dialog
685 .as_ref()
686 .map(|dialog| (dialog.scope.clone(), dialog.card.clone()))
687 {
688 self.state.update(cx, |state, cx| {
689 state.ensure_card_inputs(&dialog.0, &dialog.1, window, cx)
690 });
691 }
692 if let Some(me) = self.state.read(cx).directory.me.clone() {
693 let app = self.state.clone();
694 cx.defer(move |cx| {
695 app.update(cx, |state, cx| {
696 state.request_avatars(vec![me.user_id.clone()], cx);
697 state.request_presence(vec![me.user_id], cx);
698 });
699 });
700 }
701 let chat_thread = self.state.read(cx).call_chat_thread();
702 self.sync_call_chat(chat_thread, window, cx);
703 self.sync_prejoin(window, cx);
704 let chat_panel = self.call_chat.as_ref().map(|(_, view)| view.clone());
705 let state = self.state.read(cx);
706 let call_view =
707 render_call_view(&self.state, state, chat_panel).filter(|_| state.viewing_call());
708 let call_mini = render_call_mini(&self.state, state);
709 let stage_overlay = render_stage_overlay(&self.state, state);
710 let status = render_status_bar(
711 state,
712 &self.update,
713 cx.listener(|this, _, _, cx| this.restart_into_update(cx)),
714 cx.listener(|this, _, _, cx| {
715 this.state
716 .update(cx, |state, cx| state.run_notice_action(cx))
717 }),
718 );
719 let title_bar = render_title_bar(
720 own_status_button(&self.state, state),
721 cx.listener(|this, _, window, cx| this.toggle_switcher("", window, cx)),
722 );
723 div()
724 .id("app-shell")
725 .key_context("AppShell")
726 .track_focus(&self.focus_handle)
727 .on_action(cx.listener(|this, _: &OpenSwitcher, window, cx| {
728 this.toggle_switcher("", window, cx);
729 }))
730 .on_action(cx.listener(|this, _: &NewChat, window, cx| {
731 this.close_image_viewer(window, cx);
732 this.state.update(cx, |state, cx| state.start_new_chat(cx));
733 }))
734 .on_action(cx.listener(|this, _: &ToggleCallMute, _, cx| {
735 this.state
736 .update(cx, |state, cx| state.toggle_call_mute(cx));
737 }))
738 .on_action(cx.listener(|this, _: &ShowShortcuts, window, cx| {
739 this.toggle_shortcuts_dialog(window, cx);
740 }))
741 .on_action(cx.listener(|this, _: &OpenActivity, window, cx| {
742 this.close_image_viewer(window, cx);
743 this.sidebar
744 .update(cx, |sidebar, cx| sidebar.show_activity(cx));
745 }))
746 .on_action(cx.listener(|this, _: &OpenSaved, window, cx| {
747 this.close_image_viewer(window, cx);
748 this.sidebar
749 .update(cx, |sidebar, cx| sidebar.show_saved(cx));
750 }))
751 .on_action(cx.listener(|this, _: &OpenChatsTab, window, cx| {
752 this.close_image_viewer(window, cx);
753 this.sidebar
754 .update(cx, |sidebar, cx| sidebar.show_chats(cx));
755 }))
756 .on_action(cx.listener(|this, _: &OpenChannelsTab, window, cx| {
757 this.close_image_viewer(window, cx);
758 this.sidebar
759 .update(cx, |sidebar, cx| sidebar.show_channels(cx));
760 }))
761 .on_action(cx.listener(|this, _: &OpenCallsTab, window, cx| {
762 this.close_image_viewer(window, cx);
763 this.sidebar
764 .update(cx, |sidebar, cx| sidebar.show_calls(cx));
765 }))
766 .on_action(cx.listener(|this, _: &PreviousConversation, window, cx| {
767 this.close_image_viewer(window, cx);
768 this.sidebar.update(cx, |sidebar, cx| {
769 sidebar.select_adjacent(Step::Previous, cx)
770 });
771 }))
772 .on_action(cx.listener(|this, _: &NextConversation, window, cx| {
773 this.close_image_viewer(window, cx);
774 this.sidebar
775 .update(cx, |sidebar, cx| sidebar.select_adjacent(Step::Next, cx));
776 }))
777 .on_action(cx.listener(|this, _: &AcceptCall, _, cx| {
778 this.state
779 .update(cx, |state, cx| state.accept_ringing_call(cx));
780 }))
781 .on_action(cx.listener(|this, _: &DeclineCall, _, cx| {
782 this.state
783 .update(cx, |state, cx| state.decline_ringing_call(cx));
784 }))
785 .on_action(cx.listener(|this, _: &JoinMeetingFromToast, _, cx| {
786 this.state
787 .update(cx, |state, cx| state.join_latest_meeting_toast(cx));
788 }))
789 .on_action(cx.listener(|this, _: &HangUpCall, _, cx| {
790 this.state.update(cx, |state, cx| state.leave_call(cx));
791 }))
792 .on_action(cx.listener(|this, _: &ToggleCallCamera, _, cx| {
793 this.state
794 .update(cx, |state, cx| state.toggle_call_camera(cx));
795 }))
796 .on_action(cx.listener(|this, _: &ToggleCallShare, _, cx| {
797 this.state
798 .update(cx, |state, cx| state.toggle_call_share(cx));
799 }))
800 .on_action(cx.listener(|this, _: &ReplyToHovered, window, cx| {
801 this.close_image_viewer(window, cx);
802 this.conversation.update(cx, |conversation, cx| {
803 conversation.reply_to_hovered(window, cx)
804 });
805 }))
806 .relative()
807 .size_full()
808 .bg(theme::background())
809 .text_color(theme::text())
810 .text_size(px(14.))
811 .child(crate::frame_log::probe("first"))
812 .child(user_activity::input_probe(self.user_input.clone()))
813 .child(
814 v_flex()
815 .debug_selector(|| "shell".into())
816 .size_full()
817 .child(title_bar)
818 .child(self.islands(call_view))
819 .child(status),
820 )
821 .children(call_mini)
822 .children(stage_overlay)
823 .children(self.image_viewer.clone())
824 .children(self.switcher.clone())
825 .children(render_task_dialog(self.state.read(cx), cx))
826 .children(self.forward_dialog.clone())
827 .children(self.status_dialog.clone())
828 .children(self.shortcuts_dialog.clone())
829 .children(self.agent_dialog.clone())
830 .children(self.profile_card.clone())
831 .child(crate::frame_log::probe("last"))
832 }
833}