BlueGit

ict rusty-teams

feat(parity): Calls page like Teams (dial and history)

- Calls tab opens a full page: dial column with people picker, history with filters
- Upcoming agenda dropped from calls list, calendar covers it
- Join with ID resolves meeting links first

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-08 · 3 weeks ago

Hash
71b93d86c2b339b9486777170751876b809eace8
Parent
29318242
12 files changed +482 −682
crates/app-state/src/call/calendar.rs +0 −1
@@ -42,7 +42,6 @@ impl AppState {
42 42 self.calls_list.rebuild(
43 43 &self.call_history,
44 44 &self.sidebar.chats,
45 &self.calendar_events,
46 45 now,
47 46 offset,
48 47 );
@@ -42,7 +42,6 @@ impl AppState {
42 self.calls_list.rebuild(
42 self.calls_list.rebuild(
43 &self.call_history,
43 &self.call_history,
44 &self.sidebar.chats,
44 &self.sidebar.chats,
45 &self.calendar_events,
46 now,
45 now,
47 offset,
46 offset,
48 );
47 );
crates/app-state/src/call/join.rs +4 −12
@@ -11,7 +11,6 @@ use super::prejoin::{DemoMeeting, MeetingJoin};
11 11 use crate::app_state::{AppState, selection_for, selection_title};
12 12 use crate::runtime;
13 13
14 const NO_LINK_NOTICE: &str = "No Teams meeting link in the clipboard";
15 14 const NOT_FOUND_NOTICE: &str = "Could not find that meeting";
16 15 const BAD_ID_MESSAGE: &str = "Enter the meeting ID from the invitation.";
17 16 const DEMO_GUEST_COUNT: usize = 4;
@@ -165,23 +164,16 @@ impl AppState {
165 164 .detach();
166 165 }
167 166
168 pub fn join_meeting_from_clipboard(&mut self, cx: &mut Context<Self>) {
169 let link = cx
170 .read_from_clipboard()
171 .and_then(|item| item.text())
172 .and_then(|text| find_meeting_link(&text));
173 match link {
174 Some((url, _)) => self.join_meeting_link(&url, cx),
175 None => self.raise_notice(NO_LINK_NOTICE.to_owned(), None, cx),
176 }
177 }
178
179 167 pub fn join_meeting_by_id(
180 168 &mut self,
181 169 meeting_id: &str,
182 170 passcode: &str,
183 171 cx: &mut Context<Self>,
184 172 ) -> Result<(), String> {
173 if let Some((url, _)) = find_meeting_link(meeting_id) {
174 self.join_meeting_link(&url, cx);
175 return Ok(());
176 }
185 177 let code =
186 178 meeting_code_from_id(meeting_id, passcode).ok_or_else(|| BAD_ID_MESSAGE.to_owned())?;
187 179 self.join_meeting_code(code, JoinMode::Prejoin, cx);
@@ -11,7 +11,6 @@ use super::prejoin::{DemoMeeting, MeetingJoin};
11use crate::app_state::{AppState, selection_for, selection_title};
11use crate::app_state::{AppState, selection_for, selection_title};
12use crate::runtime;
12use crate::runtime;
13
13
14const NO_LINK_NOTICE: &str = "No Teams meeting link in the clipboard";
15const NOT_FOUND_NOTICE: &str = "Could not find that meeting";
14const NOT_FOUND_NOTICE: &str = "Could not find that meeting";
16const BAD_ID_MESSAGE: &str = "Enter the meeting ID from the invitation.";
15const BAD_ID_MESSAGE: &str = "Enter the meeting ID from the invitation.";
17const DEMO_GUEST_COUNT: usize = 4;
16const DEMO_GUEST_COUNT: usize = 4;
@@ -165,23 +164,16 @@ impl AppState {
165 .detach();
164 .detach();
166 }
165 }
167
166
168 pub fn join_meeting_from_clipboard(&mut self, cx: &mut Context<Self>) {
169 let link = cx
170 .read_from_clipboard()
171 .and_then(|item| item.text())
172 .and_then(|text| find_meeting_link(&text));
173 match link {
174 Some((url, _)) => self.join_meeting_link(&url, cx),
175 None => self.raise_notice(NO_LINK_NOTICE.to_owned(), None, cx),
176 }
177 }
178
179 pub fn join_meeting_by_id(
167 pub fn join_meeting_by_id(
180 &mut self,
168 &mut self,
181 meeting_id: &str,
169 meeting_id: &str,
182 passcode: &str,
170 passcode: &str,
183 cx: &mut Context<Self>,
171 cx: &mut Context<Self>,
184 ) -> Result<(), String> {
172 ) -> Result<(), String> {
173 if let Some((url, _)) = find_meeting_link(meeting_id) {
174 self.join_meeting_link(&url, cx);
175 return Ok(());
176 }
185 let code =
177 let code =
186 meeting_code_from_id(meeting_id, passcode).ok_or_else(|| BAD_ID_MESSAGE.to_owned())?;
178 meeting_code_from_id(meeting_id, passcode).ok_or_else(|| BAD_ID_MESSAGE.to_owned())?;
187 self.join_meeting_code(code, JoinMode::Prejoin, cx);
179 self.join_meeting_code(code, JoinMode::Prejoin, cx);
crates/app-state/src/call/list.rs +12 −98
@@ -1,23 +1,14 @@
1 1 use std::ops::Range;
2 2
3 use chatsvc::CalendarEvent;
4 3 use chrono::{DateTime, Duration, FixedOffset, NaiveDate, Utc};
5 4 use store::ChatRecord;
6 5 use teams_core::{CallDirection, CallLogEntry};
7 6
8 use super::agenda::{AgendaRow, group_by_day};
9 7 use super::history::{CallRow, call_rows};
10 8
11 pub const SECTION_HEIGHT: f32 = 34.;
12 pub const DAY_HEIGHT: f32 = 26.;
13 pub const AGENDA_ROW_HEIGHT: f32 = 58.;
14 9 pub const CALL_ROW_HEIGHT: f32 = 54.;
15 10 pub const EMPTY_HEIGHT: f32 = 56.;
16 pub const FILTERS_HEIGHT: f32 = 36.;
17 11 const MAX_AGE_SECONDS: i64 = 60;
18 const UPCOMING_TITLE: &str = "Upcoming";
19 const RECENT_TITLE: &str = "Recent";
20 const NO_MEETINGS_TEXT: &str = "No meetings in the next 7 days";
21 12 const NO_CALLS_TEXT: &str = "No calls yet";
22 13
23 14 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
@@ -67,10 +58,6 @@ impl HistoryFilter {
67 58
68 59 #[derive(Debug, Clone, PartialEq, Eq)]
69 60 pub enum ListEntry {
70 Section(&'static str),
71 Filters(HistoryFilter),
72 Day(String),
73 Agenda(AgendaRow),
74 61 Call(CallRow),
75 62 Empty(&'static str),
76 63 }
@@ -78,10 +65,6 @@ pub enum ListEntry {
78 65 impl ListEntry {
79 66 pub fn height(&self) -> f32 {
80 67 match self {
81 ListEntry::Section(_) => SECTION_HEIGHT,
82 ListEntry::Filters(_) => FILTERS_HEIGHT,
83 ListEntry::Day(_) => DAY_HEIGHT,
84 ListEntry::Agenda(_) => AGENDA_ROW_HEIGHT,
85 68 ListEntry::Call(_) => CALL_ROW_HEIGHT,
86 69 ListEntry::Empty(_) => EMPTY_HEIGHT,
87 70 }
@@ -144,21 +127,10 @@ impl CallsList {
144 127 &mut self,
145 128 history: &[CallLogEntry],
146 129 chats: &[ChatRecord],
147 events: &[CalendarEvent],
148 130 now: DateTime<Utc>,
149 131 offset: FixedOffset,
150 132 ) {
151 let mut entries = vec![ListEntry::Section(UPCOMING_TITLE)];
152 let days = group_by_day(events, now, offset);
153 if days.is_empty() {
154 entries.push(ListEntry::Empty(NO_MEETINGS_TEXT));
155 }
156 for day in days {
157 entries.push(ListEntry::Day(day.label));
158 entries.extend(day.rows.into_iter().map(ListEntry::Agenda));
159 }
160 entries.push(ListEntry::Section(RECENT_TITLE));
161 entries.push(ListEntry::Filters(self.filter));
133 let mut entries = Vec::new();
162 134 let filter = self.filter;
163 135 let admitted = history.iter().filter(|entry| filter.admits(entry));
164 136 let calls = call_rows(admitted, chats, now, offset);
@@ -210,7 +182,6 @@ impl CallsList {
210 182
211 183 #[cfg(test)]
212 184 mod tests {
213 use chatsvc::ResponseType;
214 185 use chrono::TimeZone;
215 186 use teams_core::{CallDirection, CallOutcome};
216 187
@@ -238,49 +209,17 @@ mod tests {
238 209 }
239 210 }
240 211
241 fn event(id: &str, minutes_from_now: i64) -> CalendarEvent {
242 CalendarEvent {
243 object_id: id.into(),
244 subject: id.into(),
245 start: now() + Duration::minutes(minutes_from_now),
246 end: now() + Duration::minutes(minutes_from_now + 30),
247 all_day: false,
248 cancelled: false,
249 online: true,
250 join_url: None,
251 thread_id: None,
252 organizer_name: None,
253 organizer_address: None,
254 ical_uid: None,
255 show_as: Default::default(),
256 response: ResponseType::Accepted,
257 }
258 }
259
260 fn built(calls: usize, events: usize) -> CallsList {
212 fn built(calls: usize) -> CallsList {
261 213 let history: Vec<CallLogEntry> =
262 214 (0..calls).map(|index| call(&format!("c{index}"))).collect();
263 let agenda: Vec<CalendarEvent> = (0..events)
264 .map(|index| event(&format!("e{index}"), 30 + index as i64 * 60))
265 .collect();
266 215 let mut list = CallsList::default();
267 list.rebuild(&history, &[], &agenda, now(), zero());
216 list.rebuild(&history, &[], now(), zero());
268 217 list
269 218 }
270 219
271 220 #[test]
272 fn empty_sections_show_their_empty_text() {
273 let list = built(0, 0);
274 assert_eq!(
275 list.entries(),
276 [
277 ListEntry::Section("Upcoming"),
278 ListEntry::Empty("No meetings in the next 7 days"),
279 ListEntry::Section("Recent"),
280 ListEntry::Filters(HistoryFilter::All),
281 ListEntry::Empty("No calls yet"),
282 ]
283 );
221 fn an_empty_history_shows_its_empty_text() {
222 assert_eq!(built(0).entries(), [ListEntry::Empty("No calls yet")]);
284 223 }
285 224
286 225 #[test]
@@ -298,15 +237,13 @@ mod tests {
298 237 let keys = |filter: HistoryFilter| -> Vec<String> {
299 238 let mut list = CallsList::default();
300 239 list.set_filter(filter);
301 list.rebuild(&history, &[], &[], now(), zero());
240 list.rebuild(&history, &[], now(), zero());
302 241 list.entries()
303 242 .iter()
304 243 .filter_map(|entry| match entry {
305 244 ListEntry::Call(row) => Some(row.key.clone()),
306 245 ListEntry::Empty(text) => Some((*text).to_owned()),
307 _ => None,
308 246 })
309 .skip(1)
310 247 .collect()
311 248 };
312 249 assert_eq!(keys(HistoryFilter::All), ["missed", "incoming", "outgoing"]);
@@ -315,54 +252,31 @@ mod tests {
315 252 assert_eq!(keys(HistoryFilter::Outgoing), ["outgoing"]);
316 253 let mut list = CallsList::default();
317 254 list.set_filter(HistoryFilter::Missed);
318 list.rebuild(&[call("outgoing")], &[], &[], now(), zero());
255 list.rebuild(&[call("outgoing")], &[], now(), zero());
319 256 assert_eq!(list.entries().last(), Some(&ListEntry::Empty("No missed calls")));
320 257 }
321 258
322 #[test]
323 fn upcoming_comes_before_recent_with_day_headers() {
324 let list = built(2, 2);
325 let kinds: Vec<&str> = list
326 .entries()
327 .iter()
328 .map(|entry| match entry {
329 ListEntry::Section(_) => "section",
330 ListEntry::Filters(_) => "filters",
331 ListEntry::Day(_) => "day",
332 ListEntry::Agenda(_) => "agenda",
333 ListEntry::Call(_) => "call",
334 ListEntry::Empty(_) => "empty",
335 })
336 .collect();
337 assert_eq!(
338 kinds,
339 [
340 "section", "day", "agenda", "agenda", "section", "filters", "call", "call"
341 ]
342 );
343 }
344
345 259 #[test]
346 260 fn a_fresh_list_needs_a_rebuild_until_built() {
347 261 let mut list = CallsList::default();
348 262 assert!(list.needs_rebuild(now(), zero()));
349 list.rebuild(&[], &[], &[], now(), zero());
263 list.rebuild(&[], &[], now(), zero());
350 264 assert!(!list.needs_rebuild(now() + Duration::seconds(30), zero()));
351 265 }
352 266
353 267 #[test]
354 268 fn invalidation_age_and_a_new_day_force_a_rebuild() {
355 let mut list = built(0, 0);
269 let mut list = built(0);
356 270 list.invalidate();
357 271 assert!(list.needs_rebuild(now(), zero()));
358 list.rebuild(&[], &[], &[], now(), zero());
272 list.rebuild(&[], &[], now(), zero());
359 273 assert!(list.needs_rebuild(now() + Duration::seconds(61), zero()));
360 274 assert!(list.needs_rebuild(now() + Duration::hours(17), zero()));
361 275 }
362 276
363 277 #[test]
364 278 fn the_window_keeps_only_rows_on_screen_and_spacers_for_the_rest() {
365 let list = built(100, 0);
279 let list = built(100);
366 280 let total = list.total_height();
367 281 let window = list.window(1000., 1200.);
368 282 assert!(window.range.len() < 12);
@@ -377,7 +291,7 @@ mod tests {
377 291
378 292 #[test]
379 293 fn the_window_clamps_at_both_ends() {
380 let list = built(100, 0);
294 let list = built(100);
381 295 let top = list.window(-300., 100.);
382 296 assert_eq!(top.range.start, 0);
383 297 assert_eq!(top.before, 0.);
@@ -1,23 +1,14 @@
1use std::ops::Range;
1use std::ops::Range;
2
2
3use chatsvc::CalendarEvent;
4use chrono::{DateTime, Duration, FixedOffset, NaiveDate, Utc};
3use chrono::{DateTime, Duration, FixedOffset, NaiveDate, Utc};
5use store::ChatRecord;
4use store::ChatRecord;
6use teams_core::{CallDirection, CallLogEntry};
5use teams_core::{CallDirection, CallLogEntry};
7
6
8use super::agenda::{AgendaRow, group_by_day};
9use super::history::{CallRow, call_rows};
7use super::history::{CallRow, call_rows};
10
8
11pub const SECTION_HEIGHT: f32 = 34.;
12pub const DAY_HEIGHT: f32 = 26.;
13pub const AGENDA_ROW_HEIGHT: f32 = 58.;
14pub const CALL_ROW_HEIGHT: f32 = 54.;
9pub const CALL_ROW_HEIGHT: f32 = 54.;
15pub const EMPTY_HEIGHT: f32 = 56.;
10pub const EMPTY_HEIGHT: f32 = 56.;
16pub const FILTERS_HEIGHT: f32 = 36.;
17const MAX_AGE_SECONDS: i64 = 60;
11const MAX_AGE_SECONDS: i64 = 60;
18const UPCOMING_TITLE: &str = "Upcoming";
19const RECENT_TITLE: &str = "Recent";
20const NO_MEETINGS_TEXT: &str = "No meetings in the next 7 days";
21const NO_CALLS_TEXT: &str = "No calls yet";
12const NO_CALLS_TEXT: &str = "No calls yet";
22
13
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
14#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
@@ -67,10 +58,6 @@ impl HistoryFilter {
67
58
68#[derive(Debug, Clone, PartialEq, Eq)]
59#[derive(Debug, Clone, PartialEq, Eq)]
69pub enum ListEntry {
60pub enum ListEntry {
70 Section(&'static str),
71 Filters(HistoryFilter),
72 Day(String),
73 Agenda(AgendaRow),
74 Call(CallRow),
61 Call(CallRow),
75 Empty(&'static str),
62 Empty(&'static str),
76}
63}
@@ -78,10 +65,6 @@ pub enum ListEntry {
78impl ListEntry {
65impl ListEntry {
79 pub fn height(&self) -> f32 {
66 pub fn height(&self) -> f32 {
80 match self {
67 match self {
81 ListEntry::Section(_) => SECTION_HEIGHT,
82 ListEntry::Filters(_) => FILTERS_HEIGHT,
83 ListEntry::Day(_) => DAY_HEIGHT,
84 ListEntry::Agenda(_) => AGENDA_ROW_HEIGHT,
85 ListEntry::Call(_) => CALL_ROW_HEIGHT,
68 ListEntry::Call(_) => CALL_ROW_HEIGHT,
86 ListEntry::Empty(_) => EMPTY_HEIGHT,
69 ListEntry::Empty(_) => EMPTY_HEIGHT,
87 }
70 }
@@ -144,21 +127,10 @@ impl CallsList {
144 &mut self,
127 &mut self,
145 history: &[CallLogEntry],
128 history: &[CallLogEntry],
146 chats: &[ChatRecord],
129 chats: &[ChatRecord],
147 events: &[CalendarEvent],
148 now: DateTime<Utc>,
130 now: DateTime<Utc>,
149 offset: FixedOffset,
131 offset: FixedOffset,
150 ) {
132 ) {
151 let mut entries = vec![ListEntry::Section(UPCOMING_TITLE)];
133 let mut entries = Vec::new();
152 let days = group_by_day(events, now, offset);
153 if days.is_empty() {
154 entries.push(ListEntry::Empty(NO_MEETINGS_TEXT));
155 }
156 for day in days {
157 entries.push(ListEntry::Day(day.label));
158 entries.extend(day.rows.into_iter().map(ListEntry::Agenda));
159 }
160 entries.push(ListEntry::Section(RECENT_TITLE));
161 entries.push(ListEntry::Filters(self.filter));
162 let filter = self.filter;
134 let filter = self.filter;
163 let admitted = history.iter().filter(|entry| filter.admits(entry));
135 let admitted = history.iter().filter(|entry| filter.admits(entry));
164 let calls = call_rows(admitted, chats, now, offset);
136 let calls = call_rows(admitted, chats, now, offset);
@@ -210,7 +182,6 @@ impl CallsList {
210
182
211#[cfg(test)]
183#[cfg(test)]
212mod tests {
184mod tests {
213 use chatsvc::ResponseType;
214 use chrono::TimeZone;
185 use chrono::TimeZone;
215 use teams_core::{CallDirection, CallOutcome};
186 use teams_core::{CallDirection, CallOutcome};
216
187
@@ -238,49 +209,17 @@ mod tests {
238 }
209 }
239 }
210 }
240
211
241 fn event(id: &str, minutes_from_now: i64) -> CalendarEvent {
212 fn built(calls: usize) -> CallsList {
242 CalendarEvent {
243 object_id: id.into(),
244 subject: id.into(),
245 start: now() + Duration::minutes(minutes_from_now),
246 end: now() + Duration::minutes(minutes_from_now + 30),
247 all_day: false,
248 cancelled: false,
249 online: true,
250 join_url: None,
251 thread_id: None,
252 organizer_name: None,
253 organizer_address: None,
254 ical_uid: None,
255 show_as: Default::default(),
256 response: ResponseType::Accepted,
257 }
258 }
259
260 fn built(calls: usize, events: usize) -> CallsList {
261 let history: Vec<CallLogEntry> =
213 let history: Vec<CallLogEntry> =
262 (0..calls).map(|index| call(&format!("c{index}"))).collect();
214 (0..calls).map(|index| call(&format!("c{index}"))).collect();
263 let agenda: Vec<CalendarEvent> = (0..events)
264 .map(|index| event(&format!("e{index}"), 30 + index as i64 * 60))
265 .collect();
266 let mut list = CallsList::default();
215 let mut list = CallsList::default();
267 list.rebuild(&history, &[], &agenda, now(), zero());
216 list.rebuild(&history, &[], now(), zero());
268 list
217 list
269 }
218 }
270
219
271 #[test]
220 #[test]
272 fn empty_sections_show_their_empty_text() {
221 fn an_empty_history_shows_its_empty_text() {
273 let list = built(0, 0);
222 assert_eq!(built(0).entries(), [ListEntry::Empty("No calls yet")]);
274 assert_eq!(
275 list.entries(),
276 [
277 ListEntry::Section("Upcoming"),
278 ListEntry::Empty("No meetings in the next 7 days"),
279 ListEntry::Section("Recent"),
280 ListEntry::Filters(HistoryFilter::All),
281 ListEntry::Empty("No calls yet"),
282 ]
283 );
284 }
223 }
285
224
286 #[test]
225 #[test]
@@ -298,15 +237,13 @@ mod tests {
298 let keys = |filter: HistoryFilter| -> Vec<String> {
237 let keys = |filter: HistoryFilter| -> Vec<String> {
299 let mut list = CallsList::default();
238 let mut list = CallsList::default();
300 list.set_filter(filter);
239 list.set_filter(filter);
301 list.rebuild(&history, &[], &[], now(), zero());
240 list.rebuild(&history, &[], now(), zero());
302 list.entries()
241 list.entries()
303 .iter()
242 .iter()
304 .filter_map(|entry| match entry {
243 .filter_map(|entry| match entry {
305 ListEntry::Call(row) => Some(row.key.clone()),
244 ListEntry::Call(row) => Some(row.key.clone()),
306 ListEntry::Empty(text) => Some((*text).to_owned()),
245 ListEntry::Empty(text) => Some((*text).to_owned()),
307 _ => None,
308 })
246 })
309 .skip(1)
310 .collect()
247 .collect()
311 };
248 };
312 assert_eq!(keys(HistoryFilter::All), ["missed", "incoming", "outgoing"]);
249 assert_eq!(keys(HistoryFilter::All), ["missed", "incoming", "outgoing"]);
@@ -315,54 +252,31 @@ mod tests {
315 assert_eq!(keys(HistoryFilter::Outgoing), ["outgoing"]);
252 assert_eq!(keys(HistoryFilter::Outgoing), ["outgoing"]);
316 let mut list = CallsList::default();
253 let mut list = CallsList::default();
317 list.set_filter(HistoryFilter::Missed);
254 list.set_filter(HistoryFilter::Missed);
318 list.rebuild(&[call("outgoing")], &[], &[], now(), zero());
255 list.rebuild(&[call("outgoing")], &[], now(), zero());
319 assert_eq!(list.entries().last(), Some(&ListEntry::Empty("No missed calls")));
256 assert_eq!(list.entries().last(), Some(&ListEntry::Empty("No missed calls")));
320 }
257 }
321
258
322 #[test]
323 fn upcoming_comes_before_recent_with_day_headers() {
324 let list = built(2, 2);
325 let kinds: Vec<&str> = list
326 .entries()
327 .iter()
328 .map(|entry| match entry {
329 ListEntry::Section(_) => "section",
330 ListEntry::Filters(_) => "filters",
331 ListEntry::Day(_) => "day",
332 ListEntry::Agenda(_) => "agenda",
333 ListEntry::Call(_) => "call",
334 ListEntry::Empty(_) => "empty",
335 })
336 .collect();
337 assert_eq!(
338 kinds,
339 [
340 "section", "day", "agenda", "agenda", "section", "filters", "call", "call"
341 ]
342 );
343 }
344
345 #[test]
259 #[test]
346 fn a_fresh_list_needs_a_rebuild_until_built() {
260 fn a_fresh_list_needs_a_rebuild_until_built() {
347 let mut list = CallsList::default();
261 let mut list = CallsList::default();
348 assert!(list.needs_rebuild(now(), zero()));
262 assert!(list.needs_rebuild(now(), zero()));
349 list.rebuild(&[], &[], &[], now(), zero());
263 list.rebuild(&[], &[], now(), zero());
350 assert!(!list.needs_rebuild(now() + Duration::seconds(30), zero()));
264 assert!(!list.needs_rebuild(now() + Duration::seconds(30), zero()));
351 }
265 }
352
266
353 #[test]
267 #[test]
354 fn invalidation_age_and_a_new_day_force_a_rebuild() {
268 fn invalidation_age_and_a_new_day_force_a_rebuild() {
355 let mut list = built(0, 0);
269 let mut list = built(0);
356 list.invalidate();
270 list.invalidate();
357 assert!(list.needs_rebuild(now(), zero()));
271 assert!(list.needs_rebuild(now(), zero()));
358 list.rebuild(&[], &[], &[], now(), zero());
272 list.rebuild(&[], &[], now(), zero());
359 assert!(list.needs_rebuild(now() + Duration::seconds(61), zero()));
273 assert!(list.needs_rebuild(now() + Duration::seconds(61), zero()));
360 assert!(list.needs_rebuild(now() + Duration::hours(17), zero()));
274 assert!(list.needs_rebuild(now() + Duration::hours(17), zero()));
361 }
275 }
362
276
363 #[test]
277 #[test]
364 fn the_window_keeps_only_rows_on_screen_and_spacers_for_the_rest() {
278 fn the_window_keeps_only_rows_on_screen_and_spacers_for_the_rest() {
365 let list = built(100, 0);
279 let list = built(100);
366 let total = list.total_height();
280 let total = list.total_height();
367 let window = list.window(1000., 1200.);
281 let window = list.window(1000., 1200.);
368 assert!(window.range.len() < 12);
282 assert!(window.range.len() < 12);
@@ -377,7 +291,7 @@ mod tests {
377
291
378 #[test]
292 #[test]
379 fn the_window_clamps_at_both_ends() {
293 fn the_window_clamps_at_both_ends() {
380 let list = built(100, 0);
294 let list = built(100);
381 let top = list.window(-300., 100.);
295 let top = list.window(-300., 100.);
382 assert_eq!(top.range.start, 0);
296 assert_eq!(top.range.start, 0);
383 assert_eq!(top.before, 0.);
297 assert_eq!(top.before, 0.);
crates/app-state/src/call/mod.rs +1 −4
@@ -45,10 +45,7 @@ pub use features::TransferCandidate;
45 45 pub use health::{HealthBanner, level_text, media_text, network_rows, transport_text};
46 46 pub use history::CallRow;
47 47 pub use launcher::CallLauncher;
48 pub use list::{
49 AGENDA_ROW_HEIGHT, CALL_ROW_HEIGHT, CallsList, DAY_HEIGHT, EMPTY_HEIGHT, FILTERS_HEIGHT,
50 HistoryFilter, ListEntry, SECTION_HEIGHT,
51 };
48 pub use list::{CALL_ROW_HEIGHT, CallsList, EMPTY_HEIGHT, HistoryFilter, ListEntry};
52 49 pub use media::CallMedia;
53 50 pub use model::{
54 51 ActiveCall, CAPTION_SHOWN, CallKind, CallModel, Focus, REACTION_SHOWN, Tile, TileSize,
@@ -45,10 +45,7 @@ pub use features::TransferCandidate;
45pub use health::{HealthBanner, level_text, media_text, network_rows, transport_text};
45pub use health::{HealthBanner, level_text, media_text, network_rows, transport_text};
46pub use history::CallRow;
46pub use history::CallRow;
47pub use launcher::CallLauncher;
47pub use launcher::CallLauncher;
48pub use list::{
48pub use list::{CALL_ROW_HEIGHT, CallsList, EMPTY_HEIGHT, HistoryFilter, ListEntry};
49 AGENDA_ROW_HEIGHT, CALL_ROW_HEIGHT, CallsList, DAY_HEIGHT, EMPTY_HEIGHT, FILTERS_HEIGHT,
50 HistoryFilter, ListEntry, SECTION_HEIGHT,
51};
52pub use media::CallMedia;
49pub use media::CallMedia;
53pub use model::{
50pub use model::{
54 ActiveCall, CAPTION_SHOWN, CallKind, CallModel, Focus, REACTION_SHOWN, Tile, TileSize,
51 ActiveCall, CAPTION_SHOWN, CallKind, CallModel, Focus, REACTION_SHOWN, Tile, TileSize,
crates/app/src/layout_guard.rs +6 −4
@@ -274,9 +274,8 @@ mod frames {
274 274 FIND_RESULTS_TAG,
275 275 ];
276 276 const CALLS_TAGS: &[&str] = &[
277 "shell/islands/sidebar/calls-actions",
278 "shell/islands/sidebar/calls-actions/meet-now",
279 "shell/islands/sidebar/calls-actions/new-meeting",
277 "shell/islands/main/calls-dial",
278 "shell/islands/main/calls-history",
280 279 ];
281 280 const PREJOIN_TAGS: &[&str] = &[
282 281 "shell/islands/main/prejoin",
@@ -993,7 +992,10 @@ mod frames {
993 992 expected.extend(CHAT_FILTER_OPEN_TAGS);
994 993 }
995 994 "find" => expected.extend(FIND_TAGS),
996 "calls" => expected.extend(CALLS_TAGS),
995 "calls" => {
996 expected.retain(|path| *path != "shell/islands/sidebar");
997 expected.extend(CALLS_TAGS);
998 }
997 999 "agents" => expected.push(AGENTS_LIST),
998 1000 "calendar" => {
999 1001 expected.retain(|path| {
@@ -274,9 +274,8 @@ mod frames {
274 FIND_RESULTS_TAG,
274 FIND_RESULTS_TAG,
275 ];
275 ];
276 const CALLS_TAGS: &[&str] = &[
276 const CALLS_TAGS: &[&str] = &[
277 "shell/islands/sidebar/calls-actions",
277 "shell/islands/main/calls-dial",
278 "shell/islands/sidebar/calls-actions/meet-now",
278 "shell/islands/main/calls-history",
279 "shell/islands/sidebar/calls-actions/new-meeting",
280 ];
279 ];
281 const PREJOIN_TAGS: &[&str] = &[
280 const PREJOIN_TAGS: &[&str] = &[
282 "shell/islands/main/prejoin",
281 "shell/islands/main/prejoin",
@@ -993,7 +992,10 @@ mod frames {
993 expected.extend(CHAT_FILTER_OPEN_TAGS);
992 expected.extend(CHAT_FILTER_OPEN_TAGS);
994 }
993 }
995 "find" => expected.extend(FIND_TAGS),
994 "find" => expected.extend(FIND_TAGS),
996 "calls" => expected.extend(CALLS_TAGS),
995 "calls" => {
996 expected.retain(|path| *path != "shell/islands/sidebar");
997 expected.extend(CALLS_TAGS);
998 }
997 "agents" => expected.push(AGENTS_LIST),
999 "agents" => expected.push(AGENTS_LIST),
998 "calendar" => {
1000 "calendar" => {
999 expected.retain(|path| {
1001 expected.retain(|path| {
crates/app/src/views/calendar_view.rs +1 −1
@@ -9,7 +9,7 @@ use gpui_kit::component::{h_flex, v_flex};
9 9 use gpui_kit::prelude::FluentBuilder as _;
10 10 use gpui_kit::*;
11 11
12 use super::calls_tab::rsvp_menu;
12 use super::rsvp_menu::rsvp_menu;
13 13 use super::join_dialog::open_join_with_id;
14 14 use super::new_meeting_dialog::open_new_meeting;
15 15 use crate::app_state::AppState;
@@ -9,7 +9,7 @@ use gpui_kit::component::{h_flex, v_flex};
9use gpui_kit::prelude::FluentBuilder as _;
9use gpui_kit::prelude::FluentBuilder as _;
10use gpui_kit::*;
10use gpui_kit::*;
11
11
12use super::calls_tab::rsvp_menu;
12use super::rsvp_menu::rsvp_menu;
13use super::join_dialog::open_join_with_id;
13use super::join_dialog::open_join_with_id;
14use super::new_meeting_dialog::open_new_meeting;
14use super::new_meeting_dialog::open_new_meeting;
15use crate::app_state::AppState;
15use crate::app_state::AppState;
crates/app/src/views/calls_page.rs added +377 −0
@@ -0,0 +1,377 @@
1 use std::time::Duration;
2
3 use chrono::{Local, Offset, Utc};
4 use gpui_kit::assets::IconName;
5 use gpui_kit::component::button::{Button, ButtonVariants as _};
6 use gpui_kit::component::menu::{ContextMenuExt as _, PopupMenuItem};
7 use gpui_kit::component::scroll::ScrollableElement as _;
8 use gpui_kit::component::{Disableable as _, h_flex, v_flex};
9 use gpui_kit::prelude::FluentBuilder as _;
10 use gpui_kit::*;
11
12 use super::avatar::person_avatar;
13 use super::new_chat::NewChatDraft;
14 use super::scroll_edge::{scroll_offset, with_top_edge};
15 use super::widgets::{icon, menu_icon};
16 use crate::app_state::AppState;
17 use crate::call::{CALL_ROW_HEIGHT, CallRow, EMPTY_HEIGHT, HistoryFilter, ListEntry};
18 use crate::theme;
19
20 pub const CALLS_DIAL_TAG: &str = "shell/islands/main/calls-dial";
21 pub const CALLS_HISTORY_TAG: &str = "shell/islands/main/calls-history";
22 const CALLS_SCROLL_DIVIDER: &str = "shell/islands/main/calls-history/divider-scroll";
23 const CALLS_TITLE: &str = "Calls";
24 const HISTORY_TITLE: &str = "History";
25 const CALL_LABEL: &str = "Call";
26 const CALL_ONE_PERSON_HINT: &str = "Pick one person to call";
27 const HEADER_HEIGHT: f32 = 60.;
28 const PAGE_PADDING: f32 = 20.;
29 const DIAL_WIDTH: f32 = 340.;
30 const HISTORY_HEADER_HEIGHT: f32 = 52.;
31 const CALL_BUTTON_HEIGHT: f32 = 32.;
32 const FALLBACK_VIEWPORT: f32 = 900.;
33 const VIEWPORT_MARGIN: f32 = 300.;
34 const AVATAR_SIZE: f32 = 36.;
35 const REFRESH_INTERVAL: Duration = Duration::from_secs(30);
36
37 fn meeting_avatar() -> Div {
38 div()
39 .size(px(AVATAR_SIZE))
40 .flex_none()
41 .flex()
42 .items_center()
43 .justify_center()
44 .rounded_full()
45 .bg(theme::border_strong())
46 .child(icon(IconName::Video, 16., theme::text()))
47 }
48
49 fn call_row(
50 state: &Entity<AppState>,
51 row: &CallRow,
52 can_open_chat: bool,
53 directory: &crate::data::Directory,
54 ) -> AnyElement {
55 let avatar = if row.meeting {
56 meeting_avatar().into_any_element()
57 } else {
58 person_avatar(directory, row.user_id.as_deref(), &row.title, AVATAR_SIZE)
59 };
60 let title_color = if row.missed {
61 theme::red_soft()
62 } else {
63 theme::text()
64 };
65 let click_state = state.clone();
66 let click_row = row.clone();
67 let menu_state = state.clone();
68 let menu_row = row.clone();
69 let can_call_back = !row.meeting && row.user_id.is_some();
70 h_flex()
71 .id(SharedString::from(format!("call-{}", row.key)))
72 .h(px(CALL_ROW_HEIGHT))
73 .flex_none()
74 .px(px(10.))
75 .gap(px(12.))
76 .items_center()
77 .rounded(px(8.))
78 .cursor_pointer()
79 .hover(|row| row.bg(theme::row_hover()))
80 .child(avatar)
81 .child(
82 v_flex()
83 .flex_1()
84 .min_w_0()
85 .gap(px(2.))
86 .child(
87 h_flex()
88 .gap(px(8.))
89 .items_baseline()
90 .child(
91 div()
92 .flex_1()
93 .min_w_0()
94 .truncate()
95 .text_size(px(14.))
96 .text_color(title_color)
97 .child(row.title.clone()),
98 )
99 .child(
100 div()
101 .flex_none()
102 .text_size(px(11.))
103 .text_color(theme::text_muted())
104 .child(row.time_label.clone()),
105 ),
106 )
107 .child(
108 div()
109 .truncate()
110 .text_size(px(12.5))
111 .text_color(if row.missed {
112 theme::red_soft()
113 } else {
114 theme::text_muted()
115 })
116 .child(row.subline.clone()),
117 ),
118 )
119 .on_click(move |_, _, cx| {
120 click_state.update(cx, |state, cx| state.activate_call_row(&click_row, cx));
121 })
122 .context_menu(move |popup, _, _| {
123 let call_state = menu_state.clone();
124 let call_row = menu_row.clone();
125 let chat_state = menu_state.clone();
126 let chat_row = menu_row.clone();
127 popup
128 .when(can_call_back, |popup| {
129 popup.item(
130 PopupMenuItem::new("Call back")
131 .icon(menu_icon(IconName::Phone))
132 .on_click(move |_, _, cx| {
133 call_state.update(cx, |state, cx| {
134 state.call_back_from_history(&call_row, cx)
135 });
136 }),
137 )
138 })
139 .when(can_open_chat, |popup| {
140 popup.item(
141 PopupMenuItem::new("Open chat")
142 .icon(menu_icon(IconName::MessageSquare))
143 .on_click(move |_, _, cx| {
144 chat_state.update(cx, |state, cx| {
145 state.open_chat_of_call_row(&chat_row, cx)
146 });
147 }),
148 )
149 })
150 })
151 .into_any_element()
152 }
153
154 fn history_filters(state: &Entity<AppState>, current: HistoryFilter) -> AnyElement {
155 let pills = HistoryFilter::ALL.into_iter().map(|filter| {
156 let selected = filter == current;
157 let state = state.clone();
158 div()
159 .id(SharedString::from(format!("calls-filter-{}", filter.label())))
160 .h(px(24.))
161 .px(px(10.))
162 .flex()
163 .flex_none()
164 .items_center()
165 .rounded_full()
166 .cursor_pointer()
167 .text_size(px(12.))
168 .when(selected, |pill| {
169 pill.bg(theme::accent()).text_color(theme::on_accent())
170 })
171 .when(!selected, |pill| {
172 pill.bg(theme::surface_raised())
173 .text_color(theme::text_soft())
174 .hover(|pill| pill.bg(theme::border_strong()))
175 })
176 .child(filter.label())
177 .on_click(move |_, _, cx| {
178 state.update(cx, |state, cx| state.set_call_history_filter(filter, cx))
179 })
180 });
181 h_flex().gap(px(6.)).items_center().children(pills).into_any_element()
182 }
183
184 fn empty_row(text: &'static str) -> AnyElement {
185 div()
186 .h(px(EMPTY_HEIGHT))
187 .flex()
188 .items_center()
189 .justify_center()
190 .text_size(px(13.))
191 .text_color(theme::text_muted())
192 .child(text)
193 .into_any_element()
194 }
195
196 pub struct CallsPage {
197 app: Entity<AppState>,
198 people: Entity<NewChatDraft>,
199 scroll: ScrollHandle,
200 _observations: [Subscription; 2],
201 }
202
203 impl CallsPage {
204 pub fn new(app: Entity<AppState>, window: &mut Window, cx: &mut Context<Self>) -> Self {
205 let people_app = app.clone();
206 let people = cx.new(|cx| NewChatDraft::new(people_app, window, cx).compact());
207 let observations = [
208 cx.observe(&app, |_, _, cx| cx.notify()),
209 cx.observe(&people, |_, _, cx| cx.notify()),
210 ];
211 cx.spawn(async move |this, cx| {
212 loop {
213 cx.background_executor().timer(REFRESH_INTERVAL).await;
214 if this.update(cx, |_, cx| cx.notify()).is_err() {
215 break;
216 }
217 }
218 })
219 .detach();
220 CallsPage {
221 app,
222 people,
223 scroll: ScrollHandle::new(),
224 _observations: observations,
225 }
226 }
227
228 fn call_picked(&mut self, window: &mut Window, cx: &mut Context<Self>) {
229 let picked = self.people.read(cx).chips().to_vec();
230 let [person] = picked.as_slice() else {
231 return;
232 };
233 let user_id = person.user_id.clone();
234 self.app
235 .update(cx, |state, cx| state.call_person(&user_id, false, cx));
236 self.people
237 .update(cx, |people, cx| people.reset(window, cx));
238 }
239
240 fn dial_column(&self, cx: &mut Context<Self>) -> Div {
241 let picked = self.people.read(cx).chips().len();
242 let callable = picked == 1;
243 v_flex()
244 .debug_selector(|| CALLS_DIAL_TAG.into())
245 .w(px(DIAL_WIDTH))
246 .h_full()
247 .flex_none()
248 .p(px(PAGE_PADDING))
249 .gap(px(12.))
250 .child(self.people.clone())
251 .child(
252 Button::new("calls-dial-call")
253 .w_full()
254 .h(px(CALL_BUTTON_HEIGHT))
255 .icon(IconName::Phone)
256 .label(CALL_LABEL)
257 .when(callable, |button| button.primary())
258 .disabled(!callable)
259 .when(picked > 1, |button| button.tooltip(CALL_ONE_PERSON_HINT))
260 .on_click(cx.listener(|this, _, window, cx| this.call_picked(window, cx))),
261 )
262 }
263
264 fn history_list(&self, window_height: f32, cx: &mut Context<Self>) -> Div {
265 let now = Utc::now();
266 let offset = Local::now().offset().fix();
267 if self.app.read(cx).calls_list.needs_rebuild(now, offset) {
268 let app = self.app.clone();
269 cx.defer(move |cx| app.update(cx, |state, cx| state.rebuild_calls_list(cx)));
270 }
271 let top = -f32::from(scroll_offset(&self.scroll).y);
272 let measured = f32::from(self.scroll.bounds().size.height);
273 let height = if measured > 1. {
274 measured
275 } else {
276 window_height.max(FALLBACK_VIEWPORT)
277 };
278 let state = self.app.read(cx);
279 let visible = state
280 .calls_list
281 .window(top - VIEWPORT_MARGIN, top + height + VIEWPORT_MARGIN);
282 let mut list = v_flex().w_full().px(px(PAGE_PADDING - 10.)).py(px(8.));
283 if visible.before > 0. {
284 list = list.child(div().h(px(visible.before)).flex_none());
285 }
286 for entry in &state.calls_list.entries()[visible.range.clone()] {
287 list = list.child(match entry {
288 ListEntry::Empty(text) => empty_row(text),
289 ListEntry::Call(row) => call_row(
290 &self.app,
291 row,
292 state.can_open_chat_of_call_row(row),
293 &state.directory,
294 ),
295 });
296 }
297 if visible.after > 0. {
298 list = list.child(div().h(px(visible.after)).flex_none());
299 }
300 list
301 }
302
303 fn history_column(&self, window_height: f32, cx: &mut Context<Self>) -> Div {
304 let filter = self.app.read(cx).calls_list.filter();
305 v_flex()
306 .debug_selector(|| CALLS_HISTORY_TAG.into())
307 .flex_1()
308 .min_w_0()
309 .h_full()
310 .child(
311 h_flex()
312 .h(px(HISTORY_HEADER_HEIGHT))
313 .flex_none()
314 .px(px(PAGE_PADDING))
315 .gap(px(16.))
316 .items_center()
317 .child(
318 div()
319 .text_size(px(14.))
320 .font_weight(FontWeight::SEMIBOLD)
321 .text_color(theme::text())
322 .child(HISTORY_TITLE),
323 )
324 .child(history_filters(&self.app, filter)),
325 )
326 .child(with_top_edge(
327 div()
328 .id("calls-history-scroll")
329 .flex_1()
330 .min_h_0()
331 .overflow_y_scrollbar()
332 .track_scroll(&self.scroll)
333 .child(self.history_list(window_height, cx)),
334 &self.scroll,
335 CALLS_SCROLL_DIVIDER,
336 ))
337 }
338 }
339
340 impl Render for CallsPage {
341 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
342 let window_height = f32::from(window.viewport_size().height);
343 v_flex()
344 .debug_selector(|| "shell/islands/main".into())
345 .flex_1()
346 .w_full()
347 .min_w_0()
348 .h_full()
349 .rounded(px(10.))
350 .bg(theme::surface())
351 .overflow_hidden()
352 .child(
353 h_flex()
354 .h(px(HEADER_HEIGHT))
355 .flex_none()
356 .px(px(PAGE_PADDING))
357 .items_center()
358 .child(
359 div()
360 .text_size(px(16.))
361 .font_weight(FontWeight::BOLD)
362 .text_color(theme::text())
363 .child(CALLS_TITLE),
364 ),
365 )
366 .child(div().w_full().h(px(1.)).flex_none().bg(theme::border()))
367 .child(
368 h_flex()
369 .flex_1()
370 .min_h_0()
371 .w_full()
372 .child(self.dial_column(cx))
373 .child(div().w(px(1.)).h_full().flex_none().bg(theme::border()))
374 .child(self.history_column(window_height, cx)),
375 )
376 }
377 }
@@ -0,0 +1,377 @@
1use std::time::Duration;
2
3use chrono::{Local, Offset, Utc};
4use gpui_kit::assets::IconName;
5use gpui_kit::component::button::{Button, ButtonVariants as _};
6use gpui_kit::component::menu::{ContextMenuExt as _, PopupMenuItem};
7use gpui_kit::component::scroll::ScrollableElement as _;
8use gpui_kit::component::{Disableable as _, h_flex, v_flex};
9use gpui_kit::prelude::FluentBuilder as _;
10use gpui_kit::*;
11
12use super::avatar::person_avatar;
13use super::new_chat::NewChatDraft;
14use super::scroll_edge::{scroll_offset, with_top_edge};
15use super::widgets::{icon, menu_icon};
16use crate::app_state::AppState;
17use crate::call::{CALL_ROW_HEIGHT, CallRow, EMPTY_HEIGHT, HistoryFilter, ListEntry};
18use crate::theme;
19
20pub const CALLS_DIAL_TAG: &str = "shell/islands/main/calls-dial";
21pub const CALLS_HISTORY_TAG: &str = "shell/islands/main/calls-history";
22const CALLS_SCROLL_DIVIDER: &str = "shell/islands/main/calls-history/divider-scroll";
23const CALLS_TITLE: &str = "Calls";
24const HISTORY_TITLE: &str = "History";
25const CALL_LABEL: &str = "Call";
26const CALL_ONE_PERSON_HINT: &str = "Pick one person to call";
27const HEADER_HEIGHT: f32 = 60.;
28const PAGE_PADDING: f32 = 20.;
29const DIAL_WIDTH: f32 = 340.;
30const HISTORY_HEADER_HEIGHT: f32 = 52.;
31const CALL_BUTTON_HEIGHT: f32 = 32.;
32const FALLBACK_VIEWPORT: f32 = 900.;
33const VIEWPORT_MARGIN: f32 = 300.;
34const AVATAR_SIZE: f32 = 36.;
35const REFRESH_INTERVAL: Duration = Duration::from_secs(30);
36
37fn meeting_avatar() -> Div {
38 div()
39 .size(px(AVATAR_SIZE))
40 .flex_none()
41 .flex()
42 .items_center()
43 .justify_center()
44 .rounded_full()
45 .bg(theme::border_strong())
46 .child(icon(IconName::Video, 16., theme::text()))
47}
48
49fn call_row(
50 state: &Entity<AppState>,
51 row: &CallRow,
52 can_open_chat: bool,
53 directory: &crate::data::Directory,
54) -> AnyElement {
55 let avatar = if row.meeting {
56 meeting_avatar().into_any_element()
57 } else {
58 person_avatar(directory, row.user_id.as_deref(), &row.title, AVATAR_SIZE)
59 };
60 let title_color = if row.missed {
61 theme::red_soft()
62 } else {
63 theme::text()
64 };
65 let click_state = state.clone();
66 let click_row = row.clone();
67 let menu_state = state.clone();
68 let menu_row = row.clone();
69 let can_call_back = !row.meeting && row.user_id.is_some();
70 h_flex()
71 .id(SharedString::from(format!("call-{}", row.key)))
72 .h(px(CALL_ROW_HEIGHT))
73 .flex_none()
74 .px(px(10.))
75 .gap(px(12.))
76 .items_center()
77 .rounded(px(8.))
78 .cursor_pointer()
79 .hover(|row| row.bg(theme::row_hover()))
80 .child(avatar)
81 .child(
82 v_flex()
83 .flex_1()
84 .min_w_0()
85 .gap(px(2.))
86 .child(
87 h_flex()
88 .gap(px(8.))
89 .items_baseline()
90 .child(
91 div()
92 .flex_1()
93 .min_w_0()
94 .truncate()
95 .text_size(px(14.))
96 .text_color(title_color)
97 .child(row.title.clone()),
98 )
99 .child(
100 div()
101 .flex_none()
102 .text_size(px(11.))
103 .text_color(theme::text_muted())
104 .child(row.time_label.clone()),
105 ),
106 )
107 .child(
108 div()
109 .truncate()
110 .text_size(px(12.5))
111 .text_color(if row.missed {
112 theme::red_soft()
113 } else {
114 theme::text_muted()
115 })
116 .child(row.subline.clone()),
117 ),
118 )
119 .on_click(move |_, _, cx| {
120 click_state.update(cx, |state, cx| state.activate_call_row(&click_row, cx));
121 })
122 .context_menu(move |popup, _, _| {
123 let call_state = menu_state.clone();
124 let call_row = menu_row.clone();
125 let chat_state = menu_state.clone();
126 let chat_row = menu_row.clone();
127 popup
128 .when(can_call_back, |popup| {
129 popup.item(
130 PopupMenuItem::new("Call back")
131 .icon(menu_icon(IconName::Phone))
132 .on_click(move |_, _, cx| {
133 call_state.update(cx, |state, cx| {
134 state.call_back_from_history(&call_row, cx)
135 });
136 }),
137 )
138 })
139 .when(can_open_chat, |popup| {
140 popup.item(
141 PopupMenuItem::new("Open chat")
142 .icon(menu_icon(IconName::MessageSquare))
143 .on_click(move |_, _, cx| {
144 chat_state.update(cx, |state, cx| {
145 state.open_chat_of_call_row(&chat_row, cx)
146 });
147 }),
148 )
149 })
150 })
151 .into_any_element()
152}
153
154fn history_filters(state: &Entity<AppState>, current: HistoryFilter) -> AnyElement {
155 let pills = HistoryFilter::ALL.into_iter().map(|filter| {
156 let selected = filter == current;
157 let state = state.clone();
158 div()
159 .id(SharedString::from(format!("calls-filter-{}", filter.label())))
160 .h(px(24.))
161 .px(px(10.))
162 .flex()
163 .flex_none()
164 .items_center()
165 .rounded_full()
166 .cursor_pointer()
167 .text_size(px(12.))
168 .when(selected, |pill| {
169 pill.bg(theme::accent()).text_color(theme::on_accent())
170 })
171 .when(!selected, |pill| {
172 pill.bg(theme::surface_raised())
173 .text_color(theme::text_soft())
174 .hover(|pill| pill.bg(theme::border_strong()))
175 })
176 .child(filter.label())
177 .on_click(move |_, _, cx| {
178 state.update(cx, |state, cx| state.set_call_history_filter(filter, cx))
179 })
180 });
181 h_flex().gap(px(6.)).items_center().children(pills).into_any_element()
182}
183
184fn empty_row(text: &'static str) -> AnyElement {
185 div()
186 .h(px(EMPTY_HEIGHT))
187 .flex()
188 .items_center()
189 .justify_center()
190 .text_size(px(13.))
191 .text_color(theme::text_muted())
192 .child(text)
193 .into_any_element()
194}
195
196pub struct CallsPage {
197 app: Entity<AppState>,
198 people: Entity<NewChatDraft>,
199 scroll: ScrollHandle,
200 _observations: [Subscription; 2],
201}
202
203impl CallsPage {
204 pub fn new(app: Entity<AppState>, window: &mut Window, cx: &mut Context<Self>) -> Self {
205 let people_app = app.clone();
206 let people = cx.new(|cx| NewChatDraft::new(people_app, window, cx).compact());
207 let observations = [
208 cx.observe(&app, |_, _, cx| cx.notify()),
209 cx.observe(&people, |_, _, cx| cx.notify()),
210 ];
211 cx.spawn(async move |this, cx| {
212 loop {
213 cx.background_executor().timer(REFRESH_INTERVAL).await;
214 if this.update(cx, |_, cx| cx.notify()).is_err() {
215 break;
216 }
217 }
218 })
219 .detach();
220 CallsPage {
221 app,
222 people,
223 scroll: ScrollHandle::new(),
224 _observations: observations,
225 }
226 }
227
228 fn call_picked(&mut self, window: &mut Window, cx: &mut Context<Self>) {
229 let picked = self.people.read(cx).chips().to_vec();
230 let [person] = picked.as_slice() else {
231 return;
232 };
233 let user_id = person.user_id.clone();
234 self.app
235 .update(cx, |state, cx| state.call_person(&user_id, false, cx));
236 self.people
237 .update(cx, |people, cx| people.reset(window, cx));
238 }
239
240 fn dial_column(&self, cx: &mut Context<Self>) -> Div {
241 let picked = self.people.read(cx).chips().len();
242 let callable = picked == 1;
243 v_flex()
244 .debug_selector(|| CALLS_DIAL_TAG.into())
245 .w(px(DIAL_WIDTH))
246 .h_full()
247 .flex_none()
248 .p(px(PAGE_PADDING))
249 .gap(px(12.))
250 .child(self.people.clone())
251 .child(
252 Button::new("calls-dial-call")
253 .w_full()
254 .h(px(CALL_BUTTON_HEIGHT))
255 .icon(IconName::Phone)
256 .label(CALL_LABEL)
257 .when(callable, |button| button.primary())
258 .disabled(!callable)
259 .when(picked > 1, |button| button.tooltip(CALL_ONE_PERSON_HINT))
260 .on_click(cx.listener(|this, _, window, cx| this.call_picked(window, cx))),
261 )
262 }
263
264 fn history_list(&self, window_height: f32, cx: &mut Context<Self>) -> Div {
265 let now = Utc::now();
266 let offset = Local::now().offset().fix();
267 if self.app.read(cx).calls_list.needs_rebuild(now, offset) {
268 let app = self.app.clone();
269 cx.defer(move |cx| app.update(cx, |state, cx| state.rebuild_calls_list(cx)));
270 }
271 let top = -f32::from(scroll_offset(&self.scroll).y);
272 let measured = f32::from(self.scroll.bounds().size.height);
273 let height = if measured > 1. {
274 measured
275 } else {
276 window_height.max(FALLBACK_VIEWPORT)
277 };
278 let state = self.app.read(cx);
279 let visible = state
280 .calls_list
281 .window(top - VIEWPORT_MARGIN, top + height + VIEWPORT_MARGIN);
282 let mut list = v_flex().w_full().px(px(PAGE_PADDING - 10.)).py(px(8.));
283 if visible.before > 0. {
284 list = list.child(div().h(px(visible.before)).flex_none());
285 }
286 for entry in &state.calls_list.entries()[visible.range.clone()] {
287 list = list.child(match entry {
288 ListEntry::Empty(text) => empty_row(text),
289 ListEntry::Call(row) => call_row(
290 &self.app,
291 row,
292 state.can_open_chat_of_call_row(row),
293 &state.directory,
294 ),
295 });
296 }
297 if visible.after > 0. {
298 list = list.child(div().h(px(visible.after)).flex_none());
299 }
300 list
301 }
302
303 fn history_column(&self, window_height: f32, cx: &mut Context<Self>) -> Div {
304 let filter = self.app.read(cx).calls_list.filter();
305 v_flex()
306 .debug_selector(|| CALLS_HISTORY_TAG.into())
307 .flex_1()
308 .min_w_0()
309 .h_full()
310 .child(
311 h_flex()
312 .h(px(HISTORY_HEADER_HEIGHT))
313 .flex_none()
314 .px(px(PAGE_PADDING))
315 .gap(px(16.))
316 .items_center()
317 .child(
318 div()
319 .text_size(px(14.))
320 .font_weight(FontWeight::SEMIBOLD)
321 .text_color(theme::text())
322 .child(HISTORY_TITLE),
323 )
324 .child(history_filters(&self.app, filter)),
325 )
326 .child(with_top_edge(
327 div()
328 .id("calls-history-scroll")
329 .flex_1()
330 .min_h_0()
331 .overflow_y_scrollbar()
332 .track_scroll(&self.scroll)
333 .child(self.history_list(window_height, cx)),
334 &self.scroll,
335 CALLS_SCROLL_DIVIDER,
336 ))
337 }
338}
339
340impl Render for CallsPage {
341 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
342 let window_height = f32::from(window.viewport_size().height);
343 v_flex()
344 .debug_selector(|| "shell/islands/main".into())
345 .flex_1()
346 .w_full()
347 .min_w_0()
348 .h_full()
349 .rounded(px(10.))
350 .bg(theme::surface())
351 .overflow_hidden()
352 .child(
353 h_flex()
354 .h(px(HEADER_HEIGHT))
355 .flex_none()
356 .px(px(PAGE_PADDING))
357 .items_center()
358 .child(
359 div()
360 .text_size(px(16.))
361 .font_weight(FontWeight::BOLD)
362 .text_color(theme::text())
363 .child(CALLS_TITLE),
364 ),
365 )
366 .child(div().w_full().h(px(1.)).flex_none().bg(theme::border()))
367 .child(
368 h_flex()
369 .flex_1()
370 .min_h_0()
371 .w_full()
372 .child(self.dial_column(cx))
373 .child(div().w(px(1.)).h_full().flex_none().bg(theme::border()))
374 .child(self.history_column(window_height, cx)),
375 )
376 }
377}
crates/app/src/views/calls_tab.rs deleted +0 −537
@@ -1,537 +0,0 @@
1 use chatsvc::{Reply, ResponseType};
2 use chrono::{Local, Offset, Utc};
3 use gpui_kit::component::scroll::ScrollableElement as _;
4 use gpui_kit::assets::IconName;
5 use gpui_kit::component::Sizable as _;
6 use gpui_kit::component::button::{Button, ButtonVariants as _};
7 use gpui_kit::component::menu::{ContextMenuExt as _, DropdownMenu as _, PopupMenu, PopupMenuItem};
8 use gpui_kit::component::{h_flex, v_flex};
9 use gpui_kit::prelude::FluentBuilder as _;
10 use gpui_kit::*;
11
12 use super::avatar::person_avatar;
13 use super::join_dialog::open_join_with_id;
14 use super::new_meeting_dialog::open_new_meeting;
15 use super::scroll_edge::{scroll_offset, with_top_edge};
16 use super::sidebar::SIDEBAR_SCROLL_DIVIDER;
17 use super::widgets::{icon, menu_icon};
18 use crate::app_state::AppState;
19 use crate::call::{
20 AGENDA_ROW_HEIGHT, AgendaRow, CALL_ROW_HEIGHT, CallRow, DAY_HEIGHT, EMPTY_HEIGHT,
21 FILTERS_HEIGHT, HistoryFilter, ListEntry, SECTION_HEIGHT, join_available, response_label,
22 };
23 use crate::theme;
24
25 const FALLBACK_VIEWPORT: f32 = 900.;
26 const VIEWPORT_MARGIN: f32 = 300.;
27 const TIME_COLUMN_WIDTH: f32 = 96.;
28 const AVATAR_SIZE: f32 = 36.;
29
30 fn meeting_avatar() -> Div {
31 div()
32 .size(px(AVATAR_SIZE))
33 .flex_none()
34 .flex()
35 .items_center()
36 .justify_center()
37 .rounded_full()
38 .bg(theme::border_strong())
39 .child(icon(IconName::Video, 16., theme::text()))
40 }
41
42 fn call_row(
43 state: &Entity<AppState>,
44 row: &CallRow,
45 can_open_chat: bool,
46 directory: &crate::data::Directory,
47 ) -> AnyElement {
48 let avatar = if row.meeting {
49 meeting_avatar().into_any_element()
50 } else {
51 person_avatar(directory, row.user_id.as_deref(), &row.title, AVATAR_SIZE)
52 };
53 let title_color = if row.missed {
54 theme::red_soft()
55 } else {
56 theme::text()
57 };
58 let click_state = state.clone();
59 let click_row = row.clone();
60 let menu_state = state.clone();
61 let menu_row = row.clone();
62 let can_call_back = !row.meeting && row.user_id.is_some();
63 h_flex()
64 .id(SharedString::from(format!("call-{}", row.key)))
65 .mx(px(6.))
66 .h(px(CALL_ROW_HEIGHT))
67 .flex_none()
68 .px(px(10.))
69 .gap(px(12.))
70 .items_center()
71 .rounded(px(8.))
72 .cursor_pointer()
73 .hover(|row| row.bg(theme::row_hover()))
74 .child(avatar)
75 .child(
76 v_flex()
77 .flex_1()
78 .min_w_0()
79 .gap(px(2.))
80 .child(
81 h_flex()
82 .gap(px(8.))
83 .items_baseline()
84 .child(
85 div()
86 .flex_1()
87 .min_w_0()
88 .truncate()
89 .text_size(px(14.))
90 .text_color(title_color)
91 .child(row.title.clone()),
92 )
93 .child(
94 div()
95 .flex_none()
96 .text_size(px(11.))
97 .text_color(theme::text_muted())
98 .child(row.time_label.clone()),
99 ),
100 )
101 .child(
102 div()
103 .truncate()
104 .text_size(px(12.5))
105 .text_color(if row.missed {
106 theme::red_soft()
107 } else {
108 theme::text_muted()
109 })
110 .child(row.subline.clone()),
111 ),
112 )
113 .on_click(move |_, _, cx| {
114 click_state.update(cx, |state, cx| state.activate_call_row(&click_row, cx));
115 })
116 .context_menu(move |popup, _, _| {
117 let call_state = menu_state.clone();
118 let call_row = menu_row.clone();
119 let chat_state = menu_state.clone();
120 let chat_row = menu_row.clone();
121 popup
122 .when(can_call_back, |popup| {
123 popup.item(
124 PopupMenuItem::new("Call back")
125 .icon(menu_icon(IconName::Phone))
126 .on_click(move |_, _, cx| {
127 call_state.update(cx, |state, cx| {
128 state.call_back_from_history(&call_row, cx)
129 });
130 }),
131 )
132 })
133 .when(can_open_chat, |popup| {
134 popup.item(
135 PopupMenuItem::new("Open chat")
136 .icon(menu_icon(IconName::MessageSquare))
137 .on_click(move |_, _, cx| {
138 chat_state.update(cx, |state, cx| {
139 state.open_chat_of_call_row(&chat_row, cx)
140 });
141 }),
142 )
143 })
144 })
145 .into_any_element()
146 }
147
148 fn join_button(id: &'static str, label: &'static str, primary: bool) -> Stateful<Div> {
149 let (fill, hover_fill, text_color) = if primary {
150 (theme::accent(), theme::accent_text(), theme::on_accent())
151 } else {
152 (
153 theme::surface_raised(),
154 theme::popup_hover(),
155 theme::text_strong(),
156 )
157 };
158 div()
159 .id(id)
160 .h(px(28.))
161 .px(px(12.))
162 .flex()
163 .items_center()
164 .rounded(px(7.))
165 .bg(fill)
166 .cursor_pointer()
167 .hover(move |button| button.bg(hover_fill))
168 .text_size(px(12.5))
169 .font_weight(FontWeight::SEMIBOLD)
170 .text_color(text_color)
171 .child(label)
172 }
173
174 fn join_buttons(state: &Entity<AppState>, meet_now_pending: bool) -> impl IntoElement {
175 let meet_state = state.clone();
176 let new_state = state.clone();
177 let id_state = state.clone();
178 let paste_state = state.clone();
179 h_flex()
180 .debug_selector(|| "shell/islands/sidebar/calls-actions".into())
181 .w_full()
182 .px(px(16.))
183 .pb(px(8.))
184 .gap(px(8.))
185 .flex_wrap()
186 .child(
187 join_button("meet-now", "Meet now", true)
188 .debug_selector(|| "shell/islands/sidebar/calls-actions/meet-now".into())
189 .when(meet_now_pending, |button| button.opacity(0.5))
190 .when(!meet_now_pending, |button| {
191 button.on_click(move |_, _, cx| {
192 meet_state.update(cx, |state, cx| state.start_meet_now(cx));
193 })
194 }),
195 )
196 .child(
197 join_button("new-meeting", "New meeting", false)
198 .debug_selector(|| "shell/islands/sidebar/calls-actions/new-meeting".into())
199 .on_click(move |_, window, cx| open_new_meeting(new_state.clone(), window, cx)),
200 )
201 .child(
202 join_button("join-with-id", "Join with ID", false)
203 .on_click(move |_, window, cx| open_join_with_id(id_state.clone(), window, cx)),
204 )
205 .child(
206 join_button("paste-meeting-link", "Paste a meeting link", false).on_click(
207 move |_, _, cx| {
208 paste_state.update(cx, |state, cx| state.join_meeting_from_clipboard(cx));
209 },
210 ),
211 )
212 }
213
214 fn section_header(title: &'static str) -> AnyElement {
215 div()
216 .h(px(SECTION_HEIGHT))
217 .px(px(16.))
218 .flex()
219 .items_end()
220 .pb(px(4.))
221 .text_size(px(12.))
222 .font_weight(FontWeight::SEMIBOLD)
223 .text_color(theme::text_muted())
224 .child(title)
225 .into_any_element()
226 }
227
228 fn history_filters(state: &Entity<AppState>, current: HistoryFilter) -> AnyElement {
229 let pills = HistoryFilter::ALL.into_iter().map(|filter| {
230 let selected = filter == current;
231 let state = state.clone();
232 div()
233 .id(SharedString::from(format!("calls-filter-{}", filter.label())))
234 .h(px(24.))
235 .px(px(10.))
236 .flex()
237 .flex_none()
238 .items_center()
239 .rounded_full()
240 .cursor_pointer()
241 .text_size(px(12.))
242 .when(selected, |pill| {
243 pill.bg(theme::accent()).text_color(theme::on_accent())
244 })
245 .when(!selected, |pill| {
246 pill.bg(theme::surface_raised())
247 .text_color(theme::text_soft())
248 .hover(|pill| pill.bg(theme::border_strong()))
249 })
250 .child(filter.label())
251 .on_click(move |_, _, cx| {
252 state.update(cx, |state, cx| state.set_call_history_filter(filter, cx))
253 })
254 });
255 h_flex()
256 .h(px(FILTERS_HEIGHT))
257 .px(px(16.))
258 .gap(px(6.))
259 .items_center()
260 .children(pills)
261 .into_any_element()
262 }
263
264 fn day_header(label: &str) -> AnyElement {
265 div()
266 .h(px(DAY_HEIGHT))
267 .px(px(16.))
268 .flex()
269 .items_center()
270 .text_size(px(11.5))
271 .text_color(theme::text_faint())
272 .child(label.to_owned())
273 .into_any_element()
274 }
275
276 fn empty_row(text: &'static str) -> AnyElement {
277 div()
278 .h(px(EMPTY_HEIGHT))
279 .flex()
280 .items_center()
281 .justify_center()
282 .text_size(px(13.))
283 .text_color(theme::text_muted())
284 .child(text)
285 .into_any_element()
286 }
287
288 fn rsvp_menu_item(
289 state: &Entity<AppState>,
290 event_key: &str,
291 label: &'static str,
292 reply: Reply,
293 chosen: bool,
294 ) -> PopupMenuItem {
295 let state = state.clone();
296 let event_key = event_key.to_owned();
297 PopupMenuItem::new(label)
298 .checked(chosen)
299 .on_click(move |_, _, cx| {
300 state.update(cx, |state, cx| {
301 state.respond_to_event(&event_key, reply, cx)
302 });
303 })
304 }
305
306 pub(super) fn rsvp_menu(
307 menu: PopupMenu,
308 state: &Entity<AppState>,
309 key: &str,
310 response: ResponseType,
311 send_response: bool,
312 ) -> PopupMenu {
313 let toggle_state = state.clone();
314 menu.item(rsvp_menu_item(
315 state,
316 key,
317 "Accept",
318 Reply::Accept,
319 response == ResponseType::Accepted,
320 ))
321 .item(rsvp_menu_item(
322 state,
323 key,
324 "Tentative",
325 Reply::Tentative,
326 response == ResponseType::Tentative,
327 ))
328 .item(rsvp_menu_item(
329 state,
330 key,
331 "Decline",
332 Reply::Decline,
333 response == ResponseType::Declined,
334 ))
335 .separator()
336 .item(
337 PopupMenuItem::new("Send a response")
338 .checked(send_response)
339 .on_click(move |_, _, cx| {
340 toggle_state.update(cx, |state, cx| state.toggle_rsvp_send_response(cx));
341 }),
342 )
343 }
344
345 fn rsvp_control(state: &Entity<AppState>, row: &AgendaRow, send_response: bool) -> AnyElement {
346 let menu_state = state.clone();
347 let key = row.key.clone();
348 let response = row.response;
349 div()
350 .id(SharedString::from(format!("agenda-rsvp-{}", row.key)))
351 .flex_none()
352 .on_click(|_, _, cx| cx.stop_propagation())
353 .child(
354 Button::new(SharedString::from(format!(
355 "agenda-rsvp-button-{}",
356 row.key
357 )))
358 .xsmall()
359 .outline()
360 .label(response_label(response))
361 .icon(IconName::ChevronDown)
362 .dropdown_menu(move |menu, _, _| {
363 rsvp_menu(menu, &menu_state, &key, response, send_response)
364 }),
365 )
366 .into_any_element()
367 }
368
369 fn agenda_row(
370 state: &Entity<AppState>,
371 row: &AgendaRow,
372 joinable: bool,
373 send_response: bool,
374 ) -> AnyElement {
375 let click_state = state.clone();
376 let click_row = row.clone();
377 let join_state = state.clone();
378 let join_row = row.clone();
379 let menu_join_url = row.join_url.clone();
380 let line = h_flex()
381 .id(SharedString::from(format!("agenda-{}", row.key)))
382 .mx(px(6.))
383 .h(px(AGENDA_ROW_HEIGHT))
384 .flex_none()
385 .px(px(10.))
386 .gap(px(12.))
387 .items_center()
388 .rounded(px(8.))
389 .cursor_pointer()
390 .hover(|row| row.bg(theme::row_hover()))
391 .child(
392 v_flex()
393 .w(px(TIME_COLUMN_WIDTH))
394 .flex_none()
395 .text_size(px(12.))
396 .text_color(theme::text_muted())
397 .children(time_lines(&row.time_label)),
398 )
399 .child(
400 v_flex()
401 .flex_1()
402 .min_w_0()
403 .gap(px(2.))
404 .child(
405 div()
406 .truncate()
407 .text_size(px(14.))
408 .text_color(theme::text())
409 .child(row.subject.clone()),
410 )
411 .when(!row.detail.is_empty() || row.can_respond, |column| {
412 column.child(
413 h_flex()
414 .gap(px(6.))
415 .items_center()
416 .child(
417 div()
418 .flex_1()
419 .min_w_0()
420 .truncate()
421 .text_size(px(12.5))
422 .text_color(theme::text_muted())
423 .child(row.detail.clone()),
424 )
425 .when(row.can_respond, |line| {
426 line.child(rsvp_control(state, row, send_response))
427 }),
428 )
429 }),
430 )
431 .when(joinable, |line| {
432 line.child(
433 Button::new(SharedString::from(format!("agenda-join-{}", row.key)))
434 .small()
435 .primary()
436 .label("Join")
437 .on_click(move |_, _, cx| {
438 cx.stop_propagation();
439 join_state.update(cx, |state, cx| state.join_agenda_row(&join_row, cx));
440 }),
441 )
442 })
443 .on_click(move |_, _, cx| {
444 click_state.update(cx, |state, cx| state.open_agenda_chat(&click_row, cx));
445 });
446 let Some(join_url) = menu_join_url else {
447 return line.into_any_element();
448 };
449 line.context_menu(move |popup, _, _| {
450 let join_url = join_url.clone();
451 popup.item(
452 PopupMenuItem::new("Copy meeting link")
453 .icon(menu_icon(IconName::Link))
454 .on_click(move |_, _, cx| {
455 cx.write_to_clipboard(ClipboardItem::new_string(join_url.clone()));
456 }),
457 )
458 })
459 .into_any_element()
460 }
461
462 pub fn calls_body(
463 state: &Entity<AppState>,
464 scroll: &ScrollHandle,
465 window_height: f32,
466 cx: &mut App,
467 ) -> AnyElement {
468 let now = Utc::now();
469 let offset = Local::now().offset().fix();
470 if state.read(cx).calls_list.needs_rebuild(now, offset) {
471 let rebuild_state = state.clone();
472 cx.defer(move |cx| rebuild_state.update(cx, |state, cx| state.rebuild_calls_list(cx)));
473 }
474 let top = -f32::from(scroll_offset(scroll).y);
475 let measured = f32::from(scroll.bounds().size.height);
476 let height = if measured > 1. {
477 measured
478 } else {
479 window_height.max(FALLBACK_VIEWPORT)
480 };
481 let app = state.read(cx);
482 let window = app
483 .calls_list
484 .window(top - VIEWPORT_MARGIN, top + height + VIEWPORT_MARGIN);
485 let entries = &app.calls_list.entries()[window.range.clone()];
486 let mut list = v_flex().w_full().pb(px(12.));
487 if window.before > 0. {
488 list = list.child(div().h(px(window.before)).flex_none());
489 }
490 for entry in entries {
491 list = list.child(match entry {
492 ListEntry::Section(title) => section_header(title),
493 ListEntry::Filters(filter) => history_filters(state, *filter),
494 ListEntry::Day(label) => day_header(label),
495 ListEntry::Empty(text) => empty_row(text),
496 ListEntry::Agenda(row) => agenda_row(
497 state,
498 row,
499 join_available(row.start, row.end, now) && row.join_url.is_some(),
500 app.rsvp_send_response,
501 ),
502 ListEntry::Call(row) => call_row(
503 state,
504 row,
505 app.can_open_chat_of_call_row(row),
506 &app.directory,
507 ),
508 });
509 }
510 if window.after > 0. {
511 list = list.child(div().h(px(window.after)).flex_none());
512 }
513 v_flex()
514 .flex_1()
515 .min_h_0()
516 .child(join_buttons(state, app.meet_now_pending))
517 .child(with_top_edge(
518 div()
519 .id("calls-scroll")
520 .flex_1()
521 .min_h_0()
522 .overflow_y_scrollbar()
523 .track_scroll(scroll)
524 .child(list),
525 scroll,
526 SIDEBAR_SCROLL_DIVIDER,
527 ))
528 .into_any_element()
529 }
530
531 fn time_lines(label: &str) -> Vec<String> {
532 let twelve_hour = crate::format::clock_format().contains(['p', 'P']);
533 match label.split_once(" - ") {
534 Some((start, end)) if twelve_hour => vec![start.to_owned(), end.to_owned()],
535 _ => vec![label.to_owned()],
536 }
537 }
@@ -1,537 +0,0 @@
1use chatsvc::{Reply, ResponseType};
2use chrono::{Local, Offset, Utc};
3use gpui_kit::component::scroll::ScrollableElement as _;
4use gpui_kit::assets::IconName;
5use gpui_kit::component::Sizable as _;
6use gpui_kit::component::button::{Button, ButtonVariants as _};
7use gpui_kit::component::menu::{ContextMenuExt as _, DropdownMenu as _, PopupMenu, PopupMenuItem};
8use gpui_kit::component::{h_flex, v_flex};
9use gpui_kit::prelude::FluentBuilder as _;
10use gpui_kit::*;
11
12use super::avatar::person_avatar;
13use super::join_dialog::open_join_with_id;
14use super::new_meeting_dialog::open_new_meeting;
15use super::scroll_edge::{scroll_offset, with_top_edge};
16use super::sidebar::SIDEBAR_SCROLL_DIVIDER;
17use super::widgets::{icon, menu_icon};
18use crate::app_state::AppState;
19use crate::call::{
20 AGENDA_ROW_HEIGHT, AgendaRow, CALL_ROW_HEIGHT, CallRow, DAY_HEIGHT, EMPTY_HEIGHT,
21 FILTERS_HEIGHT, HistoryFilter, ListEntry, SECTION_HEIGHT, join_available, response_label,
22};
23use crate::theme;
24
25const FALLBACK_VIEWPORT: f32 = 900.;
26const VIEWPORT_MARGIN: f32 = 300.;
27const TIME_COLUMN_WIDTH: f32 = 96.;
28const AVATAR_SIZE: f32 = 36.;
29
30fn meeting_avatar() -> Div {
31 div()
32 .size(px(AVATAR_SIZE))
33 .flex_none()
34 .flex()
35 .items_center()
36 .justify_center()
37 .rounded_full()
38 .bg(theme::border_strong())
39 .child(icon(IconName::Video, 16., theme::text()))
40}
41
42fn call_row(
43 state: &Entity<AppState>,
44 row: &CallRow,
45 can_open_chat: bool,
46 directory: &crate::data::Directory,
47) -> AnyElement {
48 let avatar = if row.meeting {
49 meeting_avatar().into_any_element()
50 } else {
51 person_avatar(directory, row.user_id.as_deref(), &row.title, AVATAR_SIZE)
52 };
53 let title_color = if row.missed {
54 theme::red_soft()
55 } else {
56 theme::text()
57 };
58 let click_state = state.clone();
59 let click_row = row.clone();
60 let menu_state = state.clone();
61 let menu_row = row.clone();
62 let can_call_back = !row.meeting && row.user_id.is_some();
63 h_flex()
64 .id(SharedString::from(format!("call-{}", row.key)))
65 .mx(px(6.))
66 .h(px(CALL_ROW_HEIGHT))
67 .flex_none()
68 .px(px(10.))
69 .gap(px(12.))
70 .items_center()
71 .rounded(px(8.))
72 .cursor_pointer()
73 .hover(|row| row.bg(theme::row_hover()))
74 .child(avatar)
75 .child(
76 v_flex()
77 .flex_1()
78 .min_w_0()
79 .gap(px(2.))
80 .child(
81 h_flex()
82 .gap(px(8.))
83 .items_baseline()
84 .child(
85 div()
86 .flex_1()
87 .min_w_0()
88 .truncate()
89 .text_size(px(14.))
90 .text_color(title_color)
91 .child(row.title.clone()),
92 )
93 .child(
94 div()
95 .flex_none()
96 .text_size(px(11.))
97 .text_color(theme::text_muted())
98 .child(row.time_label.clone()),
99 ),
100 )
101 .child(
102 div()
103 .truncate()
104 .text_size(px(12.5))
105 .text_color(if row.missed {
106 theme::red_soft()
107 } else {
108 theme::text_muted()
109 })
110 .child(row.subline.clone()),
111 ),
112 )
113 .on_click(move |_, _, cx| {
114 click_state.update(cx, |state, cx| state.activate_call_row(&click_row, cx));
115 })
116 .context_menu(move |popup, _, _| {
117 let call_state = menu_state.clone();
118 let call_row = menu_row.clone();
119 let chat_state = menu_state.clone();
120 let chat_row = menu_row.clone();
121 popup
122 .when(can_call_back, |popup| {
123 popup.item(
124 PopupMenuItem::new("Call back")
125 .icon(menu_icon(IconName::Phone))
126 .on_click(move |_, _, cx| {
127 call_state.update(cx, |state, cx| {
128 state.call_back_from_history(&call_row, cx)
129 });
130 }),
131 )
132 })
133 .when(can_open_chat, |popup| {
134 popup.item(
135 PopupMenuItem::new("Open chat")
136 .icon(menu_icon(IconName::MessageSquare))
137 .on_click(move |_, _, cx| {
138 chat_state.update(cx, |state, cx| {
139 state.open_chat_of_call_row(&chat_row, cx)
140 });
141 }),
142 )
143 })
144 })
145 .into_any_element()
146}
147
148fn join_button(id: &'static str, label: &'static str, primary: bool) -> Stateful<Div> {
149 let (fill, hover_fill, text_color) = if primary {
150 (theme::accent(), theme::accent_text(), theme::on_accent())
151 } else {
152 (
153 theme::surface_raised(),
154 theme::popup_hover(),
155 theme::text_strong(),
156 )
157 };
158 div()
159 .id(id)
160 .h(px(28.))
161 .px(px(12.))
162 .flex()
163 .items_center()
164 .rounded(px(7.))
165 .bg(fill)
166 .cursor_pointer()
167 .hover(move |button| button.bg(hover_fill))
168 .text_size(px(12.5))
169 .font_weight(FontWeight::SEMIBOLD)
170 .text_color(text_color)
171 .child(label)
172}
173
174fn join_buttons(state: &Entity<AppState>, meet_now_pending: bool) -> impl IntoElement {
175 let meet_state = state.clone();
176 let new_state = state.clone();
177 let id_state = state.clone();
178 let paste_state = state.clone();
179 h_flex()
180 .debug_selector(|| "shell/islands/sidebar/calls-actions".into())
181 .w_full()
182 .px(px(16.))
183 .pb(px(8.))
184 .gap(px(8.))
185 .flex_wrap()
186 .child(
187 join_button("meet-now", "Meet now", true)
188 .debug_selector(|| "shell/islands/sidebar/calls-actions/meet-now".into())
189 .when(meet_now_pending, |button| button.opacity(0.5))
190 .when(!meet_now_pending, |button| {
191 button.on_click(move |_, _, cx| {
192 meet_state.update(cx, |state, cx| state.start_meet_now(cx));
193 })
194 }),
195 )
196 .child(
197 join_button("new-meeting", "New meeting", false)
198 .debug_selector(|| "shell/islands/sidebar/calls-actions/new-meeting".into())
199 .on_click(move |_, window, cx| open_new_meeting(new_state.clone(), window, cx)),
200 )
201 .child(
202 join_button("join-with-id", "Join with ID", false)
203 .on_click(move |_, window, cx| open_join_with_id(id_state.clone(), window, cx)),
204 )
205 .child(
206 join_button("paste-meeting-link", "Paste a meeting link", false).on_click(
207 move |_, _, cx| {
208 paste_state.update(cx, |state, cx| state.join_meeting_from_clipboard(cx));
209 },
210 ),
211 )
212}
213
214fn section_header(title: &'static str) -> AnyElement {
215 div()
216 .h(px(SECTION_HEIGHT))
217 .px(px(16.))
218 .flex()
219 .items_end()
220 .pb(px(4.))
221 .text_size(px(12.))
222 .font_weight(FontWeight::SEMIBOLD)
223 .text_color(theme::text_muted())
224 .child(title)
225 .into_any_element()
226}
227
228fn history_filters(state: &Entity<AppState>, current: HistoryFilter) -> AnyElement {
229 let pills = HistoryFilter::ALL.into_iter().map(|filter| {
230 let selected = filter == current;
231 let state = state.clone();
232 div()
233 .id(SharedString::from(format!("calls-filter-{}", filter.label())))
234 .h(px(24.))
235 .px(px(10.))
236 .flex()
237 .flex_none()
238 .items_center()
239 .rounded_full()
240 .cursor_pointer()
241 .text_size(px(12.))
242 .when(selected, |pill| {
243 pill.bg(theme::accent()).text_color(theme::on_accent())
244 })
245 .when(!selected, |pill| {
246 pill.bg(theme::surface_raised())
247 .text_color(theme::text_soft())
248 .hover(|pill| pill.bg(theme::border_strong()))
249 })
250 .child(filter.label())
251 .on_click(move |_, _, cx| {
252 state.update(cx, |state, cx| state.set_call_history_filter(filter, cx))
253 })
254 });
255 h_flex()
256 .h(px(FILTERS_HEIGHT))
257 .px(px(16.))
258 .gap(px(6.))
259 .items_center()
260 .children(pills)
261 .into_any_element()
262}
263
264fn day_header(label: &str) -> AnyElement {
265 div()
266 .h(px(DAY_HEIGHT))
267 .px(px(16.))
268 .flex()
269 .items_center()
270 .text_size(px(11.5))
271 .text_color(theme::text_faint())
272 .child(label.to_owned())
273 .into_any_element()
274}
275
276fn empty_row(text: &'static str) -> AnyElement {
277 div()
278 .h(px(EMPTY_HEIGHT))
279 .flex()
280 .items_center()
281 .justify_center()
282 .text_size(px(13.))
283 .text_color(theme::text_muted())
284 .child(text)
285 .into_any_element()
286}
287
288fn rsvp_menu_item(
289 state: &Entity<AppState>,
290 event_key: &str,
291 label: &'static str,
292 reply: Reply,
293 chosen: bool,
294) -> PopupMenuItem {
295 let state = state.clone();
296 let event_key = event_key.to_owned();
297 PopupMenuItem::new(label)
298 .checked(chosen)
299 .on_click(move |_, _, cx| {
300 state.update(cx, |state, cx| {
301 state.respond_to_event(&event_key, reply, cx)
302 });
303 })
304}
305
306pub(super) fn rsvp_menu(
307 menu: PopupMenu,
308 state: &Entity<AppState>,
309 key: &str,
310 response: ResponseType,
311 send_response: bool,
312) -> PopupMenu {
313 let toggle_state = state.clone();
314 menu.item(rsvp_menu_item(
315 state,
316 key,
317 "Accept",
318 Reply::Accept,
319 response == ResponseType::Accepted,
320 ))
321 .item(rsvp_menu_item(
322 state,
323 key,
324 "Tentative",
325 Reply::Tentative,
326 response == ResponseType::Tentative,
327 ))
328 .item(rsvp_menu_item(
329 state,
330 key,
331 "Decline",
332 Reply::Decline,
333 response == ResponseType::Declined,
334 ))
335 .separator()
336 .item(
337 PopupMenuItem::new("Send a response")
338 .checked(send_response)
339 .on_click(move |_, _, cx| {
340 toggle_state.update(cx, |state, cx| state.toggle_rsvp_send_response(cx));
341 }),
342 )
343}
344
345fn rsvp_control(state: &Entity<AppState>, row: &AgendaRow, send_response: bool) -> AnyElement {
346 let menu_state = state.clone();
347 let key = row.key.clone();
348 let response = row.response;
349 div()
350 .id(SharedString::from(format!("agenda-rsvp-{}", row.key)))
351 .flex_none()
352 .on_click(|_, _, cx| cx.stop_propagation())
353 .child(
354 Button::new(SharedString::from(format!(
355 "agenda-rsvp-button-{}",
356 row.key
357 )))
358 .xsmall()
359 .outline()
360 .label(response_label(response))
361 .icon(IconName::ChevronDown)
362 .dropdown_menu(move |menu, _, _| {
363 rsvp_menu(menu, &menu_state, &key, response, send_response)
364 }),
365 )
366 .into_any_element()
367}
368
369fn agenda_row(
370 state: &Entity<AppState>,
371 row: &AgendaRow,
372 joinable: bool,
373 send_response: bool,
374) -> AnyElement {
375 let click_state = state.clone();
376 let click_row = row.clone();
377 let join_state = state.clone();
378 let join_row = row.clone();
379 let menu_join_url = row.join_url.clone();
380 let line = h_flex()
381 .id(SharedString::from(format!("agenda-{}", row.key)))
382 .mx(px(6.))
383 .h(px(AGENDA_ROW_HEIGHT))
384 .flex_none()
385 .px(px(10.))
386 .gap(px(12.))
387 .items_center()
388 .rounded(px(8.))
389 .cursor_pointer()
390 .hover(|row| row.bg(theme::row_hover()))
391 .child(
392 v_flex()
393 .w(px(TIME_COLUMN_WIDTH))
394 .flex_none()
395 .text_size(px(12.))
396 .text_color(theme::text_muted())
397 .children(time_lines(&row.time_label)),
398 )
399 .child(
400 v_flex()
401 .flex_1()
402 .min_w_0()
403 .gap(px(2.))
404 .child(
405 div()
406 .truncate()
407 .text_size(px(14.))
408 .text_color(theme::text())
409 .child(row.subject.clone()),
410 )
411 .when(!row.detail.is_empty() || row.can_respond, |column| {
412 column.child(
413 h_flex()
414 .gap(px(6.))
415 .items_center()
416 .child(
417 div()
418 .flex_1()
419 .min_w_0()
420 .truncate()
421 .text_size(px(12.5))
422 .text_color(theme::text_muted())
423 .child(row.detail.clone()),
424 )
425 .when(row.can_respond, |line| {
426 line.child(rsvp_control(state, row, send_response))
427 }),
428 )
429 }),
430 )
431 .when(joinable, |line| {
432 line.child(
433 Button::new(SharedString::from(format!("agenda-join-{}", row.key)))
434 .small()
435 .primary()
436 .label("Join")
437 .on_click(move |_, _, cx| {
438 cx.stop_propagation();
439 join_state.update(cx, |state, cx| state.join_agenda_row(&join_row, cx));
440 }),
441 )
442 })
443 .on_click(move |_, _, cx| {
444 click_state.update(cx, |state, cx| state.open_agenda_chat(&click_row, cx));
445 });
446 let Some(join_url) = menu_join_url else {
447 return line.into_any_element();
448 };
449 line.context_menu(move |popup, _, _| {
450 let join_url = join_url.clone();
451 popup.item(
452 PopupMenuItem::new("Copy meeting link")
453 .icon(menu_icon(IconName::Link))
454 .on_click(move |_, _, cx| {
455 cx.write_to_clipboard(ClipboardItem::new_string(join_url.clone()));
456 }),
457 )
458 })
459 .into_any_element()
460}
461
462pub fn calls_body(
463 state: &Entity<AppState>,
464 scroll: &ScrollHandle,
465 window_height: f32,
466 cx: &mut App,
467) -> AnyElement {
468 let now = Utc::now();
469 let offset = Local::now().offset().fix();
470 if state.read(cx).calls_list.needs_rebuild(now, offset) {
471 let rebuild_state = state.clone();
472 cx.defer(move |cx| rebuild_state.update(cx, |state, cx| state.rebuild_calls_list(cx)));
473 }
474 let top = -f32::from(scroll_offset(scroll).y);
475 let measured = f32::from(scroll.bounds().size.height);
476 let height = if measured > 1. {
477 measured
478 } else {
479 window_height.max(FALLBACK_VIEWPORT)
480 };
481 let app = state.read(cx);
482 let window = app
483 .calls_list
484 .window(top - VIEWPORT_MARGIN, top + height + VIEWPORT_MARGIN);
485 let entries = &app.calls_list.entries()[window.range.clone()];
486 let mut list = v_flex().w_full().pb(px(12.));
487 if window.before > 0. {
488 list = list.child(div().h(px(window.before)).flex_none());
489 }
490 for entry in entries {
491 list = list.child(match entry {
492 ListEntry::Section(title) => section_header(title),
493 ListEntry::Filters(filter) => history_filters(state, *filter),
494 ListEntry::Day(label) => day_header(label),
495 ListEntry::Empty(text) => empty_row(text),
496 ListEntry::Agenda(row) => agenda_row(
497 state,
498 row,
499 join_available(row.start, row.end, now) && row.join_url.is_some(),
500 app.rsvp_send_response,
501 ),
502 ListEntry::Call(row) => call_row(
503 state,
504 row,
505 app.can_open_chat_of_call_row(row),
506 &app.directory,
507 ),
508 });
509 }
510 if window.after > 0. {
511 list = list.child(div().h(px(window.after)).flex_none());
512 }
513 v_flex()
514 .flex_1()
515 .min_h_0()
516 .child(join_buttons(state, app.meet_now_pending))
517 .child(with_top_edge(
518 div()
519 .id("calls-scroll")
520 .flex_1()
521 .min_h_0()
522 .overflow_y_scrollbar()
523 .track_scroll(scroll)
524 .child(list),
525 scroll,
526 SIDEBAR_SCROLL_DIVIDER,
527 ))
528 .into_any_element()
529}
530
531fn time_lines(label: &str) -> Vec<String> {
532 let twelve_hour = crate::format::clock_format().contains(['p', 'P']);
533 match label.split_once(" - ") {
534 Some((start, end)) if twelve_hour => vec![start.to_owned(), end.to_owned()],
535 _ => vec![label.to_owned()],
536 }
537}
crates/app/src/views/mod.rs +2 −1
@@ -26,7 +26,8 @@ pub mod call_transcript;
26 26 pub mod call_view;
27 27 pub mod call_view_menu;
28 28 pub mod calendar_view;
29 pub mod calls_tab;
29 pub mod calls_page;
30 mod rsvp_menu;
30 31 pub mod card_carousel;
31 32 #[cfg(test)]
32 33 mod card_input_tests;
@@ -26,7 +26,8 @@ pub mod call_transcript;
26pub mod call_view;
26pub mod call_view;
27pub mod call_view_menu;
27pub mod call_view_menu;
28pub mod calendar_view;
28pub mod calendar_view;
29pub mod calls_tab;
29pub mod calls_page;
30mod rsvp_menu;
30pub mod card_carousel;
31pub mod card_carousel;
31#[cfg(test)]
32#[cfg(test)]
32mod card_input_tests;
33mod card_input_tests;
crates/app/src/views/rsvp_menu.rs added +62 −0
@@ -0,0 +1,62 @@
1 use chatsvc::{Reply, ResponseType};
2 use gpui_kit::component::menu::{PopupMenu, PopupMenuItem};
3 use gpui_kit::*;
4
5 use crate::app_state::AppState;
6
7 fn rsvp_menu_item(
8 state: &Entity<AppState>,
9 event_key: &str,
10 label: &'static str,
11 reply: Reply,
12 chosen: bool,
13 ) -> PopupMenuItem {
14 let state = state.clone();
15 let event_key = event_key.to_owned();
16 PopupMenuItem::new(label)
17 .checked(chosen)
18 .on_click(move |_, _, cx| {
19 state.update(cx, |state, cx| {
20 state.respond_to_event(&event_key, reply, cx)
21 });
22 })
23 }
24
25 pub(crate) fn rsvp_menu(
26 menu: PopupMenu,
27 state: &Entity<AppState>,
28 key: &str,
29 response: ResponseType,
30 send_response: bool,
31 ) -> PopupMenu {
32 let toggle_state = state.clone();
33 menu.item(rsvp_menu_item(
34 state,
35 key,
36 "Accept",
37 Reply::Accept,
38 response == ResponseType::Accepted,
39 ))
40 .item(rsvp_menu_item(
41 state,
42 key,
43 "Tentative",
44 Reply::Tentative,
45 response == ResponseType::Tentative,
46 ))
47 .item(rsvp_menu_item(
48 state,
49 key,
50 "Decline",
51 Reply::Decline,
52 response == ResponseType::Declined,
53 ))
54 .separator()
55 .item(
56 PopupMenuItem::new("Send a response")
57 .checked(send_response)
58 .on_click(move |_, _, cx| {
59 toggle_state.update(cx, |state, cx| state.toggle_rsvp_send_response(cx));
60 }),
61 )
62 }
@@ -0,0 +1,62 @@
1use chatsvc::{Reply, ResponseType};
2use gpui_kit::component::menu::{PopupMenu, PopupMenuItem};
3use gpui_kit::*;
4
5use crate::app_state::AppState;
6
7fn rsvp_menu_item(
8 state: &Entity<AppState>,
9 event_key: &str,
10 label: &'static str,
11 reply: Reply,
12 chosen: bool,
13) -> PopupMenuItem {
14 let state = state.clone();
15 let event_key = event_key.to_owned();
16 PopupMenuItem::new(label)
17 .checked(chosen)
18 .on_click(move |_, _, cx| {
19 state.update(cx, |state, cx| {
20 state.respond_to_event(&event_key, reply, cx)
21 });
22 })
23}
24
25pub(crate) fn rsvp_menu(
26 menu: PopupMenu,
27 state: &Entity<AppState>,
28 key: &str,
29 response: ResponseType,
30 send_response: bool,
31) -> PopupMenu {
32 let toggle_state = state.clone();
33 menu.item(rsvp_menu_item(
34 state,
35 key,
36 "Accept",
37 Reply::Accept,
38 response == ResponseType::Accepted,
39 ))
40 .item(rsvp_menu_item(
41 state,
42 key,
43 "Tentative",
44 Reply::Tentative,
45 response == ResponseType::Tentative,
46 ))
47 .item(rsvp_menu_item(
48 state,
49 key,
50 "Decline",
51 Reply::Decline,
52 response == ResponseType::Declined,
53 ))
54 .separator()
55 .item(
56 PopupMenuItem::new("Send a response")
57 .checked(send_response)
58 .on_click(move |_, _, cx| {
59 toggle_state.update(cx, |state, cx| state.toggle_rsvp_send_response(cx));
60 }),
61 )
62}
crates/app/src/views/shell.rs +14 −1
@@ -21,6 +21,7 @@ use super::profile_card::{ProfileCard, ProfileCardEvent};
21 21 use gpui_kit::prelude::FluentBuilder as _;
22 22 use super::rail::RailView;
23 23 use crate::chat_filter::ChatFilterPill;
24 use super::calls_page::CallsPage;
24 25 use super::quick_view_pane::{QuickViewEvent, QuickViewPane};
25 26 use super::shortcuts::{
26 27 ClearChatFilters, DeclineCall, FilterMeetingChats, FilterMutedChats,
@@ -155,6 +156,7 @@ pub struct AppShell {
155 156 sidebar: Entity<SidebarView>,
156 157 calendar: Entity<CalendarView>,
157 158 quick_pane: Entity<QuickViewPane>,
159 calls_page: Entity<CallsPage>,
158 160 shown_quick_view: Option<QuickView>,
159 161 conversation: Entity<ConversationView>,
160 162 call_chat: Option<(String, Entity<ConversationView>)>,
@@ -267,6 +269,7 @@ impl AppShell {
267 269 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
268 270 let activity_panel = cx.new(|cx| ActivityPanel::new(state.clone(), activity.clone(), cx));
269 271 let quick_pane = cx.new(|cx| QuickViewPane::new(state.clone(), activity.clone(), cx));
272 let calls_page = cx.new(|cx| CallsPage::new(state.clone(), window, cx));
270 273 let agents_panel = crate::agents::runs_handle(cx)
271 274 .map(|runs| cx.new(|cx| crate::agents::AgentsPanel::new(runs, cx)));
272 275 let agents_subscription = agents_panel.as_ref().map(|panel| {
@@ -404,6 +407,7 @@ impl AppShell {
404 407 sidebar,
405 408 calendar,
406 409 quick_pane,
410 calls_page,
407 411 shown_quick_view: None,
408 412 conversation,
409 413 call_chat: None,
@@ -901,6 +905,7 @@ impl AppShell {
901 905 show_sidebar: bool,
902 906 calendar_open: bool,
903 907 quick_view_open: bool,
908 calls_open: bool,
904 909 ) -> impl IntoElement {
905 910 h_flex()
906 911 .debug_selector(|| "shell/islands".into())
@@ -931,6 +936,11 @@ impl AppShell {
931 936 (None, Some(prejoin)) => prejoin
932 937 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
933 938 .into_any_element(),
939 (None, None) if calls_open => self
940 .calls_page
941 .clone()
942 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
943 .into_any_element(),
934 944 (None, None) if quick_view_open => self
935 945 .quick_pane
936 946 .clone()
@@ -1009,6 +1019,7 @@ impl Render for AppShell {
1009 1019 let chat_panel = self.call_chat.as_ref().map(|(_, view)| view.clone().into());
1010 1020 let calendar_tab = self.sidebar.read(cx).tab() == SidebarTab::Calendar;
1011 1021 let chats_tab = self.sidebar.read(cx).tab() == SidebarTab::Chats;
1022 let calls_tab = self.sidebar.read(cx).tab() == SidebarTab::Calls;
1012 1023 let state = self.state.read(cx);
1013 1024 let call_fullscreen = state.call_fullscreen();
1014 1025 let window_width = f32::from(window.viewport_size().width);
@@ -1018,7 +1029,9 @@ impl Render for AppShell {
1018 1029 .is_some_and(|call| call.chat_open || call.people_open || call.transcript_open);
1019 1030 let calendar_open = calendar_tab && !state.viewing_call();
1020 1031 let quick_view_open = chats_tab && state.quick_view.is_some();
1032 let calls_open = calls_tab && !state.viewing_call();
1021 1033 let show_sidebar = !calendar_open
1034 && !calls_open
1022 1035 && !(state.viewing_call()
1023 1036 && !call_fullscreen
1024 1037 && sidebar_hidden_in_call(window_width, panel_open));
@@ -1259,7 +1272,7 @@ impl Render for AppShell {
1259 1272 .size_full()
1260 1273 .child(title_bar)
1261 1274 .children(banner)
1262 .child(self.islands(call_view, show_sidebar, calendar_open, quick_view_open)),
1275 .child(self.islands(call_view, show_sidebar, calendar_open, quick_view_open, calls_open)),
1263 1276 )
1264 1277 .children(call_mini)
1265 1278 .children(call_overlay)
@@ -21,6 +21,7 @@ use super::profile_card::{ProfileCard, ProfileCardEvent};
21use gpui_kit::prelude::FluentBuilder as _;
21use gpui_kit::prelude::FluentBuilder as _;
22use super::rail::RailView;
22use super::rail::RailView;
23use crate::chat_filter::ChatFilterPill;
23use crate::chat_filter::ChatFilterPill;
24use super::calls_page::CallsPage;
24use super::quick_view_pane::{QuickViewEvent, QuickViewPane};
25use super::quick_view_pane::{QuickViewEvent, QuickViewPane};
25use super::shortcuts::{
26use super::shortcuts::{
26 ClearChatFilters, DeclineCall, FilterMeetingChats, FilterMutedChats,
27 ClearChatFilters, DeclineCall, FilterMeetingChats, FilterMutedChats,
@@ -155,6 +156,7 @@ pub struct AppShell {
155 sidebar: Entity<SidebarView>,
156 sidebar: Entity<SidebarView>,
156 calendar: Entity<CalendarView>,
157 calendar: Entity<CalendarView>,
157 quick_pane: Entity<QuickViewPane>,
158 quick_pane: Entity<QuickViewPane>,
159 calls_page: Entity<CallsPage>,
158 shown_quick_view: Option<QuickView>,
160 shown_quick_view: Option<QuickView>,
159 conversation: Entity<ConversationView>,
161 conversation: Entity<ConversationView>,
160 call_chat: Option<(String, Entity<ConversationView>)>,
162 call_chat: Option<(String, Entity<ConversationView>)>,
@@ -267,6 +269,7 @@ impl AppShell {
267 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
269 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));
270 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));
271 let quick_pane = cx.new(|cx| QuickViewPane::new(state.clone(), activity.clone(), cx));
272 let calls_page = cx.new(|cx| CallsPage::new(state.clone(), window, cx));
270 let agents_panel = crate::agents::runs_handle(cx)
273 let agents_panel = crate::agents::runs_handle(cx)
271 .map(|runs| cx.new(|cx| crate::agents::AgentsPanel::new(runs, cx)));
274 .map(|runs| cx.new(|cx| crate::agents::AgentsPanel::new(runs, cx)));
272 let agents_subscription = agents_panel.as_ref().map(|panel| {
275 let agents_subscription = agents_panel.as_ref().map(|panel| {
@@ -404,6 +407,7 @@ impl AppShell {
404 sidebar,
407 sidebar,
405 calendar,
408 calendar,
406 quick_pane,
409 quick_pane,
410 calls_page,
407 shown_quick_view: None,
411 shown_quick_view: None,
408 conversation,
412 conversation,
409 call_chat: None,
413 call_chat: None,
@@ -901,6 +905,7 @@ impl AppShell {
901 show_sidebar: bool,
905 show_sidebar: bool,
902 calendar_open: bool,
906 calendar_open: bool,
903 quick_view_open: bool,
907 quick_view_open: bool,
908 calls_open: bool,
904 ) -> impl IntoElement {
909 ) -> impl IntoElement {
905 h_flex()
910 h_flex()
906 .debug_selector(|| "shell/islands".into())
911 .debug_selector(|| "shell/islands".into())
@@ -931,6 +936,11 @@ impl AppShell {
931 (None, Some(prejoin)) => prejoin
936 (None, Some(prejoin)) => prejoin
932 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
937 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
933 .into_any_element(),
938 .into_any_element(),
939 (None, None) if calls_open => self
940 .calls_page
941 .clone()
942 .cached(StyleRefinement::default().flex_1().min_w_0().h_full())
943 .into_any_element(),
934 (None, None) if quick_view_open => self
944 (None, None) if quick_view_open => self
935 .quick_pane
945 .quick_pane
936 .clone()
946 .clone()
@@ -1009,6 +1019,7 @@ impl Render for AppShell {
1009 let chat_panel = self.call_chat.as_ref().map(|(_, view)| view.clone().into());
1019 let chat_panel = self.call_chat.as_ref().map(|(_, view)| view.clone().into());
1010 let calendar_tab = self.sidebar.read(cx).tab() == SidebarTab::Calendar;
1020 let calendar_tab = self.sidebar.read(cx).tab() == SidebarTab::Calendar;
1011 let chats_tab = self.sidebar.read(cx).tab() == SidebarTab::Chats;
1021 let chats_tab = self.sidebar.read(cx).tab() == SidebarTab::Chats;
1022 let calls_tab = self.sidebar.read(cx).tab() == SidebarTab::Calls;
1012 let state = self.state.read(cx);
1023 let state = self.state.read(cx);
1013 let call_fullscreen = state.call_fullscreen();
1024 let call_fullscreen = state.call_fullscreen();
1014 let window_width = f32::from(window.viewport_size().width);
1025 let window_width = f32::from(window.viewport_size().width);
@@ -1018,7 +1029,9 @@ impl Render for AppShell {
1018 .is_some_and(|call| call.chat_open || call.people_open || call.transcript_open);
1029 .is_some_and(|call| call.chat_open || call.people_open || call.transcript_open);
1019 let calendar_open = calendar_tab && !state.viewing_call();
1030 let calendar_open = calendar_tab && !state.viewing_call();
1020 let quick_view_open = chats_tab && state.quick_view.is_some();
1031 let quick_view_open = chats_tab && state.quick_view.is_some();
1032 let calls_open = calls_tab && !state.viewing_call();
1021 let show_sidebar = !calendar_open
1033 let show_sidebar = !calendar_open
1034 && !calls_open
1022 && !(state.viewing_call()
1035 && !(state.viewing_call()
1023 && !call_fullscreen
1036 && !call_fullscreen
1024 && sidebar_hidden_in_call(window_width, panel_open));
1037 && sidebar_hidden_in_call(window_width, panel_open));
@@ -1259,7 +1272,7 @@ impl Render for AppShell {
1259 .size_full()
1272 .size_full()
1260 .child(title_bar)
1273 .child(title_bar)
1261 .children(banner)
1274 .children(banner)
1262 .child(self.islands(call_view, show_sidebar, calendar_open, quick_view_open)),
1275 .child(self.islands(call_view, show_sidebar, calendar_open, quick_view_open, calls_open)),
1263 )
1276 )
1264 .children(call_mini)
1277 .children(call_mini)
1265 .children(call_overlay)
1278 .children(call_overlay)
crates/app/src/views/sidebar.rs +3 −23
@@ -1,6 +1,5 @@
1 1 use std::cell::{Cell, RefCell};
2 2 use std::collections::{HashMap, HashSet};
3 use std::time::Duration;
4 3
5 4 use chrono::{Local, Offset, Utc};
6 5 use gpui_kit::component::scroll::ScrollableElement as _;
@@ -19,7 +18,6 @@ use teams_core::team_avatar_key;
19 18
20 19 use super::activity_panel::ActivityPanel;
21 20 use super::avatar::{spec_avatar, team_avatar, with_presence};
22 use super::calls_tab::calls_body;
23 21 use super::chat_menu::{ChatMenuTarget, MenuContext, chat_menu};
24 22 use super::scroll_edge::{scroll_offset, with_top_edge};
25 23 use super::channel_admin_dialogs::{confirm_delete_channel, open_edit_channel_dialog};
@@ -74,7 +72,6 @@ const HINT_HEIGHT: f32 = 26.;
74 72 const SEE_MORE_HEIGHT: f32 = 28.;
75 73 const LOADING_OLDER_LABEL: &str = "Loading older chats";
76 74 const FALLBACK_VIEWPORT: f32 = 900.;
77 const CALLS_REFRESH: Duration = Duration::from_secs(30);
78 75 const VIEWPORT_MARGIN: f32 = 300.;
79 76 const AVATAR_SIZE: f32 = 36.;
80 77 const PINNED_LABEL: &str = "Pinned";
@@ -353,7 +350,6 @@ pub struct SidebarView {
353 350 older_chats_seen: Cell<(bool, bool)>,
354 351 section_ids: RefCell<Vec<String>>,
355 352 channels_scroll: ScrollHandle,
356 calls_scroll: ScrollHandle,
357 353 chat_filter: ChatFilter,
358 354 filter_box_open: bool,
359 355 more_filters_open: bool,
@@ -462,20 +458,6 @@ impl SidebarView {
462 458 cx.notify();
463 459 }
464 460 });
465 cx.spawn(async move |this, cx| {
466 loop {
467 cx.background_executor().timer(CALLS_REFRESH).await;
468 let alive = this.update(cx, |view, cx| {
469 if view.tab == SidebarTab::Calls {
470 cx.notify();
471 }
472 });
473 if alive.is_err() {
474 break;
475 }
476 }
477 })
478 .detach();
479 461 SidebarView {
480 462 state,
481 463 tab,
@@ -489,7 +471,6 @@ impl SidebarView {
489 471 older_chats_seen: Cell::new((false, false)),
490 472 section_ids: RefCell::new(Vec::new()),
491 473 channels_scroll: ScrollHandle::new(),
492 calls_scroll: ScrollHandle::new(),
493 474 chat_filter: ChatFilter::default(),
494 475 filter_box_open: false,
495 476 more_filters_open: false,
@@ -2098,12 +2079,11 @@ impl Render for SidebarView {
2098 2079 SidebarTab::Activity => self.activity_panel.clone().into_any_element(),
2099 2080 SidebarTab::Chats => self.chats_body(window_height, cx),
2100 2081 SidebarTab::Channels => self.channels_body(cx),
2101 SidebarTab::Calls => calls_body(&self.state, &self.calls_scroll, window_height, cx),
2102 2082 SidebarTab::Agents => match &self.agents_panel {
2103 2083 Some(panel) => panel.clone().into_any_element(),
2104 2084 None => div().into_any_element(),
2105 2085 },
2106 SidebarTab::Calendar => div().into_any_element(),
2086 SidebarTab::Calls | SidebarTab::Calendar => div().into_any_element(),
2107 2087 };
2108 2088 let header = match self.tab {
2109 2089 SidebarTab::Chats => Some(
@@ -2120,8 +2100,8 @@ impl Render for SidebarView {
2120 2100 SidebarTab::Channels => {
2121 2101 Some(page_header(self.tab.title()).child(self.channel_list_menu_button(cx)))
2122 2102 }
2123 SidebarTab::Calls | SidebarTab::Agents => Some(page_header(self.tab.title())),
2124 SidebarTab::Activity | SidebarTab::Calendar => None,
2103 SidebarTab::Agents => Some(page_header(self.tab.title())),
2104 SidebarTab::Activity | SidebarTab::Calls | SidebarTab::Calendar => None,
2125 2105 };
2126 2106 v_flex()
2127 2107 .debug_selector(|| "shell/islands/sidebar".into())
@@ -1,6 +1,5 @@
1use std::cell::{Cell, RefCell};
1use std::cell::{Cell, RefCell};
2use std::collections::{HashMap, HashSet};
2use std::collections::{HashMap, HashSet};
3use std::time::Duration;
4
3
5use chrono::{Local, Offset, Utc};
4use chrono::{Local, Offset, Utc};
6use gpui_kit::component::scroll::ScrollableElement as _;
5use gpui_kit::component::scroll::ScrollableElement as _;
@@ -19,7 +18,6 @@ use teams_core::team_avatar_key;
19
18
20use super::activity_panel::ActivityPanel;
19use super::activity_panel::ActivityPanel;
21use super::avatar::{spec_avatar, team_avatar, with_presence};
20use super::avatar::{spec_avatar, team_avatar, with_presence};
22use super::calls_tab::calls_body;
23use super::chat_menu::{ChatMenuTarget, MenuContext, chat_menu};
21use super::chat_menu::{ChatMenuTarget, MenuContext, chat_menu};
24use super::scroll_edge::{scroll_offset, with_top_edge};
22use super::scroll_edge::{scroll_offset, with_top_edge};
25use super::channel_admin_dialogs::{confirm_delete_channel, open_edit_channel_dialog};
23use super::channel_admin_dialogs::{confirm_delete_channel, open_edit_channel_dialog};
@@ -74,7 +72,6 @@ const HINT_HEIGHT: f32 = 26.;
74const SEE_MORE_HEIGHT: f32 = 28.;
72const SEE_MORE_HEIGHT: f32 = 28.;
75const LOADING_OLDER_LABEL: &str = "Loading older chats";
73const LOADING_OLDER_LABEL: &str = "Loading older chats";
76const FALLBACK_VIEWPORT: f32 = 900.;
74const FALLBACK_VIEWPORT: f32 = 900.;
77const CALLS_REFRESH: Duration = Duration::from_secs(30);
78const VIEWPORT_MARGIN: f32 = 300.;
75const VIEWPORT_MARGIN: f32 = 300.;
79const AVATAR_SIZE: f32 = 36.;
76const AVATAR_SIZE: f32 = 36.;
80const PINNED_LABEL: &str = "Pinned";
77const PINNED_LABEL: &str = "Pinned";
@@ -353,7 +350,6 @@ pub struct SidebarView {
353 older_chats_seen: Cell<(bool, bool)>,
350 older_chats_seen: Cell<(bool, bool)>,
354 section_ids: RefCell<Vec<String>>,
351 section_ids: RefCell<Vec<String>>,
355 channels_scroll: ScrollHandle,
352 channels_scroll: ScrollHandle,
356 calls_scroll: ScrollHandle,
357 chat_filter: ChatFilter,
353 chat_filter: ChatFilter,
358 filter_box_open: bool,
354 filter_box_open: bool,
359 more_filters_open: bool,
355 more_filters_open: bool,
@@ -462,20 +458,6 @@ impl SidebarView {
462 cx.notify();
458 cx.notify();
463 }
459 }
464 });
460 });
465 cx.spawn(async move |this, cx| {
466 loop {
467 cx.background_executor().timer(CALLS_REFRESH).await;
468 let alive = this.update(cx, |view, cx| {
469 if view.tab == SidebarTab::Calls {
470 cx.notify();
471 }
472 });
473 if alive.is_err() {
474 break;
475 }
476 }
477 })
478 .detach();
479 SidebarView {
461 SidebarView {
480 state,
462 state,
481 tab,
463 tab,
@@ -489,7 +471,6 @@ impl SidebarView {
489 older_chats_seen: Cell::new((false, false)),
471 older_chats_seen: Cell::new((false, false)),
490 section_ids: RefCell::new(Vec::new()),
472 section_ids: RefCell::new(Vec::new()),
491 channels_scroll: ScrollHandle::new(),
473 channels_scroll: ScrollHandle::new(),
492 calls_scroll: ScrollHandle::new(),
493 chat_filter: ChatFilter::default(),
474 chat_filter: ChatFilter::default(),
494 filter_box_open: false,
475 filter_box_open: false,
495 more_filters_open: false,
476 more_filters_open: false,
@@ -2098,12 +2079,11 @@ impl Render for SidebarView {
2098 SidebarTab::Activity => self.activity_panel.clone().into_any_element(),
2079 SidebarTab::Activity => self.activity_panel.clone().into_any_element(),
2099 SidebarTab::Chats => self.chats_body(window_height, cx),
2080 SidebarTab::Chats => self.chats_body(window_height, cx),
2100 SidebarTab::Channels => self.channels_body(cx),
2081 SidebarTab::Channels => self.channels_body(cx),
2101 SidebarTab::Calls => calls_body(&self.state, &self.calls_scroll, window_height, cx),
2102 SidebarTab::Agents => match &self.agents_panel {
2082 SidebarTab::Agents => match &self.agents_panel {
2103 Some(panel) => panel.clone().into_any_element(),
2083 Some(panel) => panel.clone().into_any_element(),
2104 None => div().into_any_element(),
2084 None => div().into_any_element(),
2105 },
2085 },
2106 SidebarTab::Calendar => div().into_any_element(),
2086 SidebarTab::Calls | SidebarTab::Calendar => div().into_any_element(),
2107 };
2087 };
2108 let header = match self.tab {
2088 let header = match self.tab {
2109 SidebarTab::Chats => Some(
2089 SidebarTab::Chats => Some(
@@ -2120,8 +2100,8 @@ impl Render for SidebarView {
2120 SidebarTab::Channels => {
2100 SidebarTab::Channels => {
2121 Some(page_header(self.tab.title()).child(self.channel_list_menu_button(cx)))
2101 Some(page_header(self.tab.title()).child(self.channel_list_menu_button(cx)))
2122 }
2102 }
2123 SidebarTab::Calls | SidebarTab::Agents => Some(page_header(self.tab.title())),
2103 SidebarTab::Agents => Some(page_header(self.tab.title())),
2124 SidebarTab::Activity | SidebarTab::Calendar => None,
2104 SidebarTab::Activity | SidebarTab::Calls | SidebarTab::Calendar => None,
2125 };
2105 };
2126 v_flex()
2106 v_flex()
2127 .debug_selector(|| "shell/islands/sidebar".into())
2107 .debug_selector(|| "shell/islands/sidebar".into())