feat(meetings): recap tab with recording, transcript, attendance and files
- Recap tab next to Chat in meeting chats with a finished recording - Occurrence picker, recording card, Play, Download (save dialog, progress), organizer Delete - Searchable read-only transcript with .vtt and .docx download - Attendance via Graph, muted note when reports are off - Files shared in the chat reuse the Shared tab rows - Demo data for "Daily standup", layout guard test for the new region Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -173,6 +173,7 @@ Feature parity with the Microsoft Teams desktop client.
173
173
| Backgrounds | Partial | Camera menu Background: None / Blur / Microsoft's default images / "Add image..." (remembered). The image list and thumbnails are fetched at runtime into the app data folder, nothing of Microsoft's ships with the app; the picture is cover-scaled behind the same segmentation mask (checked with a synthetic mask, demo with generated pictures, the CDN download only through `meet_now --background`). On-device MediaPipe selfie segmentation through tract (Apache-2.0 model, 11 ms per 640x360 frame in a release build), edge feathering, self view shows the result. Checked with a still photo and synthetic frames; not yet on a real camera |
174
174
| Video calls (1:1 and incoming) | Partial | Camera button in 1:1 calls renegotiates a video line on the same peer connection (modalities Audio and Video), incoming video ring toast with Decline / Audio / Video, accept with video answers the video line sending, accept with audio receive-only. Offer and answer built from the Teams code and unit tested at SDP level; needs a second person |
175
175
| Recording | Partial | Organizer "..." > Start recording / Stop recording (confirm) through the recorder bot, red dot and "Recording" in the header for everyone from the meeting state, consent notice that keeps mic and camera off until OK. Bodies unit tested; start and stop run live through `meet_now --record`, consent needs a tenant with the policy on and a second person |
176
| Meeting recap tab | Partial Recap in meeting chats with a recording: occurrence picker, recording card (duration, Audio only, expiry amber under 7 days), Play in the browser, Download with save dialog and percent, organizer Delete with confirm, searchable read-only transcript with .vtt and .docx download, attendance (muted note when the tenant has reports off), files shared in the chat. Parsing and expiry unit tested, demo checked; the Graph and SharePoint calls are not yet run against a real recording |
176
177
| Hold, resume, transfer | Partial | 1:1 "..." > Hold renegotiates every line inactive, "On hold" view with Resume, "You're on hold" when the other side holds, Transfer... person picker with Transfer now (blind) and Consult first (second call, first held, Transfer now). Needs a second person; redirect and park not built |
177
178
| Breakout rooms (participant) | Partial | Move message from the participant update or the replacement invite: notice "Moving you to <room>", leave and join the room, "Return to main meeting" in the header, a closed room goes back to the main meeting. Parsing unit tested; needs an organizer who moves people |
178
179
| Whiteboard | Partial | Stage shows "<name> is sharing a whiteboard" with Open in browser, "..." > Whiteboard opens the meeting's board. State parsing unit tested; the share callback link is registered on join but not yet seen live |
@@ -173,6 +173,7 @@ Feature parity with the Microsoft Teams desktop client.173
| Backgrounds | Partial | Camera menu Background: None / Blur / Microsoft's default images / "Add image..." (remembered). The image list and thumbnails are fetched at runtime into the app data folder, nothing of Microsoft's ships with the app; the picture is cover-scaled behind the same segmentation mask (checked with a synthetic mask, demo with generated pictures, the CDN download only through `meet_now --background`). On-device MediaPipe selfie segmentation through tract (Apache-2.0 model, 11 ms per 640x360 frame in a release build), edge feathering, self view shows the result. Checked with a still photo and synthetic frames; not yet on a real camera |173
| Backgrounds | Partial | Camera menu Background: None / Blur / Microsoft's default images / "Add image..." (remembered). The image list and thumbnails are fetched at runtime into the app data folder, nothing of Microsoft's ships with the app; the picture is cover-scaled behind the same segmentation mask (checked with a synthetic mask, demo with generated pictures, the CDN download only through `meet_now --background`). On-device MediaPipe selfie segmentation through tract (Apache-2.0 model, 11 ms per 640x360 frame in a release build), edge feathering, self view shows the result. Checked with a still photo and synthetic frames; not yet on a real camera |174
| Video calls (1:1 and incoming) | Partial | Camera button in 1:1 calls renegotiates a video line on the same peer connection (modalities Audio and Video), incoming video ring toast with Decline / Audio / Video, accept with video answers the video line sending, accept with audio receive-only. Offer and answer built from the Teams code and unit tested at SDP level; needs a second person |174
| Video calls (1:1 and incoming) | Partial | Camera button in 1:1 calls renegotiates a video line on the same peer connection (modalities Audio and Video), incoming video ring toast with Decline / Audio / Video, accept with video answers the video line sending, accept with audio receive-only. Offer and answer built from the Teams code and unit tested at SDP level; needs a second person |175
| Recording | Partial | Organizer "..." > Start recording / Stop recording (confirm) through the recorder bot, red dot and "Recording" in the header for everyone from the meeting state, consent notice that keeps mic and camera off until OK. Bodies unit tested; start and stop run live through `meet_now --record`, consent needs a tenant with the policy on and a second person |175
| Recording | Partial | Organizer "..." > Start recording / Stop recording (confirm) through the recorder bot, red dot and "Recording" in the header for everyone from the meeting state, consent notice that keeps mic and camera off until OK. Bodies unit tested; start and stop run live through `meet_now --record`, consent needs a tenant with the policy on and a second person |176
| Meeting recap tab | Partial Recap in meeting chats with a recording: occurrence picker, recording card (duration, Audio only, expiry amber under 7 days), Play in the browser, Download with save dialog and percent, organizer Delete with confirm, searchable read-only transcript with .vtt and .docx download, attendance (muted note when the tenant has reports off), files shared in the chat. Parsing and expiry unit tested, demo checked; the Graph and SharePoint calls are not yet run against a real recording |176
| Hold, resume, transfer | Partial | 1:1 "..." > Hold renegotiates every line inactive, "On hold" view with Resume, "You're on hold" when the other side holds, Transfer... person picker with Transfer now (blind) and Consult first (second call, first held, Transfer now). Needs a second person; redirect and park not built |177
| Hold, resume, transfer | Partial | 1:1 "..." > Hold renegotiates every line inactive, "On hold" view with Resume, "You're on hold" when the other side holds, Transfer... person picker with Transfer now (blind) and Consult first (second call, first held, Transfer now). Needs a second person; redirect and park not built |177
| Breakout rooms (participant) | Partial | Move message from the participant update or the replacement invite: notice "Moving you to <room>", leave and join the room, "Return to main meeting" in the header, a closed room goes back to the main meeting. Parsing unit tested; needs an organizer who moves people |178
| Breakout rooms (participant) | Partial | Move message from the participant update or the replacement invite: notice "Moving you to <room>", leave and join the room, "Return to main meeting" in the header, a closed room goes back to the main meeting. Parsing unit tested; needs an organizer who moves people |178
| Whiteboard | Partial | Stage shows "<name> is sharing a whiteboard" with Open in browser, "..." > Whiteboard opens the meeting's board. State parsing unit tested; the share callback link is registered on join but not yet seen live |179
| Whiteboard | Partial | Stage shows "<name> is sharing a whiteboard" with Open in browser, "..." > Whiteboard opens the meeting's board. State parsing unit tested; the share callback link is registered on join but not yet seen live |@@ -782,6 +782,7 @@ pub fn seed(store: &Store) {
782
782
let _ = store.upsert_messages(&channel_messages());
783
783
let _ = store.upsert_messages(&priority_messages());
784
784
let _ = store.upsert_messages(&meeting_link_messages());
785
let _ = store.upsert_messages(&standup_messages());
785
786
let _ = store.upsert_messages(&bot_messages());
786
787
seed_agent_access(store);
787
788
}
@@ -1241,6 +1242,36 @@ fn meeting_link_messages() -> Vec<MessageRecord> {
1241
1242
)]
1242
1243
}
1243
1244
1245
fn standup_messages() -> Vec<MessageRecord> {
1246
let jonas = (JONAS_ID, "Jonas Ortega");
1247
let priya = (PRIYA_ID, "Priya Nair");
1248
vec![
1249
with_attachments(
1250
message(
1251
"demo-chat-meeting-standup",
1252
"su1",
1253
None,
1254
priya,
1255
at(0, 9, 30),
1256
"<p>Notes from today.</p>",
1257
"[]",
1258
false,
1259
),
1260
r#"[{"content_type":"reference","name":"Standup-notes.docx","url":"https://example.com/files/standup-notes.docx","text":null,"size":38900}]"#,
1261
),
1262
message(
1263
"demo-chat-meeting-standup",
1264
"su2",
1265
None,
1266
jonas,
1267
at(0, 9, 45),
1268
"<p>Recording is available</p>",
1269
"[]",
1270
false,
1271
),
1272
]
1273
}
1274
1244
1275
fn priority_messages() -> Vec<MessageRecord> {
1245
1276
let priya = (PRIYA_ID, "Priya Nair");
1246
1277
let me = (DEMO_USER_ID, DEMO_USER_NAME);
@@ -782,6 +782,7 @@ pub fn seed(store: &Store) {782
let _ = store.upsert_messages(&channel_messages());782
let _ = store.upsert_messages(&channel_messages());783
let _ = store.upsert_messages(&priority_messages());783
let _ = store.upsert_messages(&priority_messages());784
let _ = store.upsert_messages(&meeting_link_messages());784
let _ = store.upsert_messages(&meeting_link_messages());785
let _ = store.upsert_messages(&standup_messages());785
let _ = store.upsert_messages(&bot_messages());786
let _ = store.upsert_messages(&bot_messages());786
seed_agent_access(store);787
seed_agent_access(store);787
}788
}@@ -1241,6 +1242,36 @@ fn meeting_link_messages() -> Vec<MessageRecord> {1241
)]1242
)]1242
}1243
}1243
1244
1245
fn standup_messages() -> Vec<MessageRecord> {1246
let jonas = (JONAS_ID, "Jonas Ortega");1247
let priya = (PRIYA_ID, "Priya Nair");1248
vec![1249
with_attachments(1250
message(1251
"demo-chat-meeting-standup",1252
"su1",1253
None,1254
priya,1255
at(0, 9, 30),1256
"<p>Notes from today.</p>",1257
"[]",1258
false,1259
),1260
r#"[{"content_type":"reference","name":"Standup-notes.docx","url":"https://example.com/files/standup-notes.docx","text":null,"size":38900}]"#,1261
),1262
message(1263
"demo-chat-meeting-standup",1264
"su2",1265
None,1266
jonas,1267
at(0, 9, 45),1268
"<p>Recording is available</p>",1269
"[]",1270
false,1271
),1272
]1273
}1274
1244
fn priority_messages() -> Vec<MessageRecord> {1275
fn priority_messages() -> Vec<MessageRecord> {1245
let priya = (PRIYA_ID, "Priya Nair");1276
let priya = (PRIYA_ID, "Priya Nair");1246
let me = (DEMO_USER_ID, DEMO_USER_NAME);1277
let me = (DEMO_USER_ID, DEMO_USER_NAME);@@ -0,0 +1,85 @@
1
use chatsvc::{Attendance, AttendanceRecord, Occurrence, RecordingDetails, TranscriptTurn};
2
use chrono::{DateTime, Duration, Utc};
3
4
pub const DEMO_RECAP_CHAT: &str = "demo-chat-meeting-standup";
5
const ORGANIZER_ID: &str = "demo-me";
6
const OCCURRENCE_DAYS: [i64; 3] = [0, 1, 2];
7
const DEMO_RECORDING_URL: &str = "https://demo.sharepoint.example/personal/demo/Recordings/standup";
8
const SHORT_EXPIRY_DAYS: i64 = 5;
9
const LONG_EXPIRY_DAYS: i64 = 58;
10
11
const LINES: [(&str, f64, &str); 7] = [
12
("Jonas Ortega", 4.0, "Morning everyone. Quick round, then we are done in ten."),
13
("Priya Nair", 21.0, "Yesterday I finished the export flow. Today I pick up the retry logic."),
14
("Mara Lindqvist", 49.0, "I am blocked on the staging certificate. Can someone ping IT?"),
15
("Jonas Ortega", 63.0, "I will ping them right after this. Anything else on the release?"),
16
("Tobias Klein", 88.0, "The release notes are drafted, I need a second pair of eyes."),
17
("Priya Nair", 104.0, "I can review them before lunch."),
18
("Jonas Ortega", 121.0, "Great. Thanks all, see you tomorrow."),
19
];
20
21
pub fn occurrences(conversation_id: &str, now: DateTime<Utc>) -> Vec<Occurrence> {
22
if conversation_id != DEMO_RECAP_CHAT {
23
return Vec::new();
24
}
25
OCCURRENCE_DAYS
26
.into_iter()
27
.map(|days_ago| Occurrence {
28
message_id: format!("demo-recap-{days_ago}"),
29
started_at: Some(now - Duration::days(days_ago) - Duration::hours(1)),
30
recording_url: format!("{DEMO_RECORDING_URL}-{days_ago}.mp4"),
31
recording_name: Some(format!(
32
"Daily standup-{days_ago}-Meeting Recording.mp4"
33
)),
34
duration_seconds: Some(920 + days_ago as u64 * 65),
35
organizer_id: Some(ORGANIZER_ID.to_owned()),
36
})
37
.collect()
38
}
39
40
pub fn details(occurrence: &Occurrence, now: DateTime<Utc>) -> RecordingDetails {
41
let latest = occurrence.message_id.ends_with('0');
42
RecordingDetails {
43
item_url: occurrence.recording_url.clone(),
44
audio_only: occurrence.message_id.ends_with('2'),
45
duration_seconds: occurrence.duration_seconds,
46
expires_at: Some(
47
now + Duration::days(if latest {
48
LONG_EXPIRY_DAYS
49
} else {
50
SHORT_EXPIRY_DAYS
51
}) - Duration::minutes(1),
52
),
53
transcript_id: Some("demo-transcript".to_owned()),
54
}
55
}
56
57
pub fn transcript() -> Vec<TranscriptTurn> {
58
LINES
59
.iter()
60
.map(|(speaker, start_seconds, text)| TranscriptTurn {
61
speaker: (*speaker).to_owned(),
62
start_seconds: *start_seconds,
63
end_seconds: start_seconds + 12.0,
64
text: (*text).to_owned(),
65
})
66
.collect()
67
}
68
69
pub fn attendance(now: DateTime<Utc>) -> Attendance {
70
let start = now - Duration::hours(1);
71
let record = |name: &str, joined: i64, left: i64| AttendanceRecord {
72
name: name.to_owned(),
73
joined_at: Some(start + Duration::minutes(joined)),
74
left_at: Some(start + Duration::minutes(left)),
75
duration_seconds: ((left - joined) * 60) as u64,
76
};
77
Attendance::Report(vec![
78
record("Jonas Ortega", 0, 16),
79
record("Priya Nair", 1, 16),
80
record("Mara Lindqvist", 2, 15),
81
record("Tobias Klein", 5, 12),
82
])
83
}
84
85
pub const DEMO_FILE_BYTES: &[u8] = b"Rusty Teams demo file\n";
@@ -0,0 +1,85 @@1
use chatsvc::{Attendance, AttendanceRecord, Occurrence, RecordingDetails, TranscriptTurn};2
use chrono::{DateTime, Duration, Utc};3
4
pub const DEMO_RECAP_CHAT: &str = "demo-chat-meeting-standup";5
const ORGANIZER_ID: &str = "demo-me";6
const OCCURRENCE_DAYS: [i64; 3] = [0, 1, 2];7
const DEMO_RECORDING_URL: &str = "https://demo.sharepoint.example/personal/demo/Recordings/standup";8
const SHORT_EXPIRY_DAYS: i64 = 5;9
const LONG_EXPIRY_DAYS: i64 = 58;10
11
const LINES: [(&str, f64, &str); 7] = [12
("Jonas Ortega", 4.0, "Morning everyone. Quick round, then we are done in ten."),13
("Priya Nair", 21.0, "Yesterday I finished the export flow. Today I pick up the retry logic."),14
("Mara Lindqvist", 49.0, "I am blocked on the staging certificate. Can someone ping IT?"),15
("Jonas Ortega", 63.0, "I will ping them right after this. Anything else on the release?"),16
("Tobias Klein", 88.0, "The release notes are drafted, I need a second pair of eyes."),17
("Priya Nair", 104.0, "I can review them before lunch."),18
("Jonas Ortega", 121.0, "Great. Thanks all, see you tomorrow."),19
];20
21
pub fn occurrences(conversation_id: &str, now: DateTime<Utc>) -> Vec<Occurrence> {22
if conversation_id != DEMO_RECAP_CHAT {23
return Vec::new();24
}25
OCCURRENCE_DAYS26
.into_iter()27
.map(|days_ago| Occurrence {28
message_id: format!("demo-recap-{days_ago}"),29
started_at: Some(now - Duration::days(days_ago) - Duration::hours(1)),30
recording_url: format!("{DEMO_RECORDING_URL}-{days_ago}.mp4"),31
recording_name: Some(format!(32
"Daily standup-{days_ago}-Meeting Recording.mp4"33
)),34
duration_seconds: Some(920 + days_ago as u64 * 65),35
organizer_id: Some(ORGANIZER_ID.to_owned()),36
})37
.collect()38
}39
40
pub fn details(occurrence: &Occurrence, now: DateTime<Utc>) -> RecordingDetails {41
let latest = occurrence.message_id.ends_with('0');42
RecordingDetails {43
item_url: occurrence.recording_url.clone(),44
audio_only: occurrence.message_id.ends_with('2'),45
duration_seconds: occurrence.duration_seconds,46
expires_at: Some(47
now + Duration::days(if latest {48
LONG_EXPIRY_DAYS49
} else {50
SHORT_EXPIRY_DAYS51
}) - Duration::minutes(1),52
),53
transcript_id: Some("demo-transcript".to_owned()),54
}55
}56
57
pub fn transcript() -> Vec<TranscriptTurn> {58
LINES59
.iter()60
.map(|(speaker, start_seconds, text)| TranscriptTurn {61
speaker: (*speaker).to_owned(),62
start_seconds: *start_seconds,63
end_seconds: start_seconds + 12.0,64
text: (*text).to_owned(),65
})66
.collect()67
}68
69
pub fn attendance(now: DateTime<Utc>) -> Attendance {70
let start = now - Duration::hours(1);71
let record = |name: &str, joined: i64, left: i64| AttendanceRecord {72
name: name.to_owned(),73
joined_at: Some(start + Duration::minutes(joined)),74
left_at: Some(start + Duration::minutes(left)),75
duration_seconds: ((left - joined) * 60) as u64,76
};77
Attendance::Report(vec![78
record("Jonas Ortega", 0, 16),79
record("Priya Nair", 1, 16),80
record("Mara Lindqvist", 2, 15),81
record("Tobias Klein", 5, 12),82
])83
}84
85
pub const DEMO_FILE_BYTES: &[u8] = b"Rusty Teams demo file\n";@@ -120,9 +120,10 @@ mod frames {
120
120
};
121
121
use store::Store;
122
122
123
use crate::app_state::{AppState, Mode};
123
use crate::app_state::{AppState, Mode, Selection};
124
124
use crate::demo;
125
125
use crate::user_activity::UserInput;
126
use crate::views::recap_tab::RECAP_REGION;
126
127
use crate::views::shell::{AppShell, Startup, bind_keys, install_globals};
127
128
use crate::views::shortcuts::{OpenActivity, OpenCallsTab, OpenChannelsTab, OpenSaved};
128
129
@@ -140,6 +141,8 @@ mod frames {
140
141
];
141
142
const MENU: &str = "popup-menu";
142
143
const OWN_STATUS: &str = "shell/title-bar/own-status";
144
const RECAP_TAB: &str = "shell/islands/main/recap-tab";
145
const RECAP_MEETING_CHAT: &str = "demo-chat-meeting-standup";
143
146
const SIZES: [(f32, f32); 2] = [(640., 480.), (1920., 1080.)];
144
147
const TOLERANCE: f32 = 0.5;
145
148
const KNOWN_VIOLATIONS: &[&str] = &[];
@@ -263,12 +266,12 @@ mod frames {
263
266
}
264
267
GUARDED
265
268
.iter()
266
.chain([&MENU])
269
.chain([&MENU, &RECAP_TAB, &RECAP_REGION])
267
270
.filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))
268
271
.collect()
269
272
}
270
273
271
fn mount(cx: &mut TestAppContext) -> gpui_kit::AnyWindowHandle {
274
fn mount(cx: &mut TestAppContext) -> (gpui_kit::AnyWindowHandle, gpui_kit::Entity<AppState>) {
272
275
cx.update(gpui_kit::init);
273
276
cx.update(|cx| {
274
277
crate::theme::apply(cx);
@@ -288,11 +291,13 @@ mod frames {
288
291
composer_text: None,
289
292
reply_to_last: false,
290
293
};
291
gpui_kit::open_window(WindowOptions::default(), cx, move |window, cx| {
292
cx.new(|cx| AppShell::new(state, None, startup, window, cx))
294
let shell_state = state.clone();
295
let handle = gpui_kit::open_window(WindowOptions::default(), cx, move |window, cx| {
296
cx.new(|cx| AppShell::new(shell_state, None, startup, window, cx))
293
297
})
294
298
.expect("open test window")
295
.0
299
.0;
300
(handle, state)
296
301
})
297
302
}
298
303
@@ -329,7 +334,7 @@ mod frames {
329
334
330
335
#[gpui_kit::test]
331
336
fn no_element_overlaps_or_leaves_its_container(cx: &mut TestAppContext) {
332
let handle = mount(cx);
337
let (handle, _) = mount(cx);
333
338
let mut visual = VisualTestContext::from_window(handle, cx);
334
339
let mut seen_known = HashSet::new();
335
340
let mut unexpected = Vec::new();
@@ -427,4 +432,32 @@ mod frames {
427
432
.join("\n")
428
433
);
429
434
}
435
#[gpui_kit::test]
436
fn recap_tab_stays_inside_the_main_island(cx: &mut TestAppContext) {
437
let (handle, state) = mount(cx);
438
let mut visual = VisualTestContext::from_window(handle, cx);
439
for (width, height) in SIZES {
440
visual.simulate_resize(size(px(width), px(height)));
441
let window = Bounds {
442
origin: point(px(0.), px(0.)),
443
size: size(px(width), px(height)),
444
};
445
visual.update(|_, cx| {
446
state.update(cx, |state, cx| {
447
state.select(Selection::Chat(RECAP_MEETING_CHAT.to_owned()), cx)
448
})
449
});
450
collect(&mut visual, Some(RECAP_TAB));
451
let tab = visual.debug_bounds(RECAP_TAB).expect("recap tab rendered");
452
visual.simulate_click(tab.center(), Default::default());
453
let tags = collect(&mut visual, Some(RECAP_REGION));
454
let mut expected = GUARDED.to_vec();
455
expected.extend([RECAP_TAB, RECAP_REGION]);
456
let found: Vec<String> = violations(&tags, window, &expected)
457
.into_iter()
458
.map(|(key, message)| format!("recap@{width}x{height}:{key}: {message}"))
459
.collect();
460
assert!(found.is_empty(), "{}", found.join("\n"));
461
}
462
}
430
463
}
@@ -120,9 +120,10 @@ mod frames {120
};120
};121
use store::Store;121
use store::Store;122
122
123
use crate::app_state::{AppState, Mode};123
use crate::app_state::{AppState, Mode, Selection};124
use crate::demo;124
use crate::demo;125
use crate::user_activity::UserInput;125
use crate::user_activity::UserInput;126
use crate::views::recap_tab::RECAP_REGION;126
use crate::views::shell::{AppShell, Startup, bind_keys, install_globals};127
use crate::views::shell::{AppShell, Startup, bind_keys, install_globals};127
use crate::views::shortcuts::{OpenActivity, OpenCallsTab, OpenChannelsTab, OpenSaved};128
use crate::views::shortcuts::{OpenActivity, OpenCallsTab, OpenChannelsTab, OpenSaved};128
129
@@ -140,6 +141,8 @@ mod frames {140
];141
];141
const MENU: &str = "popup-menu";142
const MENU: &str = "popup-menu";142
const OWN_STATUS: &str = "shell/title-bar/own-status";143
const OWN_STATUS: &str = "shell/title-bar/own-status";144
const RECAP_TAB: &str = "shell/islands/main/recap-tab";145
const RECAP_MEETING_CHAT: &str = "demo-chat-meeting-standup";143
const SIZES: [(f32, f32); 2] = [(640., 480.), (1920., 1080.)];146
const SIZES: [(f32, f32); 2] = [(640., 480.), (1920., 1080.)];144
const TOLERANCE: f32 = 0.5;147
const TOLERANCE: f32 = 0.5;145
const KNOWN_VIOLATIONS: &[&str] = &[];148
const KNOWN_VIOLATIONS: &[&str] = &[];@@ -263,12 +266,12 @@ mod frames {263
}266
}264
GUARDED267
GUARDED265
.iter()268
.iter()266
.chain([&MENU])269
.chain([&MENU, &RECAP_TAB, &RECAP_REGION])267
.filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))270
.filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))268
.collect()271
.collect()269
}272
}270
273
271
fn mount(cx: &mut TestAppContext) -> gpui_kit::AnyWindowHandle {274
fn mount(cx: &mut TestAppContext) -> (gpui_kit::AnyWindowHandle, gpui_kit::Entity<AppState>) {272
cx.update(gpui_kit::init);275
cx.update(gpui_kit::init);273
cx.update(|cx| {276
cx.update(|cx| {274
crate::theme::apply(cx);277
crate::theme::apply(cx);@@ -288,11 +291,13 @@ mod frames {288
composer_text: None,291
composer_text: None,289
reply_to_last: false,292
reply_to_last: false,290
};293
};291
gpui_kit::open_window(WindowOptions::default(), cx, move |window, cx| {294
let shell_state = state.clone();292
cx.new(|cx| AppShell::new(state, None, startup, window, cx))295
let handle = gpui_kit::open_window(WindowOptions::default(), cx, move |window, cx| {296
cx.new(|cx| AppShell::new(shell_state, None, startup, window, cx))293
})297
})294
.expect("open test window")298
.expect("open test window")295
.0299
.0;300
(handle, state)296
})301
})297
}302
}298
303
@@ -329,7 +334,7 @@ mod frames {329
334
330
#[gpui_kit::test]335
#[gpui_kit::test]331
fn no_element_overlaps_or_leaves_its_container(cx: &mut TestAppContext) {336
fn no_element_overlaps_or_leaves_its_container(cx: &mut TestAppContext) {332
let handle = mount(cx);337
let (handle, _) = mount(cx);333
let mut visual = VisualTestContext::from_window(handle, cx);338
let mut visual = VisualTestContext::from_window(handle, cx);334
let mut seen_known = HashSet::new();339
let mut seen_known = HashSet::new();335
let mut unexpected = Vec::new();340
let mut unexpected = Vec::new();@@ -427,4 +432,32 @@ mod frames {427
.join("\n")432
.join("\n")428
);433
);429
}434
}435
#[gpui_kit::test]436
fn recap_tab_stays_inside_the_main_island(cx: &mut TestAppContext) {437
let (handle, state) = mount(cx);438
let mut visual = VisualTestContext::from_window(handle, cx);439
for (width, height) in SIZES {440
visual.simulate_resize(size(px(width), px(height)));441
let window = Bounds {442
origin: point(px(0.), px(0.)),443
size: size(px(width), px(height)),444
};445
visual.update(|_, cx| {446
state.update(cx, |state, cx| {447
state.select(Selection::Chat(RECAP_MEETING_CHAT.to_owned()), cx)448
})449
});450
collect(&mut visual, Some(RECAP_TAB));451
let tab = visual.debug_bounds(RECAP_TAB).expect("recap tab rendered");452
visual.simulate_click(tab.center(), Default::default());453
let tags = collect(&mut visual, Some(RECAP_REGION));454
let mut expected = GUARDED.to_vec();455
expected.extend([RECAP_TAB, RECAP_REGION]);456
let found: Vec<String> = violations(&tags, window, &expected)457
.into_iter()458
.map(|(key, message)| format!("recap@{width}x{height}:{key}: {message}"))459
.collect();460
assert!(found.is_empty(), "{}", found.join("\n"));461
}462
}430
}463
}@@ -26,6 +26,7 @@ mod demo_gifs;
26
26
mod demo_input_cards;
27
27
mod demo_library;
28
28
mod demo_profiles;
29
mod demo_recap;
29
30
mod diagnostics;
30
31
mod downloads;
31
32
mod emoji;
@@ -50,6 +51,7 @@ mod profile_model;
50
51
mod profile_state;
51
52
mod reaction_model;
52
53
mod read_state;
54
mod recap;
53
55
mod remote_image;
54
56
mod render;
55
57
mod rows;
@@ -26,6 +26,7 @@ mod demo_gifs;26
mod demo_input_cards;26
mod demo_input_cards;27
mod demo_library;27
mod demo_library;28
mod demo_profiles;28
mod demo_profiles;29
mod demo_recap;29
mod diagnostics;30
mod diagnostics;30
mod downloads;31
mod downloads;31
mod emoji;32
mod emoji;@@ -50,6 +51,7 @@ mod profile_model;50
mod profile_state;51
mod profile_state;51
mod reaction_model;52
mod reaction_model;52
mod read_state;53
mod read_state;54
mod recap;53
mod remote_image;55
mod remote_image;54
mod render;56
mod render;55
mod rows;57
mod rows;@@ -0,0 +1,239 @@
1
use chatsvc::{Occurrence, TranscriptTurn};
2
use chrono::{DateTime, FixedOffset, NaiveDate, Utc};
3
4
use crate::format;
5
6
pub const EMPTY_RECAP: &str = "No recording or transcript for this meeting.";
7
pub const NO_TRANSCRIPT: &str = "No transcript for this recording.";
8
pub const ATTENDANCE_OFF: &str = "Attendance reports are turned off for your organization.";
9
pub const ATTENDANCE_FAILED: &str = "Attendance could not be loaded.";
10
pub const DELETE_QUESTION: &str = "Delete this recording for everyone?";
11
const URGENT_EXPIRY_DAYS: i64 = 7;
12
const SECONDS_PER_MINUTE: u64 = 60;
13
const SECONDS_PER_HOUR: u64 = 3600;
14
15
#[derive(Debug, Clone, PartialEq, Eq)]
16
pub enum Load<T> {
17
Loading,
18
Failed(String),
19
Ready(T),
20
}
21
22
impl<T> Load<T> {
23
pub fn ready(&self) -> Option<&T> {
24
match self {
25
Load::Ready(value) => Some(value),
26
_ => None,
27
}
28
}
29
}
30
31
pub fn expiry_label(days: i64) -> String {
32
match days {
33
0 => "Expires today".to_owned(),
34
1 => "Expires in 1 day".to_owned(),
35
days => format!("Expires in {days} days"),
36
}
37
}
38
39
pub fn expiry_is_urgent(days: i64) -> bool {
40
days < URGENT_EXPIRY_DAYS
41
}
42
43
pub fn clock_label(seconds: u64) -> String {
44
let hours = seconds / SECONDS_PER_HOUR;
45
let minutes = seconds % SECONDS_PER_HOUR / SECONDS_PER_MINUTE;
46
let rest = seconds % SECONDS_PER_MINUTE;
47
if hours > 0 {
48
format!("{hours}:{minutes:02}:{rest:02}")
49
} else {
50
format!("{minutes}:{rest:02}")
51
}
52
}
53
54
pub fn span_label(seconds: u64) -> String {
55
let hours = seconds / SECONDS_PER_HOUR;
56
let minutes = seconds % SECONDS_PER_HOUR / SECONDS_PER_MINUTE;
57
match (hours, minutes) {
58
(0, 0) => "< 1 min".to_owned(),
59
(0, minutes) => format!("{minutes} min"),
60
(hours, 0) => format!("{hours} h"),
61
(hours, minutes) => format!("{hours} h {minutes} min"),
62
}
63
}
64
65
pub fn occurrence_label(
66
occurrence: &Occurrence,
67
today: NaiveDate,
68
offset: FixedOffset,
69
) -> String {
70
occurrence.started_at.map_or_else(
71
|| occurrence.recording_name.clone().unwrap_or_default(),
72
|started_at| {
73
let local = started_at.with_timezone(&offset);
74
format!(
75
"{}, {}",
76
format::day_label(local.date_naive(), today),
77
local.format("%H:%M")
78
)
79
},
80
)
81
}
82
83
pub fn time_label(time: Option<DateTime<Utc>>, offset: FixedOffset) -> String {
84
time.map_or_else(
85
|| "-".to_owned(),
86
|time| time.with_timezone(&offset).format("%H:%M").to_string(),
87
)
88
}
89
90
pub fn matching_turns(turns: &[TranscriptTurn], query: &str) -> Vec<usize> {
91
let needle = query.trim().to_lowercase();
92
turns
93
.iter()
94
.enumerate()
95
.filter(|(_, turn)| {
96
needle.is_empty()
97
|| turn.text.to_lowercase().contains(&needle)
98
|| turn.speaker.to_lowercase().contains(&needle)
99
})
100
.map(|(index, _)| index)
101
.collect()
102
}
103
104
pub fn highlight_segments(text: &str, query: &str) -> Vec<(String, bool)> {
105
let needle = query.trim().to_lowercase();
106
if needle.is_empty() {
107
return vec![(text.to_owned(), false)];
108
}
109
let mut segments = Vec::new();
110
let mut plain = String::new();
111
let mut rest = text;
112
while !rest.is_empty() {
113
let hit = rest
114
.char_indices()
115
.map(|(start, _)| start)
116
.find_map(|start| matched_len(&rest[start..], &needle).map(|length| (start, length)));
117
match hit {
118
Some((start, length)) => {
119
plain.push_str(&rest[..start]);
120
if !plain.is_empty() {
121
segments.push((std::mem::take(&mut plain), false));
122
}
123
segments.push((rest[start..start + length].to_owned(), true));
124
rest = &rest[start + length..];
125
}
126
None => {
127
plain.push_str(rest);
128
rest = "";
129
}
130
}
131
}
132
if !plain.is_empty() {
133
segments.push((plain, false));
134
}
135
segments
136
}
137
138
fn matched_len(text: &str, lowered_needle: &str) -> Option<usize> {
139
let mut lowered = String::new();
140
for (position, character) in text.char_indices() {
141
lowered.extend(character.to_lowercase());
142
if lowered == lowered_needle {
143
return Some(position + character.len_utf8());
144
}
145
if !lowered_needle.starts_with(&lowered) {
146
return None;
147
}
148
}
149
None
150
}
151
152
pub fn save_name(occurrence: &Occurrence, extension: &str) -> String {
153
let stem = occurrence
154
.recording_name
155
.as_deref()
156
.map(|name| name.rsplit_once('.').map_or(name, |(stem, _)| stem))
157
.unwrap_or("Meeting recording");
158
format!("{stem}.{extension}")
159
}
160
161
#[cfg(test)]
162
mod tests {
163
use super::*;
164
165
fn turn(speaker: &str, text: &str) -> TranscriptTurn {
166
TranscriptTurn {
167
speaker: speaker.to_owned(),
168
start_seconds: 0.,
169
end_seconds: 1.,
170
text: text.to_owned(),
171
}
172
}
173
174
fn occurrence(name: Option<&str>) -> Occurrence {
175
Occurrence {
176
message_id: "1".to_owned(),
177
started_at: None,
178
recording_url: "https://a.example/x.mp4".to_owned(),
179
recording_name: name.map(str::to_owned),
180
duration_seconds: None,
181
organizer_id: None,
182
}
183
}
184
185
#[test]
186
fn expiry_wording_and_urgency() {
187
assert_eq!(expiry_label(0), "Expires today");
188
assert_eq!(expiry_label(1), "Expires in 1 day");
189
assert_eq!(expiry_label(42), "Expires in 42 days");
190
assert!(expiry_is_urgent(6));
191
assert!(!expiry_is_urgent(7));
192
}
193
194
#[test]
195
fn clocks_and_spans() {
196
assert_eq!(clock_label(1832), "30:32");
197
assert_eq!(clock_label(3723), "1:02:03");
198
assert_eq!(span_label(20), "< 1 min");
199
assert_eq!(span_label(1500), "25 min");
200
assert_eq!(span_label(3600), "1 h");
201
assert_eq!(span_label(3900), "1 h 5 min");
202
}
203
204
#[test]
205
fn search_matches_text_and_speaker_ignoring_case() {
206
let turns = [turn("Alex", "Ship it"), turn("Sam", "Later"), turn("Sam", "SHIP?")];
207
assert_eq!(matching_turns(&turns, ""), vec![0, 1, 2]);
208
assert_eq!(matching_turns(&turns, " ship "), vec![0, 2]);
209
assert_eq!(matching_turns(&turns, "sam"), vec![1, 2]);
210
assert!(matching_turns(&turns, "zzz").is_empty());
211
}
212
213
#[test]
214
fn highlight_splits_around_every_hit() {
215
assert_eq!(
216
highlight_segments("Ship it, ship", "SHIP"),
217
vec![
218
("Ship".to_owned(), true),
219
(" it, ".to_owned(), false),
220
("ship".to_owned(), true),
221
]
222
);
223
assert_eq!(
224
highlight_segments("nothing", "x"),
225
vec![("nothing".to_owned(), false)]
226
);
227
assert_eq!(highlight_segments("a", ""), vec![("a".to_owned(), false)]);
228
}
229
230
#[test]
231
fn save_names_keep_the_recording_stem() {
232
let named = occurrence(Some("Weekly sync-20260302-Meeting Recording.mp4"));
233
assert_eq!(
234
save_name(&named, "vtt"),
235
"Weekly sync-20260302-Meeting Recording.vtt"
236
);
237
assert_eq!(save_name(&occurrence(None), "docx"), "Meeting recording.docx");
238
}
239
}
@@ -0,0 +1,239 @@1
use chatsvc::{Occurrence, TranscriptTurn};2
use chrono::{DateTime, FixedOffset, NaiveDate, Utc};3
4
use crate::format;5
6
pub const EMPTY_RECAP: &str = "No recording or transcript for this meeting.";7
pub const NO_TRANSCRIPT: &str = "No transcript for this recording.";8
pub const ATTENDANCE_OFF: &str = "Attendance reports are turned off for your organization.";9
pub const ATTENDANCE_FAILED: &str = "Attendance could not be loaded.";10
pub const DELETE_QUESTION: &str = "Delete this recording for everyone?";11
const URGENT_EXPIRY_DAYS: i64 = 7;12
const SECONDS_PER_MINUTE: u64 = 60;13
const SECONDS_PER_HOUR: u64 = 3600;14
15
#[derive(Debug, Clone, PartialEq, Eq)]16
pub enum Load<T> {17
Loading,18
Failed(String),19
Ready(T),20
}21
22
impl<T> Load<T> {23
pub fn ready(&self) -> Option<&T> {24
match self {25
Load::Ready(value) => Some(value),26
_ => None,27
}28
}29
}30
31
pub fn expiry_label(days: i64) -> String {32
match days {33
0 => "Expires today".to_owned(),34
1 => "Expires in 1 day".to_owned(),35
days => format!("Expires in {days} days"),36
}37
}38
39
pub fn expiry_is_urgent(days: i64) -> bool {40
days < URGENT_EXPIRY_DAYS41
}42
43
pub fn clock_label(seconds: u64) -> String {44
let hours = seconds / SECONDS_PER_HOUR;45
let minutes = seconds % SECONDS_PER_HOUR / SECONDS_PER_MINUTE;46
let rest = seconds % SECONDS_PER_MINUTE;47
if hours > 0 {48
format!("{hours}:{minutes:02}:{rest:02}")49
} else {50
format!("{minutes}:{rest:02}")51
}52
}53
54
pub fn span_label(seconds: u64) -> String {55
let hours = seconds / SECONDS_PER_HOUR;56
let minutes = seconds % SECONDS_PER_HOUR / SECONDS_PER_MINUTE;57
match (hours, minutes) {58
(0, 0) => "< 1 min".to_owned(),59
(0, minutes) => format!("{minutes} min"),60
(hours, 0) => format!("{hours} h"),61
(hours, minutes) => format!("{hours} h {minutes} min"),62
}63
}64
65
pub fn occurrence_label(66
occurrence: &Occurrence,67
today: NaiveDate,68
offset: FixedOffset,69
) -> String {70
occurrence.started_at.map_or_else(71
|| occurrence.recording_name.clone().unwrap_or_default(),72
|started_at| {73
let local = started_at.with_timezone(&offset);74
format!(75
"{}, {}",76
format::day_label(local.date_naive(), today),77
local.format("%H:%M")78
)79
},80
)81
}82
83
pub fn time_label(time: Option<DateTime<Utc>>, offset: FixedOffset) -> String {84
time.map_or_else(85
|| "-".to_owned(),86
|time| time.with_timezone(&offset).format("%H:%M").to_string(),87
)88
}89
90
pub fn matching_turns(turns: &[TranscriptTurn], query: &str) -> Vec<usize> {91
let needle = query.trim().to_lowercase();92
turns93
.iter()94
.enumerate()95
.filter(|(_, turn)| {96
needle.is_empty()97
|| turn.text.to_lowercase().contains(&needle)98
|| turn.speaker.to_lowercase().contains(&needle)99
})100
.map(|(index, _)| index)101
.collect()102
}103
104
pub fn highlight_segments(text: &str, query: &str) -> Vec<(String, bool)> {105
let needle = query.trim().to_lowercase();106
if needle.is_empty() {107
return vec![(text.to_owned(), false)];108
}109
let mut segments = Vec::new();110
let mut plain = String::new();111
let mut rest = text;112
while !rest.is_empty() {113
let hit = rest114
.char_indices()115
.map(|(start, _)| start)116
.find_map(|start| matched_len(&rest[start..], &needle).map(|length| (start, length)));117
match hit {118
Some((start, length)) => {119
plain.push_str(&rest[..start]);120
if !plain.is_empty() {121
segments.push((std::mem::take(&mut plain), false));122
}123
segments.push((rest[start..start + length].to_owned(), true));124
rest = &rest[start + length..];125
}126
None => {127
plain.push_str(rest);128
rest = "";129
}130
}131
}132
if !plain.is_empty() {133
segments.push((plain, false));134
}135
segments136
}137
138
fn matched_len(text: &str, lowered_needle: &str) -> Option<usize> {139
let mut lowered = String::new();140
for (position, character) in text.char_indices() {141
lowered.extend(character.to_lowercase());142
if lowered == lowered_needle {143
return Some(position + character.len_utf8());144
}145
if !lowered_needle.starts_with(&lowered) {146
return None;147
}148
}149
None150
}151
152
pub fn save_name(occurrence: &Occurrence, extension: &str) -> String {153
let stem = occurrence154
.recording_name155
.as_deref()156
.map(|name| name.rsplit_once('.').map_or(name, |(stem, _)| stem))157
.unwrap_or("Meeting recording");158
format!("{stem}.{extension}")159
}160
161
#[cfg(test)]162
mod tests {163
use super::*;164
165
fn turn(speaker: &str, text: &str) -> TranscriptTurn {166
TranscriptTurn {167
speaker: speaker.to_owned(),168
start_seconds: 0.,169
end_seconds: 1.,170
text: text.to_owned(),171
}172
}173
174
fn occurrence(name: Option<&str>) -> Occurrence {175
Occurrence {176
message_id: "1".to_owned(),177
started_at: None,178
recording_url: "https://a.example/x.mp4".to_owned(),179
recording_name: name.map(str::to_owned),180
duration_seconds: None,181
organizer_id: None,182
}183
}184
185
#[test]186
fn expiry_wording_and_urgency() {187
assert_eq!(expiry_label(0), "Expires today");188
assert_eq!(expiry_label(1), "Expires in 1 day");189
assert_eq!(expiry_label(42), "Expires in 42 days");190
assert!(expiry_is_urgent(6));191
assert!(!expiry_is_urgent(7));192
}193
194
#[test]195
fn clocks_and_spans() {196
assert_eq!(clock_label(1832), "30:32");197
assert_eq!(clock_label(3723), "1:02:03");198
assert_eq!(span_label(20), "< 1 min");199
assert_eq!(span_label(1500), "25 min");200
assert_eq!(span_label(3600), "1 h");201
assert_eq!(span_label(3900), "1 h 5 min");202
}203
204
#[test]205
fn search_matches_text_and_speaker_ignoring_case() {206
let turns = [turn("Alex", "Ship it"), turn("Sam", "Later"), turn("Sam", "SHIP?")];207
assert_eq!(matching_turns(&turns, ""), vec![0, 1, 2]);208
assert_eq!(matching_turns(&turns, " ship "), vec![0, 2]);209
assert_eq!(matching_turns(&turns, "sam"), vec![1, 2]);210
assert!(matching_turns(&turns, "zzz").is_empty());211
}212
213
#[test]214
fn highlight_splits_around_every_hit() {215
assert_eq!(216
highlight_segments("Ship it, ship", "SHIP"),217
vec![218
("Ship".to_owned(), true),219
(" it, ".to_owned(), false),220
("ship".to_owned(), true),221
]222
);223
assert_eq!(224
highlight_segments("nothing", "x"),225
vec![("nothing".to_owned(), false)]226
);227
assert_eq!(highlight_segments("a", ""), vec![("a".to_owned(), false)]);228
}229
230
#[test]231
fn save_names_keep_the_recording_stem() {232
let named = occurrence(Some("Weekly sync-20260302-Meeting Recording.mp4"));233
assert_eq!(234
save_name(&named, "vtt"),235
"Weekly sync-20260302-Meeting Recording.vtt"236
);237
assert_eq!(save_name(&occurrence(None), "docx"), "Meeting recording.docx");238
}239
}@@ -25,11 +25,14 @@ const EXTERNAL_ARROW: &str = "\u{2197}";
25
25
26
26
pub const POSTS_LABEL: &str = "Posts";
27
27
pub const SHARED_LABEL: &str = "Shared";
28
pub const CHAT_LABEL: &str = "Chat";
29
pub const RECAP_LABEL: &str = "Recap";
28
30
29
31
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30
32
pub enum ChannelPane {
31
33
Posts,
32
34
Shared,
35
Recap,
33
36
}
34
37
35
38
pub type SelectPane = Rc<dyn Fn(ChannelPane, &mut App)>;
@@ -197,6 +200,37 @@ pub fn render_tab_bar(
197
200
.into_any_element()
198
201
}
199
202
203
pub fn render_meeting_bar(pane: ChannelPane, select: SelectPane) -> AnyElement {
204
let chat = tab_label(
205
"meeting-tab-chat".into(),
206
CHAT_LABEL,
207
pane == ChannelPane::Posts,
208
false,
209
{
210
let select = select.clone();
211
move |_, cx| select(ChannelPane::Posts, cx)
212
},
213
);
214
let recap = tab_label(
215
"meeting-tab-recap".into(),
216
RECAP_LABEL,
217
pane == ChannelPane::Recap,
218
false,
219
move |_, cx| select(ChannelPane::Recap, cx),
220
)
221
.debug_selector(|| "shell/islands/main/recap-tab".into());
222
h_flex()
223
.w_full()
224
.h(px(BAR_HEIGHT))
225
.flex_none()
226
.px(px(BAR_PADDING))
227
.gap(px(TAB_GAP))
228
.items_center()
229
.child(chat)
230
.child(recap)
231
.into_any_element()
232
}
233
200
234
#[cfg(test)]
201
235
mod tests {
202
236
use store::ChannelTabRecord;
@@ -25,11 +25,14 @@ const EXTERNAL_ARROW: &str = "\u{2197}";25
25
26
pub const POSTS_LABEL: &str = "Posts";26
pub const POSTS_LABEL: &str = "Posts";27
pub const SHARED_LABEL: &str = "Shared";27
pub const SHARED_LABEL: &str = "Shared";28
pub const CHAT_LABEL: &str = "Chat";29
pub const RECAP_LABEL: &str = "Recap";28
30
29
#[derive(Debug, Clone, Copy, PartialEq, Eq)]31
#[derive(Debug, Clone, Copy, PartialEq, Eq)]30
pub enum ChannelPane {32
pub enum ChannelPane {31
Posts,33
Posts,32
Shared,34
Shared,35
Recap,33
}36
}34
37
35
pub type SelectPane = Rc<dyn Fn(ChannelPane, &mut App)>;38
pub type SelectPane = Rc<dyn Fn(ChannelPane, &mut App)>;@@ -197,6 +200,37 @@ pub fn render_tab_bar(197
.into_any_element()200
.into_any_element()198
}201
}199
202
203
pub fn render_meeting_bar(pane: ChannelPane, select: SelectPane) -> AnyElement {204
let chat = tab_label(205
"meeting-tab-chat".into(),206
CHAT_LABEL,207
pane == ChannelPane::Posts,208
false,209
{210
let select = select.clone();211
move |_, cx| select(ChannelPane::Posts, cx)212
},213
);214
let recap = tab_label(215
"meeting-tab-recap".into(),216
RECAP_LABEL,217
pane == ChannelPane::Recap,218
false,219
move |_, cx| select(ChannelPane::Recap, cx),220
)221
.debug_selector(|| "shell/islands/main/recap-tab".into());222
h_flex()223
.w_full()224
.h(px(BAR_HEIGHT))225
.flex_none()226
.px(px(BAR_PADDING))227
.gap(px(TAB_GAP))228
.items_center()229
.child(chat)230
.child(recap)231
.into_any_element()232
}233
200
#[cfg(test)]234
#[cfg(test)]201
mod tests {235
mod tests {202
use store::ChannelTabRecord;236
use store::ChannelTabRecord;@@ -22,6 +22,7 @@ use teams_core::{ExecuteAction, FileCard, LinkPreview};
22
22
mod feed;
23
23
mod pins;
24
24
mod proposal;
25
mod recap;
25
26
mod render_env;
26
27
mod scheduled;
27
28
mod shared;
@@ -185,6 +186,8 @@ pub struct ConversationView {
185
186
sync_generation: u64,
186
187
window_active: bool,
187
188
pane: ChannelPane,
189
recap: recap::RecapState,
190
recap_search: Entity<InputState>,
188
191
channel_tabs: Vec<ChannelTabRecord>,
189
192
tab_links: HashMap<String, String>,
190
193
focus_handle: FocusHandle,
@@ -434,6 +437,7 @@ impl ConversationView {
434
437
let scroller = cx.new(|cx| MessageScrollerState::new(0, cx));
435
438
let composer = cx.new(|cx| Composer::new(app.clone(), window, cx));
436
439
let subject = subject_input(window, cx);
440
let recap_search = recap::search_input(window, cx);
437
441
let recent = cx.new(|cx| emoji::Recent::load(&app.read(cx).store));
438
442
let picker = cx.new(|cx| ReactionPicker::new(app.clone(), recent.clone(), window, cx));
439
443
let draft = cx.new(|cx| NewChatDraft::new(app.clone(), window, cx));
@@ -443,6 +447,7 @@ impl ConversationView {
443
447
cx.subscribe_in(&composer, window, Self::on_composer_event),
444
448
cx.subscribe_in(&draft, window, Self::on_draft_event),
445
449
cx.subscribe_in(&subject, window, Self::on_subject_event),
450
cx.subscribe_in(&recap_search, window, Self::on_recap_search_event),
446
451
cx.observe_window_activation(window, Self::on_window_activation),
447
452
cx.on_app_quit(|this, cx| {
448
453
this.composer
@@ -499,6 +504,8 @@ impl ConversationView {
499
504
sync_generation: 0,
500
505
window_active: window.is_window_active(),
501
506
pane: ChannelPane::Posts,
507
recap: recap::RecapState::default(),
508
recap_search,
502
509
channel_tabs: Vec::new(),
503
510
tab_links: HashMap::new(),
504
511
focus_handle: cx.focus_handle(),
@@ -576,7 +583,7 @@ impl ConversationView {
576
583
.as_ref()
577
584
.is_some_and(|current| current.selection.conversation_id() == conversation_id);
578
585
if is_current {
579
if self.shared_active() {
586
if self.shared_active() || self.recap_active() {
580
587
self.refresh_shared_items(cx);
581
588
}
582
589
self.rebuild(false, cx);
@@ -810,6 +817,7 @@ impl ConversationView {
810
817
self.refresh_agent_runs(cx);
811
818
self.sync_generation += 1;
812
819
self.reset_channel_tabs(cx);
820
self.reset_recap(cx);
813
821
self.reload_pending(cx);
814
822
self.notice = None;
815
823
self.scheduled_failure = None;
@@ -3303,7 +3311,10 @@ impl Render for ConversationView {
3303
3311
Some(current) => root.child(self.render_header(current, cx)),
3304
3312
None => root.child(self.draft.clone()),
3305
3313
};
3306
root = root.children(self.render_tab_bar(window, cx).filter(|_| !drafting));
3314
let tab_bar = self
3315
.render_tab_bar(window, cx)
3316
.or_else(|| self.render_meeting_tab_bar(cx));
3317
root = root.children(tab_bar.filter(|_| !drafting));
3307
3318
root = root.children(self.render_pin_banner(cx).filter(|_| !drafting));
3308
3319
let sync_failed = self
3309
3320
.current
@@ -3331,6 +3342,7 @@ impl Render for ConversationView {
3331
3342
}),
3332
3343
);
3333
3344
}
3345
let recap_active = self.recap_active();
3334
3346
let empty_channel = in_feed && self.rows.borrow().is_empty();
3335
3347
let new_post = self.render_new_post(window, cx);
3336
3348
let body = if drafting && self.current.is_none() && self.rows.borrow().is_empty() {
@@ -3339,6 +3351,8 @@ impl Render for ConversationView {
3339
3351
draft.render_empty(&self.app.read(cx).directory, &group_name)
3340
3352
} else if self.shared_active() {
3341
3353
self.render_shared(cx)
3354
} else if self.recap_active() {
3355
self.render_recap(cx)
3342
3356
} else if empty_channel {
3343
3357
div()
3344
3358
.size_full()
@@ -3370,7 +3384,7 @@ impl Render for ConversationView {
3370
3384
.child(body),
3371
3385
)
3372
3386
.children(self.render_draft_error(cx))
3373
.when(!in_feed, |column| {
3387
.when(!in_feed && !recap_active, |column| {
3374
3388
column
3375
3389
.child(self.render_typing_line(cx))
3376
3390
.children(self.render_proposal_card(cx))
@@ -22,6 +22,7 @@ use teams_core::{ExecuteAction, FileCard, LinkPreview};22
mod feed;22
mod feed;23
mod pins;23
mod pins;24
mod proposal;24
mod proposal;25
mod recap;25
mod render_env;26
mod render_env;26
mod scheduled;27
mod scheduled;27
mod shared;28
mod shared;@@ -185,6 +186,8 @@ pub struct ConversationView {185
sync_generation: u64,186
sync_generation: u64,186
window_active: bool,187
window_active: bool,187
pane: ChannelPane,188
pane: ChannelPane,189
recap: recap::RecapState,190
recap_search: Entity<InputState>,188
channel_tabs: Vec<ChannelTabRecord>,191
channel_tabs: Vec<ChannelTabRecord>,189
tab_links: HashMap<String, String>,192
tab_links: HashMap<String, String>,190
focus_handle: FocusHandle,193
focus_handle: FocusHandle,@@ -434,6 +437,7 @@ impl ConversationView {434
let scroller = cx.new(|cx| MessageScrollerState::new(0, cx));437
let scroller = cx.new(|cx| MessageScrollerState::new(0, cx));435
let composer = cx.new(|cx| Composer::new(app.clone(), window, cx));438
let composer = cx.new(|cx| Composer::new(app.clone(), window, cx));436
let subject = subject_input(window, cx);439
let subject = subject_input(window, cx);440
let recap_search = recap::search_input(window, cx);437
let recent = cx.new(|cx| emoji::Recent::load(&app.read(cx).store));441
let recent = cx.new(|cx| emoji::Recent::load(&app.read(cx).store));438
let picker = cx.new(|cx| ReactionPicker::new(app.clone(), recent.clone(), window, cx));442
let picker = cx.new(|cx| ReactionPicker::new(app.clone(), recent.clone(), window, cx));439
let draft = cx.new(|cx| NewChatDraft::new(app.clone(), window, cx));443
let draft = cx.new(|cx| NewChatDraft::new(app.clone(), window, cx));@@ -443,6 +447,7 @@ impl ConversationView {443
cx.subscribe_in(&composer, window, Self::on_composer_event),447
cx.subscribe_in(&composer, window, Self::on_composer_event),444
cx.subscribe_in(&draft, window, Self::on_draft_event),448
cx.subscribe_in(&draft, window, Self::on_draft_event),445
cx.subscribe_in(&subject, window, Self::on_subject_event),449
cx.subscribe_in(&subject, window, Self::on_subject_event),450
cx.subscribe_in(&recap_search, window, Self::on_recap_search_event),446
cx.observe_window_activation(window, Self::on_window_activation),451
cx.observe_window_activation(window, Self::on_window_activation),447
cx.on_app_quit(|this, cx| {452
cx.on_app_quit(|this, cx| {448
this.composer453
this.composer@@ -499,6 +504,8 @@ impl ConversationView {499
sync_generation: 0,504
sync_generation: 0,500
window_active: window.is_window_active(),505
window_active: window.is_window_active(),501
pane: ChannelPane::Posts,506
pane: ChannelPane::Posts,507
recap: recap::RecapState::default(),508
recap_search,502
channel_tabs: Vec::new(),509
channel_tabs: Vec::new(),503
tab_links: HashMap::new(),510
tab_links: HashMap::new(),504
focus_handle: cx.focus_handle(),511
focus_handle: cx.focus_handle(),@@ -576,7 +583,7 @@ impl ConversationView {576
.as_ref()583
.as_ref()577
.is_some_and(|current| current.selection.conversation_id() == conversation_id);584
.is_some_and(|current| current.selection.conversation_id() == conversation_id);578
if is_current {585
if is_current {579
if self.shared_active() {586
if self.shared_active() || self.recap_active() {580
self.refresh_shared_items(cx);587
self.refresh_shared_items(cx);581
}588
}582
self.rebuild(false, cx);589
self.rebuild(false, cx);@@ -810,6 +817,7 @@ impl ConversationView {810
self.refresh_agent_runs(cx);817
self.refresh_agent_runs(cx);811
self.sync_generation += 1;818
self.sync_generation += 1;812
self.reset_channel_tabs(cx);819
self.reset_channel_tabs(cx);820
self.reset_recap(cx);813
self.reload_pending(cx);821
self.reload_pending(cx);814
self.notice = None;822
self.notice = None;815
self.scheduled_failure = None;823
self.scheduled_failure = None;@@ -3303,7 +3311,10 @@ impl Render for ConversationView {3303
Some(current) => root.child(self.render_header(current, cx)),3311
Some(current) => root.child(self.render_header(current, cx)),3304
None => root.child(self.draft.clone()),3312
None => root.child(self.draft.clone()),3305
};3313
};3306
root = root.children(self.render_tab_bar(window, cx).filter(|_| !drafting));3314
let tab_bar = self3315
.render_tab_bar(window, cx)3316
.or_else(|| self.render_meeting_tab_bar(cx));3317
root = root.children(tab_bar.filter(|_| !drafting));3307
root = root.children(self.render_pin_banner(cx).filter(|_| !drafting));3318
root = root.children(self.render_pin_banner(cx).filter(|_| !drafting));3308
let sync_failed = self3319
let sync_failed = self3309
.current3320
.current@@ -3331,6 +3342,7 @@ impl Render for ConversationView {3331
}),3342
}),3332
);3343
);3333
}3344
}3345
let recap_active = self.recap_active();3334
let empty_channel = in_feed && self.rows.borrow().is_empty();3346
let empty_channel = in_feed && self.rows.borrow().is_empty();3335
let new_post = self.render_new_post(window, cx);3347
let new_post = self.render_new_post(window, cx);3336
let body = if drafting && self.current.is_none() && self.rows.borrow().is_empty() {3348
let body = if drafting && self.current.is_none() && self.rows.borrow().is_empty() {@@ -3339,6 +3351,8 @@ impl Render for ConversationView {3339
draft.render_empty(&self.app.read(cx).directory, &group_name)3351
draft.render_empty(&self.app.read(cx).directory, &group_name)3340
} else if self.shared_active() {3352
} else if self.shared_active() {3341
self.render_shared(cx)3353
self.render_shared(cx)3354
} else if self.recap_active() {3355
self.render_recap(cx)3342
} else if empty_channel {3356
} else if empty_channel {3343
div()3357
div()3344
.size_full()3358
.size_full()@@ -3370,7 +3384,7 @@ impl Render for ConversationView {3370
.child(body),3384
.child(body),3371
)3385
)3372
.children(self.render_draft_error(cx))3386
.children(self.render_draft_error(cx))3373
.when(!in_feed, |column| {3387
.when(!in_feed && !recap_active, |column| {3374
column3388
column3375
.child(self.render_typing_line(cx))3389
.child(self.render_typing_line(cx))3376
.children(self.render_proposal_card(cx))3390
.children(self.render_proposal_card(cx))@@ -0,0 +1,567 @@
1
use std::collections::HashMap;
2
use std::io::Write as _;
3
use std::path::PathBuf;
4
use std::rc::Rc;
5
6
use chatsvc::{
7
Attendance, Occurrence, Recap, RecordingDetails, TranscriptFormat, TranscriptTurn,
8
};
9
use chrono::Utc;
10
use gpui_kit::component::button::{Button, ButtonVariants as _};
11
use gpui_kit::component::dialog::DialogFooter;
12
use gpui_kit::component::input::{InputEvent, InputState};
13
use gpui_kit::component::WindowExt as _;
14
use gpui_kit::*;
15
16
use super::ConversationView;
17
use crate::app_state::Selection;
18
use crate::channel_files::SharedContent;
19
use crate::demo_recap;
20
use crate::downloads::{self, DownloadState};
21
use crate::notice::short_error;
22
use crate::recap::{DELETE_QUESTION, Load, save_name};
23
use crate::runtime;
24
use crate::views::channel_tabs::{ChannelPane, render_meeting_bar};
25
use crate::views::recap_tab::{RecapCommand, RecapDownload, RecapRun, RecapView, render_recap};
26
use crate::views::shared_tab::{SharedCommand, SharedRun};
27
28
const SEARCH_PLACEHOLDER: &str = "Search transcript";
29
const RECORDING_EXTENSION: &str = "mp4";
30
31
pub(super) fn search_input(
32
window: &mut Window,
33
cx: &mut Context<ConversationView>,
34
) -> Entity<InputState> {
35
cx.new(|cx| InputState::new(window, cx).placeholder(SEARCH_PLACEHOLDER))
36
}
37
38
pub(super) struct RecapState {
39
listing: Load<Vec<Occurrence>>,
40
selected: usize,
41
details: Load<RecordingDetails>,
42
transcript: Load<Vec<TranscriptTurn>>,
43
attendance: Load<Attendance>,
44
query: String,
45
downloads: HashMap<RecapDownload, DownloadState>,
46
generation: u64,
47
}
48
49
impl Default for RecapState {
50
fn default() -> Self {
51
RecapState {
52
listing: Load::Loading,
53
selected: 0,
54
details: Load::Loading,
55
transcript: Load::Loading,
56
attendance: Load::Loading,
57
query: String::new(),
58
downloads: HashMap::new(),
59
generation: 0,
60
}
61
}
62
}
63
64
enum SaveEvent {
65
Progress(u8),
66
Finished(Result<PathBuf, String>),
67
}
68
69
impl ConversationView {
70
fn is_meeting_chat(&self, cx: &App) -> bool {
71
let Some(Selection::Chat(chat_id)) = self.current.as_ref().map(|current| ¤t.selection)
72
else {
73
return false;
74
};
75
self.app
76
.read(cx)
77
.sidebar
78
.chats
79
.iter()
80
.any(|chat| &chat.id == chat_id && chat.kind.eq_ignore_ascii_case("meeting"))
81
}
82
83
fn occurrences(&self) -> &[Occurrence] {
84
self.recap.listing.ready().map_or(&[], Vec::as_slice)
85
}
86
87
fn selected_occurrence(&self) -> Option<Occurrence> {
88
self.occurrences().get(self.recap.selected).cloned()
89
}
90
91
pub(super) fn recap_active(&self) -> bool {
92
self.pane == ChannelPane::Recap && !self.occurrences().is_empty()
93
}
94
95
pub(super) fn on_recap_search_event(
96
&mut self,
97
input: &Entity<InputState>,
98
event: &InputEvent,
99
_: &mut Window,
100
cx: &mut Context<Self>,
101
) {
102
if matches!(event, InputEvent::Change) {
103
self.recap.query = input.read(cx).value().to_string();
104
cx.notify();
105
}
106
}
107
108
pub(super) fn reset_recap(&mut self, cx: &mut Context<Self>) {
109
self.recap = RecapState {
110
generation: self.recap.generation + 1,
111
..RecapState::default()
112
};
113
if !self.is_meeting_chat(cx) {
114
return;
115
}
116
let Some(conversation_id) = self.conversation_id() else {
117
return;
118
};
119
let state = self.app.read(cx);
120
let (demo, engine) = (state.mode.demo, state.engine.clone());
121
if demo {
122
self.recap.listing = Load::Ready(demo_recap::occurrences(&conversation_id, Utc::now()));
123
return;
124
}
125
let Some(engine) = engine else {
126
return;
127
};
128
let generation = self.recap.generation;
129
let receiver = runtime::spawn(async move {
130
Recap::new(engine.remote().session())
131
.occurrences(&conversation_id)
132
.await
133
});
134
cx.spawn(async move |this, cx| {
135
let outcome = match receiver.await {
136
Ok(Ok(occurrences)) => Ok(occurrences),
137
Ok(Err(error)) => Err(short_error(&error)),
138
Err(error) => Err(short_error(&error)),
139
};
140
this.update(cx, |this, cx| {
141
if generation != this.recap.generation {
142
return;
143
}
144
this.recap.listing = match outcome {
145
Ok(occurrences) => Load::Ready(occurrences),
146
Err(reason) => Load::Failed(reason),
147
};
148
if this.pane == ChannelPane::Recap {
149
this.select_occurrence(0, cx);
150
}
151
cx.notify();
152
})
153
.ok();
154
})
155
.detach();
156
}
157
158
pub(super) fn open_recap_pane(&mut self, cx: &mut Context<Self>) {
159
self.refresh_shared_items(cx);
160
if matches!(self.recap.details, Load::Loading) {
161
self.select_occurrence(0, cx);
162
}
163
}
164
165
fn select_occurrence(&mut self, index: usize, cx: &mut Context<Self>) {
166
let Some(occurrence) = self.occurrences().get(index).cloned() else {
167
return;
168
};
169
self.recap.selected = index;
170
self.recap.details = Load::Loading;
171
self.recap.transcript = Load::Loading;
172
self.recap.attendance = Load::Loading;
173
self.recap.downloads.clear();
174
self.recap.generation += 1;
175
let generation = self.recap.generation;
176
cx.notify();
177
let state = self.app.read(cx);
178
let (demo, engine) = (state.mode.demo, state.engine.clone());
179
if demo {
180
let now = Utc::now();
181
self.recap.details = Load::Ready(demo_recap::details(&occurrence, now));
182
self.recap.transcript = Load::Ready(demo_recap::transcript());
183
self.recap.attendance = Load::Ready(demo_recap::attendance(now));
184
return;
185
}
186
let (Some(engine), Some(conversation_id)) = (engine, self.conversation_id()) else {
187
return;
188
};
189
let attendance_engine = engine.clone();
190
let loaded = runtime::spawn(async move {
191
let recap = Recap::new(engine.remote().session());
192
let details = recap.details(&occurrence).await?;
193
let transcript = recap.transcript(&details).await.ok();
194
Ok::<_, chatsvc::TranscriptError>((details, transcript))
195
});
196
let attendance = runtime::spawn(async move {
197
Recap::new(attendance_engine.remote().session())
198
.attendance(&conversation_id)
199
.await
200
});
201
cx.spawn(async move |this, cx| {
202
let loaded = match loaded.await {
203
Ok(Ok(loaded)) => Ok(loaded),
204
Ok(Err(error)) => Err(short_error(&error)),
205
Err(error) => Err(short_error(&error)),
206
};
207
this.update(cx, |this, cx| {
208
if generation != this.recap.generation {
209
return;
210
}
211
match loaded {
212
Ok((details, transcript)) => {
213
this.recap.details = Load::Ready(details);
214
this.recap.transcript = Load::Ready(transcript.unwrap_or_default());
215
}
216
Err(reason) => {
217
this.recap.details = Load::Failed(reason.clone());
218
this.recap.transcript = Load::Failed(reason);
219
}
220
}
221
cx.notify();
222
})
223
.ok();
224
})
225
.detach();
226
cx.spawn(async move |this, cx| {
227
let outcome = match attendance.await {
228
Ok(Ok(attendance)) => Ok(attendance),
229
Ok(Err(error)) => Err(short_error(&error)),
230
Err(error) => Err(short_error(&error)),
231
};
232
this.update(cx, |this, cx| {
233
if generation != this.recap.generation {
234
return;
235
}
236
this.recap.attendance = match outcome {
237
Ok(attendance) => Load::Ready(attendance),
238
Err(reason) => Load::Failed(reason),
239
};
240
cx.notify();
241
})
242
.ok();
243
})
244
.detach();
245
}
246
247
pub(super) fn render_meeting_tab_bar(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
248
if self.occurrences().is_empty() || !self.is_meeting_chat(cx) {
249
return None;
250
}
251
let view = cx.weak_entity();
252
let select = Rc::new(move |pane, cx: &mut App| {
253
view.update(cx, |this, cx| this.select_pane(pane, cx)).ok();
254
});
255
Some(render_meeting_bar(self.pane, select))
256
}
257
258
pub(super) fn render_recap(&self, cx: &mut Context<Self>) -> AnyElement {
259
let view = cx.weak_entity();
260
let run: RecapRun = Rc::new(move |command, window, cx| {
261
view.update(cx, |this, cx| this.run_recap(command, window, cx))
262
.ok();
263
});
264
let file_indices: Rc<Vec<usize>> = Rc::new(
265
self.shared
266
.items
267
.iter()
268
.enumerate()
269
.filter(|(_, item)| matches!(item.content, SharedContent::File(_)))
270
.map(|(index, _)| index)
271
.collect(),
272
);
273
let file_states = self.item_download_states();
274
let files = file_indices
275
.iter()
276
.map(|index| self.shared.items[*index].clone())
277
.collect::<Vec<_>>();
278
let file_labels = file_indices
279
.iter()
280
.map(|index| {
281
crate::views::shared_tab::download_label(
282
file_states.get(*index).and_then(Option::as_ref),
283
)
284
})
285
.collect();
286
let file_run: SharedRun = {
287
let view = cx.weak_entity();
288
Rc::new(move |command, window, cx| {
289
let command = match command {
290
SharedCommand::OpenItem(index) => SharedCommand::OpenItem(file_indices[index]),
291
SharedCommand::JumpToPost(index) => {
292
SharedCommand::JumpToPost(file_indices[index])
293
}
294
other => other,
295
};
296
view.update(cx, |this, cx| {
297
if matches!(command, SharedCommand::JumpToPost(_)) {
298
this.pane = ChannelPane::Posts;
299
}
300
this.run_shared(command, window, cx)
301
})
302
.ok();
303
})
304
};
305
let can_delete = self.can_delete_recording(cx);
306
render_recap(
307
RecapView {
308
occurrences: self.occurrences(),
309
selected: self.recap.selected,
310
details: &self.recap.details,
311
transcript: &self.recap.transcript,
312
attendance: &self.recap.attendance,
313
search: &self.recap_search,
314
query: &self.recap.query,
315
can_delete,
316
recording_state: self.recap.downloads.get(&RecapDownload::Recording),
317
vtt_state: self
318
.recap
319
.downloads
320
.get(&RecapDownload::Transcript(TranscriptFormat::Vtt)),
321
docx_state: self
322
.recap
323
.downloads
324
.get(&RecapDownload::Transcript(TranscriptFormat::Docx)),
325
files: &files,
326
file_labels,
327
file_run,
328
now: Utc::now(),
329
},
330
&run,
331
)
332
}
333
334
fn can_delete_recording(&self, cx: &App) -> bool {
335
let my_user_id = self.app.read(cx).directory.me.as_ref().map(|me| me.user_id.as_str());
336
match (self.selected_occurrence(), my_user_id) {
337
(Some(occurrence), Some(my_user_id)) => {
338
occurrence.organizer_id.as_deref() == Some(my_user_id)
339
}
340
_ => false,
341
}
342
}
343
344
fn run_recap(&mut self, command: RecapCommand, window: &mut Window, cx: &mut Context<Self>) {
345
match command {
346
RecapCommand::Occurrence(index) => self.select_occurrence(index, cx),
347
RecapCommand::Retry => self.select_occurrence(self.recap.selected, cx),
348
RecapCommand::Play => {
349
if let Some(occurrence) = self.selected_occurrence() {
350
cx.open_url(&occurrence.recording_url);
351
}
352
}
353
RecapCommand::Download(download) => self.pick_save_target(download, cx),
354
RecapCommand::AskDelete => self.confirm_delete(window, cx),
355
}
356
}
357
358
fn confirm_delete(&mut self, window: &mut Window, cx: &mut Context<Self>) {
359
let view = cx.weak_entity();
360
window.open_alert_dialog(cx, move |alert, _, _| {
361
let view = view.clone();
362
let cancel = Button::new("recap-delete-cancel")
363
.label("Cancel")
364
.on_click(|_, window, cx| window.close_dialog(cx));
365
let delete = Button::new("recap-delete-confirm")
366
.label("Delete")
367
.danger()
368
.on_click(move |_, window, cx| {
369
view.update(cx, |this, cx| this.delete_recording(cx)).ok();
370
window.close_dialog(cx);
371
});
372
alert
373
.title(DELETE_QUESTION)
374
.footer(DialogFooter::new().child(cancel).child(delete))
375
.on_ok(|_, _, _| false)
376
});
377
}
378
379
fn delete_recording(&mut self, cx: &mut Context<Self>) {
380
let (Some(occurrence), Some(details)) = (
381
self.selected_occurrence(),
382
self.recap.details.ready().cloned(),
383
) else {
384
return;
385
};
386
let state = self.app.read(cx);
387
let (demo, engine) = (state.mode.demo, state.engine.clone());
388
if demo {
389
self.finish_delete(&occurrence, Ok(()), cx);
390
return;
391
}
392
let Some(engine) = engine else {
393
return;
394
};
395
let receiver = runtime::spawn(async move {
396
Recap::new(engine.remote().session())
397
.delete_recording(&details)
398
.await
399
});
400
cx.spawn(async move |this, cx| {
401
let outcome = match receiver.await {
402
Ok(Ok(())) => Ok(()),
403
Ok(Err(error)) => Err(short_error(&error)),
404
Err(error) => Err(short_error(&error)),
405
};
406
this.update(cx, |this, cx| this.finish_delete(&occurrence, outcome, cx))
407
.ok();
408
})
409
.detach();
410
}
411
412
fn finish_delete(
413
&mut self,
414
occurrence: &Occurrence,
415
outcome: Result<(), String>,
416
cx: &mut Context<Self>,
417
) {
418
if let Err(reason) = outcome {
419
self.notice = Some(format!("Recording not deleted: {reason}"));
420
cx.notify();
421
return;
422
}
423
let remaining: Vec<Occurrence> = self
424
.occurrences()
425
.iter()
426
.filter(|other| other.message_id != occurrence.message_id)
427
.cloned()
428
.collect();
429
let empty = remaining.is_empty();
430
self.recap.listing = Load::Ready(remaining);
431
if empty {
432
self.pane = ChannelPane::Posts;
433
cx.notify();
434
} else {
435
self.select_occurrence(0, cx);
436
}
437
}
438
439
fn pick_save_target(&mut self, download: RecapDownload, cx: &mut Context<Self>) {
440
let Some(occurrence) = self.selected_occurrence() else {
441
return;
442
};
443
if matches!(
444
self.recap.downloads.get(&download),
445
Some(DownloadState::Saving(_))
446
) {
447
return;
448
}
449
let extension = match download {
450
RecapDownload::Recording => RECORDING_EXTENSION,
451
RecapDownload::Transcript(format) => format.query(),
452
};
453
let name = save_name(&occurrence, extension);
454
let receiver = cx.prompt_for_new_path(&downloads::downloads_directory(), Some(&name));
455
cx.spawn(async move |this, cx| {
456
if let Ok(Ok(Some(target))) = receiver.await {
457
this.update(cx, |this, cx| this.save_to(download, occurrence, target, cx))
458
.ok();
459
}
460
})
461
.detach();
462
}
463
464
fn save_to(
465
&mut self,
466
download: RecapDownload,
467
occurrence: Occurrence,
468
target: PathBuf,
469
cx: &mut Context<Self>,
470
) {
471
self.recap
472
.downloads
473
.insert(download, DownloadState::Saving(0));
474
cx.notify();
475
let generation = self.recap.generation;
476
let state = self.app.read(cx);
477
let (demo, engine) = (state.mode.demo, state.engine.clone());
478
let details = self.recap.details.ready().cloned();
479
let (sender, mut receiver) = tokio::sync::mpsc::unbounded_channel::<SaveEvent>();
480
if demo {
481
let outcome = std::fs::write(&target, demo_recap::DEMO_FILE_BYTES)
482
.map(|_| target)
483
.map_err(|error| short_error(&error));
484
self.recap.downloads.insert(download, finished_state(outcome));
485
return;
486
}
487
let (Some(engine), Some(details)) = (engine, details) else {
488
self.recap
489
.downloads
490
.insert(download, DownloadState::Failed("not connected".to_owned()));
491
return;
492
};
493
drop(runtime::spawn(async move {
494
let outcome = save_download(&engine, download, &occurrence, &details, target, &sender)
495
.await;
496
let _ = sender.send(SaveEvent::Finished(outcome));
497
}));
498
cx.spawn(async move |this, cx| {
499
while let Some(event) = receiver.recv().await {
500
let updated = this.update(cx, |this, cx| {
501
if generation == this.recap.generation {
502
match event {
503
SaveEvent::Progress(percent) => {
504
this.recap
505
.downloads
506
.insert(download, DownloadState::Saving(percent));
507
}
508
SaveEvent::Finished(outcome) => {
509
this.recap.downloads.insert(download, finished_state(outcome));
510
}
511
}
512
}
513
cx.notify();
514
});
515
if updated.is_err() {
516
return;
517
}
518
}
519
})
520
.detach();
521
}
522
}
523
524
fn finished_state(outcome: Result<PathBuf, String>) -> DownloadState {
525
match outcome {
526
Ok(path) => DownloadState::Saved(path),
527
Err(reason) => DownloadState::Failed(reason),
528
}
529
}
530
531
async fn save_download(
532
engine: &crate::backend::Engine,
533
download: RecapDownload,
534
occurrence: &Occurrence,
535
details: &RecordingDetails,
536
target: PathBuf,
537
events: &tokio::sync::mpsc::UnboundedSender<SaveEvent>,
538
) -> Result<PathBuf, String> {
539
match download {
540
RecapDownload::Transcript(format) => {
541
let bytes = Recap::new(engine.remote().session())
542
.transcript_file(details, format)
543
.await
544
.map_err(|error| short_error(&error))?;
545
std::fs::write(&target, bytes).map_err(|error| short_error(&error))?;
546
}
547
RecapDownload::Recording => {
548
let mut file = std::fs::File::create(&target).map_err(|error| short_error(&error))?;
549
let progress = |percent| {
550
let _ = events.send(SaveEvent::Progress(percent));
551
};
552
let result = engine
553
.download_file(
554
&occurrence.recording_url,
555
|bytes: &[u8]| file.write_all(bytes),
556
progress,
557
)
558
.await;
559
if let Err(error) = result {
560
drop(file);
561
let _ = std::fs::remove_file(&target);
562
return Err(short_error(&error));
563
}
564
}
565
}
566
Ok(target)
567
}
@@ -0,0 +1,567 @@1
use std::collections::HashMap;2
use std::io::Write as _;3
use std::path::PathBuf;4
use std::rc::Rc;5
6
use chatsvc::{7
Attendance, Occurrence, Recap, RecordingDetails, TranscriptFormat, TranscriptTurn,8
};9
use chrono::Utc;10
use gpui_kit::component::button::{Button, ButtonVariants as _};11
use gpui_kit::component::dialog::DialogFooter;12
use gpui_kit::component::input::{InputEvent, InputState};13
use gpui_kit::component::WindowExt as _;14
use gpui_kit::*;15
16
use super::ConversationView;17
use crate::app_state::Selection;18
use crate::channel_files::SharedContent;19
use crate::demo_recap;20
use crate::downloads::{self, DownloadState};21
use crate::notice::short_error;22
use crate::recap::{DELETE_QUESTION, Load, save_name};23
use crate::runtime;24
use crate::views::channel_tabs::{ChannelPane, render_meeting_bar};25
use crate::views::recap_tab::{RecapCommand, RecapDownload, RecapRun, RecapView, render_recap};26
use crate::views::shared_tab::{SharedCommand, SharedRun};27
28
const SEARCH_PLACEHOLDER: &str = "Search transcript";29
const RECORDING_EXTENSION: &str = "mp4";30
31
pub(super) fn search_input(32
window: &mut Window,33
cx: &mut Context<ConversationView>,34
) -> Entity<InputState> {35
cx.new(|cx| InputState::new(window, cx).placeholder(SEARCH_PLACEHOLDER))36
}37
38
pub(super) struct RecapState {39
listing: Load<Vec<Occurrence>>,40
selected: usize,41
details: Load<RecordingDetails>,42
transcript: Load<Vec<TranscriptTurn>>,43
attendance: Load<Attendance>,44
query: String,45
downloads: HashMap<RecapDownload, DownloadState>,46
generation: u64,47
}48
49
impl Default for RecapState {50
fn default() -> Self {51
RecapState {52
listing: Load::Loading,53
selected: 0,54
details: Load::Loading,55
transcript: Load::Loading,56
attendance: Load::Loading,57
query: String::new(),58
downloads: HashMap::new(),59
generation: 0,60
}61
}62
}63
64
enum SaveEvent {65
Progress(u8),66
Finished(Result<PathBuf, String>),67
}68
69
impl ConversationView {70
fn is_meeting_chat(&self, cx: &App) -> bool {71
let Some(Selection::Chat(chat_id)) = self.current.as_ref().map(|current| ¤t.selection)72
else {73
return false;74
};75
self.app76
.read(cx)77
.sidebar78
.chats79
.iter()80
.any(|chat| &chat.id == chat_id && chat.kind.eq_ignore_ascii_case("meeting"))81
}82
83
fn occurrences(&self) -> &[Occurrence] {84
self.recap.listing.ready().map_or(&[], Vec::as_slice)85
}86
87
fn selected_occurrence(&self) -> Option<Occurrence> {88
self.occurrences().get(self.recap.selected).cloned()89
}90
91
pub(super) fn recap_active(&self) -> bool {92
self.pane == ChannelPane::Recap && !self.occurrences().is_empty()93
}94
95
pub(super) fn on_recap_search_event(96
&mut self,97
input: &Entity<InputState>,98
event: &InputEvent,99
_: &mut Window,100
cx: &mut Context<Self>,101
) {102
if matches!(event, InputEvent::Change) {103
self.recap.query = input.read(cx).value().to_string();104
cx.notify();105
}106
}107
108
pub(super) fn reset_recap(&mut self, cx: &mut Context<Self>) {109
self.recap = RecapState {110
generation: self.recap.generation + 1,111
..RecapState::default()112
};113
if !self.is_meeting_chat(cx) {114
return;115
}116
let Some(conversation_id) = self.conversation_id() else {117
return;118
};119
let state = self.app.read(cx);120
let (demo, engine) = (state.mode.demo, state.engine.clone());121
if demo {122
self.recap.listing = Load::Ready(demo_recap::occurrences(&conversation_id, Utc::now()));123
return;124
}125
let Some(engine) = engine else {126
return;127
};128
let generation = self.recap.generation;129
let receiver = runtime::spawn(async move {130
Recap::new(engine.remote().session())131
.occurrences(&conversation_id)132
.await133
});134
cx.spawn(async move |this, cx| {135
let outcome = match receiver.await {136
Ok(Ok(occurrences)) => Ok(occurrences),137
Ok(Err(error)) => Err(short_error(&error)),138
Err(error) => Err(short_error(&error)),139
};140
this.update(cx, |this, cx| {141
if generation != this.recap.generation {142
return;143
}144
this.recap.listing = match outcome {145
Ok(occurrences) => Load::Ready(occurrences),146
Err(reason) => Load::Failed(reason),147
};148
if this.pane == ChannelPane::Recap {149
this.select_occurrence(0, cx);150
}151
cx.notify();152
})153
.ok();154
})155
.detach();156
}157
158
pub(super) fn open_recap_pane(&mut self, cx: &mut Context<Self>) {159
self.refresh_shared_items(cx);160
if matches!(self.recap.details, Load::Loading) {161
self.select_occurrence(0, cx);162
}163
}164
165
fn select_occurrence(&mut self, index: usize, cx: &mut Context<Self>) {166
let Some(occurrence) = self.occurrences().get(index).cloned() else {167
return;168
};169
self.recap.selected = index;170
self.recap.details = Load::Loading;171
self.recap.transcript = Load::Loading;172
self.recap.attendance = Load::Loading;173
self.recap.downloads.clear();174
self.recap.generation += 1;175
let generation = self.recap.generation;176
cx.notify();177
let state = self.app.read(cx);178
let (demo, engine) = (state.mode.demo, state.engine.clone());179
if demo {180
let now = Utc::now();181
self.recap.details = Load::Ready(demo_recap::details(&occurrence, now));182
self.recap.transcript = Load::Ready(demo_recap::transcript());183
self.recap.attendance = Load::Ready(demo_recap::attendance(now));184
return;185
}186
let (Some(engine), Some(conversation_id)) = (engine, self.conversation_id()) else {187
return;188
};189
let attendance_engine = engine.clone();190
let loaded = runtime::spawn(async move {191
let recap = Recap::new(engine.remote().session());192
let details = recap.details(&occurrence).await?;193
let transcript = recap.transcript(&details).await.ok();194
Ok::<_, chatsvc::TranscriptError>((details, transcript))195
});196
let attendance = runtime::spawn(async move {197
Recap::new(attendance_engine.remote().session())198
.attendance(&conversation_id)199
.await200
});201
cx.spawn(async move |this, cx| {202
let loaded = match loaded.await {203
Ok(Ok(loaded)) => Ok(loaded),204
Ok(Err(error)) => Err(short_error(&error)),205
Err(error) => Err(short_error(&error)),206
};207
this.update(cx, |this, cx| {208
if generation != this.recap.generation {209
return;210
}211
match loaded {212
Ok((details, transcript)) => {213
this.recap.details = Load::Ready(details);214
this.recap.transcript = Load::Ready(transcript.unwrap_or_default());215
}216
Err(reason) => {217
this.recap.details = Load::Failed(reason.clone());218
this.recap.transcript = Load::Failed(reason);219
}220
}221
cx.notify();222
})223
.ok();224
})225
.detach();226
cx.spawn(async move |this, cx| {227
let outcome = match attendance.await {228
Ok(Ok(attendance)) => Ok(attendance),229
Ok(Err(error)) => Err(short_error(&error)),230
Err(error) => Err(short_error(&error)),231
};232
this.update(cx, |this, cx| {233
if generation != this.recap.generation {234
return;235
}236
this.recap.attendance = match outcome {237
Ok(attendance) => Load::Ready(attendance),238
Err(reason) => Load::Failed(reason),239
};240
cx.notify();241
})242
.ok();243
})244
.detach();245
}246
247
pub(super) fn render_meeting_tab_bar(&self, cx: &mut Context<Self>) -> Option<AnyElement> {248
if self.occurrences().is_empty() || !self.is_meeting_chat(cx) {249
return None;250
}251
let view = cx.weak_entity();252
let select = Rc::new(move |pane, cx: &mut App| {253
view.update(cx, |this, cx| this.select_pane(pane, cx)).ok();254
});255
Some(render_meeting_bar(self.pane, select))256
}257
258
pub(super) fn render_recap(&self, cx: &mut Context<Self>) -> AnyElement {259
let view = cx.weak_entity();260
let run: RecapRun = Rc::new(move |command, window, cx| {261
view.update(cx, |this, cx| this.run_recap(command, window, cx))262
.ok();263
});264
let file_indices: Rc<Vec<usize>> = Rc::new(265
self.shared266
.items267
.iter()268
.enumerate()269
.filter(|(_, item)| matches!(item.content, SharedContent::File(_)))270
.map(|(index, _)| index)271
.collect(),272
);273
let file_states = self.item_download_states();274
let files = file_indices275
.iter()276
.map(|index| self.shared.items[*index].clone())277
.collect::<Vec<_>>();278
let file_labels = file_indices279
.iter()280
.map(|index| {281
crate::views::shared_tab::download_label(282
file_states.get(*index).and_then(Option::as_ref),283
)284
})285
.collect();286
let file_run: SharedRun = {287
let view = cx.weak_entity();288
Rc::new(move |command, window, cx| {289
let command = match command {290
SharedCommand::OpenItem(index) => SharedCommand::OpenItem(file_indices[index]),291
SharedCommand::JumpToPost(index) => {292
SharedCommand::JumpToPost(file_indices[index])293
}294
other => other,295
};296
view.update(cx, |this, cx| {297
if matches!(command, SharedCommand::JumpToPost(_)) {298
this.pane = ChannelPane::Posts;299
}300
this.run_shared(command, window, cx)301
})302
.ok();303
})304
};305
let can_delete = self.can_delete_recording(cx);306
render_recap(307
RecapView {308
occurrences: self.occurrences(),309
selected: self.recap.selected,310
details: &self.recap.details,311
transcript: &self.recap.transcript,312
attendance: &self.recap.attendance,313
search: &self.recap_search,314
query: &self.recap.query,315
can_delete,316
recording_state: self.recap.downloads.get(&RecapDownload::Recording),317
vtt_state: self318
.recap319
.downloads320
.get(&RecapDownload::Transcript(TranscriptFormat::Vtt)),321
docx_state: self322
.recap323
.downloads324
.get(&RecapDownload::Transcript(TranscriptFormat::Docx)),325
files: &files,326
file_labels,327
file_run,328
now: Utc::now(),329
},330
&run,331
)332
}333
334
fn can_delete_recording(&self, cx: &App) -> bool {335
let my_user_id = self.app.read(cx).directory.me.as_ref().map(|me| me.user_id.as_str());336
match (self.selected_occurrence(), my_user_id) {337
(Some(occurrence), Some(my_user_id)) => {338
occurrence.organizer_id.as_deref() == Some(my_user_id)339
}340
_ => false,341
}342
}343
344
fn run_recap(&mut self, command: RecapCommand, window: &mut Window, cx: &mut Context<Self>) {345
match command {346
RecapCommand::Occurrence(index) => self.select_occurrence(index, cx),347
RecapCommand::Retry => self.select_occurrence(self.recap.selected, cx),348
RecapCommand::Play => {349
if let Some(occurrence) = self.selected_occurrence() {350
cx.open_url(&occurrence.recording_url);351
}352
}353
RecapCommand::Download(download) => self.pick_save_target(download, cx),354
RecapCommand::AskDelete => self.confirm_delete(window, cx),355
}356
}357
358
fn confirm_delete(&mut self, window: &mut Window, cx: &mut Context<Self>) {359
let view = cx.weak_entity();360
window.open_alert_dialog(cx, move |alert, _, _| {361
let view = view.clone();362
let cancel = Button::new("recap-delete-cancel")363
.label("Cancel")364
.on_click(|_, window, cx| window.close_dialog(cx));365
let delete = Button::new("recap-delete-confirm")366
.label("Delete")367
.danger()368
.on_click(move |_, window, cx| {369
view.update(cx, |this, cx| this.delete_recording(cx)).ok();370
window.close_dialog(cx);371
});372
alert373
.title(DELETE_QUESTION)374
.footer(DialogFooter::new().child(cancel).child(delete))375
.on_ok(|_, _, _| false)376
});377
}378
379
fn delete_recording(&mut self, cx: &mut Context<Self>) {380
let (Some(occurrence), Some(details)) = (381
self.selected_occurrence(),382
self.recap.details.ready().cloned(),383
) else {384
return;385
};386
let state = self.app.read(cx);387
let (demo, engine) = (state.mode.demo, state.engine.clone());388
if demo {389
self.finish_delete(&occurrence, Ok(()), cx);390
return;391
}392
let Some(engine) = engine else {393
return;394
};395
let receiver = runtime::spawn(async move {396
Recap::new(engine.remote().session())397
.delete_recording(&details)398
.await399
});400
cx.spawn(async move |this, cx| {401
let outcome = match receiver.await {402
Ok(Ok(())) => Ok(()),403
Ok(Err(error)) => Err(short_error(&error)),404
Err(error) => Err(short_error(&error)),405
};406
this.update(cx, |this, cx| this.finish_delete(&occurrence, outcome, cx))407
.ok();408
})409
.detach();410
}411
412
fn finish_delete(413
&mut self,414
occurrence: &Occurrence,415
outcome: Result<(), String>,416
cx: &mut Context<Self>,417
) {418
if let Err(reason) = outcome {419
self.notice = Some(format!("Recording not deleted: {reason}"));420
cx.notify();421
return;422
}423
let remaining: Vec<Occurrence> = self424
.occurrences()425
.iter()426
.filter(|other| other.message_id != occurrence.message_id)427
.cloned()428
.collect();429
let empty = remaining.is_empty();430
self.recap.listing = Load::Ready(remaining);431
if empty {432
self.pane = ChannelPane::Posts;433
cx.notify();434
} else {435
self.select_occurrence(0, cx);436
}437
}438
439
fn pick_save_target(&mut self, download: RecapDownload, cx: &mut Context<Self>) {440
let Some(occurrence) = self.selected_occurrence() else {441
return;442
};443
if matches!(444
self.recap.downloads.get(&download),445
Some(DownloadState::Saving(_))446
) {447
return;448
}449
let extension = match download {450
RecapDownload::Recording => RECORDING_EXTENSION,451
RecapDownload::Transcript(format) => format.query(),452
};453
let name = save_name(&occurrence, extension);454
let receiver = cx.prompt_for_new_path(&downloads::downloads_directory(), Some(&name));455
cx.spawn(async move |this, cx| {456
if let Ok(Ok(Some(target))) = receiver.await {457
this.update(cx, |this, cx| this.save_to(download, occurrence, target, cx))458
.ok();459
}460
})461
.detach();462
}463
464
fn save_to(465
&mut self,466
download: RecapDownload,467
occurrence: Occurrence,468
target: PathBuf,469
cx: &mut Context<Self>,470
) {471
self.recap472
.downloads473
.insert(download, DownloadState::Saving(0));474
cx.notify();475
let generation = self.recap.generation;476
let state = self.app.read(cx);477
let (demo, engine) = (state.mode.demo, state.engine.clone());478
let details = self.recap.details.ready().cloned();479
let (sender, mut receiver) = tokio::sync::mpsc::unbounded_channel::<SaveEvent>();480
if demo {481
let outcome = std::fs::write(&target, demo_recap::DEMO_FILE_BYTES)482
.map(|_| target)483
.map_err(|error| short_error(&error));484
self.recap.downloads.insert(download, finished_state(outcome));485
return;486
}487
let (Some(engine), Some(details)) = (engine, details) else {488
self.recap489
.downloads490
.insert(download, DownloadState::Failed("not connected".to_owned()));491
return;492
};493
drop(runtime::spawn(async move {494
let outcome = save_download(&engine, download, &occurrence, &details, target, &sender)495
.await;496
let _ = sender.send(SaveEvent::Finished(outcome));497
}));498
cx.spawn(async move |this, cx| {499
while let Some(event) = receiver.recv().await {500
let updated = this.update(cx, |this, cx| {501
if generation == this.recap.generation {502
match event {503
SaveEvent::Progress(percent) => {504
this.recap505
.downloads506
.insert(download, DownloadState::Saving(percent));507
}508
SaveEvent::Finished(outcome) => {509
this.recap.downloads.insert(download, finished_state(outcome));510
}511
}512
}513
cx.notify();514
});515
if updated.is_err() {516
return;517
}518
}519
})520
.detach();521
}522
}523
524
fn finished_state(outcome: Result<PathBuf, String>) -> DownloadState {525
match outcome {526
Ok(path) => DownloadState::Saved(path),527
Err(reason) => DownloadState::Failed(reason),528
}529
}530
531
async fn save_download(532
engine: &crate::backend::Engine,533
download: RecapDownload,534
occurrence: &Occurrence,535
details: &RecordingDetails,536
target: PathBuf,537
events: &tokio::sync::mpsc::UnboundedSender<SaveEvent>,538
) -> Result<PathBuf, String> {539
match download {540
RecapDownload::Transcript(format) => {541
let bytes = Recap::new(engine.remote().session())542
.transcript_file(details, format)543
.await544
.map_err(|error| short_error(&error))?;545
std::fs::write(&target, bytes).map_err(|error| short_error(&error))?;546
}547
RecapDownload::Recording => {548
let mut file = std::fs::File::create(&target).map_err(|error| short_error(&error))?;549
let progress = |percent| {550
let _ = events.send(SaveEvent::Progress(percent));551
};552
let result = engine553
.download_file(554
&occurrence.recording_url,555
|bytes: &[u8]| file.write_all(bytes),556
progress,557
)558
.await;559
if let Err(error) = result {560
drop(file);561
let _ = std::fs::remove_file(&target);562
return Err(short_error(&error));563
}564
}565
}566
Ok(target)567
}@@ -41,6 +41,7 @@ pub mod proposal_card;
41
41
pub mod rail;
42
42
pub mod reaction_picker;
43
43
pub mod reaction_pills;
44
pub mod recap_tab;
44
45
pub mod saved_panel;
45
46
pub mod scheduled_toolbar;
46
47
pub mod section_dialog;
@@ -41,6 +41,7 @@ pub mod proposal_card;41
pub mod rail;41
pub mod rail;42
pub mod reaction_picker;42
pub mod reaction_picker;43
pub mod reaction_pills;43
pub mod reaction_pills;44
pub mod recap_tab;44
pub mod saved_panel;45
pub mod saved_panel;45
pub mod scheduled_toolbar;46
pub mod scheduled_toolbar;46
pub mod section_dialog;47
pub mod section_dialog;@@ -0,0 +1,520 @@
1
use std::rc::Rc;
2
3
use chatsvc::{
4
Attendance, AttendanceRecord, Occurrence, RecordingDetails, TranscriptFormat, TranscriptTurn,
5
days_until_expiry,
6
};
7
use chrono::{DateTime, FixedOffset, Local, NaiveDate, Offset as _, Utc};
8
use gpui_kit::assets::IconName;
9
use gpui_kit::component::{
10
button::{Button, ButtonVariants as _},
11
h_flex,
12
input::{Input, InputState},
13
v_flex,
14
};
15
use gpui_kit::prelude::FluentBuilder as _;
16
use gpui_kit::*;
17
18
use super::shared_tab::{SharedRun, download_label, item_row};
19
use super::widgets::icon;
20
use crate::channel_files::SharedItem;
21
use crate::downloads::DownloadState;
22
use crate::recap::{
23
ATTENDANCE_FAILED, ATTENDANCE_OFF, EMPTY_RECAP, Load, NO_TRANSCRIPT, clock_label,
24
expiry_is_urgent, expiry_label, highlight_segments, matching_turns, occurrence_label,
25
span_label, time_label,
26
};
27
use crate::theme;
28
29
const SIDE_PADDING: f32 = 20.;
30
const SECTION_GAP: f32 = 24.;
31
const CARD_WIDTH: f32 = 360.;
32
const CARD_HEIGHT: f32 = 202.;
33
const CARD_RADIUS: f32 = 10.;
34
const PLAY_SIZE: f32 = 52.;
35
const PLAY_GLYPH: f32 = 24.;
36
const SEARCH_WIDTH: f32 = 260.;
37
const TIME_WIDTH: f32 = 48.;
38
const ATTENDANCE_COLUMN: f32 = 90.;
39
const NAME_COLUMN: f32 = 220.;
40
41
pub const RECAP_REGION: &str = "shell/islands/main/recap";
42
43
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
44
pub enum RecapDownload {
45
Recording,
46
Transcript(TranscriptFormat),
47
}
48
49
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
50
pub enum RecapCommand {
51
Occurrence(usize),
52
Play,
53
Download(RecapDownload),
54
AskDelete,
55
Retry,
56
}
57
58
pub type RecapRun = Rc<dyn Fn(RecapCommand, &mut Window, &mut App)>;
59
60
pub struct RecapView<'a> {
61
pub occurrences: &'a [Occurrence],
62
pub selected: usize,
63
pub details: &'a Load<RecordingDetails>,
64
pub transcript: &'a Load<Vec<TranscriptTurn>>,
65
pub attendance: &'a Load<Attendance>,
66
pub search: &'a Entity<InputState>,
67
pub query: &'a str,
68
pub can_delete: bool,
69
pub recording_state: Option<&'a DownloadState>,
70
pub vtt_state: Option<&'a DownloadState>,
71
pub docx_state: Option<&'a DownloadState>,
72
pub files: &'a [SharedItem],
73
pub file_labels: Vec<Option<String>>,
74
pub file_run: SharedRun,
75
pub now: DateTime<Utc>,
76
}
77
78
fn section(title: &'static str) -> Div {
79
v_flex()
80
.w_full()
81
.flex_none()
82
.gap(px(10.))
83
.child(
84
div()
85
.text_size(px(13.))
86
.font_weight(FontWeight::SEMIBOLD)
87
.text_color(theme::text())
88
.child(title),
89
)
90
}
91
92
fn muted(text: impl Into<SharedString>) -> Div {
93
div()
94
.text_size(px(12.5))
95
.text_color(theme::text_muted())
96
.child(text.into())
97
}
98
99
fn action(
100
id: &'static str,
101
label: String,
102
glyph: IconName,
103
command: RecapCommand,
104
run: &RecapRun,
105
) -> Button {
106
let run = run.clone();
107
Button::new(id)
108
.ghost()
109
.compact()
110
.icon(glyph)
111
.label(label)
112
.on_click(move |_, window, cx| run(command, window, cx))
113
}
114
115
fn download_action(
116
id: &'static str,
117
label: &'static str,
118
download: RecapDownload,
119
state: Option<&DownloadState>,
120
run: &RecapRun,
121
) -> Button {
122
let text = download_label(state).map_or_else(
123
|| label.to_owned(),
124
|progress| format!("{label} - {progress}"),
125
);
126
action(
127
id,
128
text,
129
IconName::Download,
130
RecapCommand::Download(download),
131
run,
132
)
133
}
134
135
fn picker(view: &RecapView, offset: FixedOffset, today: NaiveDate, run: &RecapRun) -> Div {
136
h_flex()
137
.w_full()
138
.flex_none()
139
.gap(px(6.))
140
.flex_wrap()
141
.children(view.occurrences.iter().enumerate().map(|(index, occurrence)| {
142
let run = run.clone();
143
let active = index == view.selected;
144
div()
145
.id(ElementId::NamedInteger("recap-occurrence".into(), index as u64))
146
.px(px(12.))
147
.py(px(4.))
148
.rounded_full()
149
.cursor_pointer()
150
.text_size(px(12.))
151
.bg(if active {
152
theme::accent()
153
} else {
154
theme::surface_raised()
155
})
156
.text_color(if active {
157
theme::on_accent()
158
} else {
159
theme::text_soft()
160
})
161
.on_click(move |_, window, cx| {
162
run(RecapCommand::Occurrence(index), window, cx)
163
})
164
.child(occurrence_label(occurrence, today, offset))
165
}))
166
}
167
168
fn recording_card(details: &RecordingDetails) -> Div {
169
let labels = h_flex()
170
.absolute()
171
.left(px(12.))
172
.right(px(12.))
173
.bottom(px(10.))
174
.justify_between()
175
.text_size(px(12.))
176
.text_color(gpui_kit::white())
177
.child(div().child(
178
details
179
.duration_seconds
180
.map(clock_label)
181
.unwrap_or_default(),
182
))
183
.when(details.audio_only, |row| row.child(div().child("Audio only")));
184
div()
185
.relative()
186
.w(px(CARD_WIDTH))
187
.h(px(CARD_HEIGHT))
188
.flex_none()
189
.flex()
190
.items_center()
191
.justify_center()
192
.rounded(px(CARD_RADIUS))
193
.bg(hsla(0., 0., 0.07, 1.))
194
.child(
195
div()
196
.size(px(PLAY_SIZE))
197
.flex()
198
.items_center()
199
.justify_center()
200
.rounded_full()
201
.bg(gpui_kit::white().opacity(0.18))
202
.child(icon(IconName::Play, PLAY_GLYPH, gpui_kit::white())),
203
)
204
.child(labels)
205
}
206
207
fn recording_section(view: &RecapView, run: &RecapRun) -> Div {
208
let body = match view.details {
209
Load::Loading => muted("Loading recording ..").into_any_element(),
210
Load::Failed(reason) => failure(format!("Recording not available: {reason}"), run),
211
Load::Ready(details) => {
212
let days = details
213
.expires_at
214
.map(|expires_at| days_until_expiry(expires_at, view.now));
215
let expiry = days.map(|days| {
216
div()
217
.text_size(px(12.))
218
.text_color(if expiry_is_urgent(days) {
219
theme::amber()
220
} else {
221
theme::text_muted()
222
})
223
.child(expiry_label(days))
224
});
225
h_flex()
226
.gap(px(16.))
227
.items_start()
228
.child(recording_card(details))
229
.child(
230
v_flex()
231
.gap(px(8.))
232
.items_start()
233
.children(expiry)
234
.child(action(
235
"recap-play",
236
"Play".to_owned(),
237
IconName::Play,
238
RecapCommand::Play,
239
run,
240
))
241
.child(download_action(
242
"recap-download",
243
"Download",
244
RecapDownload::Recording,
245
view.recording_state,
246
run,
247
))
248
.when(view.can_delete, |column| {
249
column.child(
250
action(
251
"recap-delete",
252
"Delete".to_owned(),
253
IconName::Trash,
254
RecapCommand::AskDelete,
255
run,
256
)
257
.danger(),
258
)
259
}),
260
)
261
.into_any_element()
262
}
263
};
264
section("Recording").child(body)
265
}
266
267
fn failure(reason: String, run: &RecapRun) -> AnyElement {
268
let run = run.clone();
269
h_flex()
270
.gap(px(8.))
271
.items_center()
272
.child(muted(reason))
273
.child(
274
Button::new("recap-retry")
275
.ghost()
276
.compact()
277
.label("Retry")
278
.on_click(move |_, window, cx| run(RecapCommand::Retry, window, cx)),
279
)
280
.into_any_element()
281
}
282
283
fn highlighted(text: &str, query: &str) -> StyledText {
284
let mut start = 0;
285
let mut ranges = Vec::new();
286
for (segment, hit) in highlight_segments(text, query) {
287
let end = start + segment.len();
288
if hit {
289
ranges.push((
290
start..end,
291
HighlightStyle {
292
background_color: Some(theme::amber().opacity(0.35)),
293
..HighlightStyle::default()
294
},
295
));
296
}
297
start = end;
298
}
299
StyledText::new(text.to_owned()).with_highlights(ranges)
300
}
301
302
fn turn_row(turn: &TranscriptTurn, query: &str) -> Div {
303
h_flex()
304
.w_full()
305
.flex_none()
306
.gap(px(12.))
307
.items_start()
308
.text_size(px(13.))
309
.child(
310
div()
311
.w(px(TIME_WIDTH))
312
.flex_none()
313
.text_size(px(12.))
314
.text_color(theme::text_faint())
315
.child(clock_label(turn.start_seconds as u64)),
316
)
317
.child(
318
v_flex()
319
.flex_1()
320
.min_w_0()
321
.gap(px(2.))
322
.child(
323
div()
324
.font_weight(FontWeight::BOLD)
325
.text_color(theme::text())
326
.child(highlighted(&turn.speaker, query)),
327
)
328
.child(
329
div()
330
.text_color(theme::text_soft())
331
.child(highlighted(&turn.text, query)),
332
),
333
)
334
}
335
336
fn transcript_section(view: &RecapView, run: &RecapRun) -> Div {
337
let downloads = h_flex()
338
.gap(px(4.))
339
.child(download_action(
340
"recap-vtt",
341
"Download .vtt",
342
RecapDownload::Transcript(TranscriptFormat::Vtt),
343
view.vtt_state,
344
run,
345
))
346
.child(download_action(
347
"recap-docx",
348
"Download .docx",
349
RecapDownload::Transcript(TranscriptFormat::Docx),
350
view.docx_state,
351
run,
352
));
353
let body = match view.transcript {
354
Load::Loading => muted("Loading transcript ..").into_any_element(),
355
Load::Failed(reason) => failure(format!("Transcript not available: {reason}"), run),
356
Load::Ready(turns) if turns.is_empty() => muted(NO_TRANSCRIPT).into_any_element(),
357
Load::Ready(turns) => {
358
let matches = matching_turns(turns, view.query);
359
let list = if matches.is_empty() {
360
muted("No lines match.").into_any_element()
361
} else {
362
v_flex()
363
.w_full()
364
.gap(px(10.))
365
.children(
366
matches
367
.into_iter()
368
.map(|index| turn_row(&turns[index], view.query)),
369
)
370
.into_any_element()
371
};
372
v_flex()
373
.w_full()
374
.gap(px(12.))
375
.child(
376
h_flex()
377
.w(px(SEARCH_WIDTH))
378
.h(px(30.))
379
.px(px(8.))
380
.gap(px(6.))
381
.items_center()
382
.rounded(px(8.))
383
.bg(theme::surface_raised())
384
.child(icon(IconName::Search, 14., theme::text_muted()))
385
.child(Input::new(view.search).appearance(false).bordered(false)),
386
)
387
.child(list)
388
.into_any_element()
389
}
390
};
391
section("Transcript")
392
.child(downloads)
393
.child(body)
394
}
395
396
fn attendance_row(record: &AttendanceRecord, offset: FixedOffset) -> Div {
397
let cell = |text: String, width: f32| {
398
div()
399
.w(px(width))
400
.flex_none()
401
.truncate()
402
.text_color(theme::text_muted())
403
.child(text)
404
};
405
h_flex()
406
.w_full()
407
.flex_none()
408
.gap(px(12.))
409
.text_size(px(12.5))
410
.child(
411
div()
412
.w(px(NAME_COLUMN))
413
.flex_none()
414
.truncate()
415
.text_color(theme::text())
416
.child(record.name.clone()),
417
)
418
.child(cell(time_label(record.joined_at, offset), ATTENDANCE_COLUMN))
419
.child(cell(time_label(record.left_at, offset), ATTENDANCE_COLUMN))
420
.child(cell(span_label(record.duration_seconds), ATTENDANCE_COLUMN))
421
}
422
423
fn attendance_header() -> Div {
424
let cell = |text: &'static str, width: f32| div().w(px(width)).flex_none().child(text);
425
h_flex()
426
.w_full()
427
.flex_none()
428
.gap(px(12.))
429
.text_size(px(11.5))
430
.text_color(theme::text_faint())
431
.child(cell("Name", NAME_COLUMN))
432
.child(cell("Joined", ATTENDANCE_COLUMN))
433
.child(cell("Left", ATTENDANCE_COLUMN))
434
.child(cell("Duration", ATTENDANCE_COLUMN))
435
}
436
437
fn attendance_section(view: &RecapView, offset: FixedOffset) -> Div {
438
let body = match view.attendance {
439
Load::Loading => muted("Loading attendance ..").into_any_element(),
440
Load::Failed(_) => muted(ATTENDANCE_FAILED).into_any_element(),
441
Load::Ready(Attendance::TurnedOff) => muted(ATTENDANCE_OFF).into_any_element(),
442
Load::Ready(Attendance::Report(records)) if records.is_empty() => {
443
muted("No attendees recorded.").into_any_element()
444
}
445
Load::Ready(Attendance::Report(records)) => v_flex()
446
.w_full()
447
.gap(px(6.))
448
.child(attendance_header())
449
.children(records.iter().map(|record| attendance_row(record, offset)))
450
.into_any_element(),
451
};
452
section("Attendance").child(body)
453
}
454
455
fn files_section(view: &RecapView) -> Option<Div> {
456
(!view.files.is_empty()).then(|| {
457
v_flex()
458
.w_full()
459
.flex_none()
460
.gap(px(10.))
461
.child(
462
div()
463
.px(px(SIDE_PADDING))
464
.text_size(px(13.))
465
.font_weight(FontWeight::SEMIBOLD)
466
.text_color(theme::text())
467
.child("Files"),
468
)
469
.children(view.files.iter().enumerate().map(|(index, item)| {
470
let label = view.file_labels.get(index).cloned().flatten();
471
item_row(index, item, label, &view.file_run)
472
}))
473
})
474
}
475
476
pub fn render_recap(view: RecapView, run: &RecapRun) -> AnyElement {
477
let now_local = Local::now();
478
let (offset, today) = (now_local.offset().fix(), now_local.date_naive());
479
let body = if view.occurrences.is_empty() && view.files.is_empty() {
480
div()
481
.w_full()
482
.flex_1()
483
.flex()
484
.items_center()
485
.justify_center()
486
.text_size(px(13.))
487
.text_color(theme::text_muted())
488
.child(EMPTY_RECAP)
489
.into_any_element()
490
} else {
491
v_flex()
492
.id("recap-scroll")
493
.w_full()
494
.flex_1()
495
.min_h_0()
496
.overflow_y_scroll()
497
.py(px(16.))
498
.gap(px(SECTION_GAP))
499
.when(!view.occurrences.is_empty(), |column| {
500
column.child(
501
v_flex()
502
.w_full()
503
.flex_none()
504
.px(px(SIDE_PADDING))
505
.gap(px(SECTION_GAP))
506
.child(picker(&view, offset, today, run))
507
.child(recording_section(&view, run))
508
.child(transcript_section(&view, run))
509
.child(attendance_section(&view, offset)),
510
)
511
})
512
.children(files_section(&view))
513
.into_any_element()
514
};
515
v_flex()
516
.size_full()
517
.debug_selector(|| RECAP_REGION.into())
518
.child(body)
519
.into_any_element()
520
}
@@ -0,0 +1,520 @@1
use std::rc::Rc;2
3
use chatsvc::{4
Attendance, AttendanceRecord, Occurrence, RecordingDetails, TranscriptFormat, TranscriptTurn,5
days_until_expiry,6
};7
use chrono::{DateTime, FixedOffset, Local, NaiveDate, Offset as _, Utc};8
use gpui_kit::assets::IconName;9
use gpui_kit::component::{10
button::{Button, ButtonVariants as _},11
h_flex,12
input::{Input, InputState},13
v_flex,14
};15
use gpui_kit::prelude::FluentBuilder as _;16
use gpui_kit::*;17
18
use super::shared_tab::{SharedRun, download_label, item_row};19
use super::widgets::icon;20
use crate::channel_files::SharedItem;21
use crate::downloads::DownloadState;22
use crate::recap::{23
ATTENDANCE_FAILED, ATTENDANCE_OFF, EMPTY_RECAP, Load, NO_TRANSCRIPT, clock_label,24
expiry_is_urgent, expiry_label, highlight_segments, matching_turns, occurrence_label,25
span_label, time_label,26
};27
use crate::theme;28
29
const SIDE_PADDING: f32 = 20.;30
const SECTION_GAP: f32 = 24.;31
const CARD_WIDTH: f32 = 360.;32
const CARD_HEIGHT: f32 = 202.;33
const CARD_RADIUS: f32 = 10.;34
const PLAY_SIZE: f32 = 52.;35
const PLAY_GLYPH: f32 = 24.;36
const SEARCH_WIDTH: f32 = 260.;37
const TIME_WIDTH: f32 = 48.;38
const ATTENDANCE_COLUMN: f32 = 90.;39
const NAME_COLUMN: f32 = 220.;40
41
pub const RECAP_REGION: &str = "shell/islands/main/recap";42
43
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]44
pub enum RecapDownload {45
Recording,46
Transcript(TranscriptFormat),47
}48
49
#[derive(Debug, Clone, Copy, PartialEq, Eq)]50
pub enum RecapCommand {51
Occurrence(usize),52
Play,53
Download(RecapDownload),54
AskDelete,55
Retry,56
}57
58
pub type RecapRun = Rc<dyn Fn(RecapCommand, &mut Window, &mut App)>;59
60
pub struct RecapView<'a> {61
pub occurrences: &'a [Occurrence],62
pub selected: usize,63
pub details: &'a Load<RecordingDetails>,64
pub transcript: &'a Load<Vec<TranscriptTurn>>,65
pub attendance: &'a Load<Attendance>,66
pub search: &'a Entity<InputState>,67
pub query: &'a str,68
pub can_delete: bool,69
pub recording_state: Option<&'a DownloadState>,70
pub vtt_state: Option<&'a DownloadState>,71
pub docx_state: Option<&'a DownloadState>,72
pub files: &'a [SharedItem],73
pub file_labels: Vec<Option<String>>,74
pub file_run: SharedRun,75
pub now: DateTime<Utc>,76
}77
78
fn section(title: &'static str) -> Div {79
v_flex()80
.w_full()81
.flex_none()82
.gap(px(10.))83
.child(84
div()85
.text_size(px(13.))86
.font_weight(FontWeight::SEMIBOLD)87
.text_color(theme::text())88
.child(title),89
)90
}91
92
fn muted(text: impl Into<SharedString>) -> Div {93
div()94
.text_size(px(12.5))95
.text_color(theme::text_muted())96
.child(text.into())97
}98
99
fn action(100
id: &'static str,101
label: String,102
glyph: IconName,103
command: RecapCommand,104
run: &RecapRun,105
) -> Button {106
let run = run.clone();107
Button::new(id)108
.ghost()109
.compact()110
.icon(glyph)111
.label(label)112
.on_click(move |_, window, cx| run(command, window, cx))113
}114
115
fn download_action(116
id: &'static str,117
label: &'static str,118
download: RecapDownload,119
state: Option<&DownloadState>,120
run: &RecapRun,121
) -> Button {122
let text = download_label(state).map_or_else(123
|| label.to_owned(),124
|progress| format!("{label} - {progress}"),125
);126
action(127
id,128
text,129
IconName::Download,130
RecapCommand::Download(download),131
run,132
)133
}134
135
fn picker(view: &RecapView, offset: FixedOffset, today: NaiveDate, run: &RecapRun) -> Div {136
h_flex()137
.w_full()138
.flex_none()139
.gap(px(6.))140
.flex_wrap()141
.children(view.occurrences.iter().enumerate().map(|(index, occurrence)| {142
let run = run.clone();143
let active = index == view.selected;144
div()145
.id(ElementId::NamedInteger("recap-occurrence".into(), index as u64))146
.px(px(12.))147
.py(px(4.))148
.rounded_full()149
.cursor_pointer()150
.text_size(px(12.))151
.bg(if active {152
theme::accent()153
} else {154
theme::surface_raised()155
})156
.text_color(if active {157
theme::on_accent()158
} else {159
theme::text_soft()160
})161
.on_click(move |_, window, cx| {162
run(RecapCommand::Occurrence(index), window, cx)163
})164
.child(occurrence_label(occurrence, today, offset))165
}))166
}167
168
fn recording_card(details: &RecordingDetails) -> Div {169
let labels = h_flex()170
.absolute()171
.left(px(12.))172
.right(px(12.))173
.bottom(px(10.))174
.justify_between()175
.text_size(px(12.))176
.text_color(gpui_kit::white())177
.child(div().child(178
details179
.duration_seconds180
.map(clock_label)181
.unwrap_or_default(),182
))183
.when(details.audio_only, |row| row.child(div().child("Audio only")));184
div()185
.relative()186
.w(px(CARD_WIDTH))187
.h(px(CARD_HEIGHT))188
.flex_none()189
.flex()190
.items_center()191
.justify_center()192
.rounded(px(CARD_RADIUS))193
.bg(hsla(0., 0., 0.07, 1.))194
.child(195
div()196
.size(px(PLAY_SIZE))197
.flex()198
.items_center()199
.justify_center()200
.rounded_full()201
.bg(gpui_kit::white().opacity(0.18))202
.child(icon(IconName::Play, PLAY_GLYPH, gpui_kit::white())),203
)204
.child(labels)205
}206
207
fn recording_section(view: &RecapView, run: &RecapRun) -> Div {208
let body = match view.details {209
Load::Loading => muted("Loading recording ..").into_any_element(),210
Load::Failed(reason) => failure(format!("Recording not available: {reason}"), run),211
Load::Ready(details) => {212
let days = details213
.expires_at214
.map(|expires_at| days_until_expiry(expires_at, view.now));215
let expiry = days.map(|days| {216
div()217
.text_size(px(12.))218
.text_color(if expiry_is_urgent(days) {219
theme::amber()220
} else {221
theme::text_muted()222
})223
.child(expiry_label(days))224
});225
h_flex()226
.gap(px(16.))227
.items_start()228
.child(recording_card(details))229
.child(230
v_flex()231
.gap(px(8.))232
.items_start()233
.children(expiry)234
.child(action(235
"recap-play",236
"Play".to_owned(),237
IconName::Play,238
RecapCommand::Play,239
run,240
))241
.child(download_action(242
"recap-download",243
"Download",244
RecapDownload::Recording,245
view.recording_state,246
run,247
))248
.when(view.can_delete, |column| {249
column.child(250
action(251
"recap-delete",252
"Delete".to_owned(),253
IconName::Trash,254
RecapCommand::AskDelete,255
run,256
)257
.danger(),258
)259
}),260
)261
.into_any_element()262
}263
};264
section("Recording").child(body)265
}266
267
fn failure(reason: String, run: &RecapRun) -> AnyElement {268
let run = run.clone();269
h_flex()270
.gap(px(8.))271
.items_center()272
.child(muted(reason))273
.child(274
Button::new("recap-retry")275
.ghost()276
.compact()277
.label("Retry")278
.on_click(move |_, window, cx| run(RecapCommand::Retry, window, cx)),279
)280
.into_any_element()281
}282
283
fn highlighted(text: &str, query: &str) -> StyledText {284
let mut start = 0;285
let mut ranges = Vec::new();286
for (segment, hit) in highlight_segments(text, query) {287
let end = start + segment.len();288
if hit {289
ranges.push((290
start..end,291
HighlightStyle {292
background_color: Some(theme::amber().opacity(0.35)),293
..HighlightStyle::default()294
},295
));296
}297
start = end;298
}299
StyledText::new(text.to_owned()).with_highlights(ranges)300
}301
302
fn turn_row(turn: &TranscriptTurn, query: &str) -> Div {303
h_flex()304
.w_full()305
.flex_none()306
.gap(px(12.))307
.items_start()308
.text_size(px(13.))309
.child(310
div()311
.w(px(TIME_WIDTH))312
.flex_none()313
.text_size(px(12.))314
.text_color(theme::text_faint())315
.child(clock_label(turn.start_seconds as u64)),316
)317
.child(318
v_flex()319
.flex_1()320
.min_w_0()321
.gap(px(2.))322
.child(323
div()324
.font_weight(FontWeight::BOLD)325
.text_color(theme::text())326
.child(highlighted(&turn.speaker, query)),327
)328
.child(329
div()330
.text_color(theme::text_soft())331
.child(highlighted(&turn.text, query)),332
),333
)334
}335
336
fn transcript_section(view: &RecapView, run: &RecapRun) -> Div {337
let downloads = h_flex()338
.gap(px(4.))339
.child(download_action(340
"recap-vtt",341
"Download .vtt",342
RecapDownload::Transcript(TranscriptFormat::Vtt),343
view.vtt_state,344
run,345
))346
.child(download_action(347
"recap-docx",348
"Download .docx",349
RecapDownload::Transcript(TranscriptFormat::Docx),350
view.docx_state,351
run,352
));353
let body = match view.transcript {354
Load::Loading => muted("Loading transcript ..").into_any_element(),355
Load::Failed(reason) => failure(format!("Transcript not available: {reason}"), run),356
Load::Ready(turns) if turns.is_empty() => muted(NO_TRANSCRIPT).into_any_element(),357
Load::Ready(turns) => {358
let matches = matching_turns(turns, view.query);359
let list = if matches.is_empty() {360
muted("No lines match.").into_any_element()361
} else {362
v_flex()363
.w_full()364
.gap(px(10.))365
.children(366
matches367
.into_iter()368
.map(|index| turn_row(&turns[index], view.query)),369
)370
.into_any_element()371
};372
v_flex()373
.w_full()374
.gap(px(12.))375
.child(376
h_flex()377
.w(px(SEARCH_WIDTH))378
.h(px(30.))379
.px(px(8.))380
.gap(px(6.))381
.items_center()382
.rounded(px(8.))383
.bg(theme::surface_raised())384
.child(icon(IconName::Search, 14., theme::text_muted()))385
.child(Input::new(view.search).appearance(false).bordered(false)),386
)387
.child(list)388
.into_any_element()389
}390
};391
section("Transcript")392
.child(downloads)393
.child(body)394
}395
396
fn attendance_row(record: &AttendanceRecord, offset: FixedOffset) -> Div {397
let cell = |text: String, width: f32| {398
div()399
.w(px(width))400
.flex_none()401
.truncate()402
.text_color(theme::text_muted())403
.child(text)404
};405
h_flex()406
.w_full()407
.flex_none()408
.gap(px(12.))409
.text_size(px(12.5))410
.child(411
div()412
.w(px(NAME_COLUMN))413
.flex_none()414
.truncate()415
.text_color(theme::text())416
.child(record.name.clone()),417
)418
.child(cell(time_label(record.joined_at, offset), ATTENDANCE_COLUMN))419
.child(cell(time_label(record.left_at, offset), ATTENDANCE_COLUMN))420
.child(cell(span_label(record.duration_seconds), ATTENDANCE_COLUMN))421
}422
423
fn attendance_header() -> Div {424
let cell = |text: &'static str, width: f32| div().w(px(width)).flex_none().child(text);425
h_flex()426
.w_full()427
.flex_none()428
.gap(px(12.))429
.text_size(px(11.5))430
.text_color(theme::text_faint())431
.child(cell("Name", NAME_COLUMN))432
.child(cell("Joined", ATTENDANCE_COLUMN))433
.child(cell("Left", ATTENDANCE_COLUMN))434
.child(cell("Duration", ATTENDANCE_COLUMN))435
}436
437
fn attendance_section(view: &RecapView, offset: FixedOffset) -> Div {438
let body = match view.attendance {439
Load::Loading => muted("Loading attendance ..").into_any_element(),440
Load::Failed(_) => muted(ATTENDANCE_FAILED).into_any_element(),441
Load::Ready(Attendance::TurnedOff) => muted(ATTENDANCE_OFF).into_any_element(),442
Load::Ready(Attendance::Report(records)) if records.is_empty() => {443
muted("No attendees recorded.").into_any_element()444
}445
Load::Ready(Attendance::Report(records)) => v_flex()446
.w_full()447
.gap(px(6.))448
.child(attendance_header())449
.children(records.iter().map(|record| attendance_row(record, offset)))450
.into_any_element(),451
};452
section("Attendance").child(body)453
}454
455
fn files_section(view: &RecapView) -> Option<Div> {456
(!view.files.is_empty()).then(|| {457
v_flex()458
.w_full()459
.flex_none()460
.gap(px(10.))461
.child(462
div()463
.px(px(SIDE_PADDING))464
.text_size(px(13.))465
.font_weight(FontWeight::SEMIBOLD)466
.text_color(theme::text())467
.child("Files"),468
)469
.children(view.files.iter().enumerate().map(|(index, item)| {470
let label = view.file_labels.get(index).cloned().flatten();471
item_row(index, item, label, &view.file_run)472
}))473
})474
}475
476
pub fn render_recap(view: RecapView, run: &RecapRun) -> AnyElement {477
let now_local = Local::now();478
let (offset, today) = (now_local.offset().fix(), now_local.date_naive());479
let body = if view.occurrences.is_empty() && view.files.is_empty() {480
div()481
.w_full()482
.flex_1()483
.flex()484
.items_center()485
.justify_center()486
.text_size(px(13.))487
.text_color(theme::text_muted())488
.child(EMPTY_RECAP)489
.into_any_element()490
} else {491
v_flex()492
.id("recap-scroll")493
.w_full()494
.flex_1()495
.min_h_0()496
.overflow_y_scroll()497
.py(px(16.))498
.gap(px(SECTION_GAP))499
.when(!view.occurrences.is_empty(), |column| {500
column.child(501
v_flex()502
.w_full()503
.flex_none()504
.px(px(SIDE_PADDING))505
.gap(px(SECTION_GAP))506
.child(picker(&view, offset, today, run))507
.child(recording_section(&view, run))508
.child(transcript_section(&view, run))509
.child(attendance_section(&view, offset)),510
)511
})512
.children(files_section(&view))513
.into_any_element()514
};515
v_flex()516
.size_full()517
.debug_selector(|| RECAP_REGION.into())518
.child(body)519
.into_any_element()520
}@@ -14,6 +14,7 @@ pub mod messages;
14
14
pub mod pins;
15
15
pub mod presence;
16
16
pub mod reactions;
17
pub mod recap;
17
18
pub mod realtime;
18
19
pub mod receipts;
19
20
pub mod saved;
@@ -56,6 +57,10 @@ pub use realtime::{
56
57
pub use receipts::{MemberHorizon, Receipts};
57
58
pub use saved::SavedMessage;
58
59
pub use settings::{ChatSection, ChatSectionSettings, UserSettings};
60
pub use recap::{
61
Attendance, AttendanceRecord, Occurrence, Recap, RecordingDetails, TranscriptFormat,
62
days_until_expiry,
63
};
59
64
pub use transcripts::{MeetingTranscript, TranscriptError, TranscriptTurn, Transcripts};
60
65
pub use translate::{
61
66
Language, MAX_TRANSLATE_BATCH, MessageLanguage, TranslateRequest, Translation,
@@ -14,6 +14,7 @@ pub mod messages;14
pub mod pins;14
pub mod pins;15
pub mod presence;15
pub mod presence;16
pub mod reactions;16
pub mod reactions;17
pub mod recap;17
pub mod realtime;18
pub mod realtime;18
pub mod receipts;19
pub mod receipts;19
pub mod saved;20
pub mod saved;@@ -56,6 +57,10 @@ pub use realtime::{56
pub use receipts::{MemberHorizon, Receipts};57
pub use receipts::{MemberHorizon, Receipts};57
pub use saved::SavedMessage;58
pub use saved::SavedMessage;58
pub use settings::{ChatSection, ChatSectionSettings, UserSettings};59
pub use settings::{ChatSection, ChatSectionSettings, UserSettings};60
pub use recap::{61
Attendance, AttendanceRecord, Occurrence, Recap, RecordingDetails, TranscriptFormat,62
days_until_expiry,63
};59
pub use transcripts::{MeetingTranscript, TranscriptError, TranscriptTurn, Transcripts};64
pub use transcripts::{MeetingTranscript, TranscriptError, TranscriptTurn, Transcripts};60
pub use translate::{65
pub use translate::{61
Language, MAX_TRANSLATE_BATCH, MessageLanguage, TranslateRequest, Translation,66
Language, MAX_TRANSLATE_BATCH, MessageLanguage, TranslateRequest, Translation,@@ -0,0 +1,554 @@
1
use base64::Engine as _;
2
use base64::engine::general_purpose::STANDARD;
3
use chrono::{DateTime, Utc};
4
use serde_json::Value;
5
use session::{Method, Request, Scope, Session};
6
7
use crate::messages::encode;
8
use crate::transcripts::{
9
TranscriptError, TranscriptTurn, Transcripts, newest_transcript, parse_transcript_list,
10
parse_turns, share_id, site_origin,
11
};
12
13
const RECORDING_EVENT: &str = "#microsoft.graph.callRecordingEventMessageDetail";
14
const RECORDING_SUCCESS: &str = "success";
15
const MESSAGES_SCOPE: &str = "Chat.Read";
16
const SITE_SCOPE: &str = ".default";
17
const ATTENDANCE_SCOPE: &str = "OnlineMeetingArtifact.Read.All";
18
const MAX_MESSAGE_PAGES: usize = 40;
19
20
#[derive(Debug, Clone, PartialEq, Eq)]
21
pub struct Occurrence {
22
pub message_id: String,
23
pub started_at: Option<DateTime<Utc>>,
24
pub recording_url: String,
25
pub recording_name: Option<String>,
26
pub duration_seconds: Option<u64>,
27
pub organizer_id: Option<String>,
28
}
29
30
#[derive(Debug, Clone, PartialEq, Eq)]
31
pub struct RecordingDetails {
32
pub item_url: String,
33
pub audio_only: bool,
34
pub duration_seconds: Option<u64>,
35
pub expires_at: Option<DateTime<Utc>>,
36
pub transcript_id: Option<String>,
37
}
38
39
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
40
pub enum TranscriptFormat {
41
Vtt,
42
Docx,
43
}
44
45
impl TranscriptFormat {
46
pub fn query(self) -> &'static str {
47
match self {
48
TranscriptFormat::Vtt => "vtt",
49
TranscriptFormat::Docx => "docx",
50
}
51
}
52
}
53
54
#[derive(Debug, Clone, PartialEq, Eq)]
55
pub struct AttendanceRecord {
56
pub name: String,
57
pub joined_at: Option<DateTime<Utc>>,
58
pub left_at: Option<DateTime<Utc>>,
59
pub duration_seconds: u64,
60
}
61
62
#[derive(Debug, Clone, PartialEq, Eq)]
63
pub enum Attendance {
64
TurnedOff,
65
Report(Vec<AttendanceRecord>),
66
}
67
68
pub struct Recap<'a> {
69
session: &'a Session,
70
transcripts: Transcripts<'a>,
71
}
72
73
impl<'a> Recap<'a> {
74
pub fn new(session: &'a Session) -> Self {
75
Recap {
76
session,
77
transcripts: Transcripts::new(session),
78
}
79
}
80
81
pub async fn occurrences(&self, thread_id: &str) -> Result<Vec<Occurrence>, TranscriptError> {
82
let scope = Scope::graph(MESSAGES_SCOPE);
83
let mut url = format!(
84
"{}/v1.0/chats/{}/messages?$top=50&$orderby=createdDateTime desc",
85
session::GRAPH,
86
encode(thread_id)
87
);
88
let mut found = Vec::new();
89
for _ in 0..MAX_MESSAGE_PAGES {
90
let page = self
91
.transcripts
92
.get(&url, &scope, TranscriptError::NoRecording)
93
.await?;
94
found.extend(parse_occurrences(&page));
95
match page.get("@odata.nextLink").and_then(Value::as_str) {
96
Some(next) => url = next.to_owned(),
97
None => break,
98
}
99
}
100
Ok(sorted_occurrences(found))
101
}
102
103
pub async fn details(
104
&self,
105
occurrence: &Occurrence,
106
) -> Result<RecordingDetails, TranscriptError> {
107
let site = site_origin(&occurrence.recording_url);
108
let site_scope = Scope::new(site.clone(), SITE_SCOPE);
109
let item = self
110
.transcripts
111
.get(
112
&format!(
113
"{site}/_api/v2.1/shares/{}/driveItem?$select=id,parentReference,video,file",
114
share_id(&occurrence.recording_url)
115
),
116
&site_scope,
117
TranscriptError::NoRecording,
118
)
119
.await?;
120
let item_url = item_url(&site, &item).ok_or(TranscriptError::NoRecording)?;
121
let expiration = self
122
.transcripts
123
.get(
124
&format!("{item_url}/listItem?$expand=fields($select=_ExpirationDate)"),
125
&site_scope,
126
TranscriptError::NoRecording,
127
)
128
.await
129
.ok();
130
let listing = self
131
.transcripts
132
.get(
133
&format!("{item_url}/media/transcripts"),
134
&site_scope,
135
TranscriptError::NoTranscript,
136
)
137
.await
138
.ok();
139
Ok(RecordingDetails {
140
audio_only: is_audio_only(&item),
141
duration_seconds: item_duration_seconds(&item).or(occurrence.duration_seconds),
142
expires_at: expiration.as_ref().and_then(parse_expiration),
143
transcript_id: listing
144
.as_ref()
145
.and_then(|listing| newest_transcript(parse_transcript_list(listing)))
146
.map(|transcript| transcript.id),
147
item_url,
148
})
149
}
150
151
pub async fn transcript(
152
&self,
153
details: &RecordingDetails,
154
) -> Result<Vec<TranscriptTurn>, TranscriptError> {
155
let transcript_id = details
156
.transcript_id
157
.as_deref()
158
.ok_or(TranscriptError::NoTranscript)?;
159
let site_scope = Scope::new(site_origin(&details.item_url), SITE_SCOPE);
160
let content = self
161
.transcripts
162
.get(
163
&transcript_url(&details.item_url, transcript_id, "json"),
164
&site_scope,
165
TranscriptError::NoTranscript,
166
)
167
.await?;
168
Ok(parse_turns(&content))
169
}
170
171
pub async fn transcript_file(
172
&self,
173
details: &RecordingDetails,
174
format: TranscriptFormat,
175
) -> Result<Vec<u8>, TranscriptError> {
176
let transcript_id = details
177
.transcript_id
178
.as_deref()
179
.ok_or(TranscriptError::NoTranscript)?;
180
let site_scope = Scope::new(site_origin(&details.item_url), SITE_SCOPE);
181
let request = Request::binary_get(transcript_url(
182
&details.item_url,
183
transcript_id,
184
format.query(),
185
));
186
let answer = self
187
.session
188
.send(request, &site_scope)
189
.await
190
.map_err(request_failure)?;
191
decode_binary(&answer.body).ok_or(TranscriptError::NoTranscript)
192
}
193
194
pub async fn delete_recording(
195
&self,
196
details: &RecordingDetails,
197
) -> Result<(), TranscriptError> {
198
let site_scope = Scope::new(site_origin(&details.item_url), SITE_SCOPE);
199
self.session
200
.request(Method::Delete, &details.item_url, &site_scope, None)
201
.await
202
.map(|_| ())
203
.map_err(request_failure)
204
}
205
206
pub async fn attendance(&self, thread_id: &str) -> Result<Attendance, TranscriptError> {
207
let graph_scope = Scope::graph(MESSAGES_SCOPE);
208
let chat = match self
209
.transcripts
210
.get(
211
&format!(
212
"{}/v1.0/chats/{}?$select=onlineMeetingInfo",
213
session::GRAPH,
214
encode(thread_id)
215
),
216
&graph_scope,
217
TranscriptError::NoRecording,
218
)
219
.await
220
{
221
Ok(chat) => chat,
222
Err(TranscriptError::NoRecording | TranscriptError::AccessDenied) => {
223
return Ok(Attendance::TurnedOff);
224
}
225
Err(error) => return Err(error),
226
};
227
let Some(join_url) = chat
228
.pointer("/onlineMeetingInfo/joinWebUrl")
229
.and_then(Value::as_str)
230
else {
231
return Ok(Attendance::TurnedOff);
232
};
233
let scope = Scope::graph(ATTENDANCE_SCOPE);
234
let lookup = format!(
235
"{}/v1.0/me/onlineMeetings?$filter=JoinWebUrl eq '{}'&$select=id",
236
session::GRAPH,
237
join_url.replace('\'', "''")
238
);
239
let meeting_id = match self
240
.transcripts
241
.get(&lookup, &scope, TranscriptError::NoRecording)
242
.await
243
{
244
Ok(found) => found
245
.pointer("/value/0/id")
246
.and_then(Value::as_str)
247
.map(str::to_owned),
248
Err(TranscriptError::NoRecording | TranscriptError::AccessDenied) => None,
249
Err(error) => return Err(error),
250
};
251
let Some(meeting_id) = meeting_id else {
252
return Ok(Attendance::TurnedOff);
253
};
254
let reports_url = format!(
255
"{}/v1.0/me/onlineMeetings/{}/attendanceReports",
256
session::GRAPH,
257
encode(&meeting_id)
258
);
259
let reports = match self
260
.transcripts
261
.get(&reports_url, &scope, TranscriptError::NoRecording)
262
.await
263
{
264
Ok(reports) => reports,
265
Err(TranscriptError::NoRecording | TranscriptError::AccessDenied) => {
266
return Ok(Attendance::TurnedOff);
267
}
268
Err(error) => return Err(error),
269
};
270
let Some(report_id) = reports
271
.pointer("/value/0/id")
272
.and_then(Value::as_str)
273
else {
274
return Ok(Attendance::TurnedOff);
275
};
276
let report = self
277
.transcripts
278
.get(
279
&format!(
280
"{reports_url}/{}?$expand=attendanceRecords",
281
encode(report_id)
282
),
283
&scope,
284
TranscriptError::NoRecording,
285
)
286
.await?;
287
Ok(Attendance::Report(parse_attendance(&report)))
288
}
289
}
290
291
fn request_failure(error: session::Error) -> TranscriptError {
292
match error {
293
session::Error::Api {
294
status: 403 | 401, ..
295
} => TranscriptError::AccessDenied,
296
error => TranscriptError::Request(error),
297
}
298
}
299
300
fn transcript_url(item_url: &str, transcript_id: &str, format: &str) -> String {
301
format!(
302
"{item_url}/media/transcripts/{}/streamContent?format={format}",
303
encode(transcript_id)
304
)
305
}
306
307
fn item_url(site: &str, item: &Value) -> Option<String> {
308
let drive_id = item
309
.pointer("/parentReference/driveId")
310
.and_then(Value::as_str)?;
311
let item_id = item.get("id").and_then(Value::as_str)?;
312
Some(format!("{site}/_api/v2.1/drives/{drive_id}/items/{item_id}"))
313
}
314
315
fn decode_binary(body: &Value) -> Option<Vec<u8>> {
316
STANDARD.decode(body.get("base64")?.as_str()?).ok()
317
}
318
319
pub fn parse_occurrences(messages_json: &Value) -> Vec<Occurrence> {
320
messages_json
321
.get("value")
322
.and_then(Value::as_array)
323
.into_iter()
324
.flatten()
325
.filter_map(|message| {
326
let detail = message.get("eventDetail")?;
327
let finished = detail.get("@odata.type").and_then(Value::as_str)
328
== Some(RECORDING_EVENT)
329
&& detail.get("callRecordingStatus").and_then(Value::as_str)
330
== Some(RECORDING_SUCCESS);
331
let url = detail.get("callRecordingUrl").and_then(Value::as_str)?;
332
if !finished || !url.starts_with("https://") {
333
return None;
334
}
335
Some(Occurrence {
336
message_id: message.get("id").and_then(Value::as_str)?.to_owned(),
337
started_at: message
338
.get("createdDateTime")
339
.and_then(Value::as_str)
340
.and_then(|stamp| DateTime::parse_from_rfc3339(stamp).ok())
341
.map(|stamp| stamp.with_timezone(&Utc)),
342
recording_url: url.to_owned(),
343
recording_name: detail
344
.get("callRecordingDisplayName")
345
.and_then(Value::as_str)
346
.filter(|name| !name.is_empty())
347
.map(str::to_owned),
348
duration_seconds: detail
349
.get("callRecordingDuration")
350
.and_then(Value::as_str)
351
.and_then(parse_iso_duration),
352
organizer_id: detail
353
.pointer("/meetingOrganizer/user/id")
354
.and_then(Value::as_str)
355
.map(str::to_owned),
356
})
357
})
358
.collect()
359
}
360
361
pub fn sorted_occurrences(mut occurrences: Vec<Occurrence>) -> Vec<Occurrence> {
362
occurrences.sort_by_key(|occurrence| std::cmp::Reverse(occurrence.started_at));
363
occurrences.dedup_by(|left, right| left.recording_url == right.recording_url);
364
occurrences
365
}
366
367
pub fn parse_iso_duration(text: &str) -> Option<u64> {
368
let time = text.strip_prefix("PT")?;
369
let mut total = 0.0;
370
let mut number = String::new();
371
for character in time.chars() {
372
let unit = match character {
373
'H' => 3600.0,
374
'M' => 60.0,
375
'S' => 1.0,
376
digit => {
377
number.push(digit);
378
continue;
379
}
380
};
381
total += number.parse::<f64>().ok()? * unit;
382
number.clear();
383
}
384
number.is_empty().then_some(total as u64)
385
}
386
387
pub fn parse_expiration(listing_json: &Value) -> Option<DateTime<Utc>> {
388
let stamp = listing_json
389
.pointer("/fields/_ExpirationDate")?
390
.as_str()?;
391
DateTime::parse_from_rfc3339(stamp)
392
.ok()
393
.map(|stamp| stamp.with_timezone(&Utc))
394
}
395
396
pub fn is_audio_only(item_json: &Value) -> bool {
397
item_json
398
.get("video")
399
.and_then(|video| video.get("width"))
400
.and_then(Value::as_u64)
401
.is_none_or(|width| width == 0)
402
}
403
404
pub fn item_duration_seconds(item_json: &Value) -> Option<u64> {
405
item_json
406
.pointer("/video/duration")
407
.and_then(Value::as_u64)
408
.map(|milliseconds| milliseconds / 1000)
409
}
410
411
pub fn days_until_expiry(expires_at: DateTime<Utc>, now: DateTime<Utc>) -> i64 {
412
let remaining = expires_at - now;
413
(remaining.num_seconds() + 86_399).div_euclid(86_400).max(0)
414
}
415
416
pub fn parse_attendance(report_json: &Value) -> Vec<AttendanceRecord> {
417
let parse_stamp = |value: Option<&Value>| {
418
value
419
.and_then(Value::as_str)
420
.and_then(|stamp| DateTime::parse_from_rfc3339(stamp).ok())
421
.map(|stamp| stamp.with_timezone(&Utc))
422
};
423
report_json
424
.get("attendanceRecords")
425
.and_then(Value::as_array)
426
.into_iter()
427
.flatten()
428
.map(|record| {
429
let intervals: Vec<&Value> = record
430
.get("attendanceIntervals")
431
.and_then(Value::as_array)
432
.into_iter()
433
.flatten()
434
.collect();
435
let name = record
436
.pointer("/identity/displayName")
437
.and_then(Value::as_str)
438
.filter(|name| !name.is_empty())
439
.or_else(|| record.get("emailAddress").and_then(Value::as_str))
440
.unwrap_or("?");
441
AttendanceRecord {
442
name: name.to_owned(),
443
joined_at: intervals
444
.iter()
445
.filter_map(|interval| parse_stamp(interval.get("joinDateTime")))
446
.min(),
447
left_at: intervals
448
.iter()
449
.filter_map(|interval| parse_stamp(interval.get("leaveDateTime")))
450
.max(),
451
duration_seconds: record
452
.get("totalAttendanceInSeconds")
453
.and_then(Value::as_u64)
454
.unwrap_or(0),
455
}
456
})
457
.collect()
458
}
459
460
#[cfg(test)]
461
mod tests {
462
use super::*;
463
464
fn fixture(name: &str) -> Value {
465
let path = format!(
466
"{}/tests/fixtures/recap/{name}",
467
env!("CARGO_MANIFEST_DIR")
468
);
469
serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap()
470
}
471
472
#[test]
473
fn occurrences_keep_finished_recordings_newest_first() {
474
let occurrences = sorted_occurrences(parse_occurrences(&fixture("messages.json")));
475
assert_eq!(occurrences.len(), 2);
476
assert_eq!(occurrences[0].message_id, "2002");
477
assert_eq!(occurrences[0].duration_seconds, Some(1832));
478
assert_eq!(occurrences[0].organizer_id.as_deref(), Some("user-organizer"));
479
assert_eq!(occurrences[1].message_id, "2001");
480
assert_eq!(occurrences[1].duration_seconds, None);
481
}
482
483
#[test]
484
fn iso_durations_parse_to_seconds() {
485
assert_eq!(parse_iso_duration("PT1H2M3S"), Some(3723));
486
assert_eq!(parse_iso_duration("PT45M"), Some(2700));
487
assert_eq!(parse_iso_duration("PT12.5S"), Some(12));
488
assert_eq!(parse_iso_duration("1H"), None);
489
assert_eq!(parse_iso_duration("PT5"), None);
490
}
491
492
#[test]
493
fn expiration_reads_the_list_item_field() {
494
let expires_at = parse_expiration(&fixture("expiration.json")).unwrap();
495
assert_eq!(expires_at.to_rfc3339(), "2026-05-01T08:00:00+00:00");
496
assert_eq!(parse_expiration(&serde_json::json!({"fields": {}})), None);
497
}
498
499
#[test]
500
fn days_until_expiry_rounds_up_and_floors_at_zero() {
501
let now = DateTime::parse_from_rfc3339("2026-04-24T08:00:00Z")
502
.unwrap()
503
.with_timezone(&Utc);
504
let in_hours = |hours| now + chrono::Duration::hours(hours);
505
assert_eq!(days_until_expiry(in_hours(7 * 24), now), 7);
506
assert_eq!(days_until_expiry(in_hours(36), now), 2);
507
assert_eq!(days_until_expiry(in_hours(-5), now), 0);
508
}
509
510
#[test]
511
fn audio_only_when_the_item_has_no_video_size() {
512
assert!(is_audio_only(&serde_json::json!({"file": {}})));
513
assert!(!is_audio_only(
514
&serde_json::json!({"video": {"width": 1280, "duration": 90000}})
515
));
516
assert_eq!(
517
item_duration_seconds(&serde_json::json!({"video": {"duration": 90000}})),
518
Some(90)
519
);
520
}
521
522
#[test]
523
fn transcript_urls_request_the_wanted_format() {
524
assert_eq!(
525
transcript_url("https://a.example/_api/v2.1/drives/d/items/i", "t 1", "vtt"),
526
"https://a.example/_api/v2.1/drives/d/items/i/media/transcripts/t%201/streamContent?format=vtt"
527
);
528
assert_eq!(TranscriptFormat::Docx.query(), "docx");
529
}
530
531
#[test]
532
fn binary_answers_decode_from_base64() {
533
let body = serde_json::json!({"base64": "V0VCVlRU", "contentType": "text/vtt"});
534
assert_eq!(decode_binary(&body), Some(b"WEBVTT".to_vec()));
535
assert_eq!(decode_binary(&serde_json::json!({})), None);
536
}
537
538
#[test]
539
fn attendance_spans_first_join_to_last_leave() {
540
let records = parse_attendance(&fixture("attendance.json"));
541
assert_eq!(records.len(), 2);
542
assert_eq!(records[0].name, "Alex Example");
543
assert_eq!(records[0].duration_seconds, 1500);
544
assert_eq!(
545
records[0].joined_at.unwrap().to_rfc3339(),
546
"2026-03-02T10:00:00+00:00"
547
);
548
assert_eq!(
549
records[0].left_at.unwrap().to_rfc3339(),
550
"2026-03-02T10:30:00+00:00"
551
);
552
assert_eq!(records[1].name, "sam@example.com");
553
}
554
}
@@ -0,0 +1,554 @@1
use base64::Engine as _;2
use base64::engine::general_purpose::STANDARD;3
use chrono::{DateTime, Utc};4
use serde_json::Value;5
use session::{Method, Request, Scope, Session};6
7
use crate::messages::encode;8
use crate::transcripts::{9
TranscriptError, TranscriptTurn, Transcripts, newest_transcript, parse_transcript_list,10
parse_turns, share_id, site_origin,11
};12
13
const RECORDING_EVENT: &str = "#microsoft.graph.callRecordingEventMessageDetail";14
const RECORDING_SUCCESS: &str = "success";15
const MESSAGES_SCOPE: &str = "Chat.Read";16
const SITE_SCOPE: &str = ".default";17
const ATTENDANCE_SCOPE: &str = "OnlineMeetingArtifact.Read.All";18
const MAX_MESSAGE_PAGES: usize = 40;19
20
#[derive(Debug, Clone, PartialEq, Eq)]21
pub struct Occurrence {22
pub message_id: String,23
pub started_at: Option<DateTime<Utc>>,24
pub recording_url: String,25
pub recording_name: Option<String>,26
pub duration_seconds: Option<u64>,27
pub organizer_id: Option<String>,28
}29
30
#[derive(Debug, Clone, PartialEq, Eq)]31
pub struct RecordingDetails {32
pub item_url: String,33
pub audio_only: bool,34
pub duration_seconds: Option<u64>,35
pub expires_at: Option<DateTime<Utc>>,36
pub transcript_id: Option<String>,37
}38
39
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]40
pub enum TranscriptFormat {41
Vtt,42
Docx,43
}44
45
impl TranscriptFormat {46
pub fn query(self) -> &'static str {47
match self {48
TranscriptFormat::Vtt => "vtt",49
TranscriptFormat::Docx => "docx",50
}51
}52
}53
54
#[derive(Debug, Clone, PartialEq, Eq)]55
pub struct AttendanceRecord {56
pub name: String,57
pub joined_at: Option<DateTime<Utc>>,58
pub left_at: Option<DateTime<Utc>>,59
pub duration_seconds: u64,60
}61
62
#[derive(Debug, Clone, PartialEq, Eq)]63
pub enum Attendance {64
TurnedOff,65
Report(Vec<AttendanceRecord>),66
}67
68
pub struct Recap<'a> {69
session: &'a Session,70
transcripts: Transcripts<'a>,71
}72
73
impl<'a> Recap<'a> {74
pub fn new(session: &'a Session) -> Self {75
Recap {76
session,77
transcripts: Transcripts::new(session),78
}79
}80
81
pub async fn occurrences(&self, thread_id: &str) -> Result<Vec<Occurrence>, TranscriptError> {82
let scope = Scope::graph(MESSAGES_SCOPE);83
let mut url = format!(84
"{}/v1.0/chats/{}/messages?$top=50&$orderby=createdDateTime desc",85
session::GRAPH,86
encode(thread_id)87
);88
let mut found = Vec::new();89
for _ in 0..MAX_MESSAGE_PAGES {90
let page = self91
.transcripts92
.get(&url, &scope, TranscriptError::NoRecording)93
.await?;94
found.extend(parse_occurrences(&page));95
match page.get("@odata.nextLink").and_then(Value::as_str) {96
Some(next) => url = next.to_owned(),97
None => break,98
}99
}100
Ok(sorted_occurrences(found))101
}102
103
pub async fn details(104
&self,105
occurrence: &Occurrence,106
) -> Result<RecordingDetails, TranscriptError> {107
let site = site_origin(&occurrence.recording_url);108
let site_scope = Scope::new(site.clone(), SITE_SCOPE);109
let item = self110
.transcripts111
.get(112
&format!(113
"{site}/_api/v2.1/shares/{}/driveItem?$select=id,parentReference,video,file",114
share_id(&occurrence.recording_url)115
),116
&site_scope,117
TranscriptError::NoRecording,118
)119
.await?;120
let item_url = item_url(&site, &item).ok_or(TranscriptError::NoRecording)?;121
let expiration = self122
.transcripts123
.get(124
&format!("{item_url}/listItem?$expand=fields($select=_ExpirationDate)"),125
&site_scope,126
TranscriptError::NoRecording,127
)128
.await129
.ok();130
let listing = self131
.transcripts132
.get(133
&format!("{item_url}/media/transcripts"),134
&site_scope,135
TranscriptError::NoTranscript,136
)137
.await138
.ok();139
Ok(RecordingDetails {140
audio_only: is_audio_only(&item),141
duration_seconds: item_duration_seconds(&item).or(occurrence.duration_seconds),142
expires_at: expiration.as_ref().and_then(parse_expiration),143
transcript_id: listing144
.as_ref()145
.and_then(|listing| newest_transcript(parse_transcript_list(listing)))146
.map(|transcript| transcript.id),147
item_url,148
})149
}150
151
pub async fn transcript(152
&self,153
details: &RecordingDetails,154
) -> Result<Vec<TranscriptTurn>, TranscriptError> {155
let transcript_id = details156
.transcript_id157
.as_deref()158
.ok_or(TranscriptError::NoTranscript)?;159
let site_scope = Scope::new(site_origin(&details.item_url), SITE_SCOPE);160
let content = self161
.transcripts162
.get(163
&transcript_url(&details.item_url, transcript_id, "json"),164
&site_scope,165
TranscriptError::NoTranscript,166
)167
.await?;168
Ok(parse_turns(&content))169
}170
171
pub async fn transcript_file(172
&self,173
details: &RecordingDetails,174
format: TranscriptFormat,175
) -> Result<Vec<u8>, TranscriptError> {176
let transcript_id = details177
.transcript_id178
.as_deref()179
.ok_or(TranscriptError::NoTranscript)?;180
let site_scope = Scope::new(site_origin(&details.item_url), SITE_SCOPE);181
let request = Request::binary_get(transcript_url(182
&details.item_url,183
transcript_id,184
format.query(),185
));186
let answer = self187
.session188
.send(request, &site_scope)189
.await190
.map_err(request_failure)?;191
decode_binary(&answer.body).ok_or(TranscriptError::NoTranscript)192
}193
194
pub async fn delete_recording(195
&self,196
details: &RecordingDetails,197
) -> Result<(), TranscriptError> {198
let site_scope = Scope::new(site_origin(&details.item_url), SITE_SCOPE);199
self.session200
.request(Method::Delete, &details.item_url, &site_scope, None)201
.await202
.map(|_| ())203
.map_err(request_failure)204
}205
206
pub async fn attendance(&self, thread_id: &str) -> Result<Attendance, TranscriptError> {207
let graph_scope = Scope::graph(MESSAGES_SCOPE);208
let chat = match self209
.transcripts210
.get(211
&format!(212
"{}/v1.0/chats/{}?$select=onlineMeetingInfo",213
session::GRAPH,214
encode(thread_id)215
),216
&graph_scope,217
TranscriptError::NoRecording,218
)219
.await220
{221
Ok(chat) => chat,222
Err(TranscriptError::NoRecording | TranscriptError::AccessDenied) => {223
return Ok(Attendance::TurnedOff);224
}225
Err(error) => return Err(error),226
};227
let Some(join_url) = chat228
.pointer("/onlineMeetingInfo/joinWebUrl")229
.and_then(Value::as_str)230
else {231
return Ok(Attendance::TurnedOff);232
};233
let scope = Scope::graph(ATTENDANCE_SCOPE);234
let lookup = format!(235
"{}/v1.0/me/onlineMeetings?$filter=JoinWebUrl eq '{}'&$select=id",236
session::GRAPH,237
join_url.replace('\'', "''")238
);239
let meeting_id = match self240
.transcripts241
.get(&lookup, &scope, TranscriptError::NoRecording)242
.await243
{244
Ok(found) => found245
.pointer("/value/0/id")246
.and_then(Value::as_str)247
.map(str::to_owned),248
Err(TranscriptError::NoRecording | TranscriptError::AccessDenied) => None,249
Err(error) => return Err(error),250
};251
let Some(meeting_id) = meeting_id else {252
return Ok(Attendance::TurnedOff);253
};254
let reports_url = format!(255
"{}/v1.0/me/onlineMeetings/{}/attendanceReports",256
session::GRAPH,257
encode(&meeting_id)258
);259
let reports = match self260
.transcripts261
.get(&reports_url, &scope, TranscriptError::NoRecording)262
.await263
{264
Ok(reports) => reports,265
Err(TranscriptError::NoRecording | TranscriptError::AccessDenied) => {266
return Ok(Attendance::TurnedOff);267
}268
Err(error) => return Err(error),269
};270
let Some(report_id) = reports271
.pointer("/value/0/id")272
.and_then(Value::as_str)273
else {274
return Ok(Attendance::TurnedOff);275
};276
let report = self277
.transcripts278
.get(279
&format!(280
"{reports_url}/{}?$expand=attendanceRecords",281
encode(report_id)282
),283
&scope,284
TranscriptError::NoRecording,285
)286
.await?;287
Ok(Attendance::Report(parse_attendance(&report)))288
}289
}290
291
fn request_failure(error: session::Error) -> TranscriptError {292
match error {293
session::Error::Api {294
status: 403 | 401, ..295
} => TranscriptError::AccessDenied,296
error => TranscriptError::Request(error),297
}298
}299
300
fn transcript_url(item_url: &str, transcript_id: &str, format: &str) -> String {301
format!(302
"{item_url}/media/transcripts/{}/streamContent?format={format}",303
encode(transcript_id)304
)305
}306
307
fn item_url(site: &str, item: &Value) -> Option<String> {308
let drive_id = item309
.pointer("/parentReference/driveId")310
.and_then(Value::as_str)?;311
let item_id = item.get("id").and_then(Value::as_str)?;312
Some(format!("{site}/_api/v2.1/drives/{drive_id}/items/{item_id}"))313
}314
315
fn decode_binary(body: &Value) -> Option<Vec<u8>> {316
STANDARD.decode(body.get("base64")?.as_str()?).ok()317
}318
319
pub fn parse_occurrences(messages_json: &Value) -> Vec<Occurrence> {320
messages_json321
.get("value")322
.and_then(Value::as_array)323
.into_iter()324
.flatten()325
.filter_map(|message| {326
let detail = message.get("eventDetail")?;327
let finished = detail.get("@odata.type").and_then(Value::as_str)328
== Some(RECORDING_EVENT)329
&& detail.get("callRecordingStatus").and_then(Value::as_str)330
== Some(RECORDING_SUCCESS);331
let url = detail.get("callRecordingUrl").and_then(Value::as_str)?;332
if !finished || !url.starts_with("https://") {333
return None;334
}335
Some(Occurrence {336
message_id: message.get("id").and_then(Value::as_str)?.to_owned(),337
started_at: message338
.get("createdDateTime")339
.and_then(Value::as_str)340
.and_then(|stamp| DateTime::parse_from_rfc3339(stamp).ok())341
.map(|stamp| stamp.with_timezone(&Utc)),342
recording_url: url.to_owned(),343
recording_name: detail344
.get("callRecordingDisplayName")345
.and_then(Value::as_str)346
.filter(|name| !name.is_empty())347
.map(str::to_owned),348
duration_seconds: detail349
.get("callRecordingDuration")350
.and_then(Value::as_str)351
.and_then(parse_iso_duration),352
organizer_id: detail353
.pointer("/meetingOrganizer/user/id")354
.and_then(Value::as_str)355
.map(str::to_owned),356
})357
})358
.collect()359
}360
361
pub fn sorted_occurrences(mut occurrences: Vec<Occurrence>) -> Vec<Occurrence> {362
occurrences.sort_by_key(|occurrence| std::cmp::Reverse(occurrence.started_at));363
occurrences.dedup_by(|left, right| left.recording_url == right.recording_url);364
occurrences365
}366
367
pub fn parse_iso_duration(text: &str) -> Option<u64> {368
let time = text.strip_prefix("PT")?;369
let mut total = 0.0;370
let mut number = String::new();371
for character in time.chars() {372
let unit = match character {373
'H' => 3600.0,374
'M' => 60.0,375
'S' => 1.0,376
digit => {377
number.push(digit);378
continue;379
}380
};381
total += number.parse::<f64>().ok()? * unit;382
number.clear();383
}384
number.is_empty().then_some(total as u64)385
}386
387
pub fn parse_expiration(listing_json: &Value) -> Option<DateTime<Utc>> {388
let stamp = listing_json389
.pointer("/fields/_ExpirationDate")?390
.as_str()?;391
DateTime::parse_from_rfc3339(stamp)392
.ok()393
.map(|stamp| stamp.with_timezone(&Utc))394
}395
396
pub fn is_audio_only(item_json: &Value) -> bool {397
item_json398
.get("video")399
.and_then(|video| video.get("width"))400
.and_then(Value::as_u64)401
.is_none_or(|width| width == 0)402
}403
404
pub fn item_duration_seconds(item_json: &Value) -> Option<u64> {405
item_json406
.pointer("/video/duration")407
.and_then(Value::as_u64)408
.map(|milliseconds| milliseconds / 1000)409
}410
411
pub fn days_until_expiry(expires_at: DateTime<Utc>, now: DateTime<Utc>) -> i64 {412
let remaining = expires_at - now;413
(remaining.num_seconds() + 86_399).div_euclid(86_400).max(0)414
}415
416
pub fn parse_attendance(report_json: &Value) -> Vec<AttendanceRecord> {417
let parse_stamp = |value: Option<&Value>| {418
value419
.and_then(Value::as_str)420
.and_then(|stamp| DateTime::parse_from_rfc3339(stamp).ok())421
.map(|stamp| stamp.with_timezone(&Utc))422
};423
report_json424
.get("attendanceRecords")425
.and_then(Value::as_array)426
.into_iter()427
.flatten()428
.map(|record| {429
let intervals: Vec<&Value> = record430
.get("attendanceIntervals")431
.and_then(Value::as_array)432
.into_iter()433
.flatten()434
.collect();435
let name = record436
.pointer("/identity/displayName")437
.and_then(Value::as_str)438
.filter(|name| !name.is_empty())439
.or_else(|| record.get("emailAddress").and_then(Value::as_str))440
.unwrap_or("?");441
AttendanceRecord {442
name: name.to_owned(),443
joined_at: intervals444
.iter()445
.filter_map(|interval| parse_stamp(interval.get("joinDateTime")))446
.min(),447
left_at: intervals448
.iter()449
.filter_map(|interval| parse_stamp(interval.get("leaveDateTime")))450
.max(),451
duration_seconds: record452
.get("totalAttendanceInSeconds")453
.and_then(Value::as_u64)454
.unwrap_or(0),455
}456
})457
.collect()458
}459
460
#[cfg(test)]461
mod tests {462
use super::*;463
464
fn fixture(name: &str) -> Value {465
let path = format!(466
"{}/tests/fixtures/recap/{name}",467
env!("CARGO_MANIFEST_DIR")468
);469
serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap()470
}471
472
#[test]473
fn occurrences_keep_finished_recordings_newest_first() {474
let occurrences = sorted_occurrences(parse_occurrences(&fixture("messages.json")));475
assert_eq!(occurrences.len(), 2);476
assert_eq!(occurrences[0].message_id, "2002");477
assert_eq!(occurrences[0].duration_seconds, Some(1832));478
assert_eq!(occurrences[0].organizer_id.as_deref(), Some("user-organizer"));479
assert_eq!(occurrences[1].message_id, "2001");480
assert_eq!(occurrences[1].duration_seconds, None);481
}482
483
#[test]484
fn iso_durations_parse_to_seconds() {485
assert_eq!(parse_iso_duration("PT1H2M3S"), Some(3723));486
assert_eq!(parse_iso_duration("PT45M"), Some(2700));487
assert_eq!(parse_iso_duration("PT12.5S"), Some(12));488
assert_eq!(parse_iso_duration("1H"), None);489
assert_eq!(parse_iso_duration("PT5"), None);490
}491
492
#[test]493
fn expiration_reads_the_list_item_field() {494
let expires_at = parse_expiration(&fixture("expiration.json")).unwrap();495
assert_eq!(expires_at.to_rfc3339(), "2026-05-01T08:00:00+00:00");496
assert_eq!(parse_expiration(&serde_json::json!({"fields": {}})), None);497
}498
499
#[test]500
fn days_until_expiry_rounds_up_and_floors_at_zero() {501
let now = DateTime::parse_from_rfc3339("2026-04-24T08:00:00Z")502
.unwrap()503
.with_timezone(&Utc);504
let in_hours = |hours| now + chrono::Duration::hours(hours);505
assert_eq!(days_until_expiry(in_hours(7 * 24), now), 7);506
assert_eq!(days_until_expiry(in_hours(36), now), 2);507
assert_eq!(days_until_expiry(in_hours(-5), now), 0);508
}509
510
#[test]511
fn audio_only_when_the_item_has_no_video_size() {512
assert!(is_audio_only(&serde_json::json!({"file": {}})));513
assert!(!is_audio_only(514
&serde_json::json!({"video": {"width": 1280, "duration": 90000}})515
));516
assert_eq!(517
item_duration_seconds(&serde_json::json!({"video": {"duration": 90000}})),518
Some(90)519
);520
}521
522
#[test]523
fn transcript_urls_request_the_wanted_format() {524
assert_eq!(525
transcript_url("https://a.example/_api/v2.1/drives/d/items/i", "t 1", "vtt"),526
"https://a.example/_api/v2.1/drives/d/items/i/media/transcripts/t%201/streamContent?format=vtt"527
);528
assert_eq!(TranscriptFormat::Docx.query(), "docx");529
}530
531
#[test]532
fn binary_answers_decode_from_base64() {533
let body = serde_json::json!({"base64": "V0VCVlRU", "contentType": "text/vtt"});534
assert_eq!(decode_binary(&body), Some(b"WEBVTT".to_vec()));535
assert_eq!(decode_binary(&serde_json::json!({})), None);536
}537
538
#[test]539
fn attendance_spans_first_join_to_last_leave() {540
let records = parse_attendance(&fixture("attendance.json"));541
assert_eq!(records.len(), 2);542
assert_eq!(records[0].name, "Alex Example");543
assert_eq!(records[0].duration_seconds, 1500);544
assert_eq!(545
records[0].joined_at.unwrap().to_rfc3339(),546
"2026-03-02T10:00:00+00:00"547
);548
assert_eq!(549
records[0].left_at.unwrap().to_rfc3339(),550
"2026-03-02T10:30:00+00:00"551
);552
assert_eq!(records[1].name, "sam@example.com");553
}554
}@@ -144,7 +144,7 @@ impl<'a> Transcripts<'a> {
144
144
}
145
145
}
146
146
147
async fn get(
147
pub(crate) async fn get(
148
148
&self,
149
149
url: &str,
150
150
scope: &Scope,
@@ -144,7 +144,7 @@ impl<'a> Transcripts<'a> {144
}144
}145
}145
}146
146
147
async fn get(147
pub(crate) async fn get(148
&self,148
&self,149
url: &str,149
url: &str,150
scope: &Scope,150
scope: &Scope,@@ -0,0 +1,22 @@
1
{
2
"totalParticipantCount": 2,
3
"attendanceRecords": [
4
{
5
"emailAddress": "alex@example.com",
6
"identity": {"displayName": "Alex Example"},
7
"role": "Organizer",
8
"totalAttendanceInSeconds": 1500,
9
"attendanceIntervals": [
10
{"joinDateTime": "2026-03-02T10:10:00Z", "leaveDateTime": "2026-03-02T10:30:00Z", "durationInSeconds": 1200},
11
{"joinDateTime": "2026-03-02T10:00:00Z", "leaveDateTime": "2026-03-02T10:05:00Z", "durationInSeconds": 300}
12
]
13
},
14
{
15
"emailAddress": "sam@example.com",
16
"identity": {"displayName": ""},
17
"role": "Attendee",
18
"totalAttendanceInSeconds": 600,
19
"attendanceIntervals": []
20
}
21
]
22
}
@@ -0,0 +1,22 @@1
{2
"totalParticipantCount": 2,3
"attendanceRecords": [4
{5
"emailAddress": "alex@example.com",6
"identity": {"displayName": "Alex Example"},7
"role": "Organizer",8
"totalAttendanceInSeconds": 1500,9
"attendanceIntervals": [10
{"joinDateTime": "2026-03-02T10:10:00Z", "leaveDateTime": "2026-03-02T10:30:00Z", "durationInSeconds": 1200},11
{"joinDateTime": "2026-03-02T10:00:00Z", "leaveDateTime": "2026-03-02T10:05:00Z", "durationInSeconds": 300}12
]13
},14
{15
"emailAddress": "sam@example.com",16
"identity": {"displayName": ""},17
"role": "Attendee",18
"totalAttendanceInSeconds": 600,19
"attendanceIntervals": []20
}21
]22
}@@ -0,0 +1 @@
1
{"fields": {"_ExpirationDate": "2026-05-01T08:00:00Z"}}
@@ -0,0 +1 @@1
{"fields": {"_ExpirationDate": "2026-05-01T08:00:00Z"}}@@ -0,0 +1,35 @@
1
{
2
"value": [
3
{
4
"id": "2003",
5
"createdDateTime": "2026-03-09T10:31:00Z",
6
"eventDetail": {
7
"@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
8
"callRecordingStatus": "failure",
9
"callRecordingUrl": "https://contoso-my.sharepoint.com/failed.mp4"
10
}
11
},
12
{
13
"id": "2002",
14
"createdDateTime": "2026-03-09T10:30:00Z",
15
"eventDetail": {
16
"@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
17
"callRecordingStatus": "success",
18
"callRecordingDisplayName": "Weekly sync-20260309_100000-Meeting Recording.mp4",
19
"callRecordingDuration": "PT30M32S",
20
"callRecordingUrl": "https://contoso-my.sharepoint.com/personal/alex_example_contoso_com/Documents/Recordings/second.mp4",
21
"meetingOrganizer": {"user": {"id": "user-organizer"}}
22
}
23
},
24
{
25
"id": "2001",
26
"createdDateTime": "2026-03-02T10:30:00Z",
27
"eventDetail": {
28
"@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",
29
"callRecordingStatus": "success",
30
"callRecordingUrl": "https://contoso-my.sharepoint.com/personal/alex_example_contoso_com/Documents/Recordings/first.mp4"
31
}
32
},
33
{"id": "2000", "createdDateTime": "2026-03-02T10:00:00Z", "body": {"content": "hello"}}
34
]
35
}
@@ -0,0 +1,35 @@1
{2
"value": [3
{4
"id": "2003",5
"createdDateTime": "2026-03-09T10:31:00Z",6
"eventDetail": {7
"@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",8
"callRecordingStatus": "failure",9
"callRecordingUrl": "https://contoso-my.sharepoint.com/failed.mp4"10
}11
},12
{13
"id": "2002",14
"createdDateTime": "2026-03-09T10:30:00Z",15
"eventDetail": {16
"@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",17
"callRecordingStatus": "success",18
"callRecordingDisplayName": "Weekly sync-20260309_100000-Meeting Recording.mp4",19
"callRecordingDuration": "PT30M32S",20
"callRecordingUrl": "https://contoso-my.sharepoint.com/personal/alex_example_contoso_com/Documents/Recordings/second.mp4",21
"meetingOrganizer": {"user": {"id": "user-organizer"}}22
}23
},24
{25
"id": "2001",26
"createdDateTime": "2026-03-02T10:30:00Z",27
"eventDetail": {28
"@odata.type": "#microsoft.graph.callRecordingEventMessageDetail",29
"callRecordingStatus": "success",30
"callRecordingUrl": "https://contoso-my.sharepoint.com/personal/alex_example_contoso_com/Documents/Recordings/first.mp4"31
}32
},33
{"id": "2000", "createdDateTime": "2026-03-02T10:00:00Z", "body": {"content": "hello"}}34
]35
}