BlueGit

ict rusty-teams

feat(calendar): meeting menu with Join, chat and RSVP

- Right-click on a meeting: Join, Chat with participants, Accept / Tentative / Decline, Send a response
- RSVP menu shared with the Calls agenda; a response updates both the agenda and the week view, declined meetings leave the grid

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
e68a499bc175891095ee61a6f3894df6e61b3cbd
Parent
8986570f
3 files changed +118 −45
crates/app-state/src/call/schedule.rs +16 −11
@@ -194,6 +194,18 @@ impl AppState {
194 194 cx.notify();
195 195 }
196 196
197 fn set_event_response(&mut self, event_id: &str, response: ResponseType) {
198 for event in self
199 .calendar_events
200 .iter_mut()
201 .chain(self.calendar_week.events.iter_mut())
202 .filter(|event| event.object_id == event_id)
203 {
204 event.response = response;
205 }
206 self.calls_list.invalidate();
207 }
208
197 209 pub fn respond_to_event(&mut self, event_key: &str, reply: Reply, cx: &mut Context<Self>) {
198 210 if self.mode.read_only {
199 211 self.raise_notice(RESPONSE_FAILED_NOTICE.to_owned(), None, cx);
@@ -201,15 +213,15 @@ impl AppState {
201 213 }
202 214 let Some(event) = self
203 215 .calendar_events
204 .iter_mut()
216 .iter()
217 .chain(&self.calendar_week.events)
205 218 .find(|event| event.object_id == event_key)
206 219 else {
207 220 return;
208 221 };
209 222 let previous = event.response;
210 223 let (event_id, ical_uid) = (event.object_id.clone(), event.ical_uid.clone());
211 event.response = response_for(reply);
212 self.calls_list.invalidate();
224 self.set_event_response(&event_id, response_for(reply));
213 225 cx.notify();
214 226 let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);
215 227 let Some(launcher) = launcher else {
@@ -231,14 +243,7 @@ impl AppState {
231 243 state.refresh_calendar(cx);
232 244 return;
233 245 }
234 if let Some(event) = state
235 .calendar_events
236 .iter_mut()
237 .find(|event| event.object_id == event_id)
238 {
239 event.response = previous;
240 }
241 state.calls_list.invalidate();
246 state.set_event_response(&event_id, previous);
242 247 state.raise_notice(RESPONSE_FAILED_NOTICE.to_owned(), None, cx);
243 248 })
244 249 .ok();
@@ -194,6 +194,18 @@ impl AppState {
194 cx.notify();
194 cx.notify();
195 }
195 }
196
196
197 fn set_event_response(&mut self, event_id: &str, response: ResponseType) {
198 for event in self
199 .calendar_events
200 .iter_mut()
201 .chain(self.calendar_week.events.iter_mut())
202 .filter(|event| event.object_id == event_id)
203 {
204 event.response = response;
205 }
206 self.calls_list.invalidate();
207 }
208
197 pub fn respond_to_event(&mut self, event_key: &str, reply: Reply, cx: &mut Context<Self>) {
209 pub fn respond_to_event(&mut self, event_key: &str, reply: Reply, cx: &mut Context<Self>) {
198 if self.mode.read_only {
210 if self.mode.read_only {
199 self.raise_notice(RESPONSE_FAILED_NOTICE.to_owned(), None, cx);
211 self.raise_notice(RESPONSE_FAILED_NOTICE.to_owned(), None, cx);
@@ -201,15 +213,15 @@ impl AppState {
201 }
213 }
202 let Some(event) = self
214 let Some(event) = self
203 .calendar_events
215 .calendar_events
204 .iter_mut()
216 .iter()
217 .chain(&self.calendar_week.events)
205 .find(|event| event.object_id == event_key)
218 .find(|event| event.object_id == event_key)
206 else {
219 else {
207 return;
220 return;
208 };
221 };
209 let previous = event.response;
222 let previous = event.response;
210 let (event_id, ical_uid) = (event.object_id.clone(), event.ical_uid.clone());
223 let (event_id, ical_uid) = (event.object_id.clone(), event.ical_uid.clone());
211 event.response = response_for(reply);
224 self.set_event_response(&event_id, response_for(reply));
212 self.calls_list.invalidate();
213 cx.notify();
225 cx.notify();
214 let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);
226 let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);
215 let Some(launcher) = launcher else {
227 let Some(launcher) = launcher else {
@@ -231,14 +243,7 @@ impl AppState {
231 state.refresh_calendar(cx);
243 state.refresh_calendar(cx);
232 return;
244 return;
233 }
245 }
234 if let Some(event) = state
246 state.set_event_response(&event_id, previous);
235 .calendar_events
236 .iter_mut()
237 .find(|event| event.object_id == event_id)
238 {
239 event.response = previous;
240 }
241 state.calls_list.invalidate();
242 state.raise_notice(RESPONSE_FAILED_NOTICE.to_owned(), None, cx);
247 state.raise_notice(RESPONSE_FAILED_NOTICE.to_owned(), None, cx);
243 })
248 })
244 .ok();
249 .ok();
crates/app/src/views/calendar_view.rs +61 −2
@@ -3,10 +3,12 @@ use chrono::{DateTime, Local, NaiveDate, Offset, Timelike, Utc};
3 3 use gpui_kit::assets::IconName;
4 4 use gpui_kit::component::Sizable as _;
5 5 use gpui_kit::component::button::{Button, ButtonVariants as _};
6 use gpui_kit::component::menu::{ContextMenuExt as _, PopupMenu, PopupMenuItem};
6 7 use gpui_kit::component::{h_flex, v_flex};
7 8 use gpui_kit::prelude::FluentBuilder as _;
8 9 use gpui_kit::*;
9 10
11 use super::calls_tab::rsvp_menu;
10 12 use super::join_dialog::open_join_with_id;
11 13 use super::new_meeting_dialog::open_new_meeting;
12 14 use crate::app_state::AppState;
@@ -214,6 +216,7 @@ impl CalendarView {
214 216 block: &WeekBlock,
215 217 event: &CalendarEvent,
216 218 now: DateTime<Utc>,
219 send_response: bool,
217 220 ) -> impl IntoElement {
218 221 let top = block.start_minute as f32 / 60. * HOUR_HEIGHT;
219 222 let height = ((block.end_minute - block.start_minute) as f32 / 60. * HOUR_HEIGHT
@@ -231,6 +234,7 @@ impl CalendarView {
231 234 event.end.with_timezone(&Local).format("%-I:%M %p")
232 235 );
233 236 let (open_state, thread_id) = (self.state.clone(), event.thread_id.clone());
237 let (menu_state, menu_event) = (self.state.clone(), event.clone());
234 238 let (join_state, join_url, subject) = (
235 239 self.state.clone(),
236 240 event.join_url.clone(),
@@ -312,6 +316,9 @@ impl CalendarView {
312 316 state.open_meeting_chat(thread_id.as_deref(), cx)
313 317 });
314 318 })
319 .context_menu(move |menu, _, _| {
320 event_menu(menu, &menu_state, &menu_event, send_response)
321 })
315 322 }
316 323
317 324 fn grid(
@@ -320,6 +327,7 @@ impl CalendarView {
320 327 events: &[CalendarEvent],
321 328 today: NaiveDate,
322 329 now: DateTime<Utc>,
330 send_response: bool,
323 331 ) -> impl IntoElement {
324 332 let total_height = 24. * HOUR_HEIGHT;
325 333 let now_minute = {
@@ -369,7 +377,12 @@ impl CalendarView {
369 377 .bg(theme::border())
370 378 }))
371 379 .children(day.blocks.iter().map(|block| {
372 self.event_block(block, &events[block.event_index], now)
380 self.event_block(
381 block,
382 &events[block.event_index],
383 now,
384 send_response,
385 )
373 386 }))
374 387 .when(day.date == today, |column| {
375 388 column.child(
@@ -387,6 +400,51 @@ impl CalendarView {
387 400 }
388 401 }
389 402
403 fn event_menu(
404 menu: PopupMenu,
405 state: &Entity<AppState>,
406 event: &CalendarEvent,
407 send_response: bool,
408 ) -> PopupMenu {
409 let mut menu = menu;
410 if let Some(join_url) = event
411 .join_url
412 .clone()
413 .filter(|_| event.online && !event.cancelled)
414 {
415 let (join_state, subject) = (state.clone(), event.subject.clone());
416 menu = menu.item(PopupMenuItem::new("Join").icon(IconName::Video).on_click(
417 move |_, _, cx| {
418 join_state.update(cx, |state, cx| {
419 state.join_calendar_meeting(Some(&join_url), &subject, cx)
420 })
421 },
422 ));
423 }
424 if let Some(thread_id) = event.thread_id.clone() {
425 let chat_state = state.clone();
426 menu = menu.item(
427 PopupMenuItem::new("Chat with participants")
428 .icon(IconName::MessageSquare)
429 .on_click(move |_, _, cx| {
430 chat_state.update(cx, |state, cx| {
431 state.open_meeting_chat(Some(&thread_id), cx)
432 })
433 }),
434 );
435 }
436 if event.response == ResponseType::Organizer || event.organizer_name.is_none() {
437 return menu;
438 }
439 rsvp_menu(
440 menu.separator(),
441 state,
442 &event.object_id,
443 event.response,
444 send_response,
445 )
446 }
447
390 448 fn event_fill(response: ResponseType) -> Hsla {
391 449 match response {
392 450 ResponseType::NotResponded => theme::surface_raised(),
@@ -414,6 +472,7 @@ impl Render for CalendarView {
414 472 let state = self.state.read(cx);
415 473 let start = state.calendar_start();
416 474 let events = state.calendar_week.events.clone();
475 let send_response = state.rsvp_send_response;
417 476 let offset = Local::now().offset().fix();
418 477 let days = week_days(&events, start, WORK_WEEK_DAYS, offset);
419 478 let today = Local::now().date_naive();
@@ -430,6 +489,6 @@ impl Render for CalendarView {
430 489 .child(self.header(start, compact))
431 490 .child(self.day_headers(&days, today))
432 491 .children(self.all_day_row(&days, &events))
433 .child(self.grid(&days, &events, today, now))
492 .child(self.grid(&days, &events, today, now, send_response))
434 493 }
435 494 }
@@ -3,10 +3,12 @@ use chrono::{DateTime, Local, NaiveDate, Offset, Timelike, Utc};
3use gpui_kit::assets::IconName;
3use gpui_kit::assets::IconName;
4use gpui_kit::component::Sizable as _;
4use gpui_kit::component::Sizable as _;
5use gpui_kit::component::button::{Button, ButtonVariants as _};
5use gpui_kit::component::button::{Button, ButtonVariants as _};
6use gpui_kit::component::menu::{ContextMenuExt as _, PopupMenu, PopupMenuItem};
6use gpui_kit::component::{h_flex, v_flex};
7use gpui_kit::component::{h_flex, v_flex};
7use gpui_kit::prelude::FluentBuilder as _;
8use gpui_kit::prelude::FluentBuilder as _;
8use gpui_kit::*;
9use gpui_kit::*;
9
10
11use super::calls_tab::rsvp_menu;
10use super::join_dialog::open_join_with_id;
12use super::join_dialog::open_join_with_id;
11use super::new_meeting_dialog::open_new_meeting;
13use super::new_meeting_dialog::open_new_meeting;
12use crate::app_state::AppState;
14use crate::app_state::AppState;
@@ -214,6 +216,7 @@ impl CalendarView {
214 block: &WeekBlock,
216 block: &WeekBlock,
215 event: &CalendarEvent,
217 event: &CalendarEvent,
216 now: DateTime<Utc>,
218 now: DateTime<Utc>,
219 send_response: bool,
217 ) -> impl IntoElement {
220 ) -> impl IntoElement {
218 let top = block.start_minute as f32 / 60. * HOUR_HEIGHT;
221 let top = block.start_minute as f32 / 60. * HOUR_HEIGHT;
219 let height = ((block.end_minute - block.start_minute) as f32 / 60. * HOUR_HEIGHT
222 let height = ((block.end_minute - block.start_minute) as f32 / 60. * HOUR_HEIGHT
@@ -231,6 +234,7 @@ impl CalendarView {
231 event.end.with_timezone(&Local).format("%-I:%M %p")
234 event.end.with_timezone(&Local).format("%-I:%M %p")
232 );
235 );
233 let (open_state, thread_id) = (self.state.clone(), event.thread_id.clone());
236 let (open_state, thread_id) = (self.state.clone(), event.thread_id.clone());
237 let (menu_state, menu_event) = (self.state.clone(), event.clone());
234 let (join_state, join_url, subject) = (
238 let (join_state, join_url, subject) = (
235 self.state.clone(),
239 self.state.clone(),
236 event.join_url.clone(),
240 event.join_url.clone(),
@@ -312,6 +316,9 @@ impl CalendarView {
312 state.open_meeting_chat(thread_id.as_deref(), cx)
316 state.open_meeting_chat(thread_id.as_deref(), cx)
313 });
317 });
314 })
318 })
319 .context_menu(move |menu, _, _| {
320 event_menu(menu, &menu_state, &menu_event, send_response)
321 })
315 }
322 }
316
323
317 fn grid(
324 fn grid(
@@ -320,6 +327,7 @@ impl CalendarView {
320 events: &[CalendarEvent],
327 events: &[CalendarEvent],
321 today: NaiveDate,
328 today: NaiveDate,
322 now: DateTime<Utc>,
329 now: DateTime<Utc>,
330 send_response: bool,
323 ) -> impl IntoElement {
331 ) -> impl IntoElement {
324 let total_height = 24. * HOUR_HEIGHT;
332 let total_height = 24. * HOUR_HEIGHT;
325 let now_minute = {
333 let now_minute = {
@@ -369,7 +377,12 @@ impl CalendarView {
369 .bg(theme::border())
377 .bg(theme::border())
370 }))
378 }))
371 .children(day.blocks.iter().map(|block| {
379 .children(day.blocks.iter().map(|block| {
372 self.event_block(block, &events[block.event_index], now)
380 self.event_block(
381 block,
382 &events[block.event_index],
383 now,
384 send_response,
385 )
373 }))
386 }))
374 .when(day.date == today, |column| {
387 .when(day.date == today, |column| {
375 column.child(
388 column.child(
@@ -387,6 +400,51 @@ impl CalendarView {
387 }
400 }
388}
401}
389
402
403fn event_menu(
404 menu: PopupMenu,
405 state: &Entity<AppState>,
406 event: &CalendarEvent,
407 send_response: bool,
408) -> PopupMenu {
409 let mut menu = menu;
410 if let Some(join_url) = event
411 .join_url
412 .clone()
413 .filter(|_| event.online && !event.cancelled)
414 {
415 let (join_state, subject) = (state.clone(), event.subject.clone());
416 menu = menu.item(PopupMenuItem::new("Join").icon(IconName::Video).on_click(
417 move |_, _, cx| {
418 join_state.update(cx, |state, cx| {
419 state.join_calendar_meeting(Some(&join_url), &subject, cx)
420 })
421 },
422 ));
423 }
424 if let Some(thread_id) = event.thread_id.clone() {
425 let chat_state = state.clone();
426 menu = menu.item(
427 PopupMenuItem::new("Chat with participants")
428 .icon(IconName::MessageSquare)
429 .on_click(move |_, _, cx| {
430 chat_state.update(cx, |state, cx| {
431 state.open_meeting_chat(Some(&thread_id), cx)
432 })
433 }),
434 );
435 }
436 if event.response == ResponseType::Organizer || event.organizer_name.is_none() {
437 return menu;
438 }
439 rsvp_menu(
440 menu.separator(),
441 state,
442 &event.object_id,
443 event.response,
444 send_response,
445 )
446}
447
390fn event_fill(response: ResponseType) -> Hsla {
448fn event_fill(response: ResponseType) -> Hsla {
391 match response {
449 match response {
392 ResponseType::NotResponded => theme::surface_raised(),
450 ResponseType::NotResponded => theme::surface_raised(),
@@ -414,6 +472,7 @@ impl Render for CalendarView {
414 let state = self.state.read(cx);
472 let state = self.state.read(cx);
415 let start = state.calendar_start();
473 let start = state.calendar_start();
416 let events = state.calendar_week.events.clone();
474 let events = state.calendar_week.events.clone();
475 let send_response = state.rsvp_send_response;
417 let offset = Local::now().offset().fix();
476 let offset = Local::now().offset().fix();
418 let days = week_days(&events, start, WORK_WEEK_DAYS, offset);
477 let days = week_days(&events, start, WORK_WEEK_DAYS, offset);
419 let today = Local::now().date_naive();
478 let today = Local::now().date_naive();
@@ -430,6 +489,6 @@ impl Render for CalendarView {
430 .child(self.header(start, compact))
489 .child(self.header(start, compact))
431 .child(self.day_headers(&days, today))
490 .child(self.day_headers(&days, today))
432 .children(self.all_day_row(&days, &events))
491 .children(self.all_day_row(&days, &events))
433 .child(self.grid(&days, &events, today, now))
492 .child(self.grid(&days, &events, today, now, send_response))
434 }
493 }
435}
494}
crates/app/src/views/calls_tab.rs +41 −32
@@ -4,7 +4,7 @@ use gpui_kit::component::scroll::ScrollableElement as _;
4 4 use gpui_kit::assets::IconName;
5 5 use gpui_kit::component::Sizable as _;
6 6 use gpui_kit::component::button::{Button, ButtonVariants as _};
7 use gpui_kit::component::menu::{ContextMenuExt as _, DropdownMenu as _, PopupMenuItem};
7 use gpui_kit::component::menu::{ContextMenuExt as _, DropdownMenu as _, PopupMenu, PopupMenuItem};
8 8 use gpui_kit::component::{h_flex, v_flex};
9 9 use gpui_kit::prelude::FluentBuilder as _;
10 10 use gpui_kit::*;
@@ -303,6 +303,45 @@ fn rsvp_menu_item(
303 303 })
304 304 }
305 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
306 345 fn rsvp_control(state: &Entity<AppState>, row: &AgendaRow, send_response: bool) -> AnyElement {
307 346 let menu_state = state.clone();
308 347 let key = row.key.clone();
@@ -321,37 +360,7 @@ fn rsvp_control(state: &Entity<AppState>, row: &AgendaRow, send_response: bool)
321 360 .label(response_label(response))
322 361 .icon(IconName::ChevronDown)
323 362 .dropdown_menu(move |menu, _, _| {
324 let toggle_state = menu_state.clone();
325 menu.item(rsvp_menu_item(
326 &menu_state,
327 &key,
328 "Accept",
329 Reply::Accept,
330 response == ResponseType::Accepted,
331 ))
332 .item(rsvp_menu_item(
333 &menu_state,
334 &key,
335 "Tentative",
336 Reply::Tentative,
337 response == ResponseType::Tentative,
338 ))
339 .item(rsvp_menu_item(
340 &menu_state,
341 &key,
342 "Decline",
343 Reply::Decline,
344 response == ResponseType::Declined,
345 ))
346 .separator()
347 .item(
348 PopupMenuItem::new("Send a response")
349 .checked(send_response)
350 .on_click(move |_, _, cx| {
351 toggle_state
352 .update(cx, |state, cx| state.toggle_rsvp_send_response(cx));
353 }),
354 )
363 rsvp_menu(menu, &menu_state, &key, response, send_response)
355 364 }),
356 365 )
357 366 .into_any_element()
@@ -4,7 +4,7 @@ use gpui_kit::component::scroll::ScrollableElement as _;
4use gpui_kit::assets::IconName;
4use gpui_kit::assets::IconName;
5use gpui_kit::component::Sizable as _;
5use gpui_kit::component::Sizable as _;
6use gpui_kit::component::button::{Button, ButtonVariants as _};
6use gpui_kit::component::button::{Button, ButtonVariants as _};
7use gpui_kit::component::menu::{ContextMenuExt as _, DropdownMenu as _, PopupMenuItem};
7use gpui_kit::component::menu::{ContextMenuExt as _, DropdownMenu as _, PopupMenu, PopupMenuItem};
8use gpui_kit::component::{h_flex, v_flex};
8use 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::*;
@@ -303,6 +303,45 @@ fn rsvp_menu_item(
303 })
303 })
304}
304}
305
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
306fn rsvp_control(state: &Entity<AppState>, row: &AgendaRow, send_response: bool) -> AnyElement {
345fn rsvp_control(state: &Entity<AppState>, row: &AgendaRow, send_response: bool) -> AnyElement {
307 let menu_state = state.clone();
346 let menu_state = state.clone();
308 let key = row.key.clone();
347 let key = row.key.clone();
@@ -321,37 +360,7 @@ fn rsvp_control(state: &Entity<AppState>, row: &AgendaRow, send_response: bool)
321 .label(response_label(response))
360 .label(response_label(response))
322 .icon(IconName::ChevronDown)
361 .icon(IconName::ChevronDown)
323 .dropdown_menu(move |menu, _, _| {
362 .dropdown_menu(move |menu, _, _| {
324 let toggle_state = menu_state.clone();
363 rsvp_menu(menu, &menu_state, &key, response, send_response)
325 menu.item(rsvp_menu_item(
326 &menu_state,
327 &key,
328 "Accept",
329 Reply::Accept,
330 response == ResponseType::Accepted,
331 ))
332 .item(rsvp_menu_item(
333 &menu_state,
334 &key,
335 "Tentative",
336 Reply::Tentative,
337 response == ResponseType::Tentative,
338 ))
339 .item(rsvp_menu_item(
340 &menu_state,
341 &key,
342 "Decline",
343 Reply::Decline,
344 response == ResponseType::Declined,
345 ))
346 .separator()
347 .item(
348 PopupMenuItem::new("Send a response")
349 .checked(send_response)
350 .on_click(move |_, _, cx| {
351 toggle_state
352 .update(cx, |state, cx| state.toggle_rsvp_send_response(cx));
353 }),
354 )
355 }),
364 }),
356 )
365 )
357 .into_any_element()
366 .into_any_element()