BlueGit

ict rusty-teams

Files

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

shell.rs

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