BlueGit

ict rusty-teams

Files

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

shell.rs

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