BlueGit

ict rusty-teams

Files

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

shell.rs

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