BlueGit

ict rusty-teams

Files

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

shell.rs

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