feat(calendar): Copy join info with phone dial-in
- Calendar view reads onlineMeetingTollNumber and onlineMeetingConferenceId (filled for 25 of 53 live meetings) - Meeting menu: Copy join info puts link, dial-in number and conference ID on the clipboard - dial_in_probe example lists the event fields without content Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -168,6 +168,7 @@ pub fn demo_events(now: DateTime<Utc>) -> Vec<CalendarEvent> {
168
168
organizer_address: None,
169
169
ical_uid: None,
170
170
show_as: Default::default(),
171
dial_in: None,
171
172
response,
172
173
};
173
174
vec![
@@ -244,6 +245,7 @@ mod tests {
244
245
organizer_address: None,
245
246
ical_uid: None,
246
247
show_as: Default::default(),
248
dial_in: None,
247
249
response: ResponseType::Accepted,
248
250
}
249
251
}
@@ -168,6 +168,7 @@ pub fn demo_events(now: DateTime<Utc>) -> Vec<CalendarEvent> {168
organizer_address: None,168
organizer_address: None,169
ical_uid: None,169
ical_uid: None,170
show_as: Default::default(),170
show_as: Default::default(),171
dial_in: None,171
response,172
response,172
};173
};173
vec![174
vec![@@ -244,6 +245,7 @@ mod tests {244
organizer_address: None,245
organizer_address: None,245
ical_uid: None,246
ical_uid: None,246
show_as: Default::default(),247
show_as: Default::default(),248
dial_in: None,247
response: ResponseType::Accepted,249
response: ResponseType::Accepted,248
}250
}249
}251
}@@ -272,6 +272,7 @@ mod tests {
272
272
organizer_address: None,
273
273
ical_uid: None,
274
274
show_as: Default::default(),
275
dial_in: None,
275
276
response: ResponseType::Accepted,
276
277
}
277
278
}
@@ -272,6 +272,7 @@ mod tests {272
organizer_address: None,272
organizer_address: None,273
ical_uid: None,273
ical_uid: None,274
show_as: Default::default(),274
show_as: Default::default(),275
dial_in: None,275
response: ResponseType::Accepted,276
response: ResponseType::Accepted,276
}277
}277
}278
}@@ -190,6 +190,7 @@ mod tests {
190
190
organizer_address: None,
191
191
ical_uid: None,
192
192
show_as: Default::default(),
193
dial_in: None,
193
194
response: ResponseType::Accepted,
194
195
}
195
196
}
@@ -190,6 +190,7 @@ mod tests {190
organizer_address: None,190
organizer_address: None,191
ical_uid: None,191
ical_uid: None,192
show_as: Default::default(),192
show_as: Default::default(),193
dial_in: None,193
response: ResponseType::Accepted,194
response: ResponseType::Accepted,194
}195
}195
}196
}@@ -344,6 +344,7 @@ mod tests {
344
344
organizer_address: None,
345
345
ical_uid: None,
346
346
show_as: Default::default(),
347
dial_in: None,
347
348
response: ResponseType::Accepted,
348
349
}
349
350
}
@@ -344,6 +344,7 @@ mod tests {344
organizer_address: None,344
organizer_address: None,345
ical_uid: None,345
ical_uid: None,346
show_as: Default::default(),346
show_as: Default::default(),347
dial_in: None,347
response: ResponseType::Accepted,348
response: ResponseType::Accepted,348
}349
}349
}350
}@@ -127,6 +127,7 @@ fn demo_event(draft: &MeetingDraft, serial: u64) -> CalendarEvent {
127
127
organizer_address: None,
128
128
ical_uid: None,
129
129
show_as: Default::default(),
130
dial_in: None,
130
131
response: ResponseType::Organizer,
131
132
}
132
133
}
@@ -127,6 +127,7 @@ fn demo_event(draft: &MeetingDraft, serial: u64) -> CalendarEvent {127
organizer_address: None,127
organizer_address: None,128
ical_uid: None,128
ical_uid: None,129
show_as: Default::default(),129
show_as: Default::default(),130
dial_in: None,130
response: ResponseType::Organizer,131
response: ResponseType::Organizer,131
}132
}132
}133
}@@ -199,6 +199,7 @@ fn demo_week(monday: NaiveDate, offset: FixedOffset) -> Vec<CalendarEvent> {
199
199
organizer_address: None,
200
200
ical_uid: None,
201
201
show_as: demo_show_as(subject, *response),
202
dial_in: None,
202
203
response: *response,
203
204
}
204
205
})
@@ -199,6 +199,7 @@ fn demo_week(monday: NaiveDate, offset: FixedOffset) -> Vec<CalendarEvent> {199
organizer_address: None,199
organizer_address: None,200
ical_uid: None,200
ical_uid: None,201
show_as: demo_show_as(subject, *response),201
show_as: demo_show_as(subject, *response),202
dial_in: None,202
response: *response,203
response: *response,203
}204
}204
})205
})@@ -1,5 +1,5 @@
1
1
use app_base::format::clock_format;
2
use chatsvc::{CalendarEvent, ResponseType};
2
use chatsvc::{CalendarEvent, ResponseType, join_info_text};
3
3
use chrono::{DateTime, Local, NaiveDate, Offset, Timelike, Utc};
4
4
use gpui_kit::assets::IconName;
5
5
use gpui_kit::component::Sizable as _;
@@ -31,6 +31,7 @@ const ALL_DAY_HEIGHT: f32 = 26.;
31
31
const BLOCK_GAP: f32 = 2.;
32
32
const FIRST_VISIBLE_HOUR: f32 = 8.;
33
33
const CANCELED_PREFIX: &str = "Canceled: ";
34
const COPY_JOIN_INFO: &str = "Copy join info";
34
35
const COMPACT_HEADER_WIDTH: f32 = 960.;
35
36
const BUSY_FILL_OPACITY: f32 = 0.28;
36
37
const FREE_FILL_OPACITY: f32 = 0.12;
@@ -504,6 +505,16 @@ fn event_menu(
504
505
},
505
506
));
506
507
}
508
if let Some(join_url) = event.join_url.as_deref().filter(|_| event.online) {
509
let info = join_info_text(join_url, event.dial_in.as_ref());
510
menu = menu.item(
511
PopupMenuItem::new(COPY_JOIN_INFO)
512
.icon(IconName::Copy)
513
.on_click(move |_, _, cx| {
514
cx.write_to_clipboard(ClipboardItem::new_string(info.clone()))
515
}),
516
);
517
}
507
518
if let Some(thread_id) = event.thread_id.clone() {
508
519
let chat_state = state.clone();
509
520
menu = menu.item(
@@ -1,5 +1,5 @@1
use app_base::format::clock_format;1
use app_base::format::clock_format;2
use chatsvc::{CalendarEvent, ResponseType};2
use chatsvc::{CalendarEvent, ResponseType, join_info_text};3
use chrono::{DateTime, Local, NaiveDate, Offset, Timelike, Utc};3
use chrono::{DateTime, Local, NaiveDate, Offset, Timelike, Utc};4
use gpui_kit::assets::IconName;4
use gpui_kit::assets::IconName;5
use gpui_kit::component::Sizable as _;5
use gpui_kit::component::Sizable as _;@@ -31,6 +31,7 @@ const ALL_DAY_HEIGHT: f32 = 26.;31
const BLOCK_GAP: f32 = 2.;31
const BLOCK_GAP: f32 = 2.;32
const FIRST_VISIBLE_HOUR: f32 = 8.;32
const FIRST_VISIBLE_HOUR: f32 = 8.;33
const CANCELED_PREFIX: &str = "Canceled: ";33
const CANCELED_PREFIX: &str = "Canceled: ";34
const COPY_JOIN_INFO: &str = "Copy join info";34
const COMPACT_HEADER_WIDTH: f32 = 960.;35
const COMPACT_HEADER_WIDTH: f32 = 960.;35
const BUSY_FILL_OPACITY: f32 = 0.28;36
const BUSY_FILL_OPACITY: f32 = 0.28;36
const FREE_FILL_OPACITY: f32 = 0.12;37
const FREE_FILL_OPACITY: f32 = 0.12;@@ -504,6 +505,16 @@ fn event_menu(504
},505
},505
));506
));506
}507
}508
if let Some(join_url) = event.join_url.as_deref().filter(|_| event.online) {509
let info = join_info_text(join_url, event.dial_in.as_ref());510
menu = menu.item(511
PopupMenuItem::new(COPY_JOIN_INFO)512
.icon(IconName::Copy)513
.on_click(move |_, _, cx| {514
cx.write_to_clipboard(ClipboardItem::new_string(info.clone()))515
}),516
);517
}507
if let Some(thread_id) = event.thread_id.clone() {518
if let Some(thread_id) = event.thread_id.clone() {508
let chat_state = state.clone();519
let chat_state = state.clone();509
menu = menu.item(520
menu = menu.item(@@ -0,0 +1,84 @@
1
use std::collections::BTreeSet;
2
3
use chatsvc::Calendar;
4
use chrono::{Duration, Utc};
5
use serde_json::Value;
6
use session::{DEFAULT_ENDPOINT, Session};
7
8
const DIAL_IN_HINTS: [&str; 5] = ["tel:", "Conference ID", "Konferenz-ID", "tollNumber", "dialin"];
9
10
fn key_paths(value: &Value, prefix: &str, paths: &mut BTreeSet<String>) {
11
match value {
12
Value::Object(map) => {
13
for (key, child) in map {
14
let path = format!("{prefix}.{key}");
15
paths.insert(path.clone());
16
key_paths(child, &path, paths);
17
}
18
}
19
Value::Array(items) => {
20
for item in items.iter().take(1) {
21
key_paths(item, &format!("{prefix}[]"), paths);
22
}
23
}
24
_ => {}
25
}
26
}
27
28
#[tokio::main]
29
async fn main() {
30
let endpoint = std::env::var("CDP_ENDPOINT").unwrap_or_else(|_| DEFAULT_ENDPOINT.to_owned());
31
let session = Session::connect(&endpoint).await.expect("browser");
32
let start = Utc::now() - Duration::days(7);
33
let answer = Calendar::new(&session)
34
.view_response(start, start + Duration::days(21))
35
.await
36
.expect("calendar view");
37
println!("# calendar view: HTTP {}", answer.status);
38
let events: Vec<&Value> = match &answer.body {
39
Value::Array(items) => items.iter().collect(),
40
Value::Object(map) => map
41
.get("value")
42
.and_then(Value::as_array)
43
.map(|items| items.iter().collect())
44
.unwrap_or_default(),
45
_ => Vec::new(),
46
};
47
println!("# events: {}", events.len());
48
for field in ["onlineMeetingConferenceId", "onlineMeetingTollNumber"] {
49
let filled = events
50
.iter()
51
.filter(|event| {
52
event
53
.get(field)
54
.and_then(Value::as_str)
55
.is_some_and(|value| !value.is_empty())
56
})
57
.count();
58
println!("# {field} filled: {filled}");
59
}
60
let shape = events
61
.iter()
62
.find_map(|event| event.get("onlineMeetingTollNumber").and_then(Value::as_str))
63
.filter(|value| !value.is_empty())
64
.map(|value| value.chars().map(|character| if character.is_ascii_digit() { '9' } else { character }).collect::<String>());
65
println!("# toll number shape: {shape:?}");
66
let online = events.iter().find(|event| {
67
event.get("isOnlineMeeting").and_then(Value::as_bool) == Some(true)
68
|| event.get("skypeTeamsMeetingUrl").is_some()
69
});
70
let Some(event) = online else {
71
println!("# no online meeting in range");
72
return;
73
};
74
let mut paths = BTreeSet::new();
75
key_paths(event, "", &mut paths);
76
println!("# keys of one online meeting:");
77
for path in &paths {
78
println!("{path}");
79
}
80
let text = event.to_string();
81
for hint in DIAL_IN_HINTS {
82
println!("# contains {hint:?}: {}", text.contains(hint));
83
}
84
}
@@ -0,0 +1,84 @@1
use std::collections::BTreeSet;2
3
use chatsvc::Calendar;4
use chrono::{Duration, Utc};5
use serde_json::Value;6
use session::{DEFAULT_ENDPOINT, Session};7
8
const DIAL_IN_HINTS: [&str; 5] = ["tel:", "Conference ID", "Konferenz-ID", "tollNumber", "dialin"];9
10
fn key_paths(value: &Value, prefix: &str, paths: &mut BTreeSet<String>) {11
match value {12
Value::Object(map) => {13
for (key, child) in map {14
let path = format!("{prefix}.{key}");15
paths.insert(path.clone());16
key_paths(child, &path, paths);17
}18
}19
Value::Array(items) => {20
for item in items.iter().take(1) {21
key_paths(item, &format!("{prefix}[]"), paths);22
}23
}24
_ => {}25
}26
}27
28
#[tokio::main]29
async fn main() {30
let endpoint = std::env::var("CDP_ENDPOINT").unwrap_or_else(|_| DEFAULT_ENDPOINT.to_owned());31
let session = Session::connect(&endpoint).await.expect("browser");32
let start = Utc::now() - Duration::days(7);33
let answer = Calendar::new(&session)34
.view_response(start, start + Duration::days(21))35
.await36
.expect("calendar view");37
println!("# calendar view: HTTP {}", answer.status);38
let events: Vec<&Value> = match &answer.body {39
Value::Array(items) => items.iter().collect(),40
Value::Object(map) => map41
.get("value")42
.and_then(Value::as_array)43
.map(|items| items.iter().collect())44
.unwrap_or_default(),45
_ => Vec::new(),46
};47
println!("# events: {}", events.len());48
for field in ["onlineMeetingConferenceId", "onlineMeetingTollNumber"] {49
let filled = events50
.iter()51
.filter(|event| {52
event53
.get(field)54
.and_then(Value::as_str)55
.is_some_and(|value| !value.is_empty())56
})57
.count();58
println!("# {field} filled: {filled}");59
}60
let shape = events61
.iter()62
.find_map(|event| event.get("onlineMeetingTollNumber").and_then(Value::as_str))63
.filter(|value| !value.is_empty())64
.map(|value| value.chars().map(|character| if character.is_ascii_digit() { '9' } else { character }).collect::<String>());65
println!("# toll number shape: {shape:?}");66
let online = events.iter().find(|event| {67
event.get("isOnlineMeeting").and_then(Value::as_bool) == Some(true)68
|| event.get("skypeTeamsMeetingUrl").is_some()69
});70
let Some(event) = online else {71
println!("# no online meeting in range");72
return;73
};74
let mut paths = BTreeSet::new();75
key_paths(event, "", &mut paths);76
println!("# keys of one online meeting:");77
for path in &paths {78
println!("{path}");79
}80
let text = event.to_string();81
for hint in DIAL_IN_HINTS {82
println!("# contains {hint:?}: {}", text.contains(hint));83
}84
}@@ -52,6 +52,38 @@ pub struct CalendarEvent {
52
52
pub ical_uid: Option<String>,
53
53
pub response: ResponseType,
54
54
pub show_as: ShowAs,
55
pub dial_in: Option<DialIn>,
56
}
57
58
#[derive(Debug, Clone, PartialEq, Eq)]
59
pub struct DialIn {
60
pub toll_number: String,
61
pub conference_id: String,
62
}
63
64
const JOIN_INFO_TITLE: &str = "Microsoft Teams meeting";
65
66
/// The plain text Teams puts on the clipboard for "Copy join info".
67
pub fn join_info_text(join_url: &str, dial_in: Option<&DialIn>) -> String {
68
let mut lines = vec![JOIN_INFO_TITLE.to_owned(), format!("Join: {join_url}")];
69
if let Some(dial_in) = dial_in {
70
lines.push(String::new());
71
lines.push("Dial in by phone".to_owned());
72
lines.push(format!(
73
"{},,{}#",
74
dial_in.toll_number, dial_in.conference_id
75
));
76
lines.push(format!("Phone conference ID: {}#", dial_in.conference_id));
77
}
78
lines.join("\n")
79
}
80
81
fn dial_in(entry: &Value) -> Option<DialIn> {
82
Some(DialIn {
83
toll_number: text(entry, "onlineMeetingTollNumber").filter(|value| !value.is_empty())?,
84
conference_id: text(entry, "onlineMeetingConferenceId")
85
.filter(|value| !value.is_empty())?,
86
})
55
87
}
56
88
57
89
pub struct Calendar<T: CardTransport = SessionCardTransport> {
@@ -239,11 +271,30 @@ fn parse_event(entry: &Value) -> Option<CalendarEvent> {
239
271
ical_uid: text(entry, "iCalUid").or_else(|| text(entry, "iCalUId")),
240
272
response: response_type(entry),
241
273
show_as: show_as(entry),
274
dial_in: dial_in(entry),
242
275
})
243
276
}
244
277
245
278
#[cfg(test)]
246
279
mod tests {
280
#[test]
281
fn join_info_carries_the_phone_dial_in_like_teams() {
282
let entry = serde_json::json!({
283
"onlineMeetingTollNumber": "+49 30 123456",
284
"onlineMeetingConferenceId": "987654321",
285
});
286
let parsed = dial_in(&entry).expect("dial in");
287
assert_eq!(
288
join_info_text("https://teams.microsoft.com/l/meetup-join/x", Some(&parsed)),
289
"Microsoft Teams meeting\nJoin: https://teams.microsoft.com/l/meetup-join/x\n\nDial in by phone\n+49 30 123456,,987654321#\nPhone conference ID: 987654321#"
290
);
291
assert_eq!(dial_in(&serde_json::json!({"onlineMeetingTollNumber": ""})), None);
292
assert_eq!(
293
join_info_text("https://x", None),
294
"Microsoft Teams meeting\nJoin: https://x"
295
);
296
}
297
247
298
#[test]
248
299
fn meet_now_join_url_prefers_the_join_link() {
249
300
let body = serde_json::json!({"value": {
@@ -52,6 +52,38 @@ pub struct CalendarEvent {52
pub ical_uid: Option<String>,52
pub ical_uid: Option<String>,53
pub response: ResponseType,53
pub response: ResponseType,54
pub show_as: ShowAs,54
pub show_as: ShowAs,55
pub dial_in: Option<DialIn>,56
}57
58
#[derive(Debug, Clone, PartialEq, Eq)]59
pub struct DialIn {60
pub toll_number: String,61
pub conference_id: String,62
}63
64
const JOIN_INFO_TITLE: &str = "Microsoft Teams meeting";65
66
/// The plain text Teams puts on the clipboard for "Copy join info".67
pub fn join_info_text(join_url: &str, dial_in: Option<&DialIn>) -> String {68
let mut lines = vec![JOIN_INFO_TITLE.to_owned(), format!("Join: {join_url}")];69
if let Some(dial_in) = dial_in {70
lines.push(String::new());71
lines.push("Dial in by phone".to_owned());72
lines.push(format!(73
"{},,{}#",74
dial_in.toll_number, dial_in.conference_id75
));76
lines.push(format!("Phone conference ID: {}#", dial_in.conference_id));77
}78
lines.join("\n")79
}80
81
fn dial_in(entry: &Value) -> Option<DialIn> {82
Some(DialIn {83
toll_number: text(entry, "onlineMeetingTollNumber").filter(|value| !value.is_empty())?,84
conference_id: text(entry, "onlineMeetingConferenceId")85
.filter(|value| !value.is_empty())?,86
})55
}87
}56
88
57
pub struct Calendar<T: CardTransport = SessionCardTransport> {89
pub struct Calendar<T: CardTransport = SessionCardTransport> {@@ -239,11 +271,30 @@ fn parse_event(entry: &Value) -> Option<CalendarEvent> {239
ical_uid: text(entry, "iCalUid").or_else(|| text(entry, "iCalUId")),271
ical_uid: text(entry, "iCalUid").or_else(|| text(entry, "iCalUId")),240
response: response_type(entry),272
response: response_type(entry),241
show_as: show_as(entry),273
show_as: show_as(entry),274
dial_in: dial_in(entry),242
})275
})243
}276
}244
277
245
#[cfg(test)]278
#[cfg(test)]246
mod tests {279
mod tests {280
#[test]281
fn join_info_carries_the_phone_dial_in_like_teams() {282
let entry = serde_json::json!({283
"onlineMeetingTollNumber": "+49 30 123456",284
"onlineMeetingConferenceId": "987654321",285
});286
let parsed = dial_in(&entry).expect("dial in");287
assert_eq!(288
join_info_text("https://teams.microsoft.com/l/meetup-join/x", Some(&parsed)),289
"Microsoft Teams meeting\nJoin: https://teams.microsoft.com/l/meetup-join/x\n\nDial in by phone\n+49 30 123456,,987654321#\nPhone conference ID: 987654321#"290
);291
assert_eq!(dial_in(&serde_json::json!({"onlineMeetingTollNumber": ""})), None);292
assert_eq!(293
join_info_text("https://x", None),294
"Microsoft Teams meeting\nJoin: https://x"295
);296
}297
247
#[test]298
#[test]248
fn meet_now_join_url_prefers_the_join_link() {299
fn meet_now_join_url_prefers_the_join_link() {249
let body = serde_json::json!({"value": {300
let body = serde_json::json!({"value": {@@ -48,7 +48,7 @@ pub use activity_feed::{
48
48
pub use activity_mentions::{MentionActivity, MentionKind, mentions_of};
49
49
pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};
50
50
pub use calendar::{
51
Attendee, Calendar, CalendarEvent, CreatedEvent, NewEvent, Reminder, Repeat, Reply,
51
Attendee, Calendar, CalendarEvent, CreatedEvent, DialIn, join_info_text, NewEvent, Reminder, Repeat, Reply,
52
52
ResponseType, ShowAs, meet_now_join_url, new_event_body, parse_calendar_events, parse_created_event,
53
53
};
54
54
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};
@@ -48,7 +48,7 @@ pub use activity_feed::{48
pub use activity_mentions::{MentionActivity, MentionKind, mentions_of};48
pub use activity_mentions::{MentionActivity, MentionKind, mentions_of};49
pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};49
pub use bot_profiles::{BotProfile, BotProfiles, parse_bot_profiles};50
pub use calendar::{50
pub use calendar::{51
Attendee, Calendar, CalendarEvent, CreatedEvent, NewEvent, Reminder, Repeat, Reply,51
Attendee, Calendar, CalendarEvent, CreatedEvent, DialIn, join_info_text, NewEvent, Reminder, Repeat, Reply,52
ResponseType, ShowAs, meet_now_join_url, new_event_body, parse_calendar_events, parse_created_event,52
ResponseType, ShowAs, meet_now_join_url, new_event_body, parse_calendar_events, parse_created_event,53
};53
};54
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};54
pub use calllog::{CallDirection, CallLogEntry, CallOutcome};