feat(calls): audio-only recording, transcription only, live transcript panel, caption language and style
- Record and transcribe submenu: video, audio only, transcription only - Stop variants (both, recording, transcription) sent even when started elsewhere - Header chip: Recording, Recording audio, Transcribing - Transcript panel (320 px, shares the chat frame): speaker, mm:ss, search, Jump to latest - Captions settings: spoken language (setLanguage), size, position (persisted) - Demo recording scene shows transcript and answers the new commands - Layout guard tag for the transcript panel; side panels shrink in narrow windows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -170,11 +170,11 @@ Feature parity with the Microsoft Teams desktop client.
170
170
| Video and screen sharing | Partial | Send and receive over libwebrtc H264, source requests through `applyChannelParameters`, stage, strip, self view, share banner. Sent frames acknowledged by the mixer; receive only checked by a local loopback, not with a second person |
171
171
| Meeting extras | Partial | Share menu switch "Include computer sound" (remembered, mixed into the one audio track with the mic, own playback excluded on Windows 10 build 20348+), raise hand with queue badge, lower hand and Lower all hands for organizers, reactions on the sender's tile for 3 s, meeting chat in a 320 px side panel with unread badge. Checked with synthetic sources and the demo only; not yet live in a meeting or with a second person |
172
172
| Organizer controls | Partial | Amber lobby banner with View (Admit, Deny per person) and Admit all, tile menu (right-click or "..." on hover): Pin for me, Spotlight for everyone, Mute, Lower hand, Remove from meeting with a confirm dialog, "..." controls menu with Mute all. Request bodies built from the Teams code and unit tested; demo checked, not yet live with a second person |
173
| Live captions | Partial | "..." > Turn on live captions: recorder bot joins, start command with a skype token, captions arrive on the SCTP data channel (data id 3), 2-line overlay with bold speaker that fades after 4 s. Message framing and parsing from the Teams code; not yet seen with real speech |
173
| Live captions | Partial | "..." > Turn on live captions: recorder bot joins, start command with a skype token, captions arrive on the SCTP data channel (data id 3), 2-line overlay with bold speaker that fades after 4 s. "Captions settings": spoken language (`setLanguage`), size S/M/L, position bottom/top (size and position remembered). "Show transcript": 320 px side panel with the whole call (speaker, mm:ss, text), search, Jump to latest. Message framing and parsing from the Teams code; `setLanguage` body from capture, not sent live; not yet seen with real speech |
174
174
| 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 |
175
175
| Camera effects | Partial | Camera menu "Effects" and Settings > Devices: Mirror my video (self view and camera test only, default on), Auto framing, Adjust brightness, Soft focus (Low / Medium / High in Settings). Framing, brightness and soft focus run on the send path, so others see them; one segmentation mask per frame is shared with the background. Crop planner, gamma and blend are unit tested; not yet checked on a real camera |
176
176
| 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 |
177
| 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 |
177
| Recording | Partial | Organizer "..." > Record and transcribe: Start recording, Record audio only, Start transcription only; Stop recording / Stop transcription / Stop both (confirm) through the recorder bot; header chip red "Recording" / "Recording audio" or blue "Transcribing" for everyone from the meeting state, consent notice that keeps mic and camera off until OK. Bodies unit tested; video start and stop run live through `meet_now --record` (audio only, transcription only and the stop variants are from capture, not run live), consent needs a tenant with the policy on and a second person |
178
178
| 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 |
179
179
| 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 |
180
180
| Noise suppression, music mode | Partial | Mic menu and Settings > Devices: Auto (device track with WebRTC echo cancellation, AGC, NS) or Off, Music mode keeps echo cancellation only. No Low/High, the APM has on/off flags only. Off and Music mode run a cpal mic through our own APM; checked with synthetic sources only, not with a real mic in a call |
@@ -170,11 +170,11 @@ Feature parity with the Microsoft Teams desktop client.170
| Video and screen sharing | Partial | Send and receive over libwebrtc H264, source requests through `applyChannelParameters`, stage, strip, self view, share banner. Sent frames acknowledged by the mixer; receive only checked by a local loopback, not with a second person |170
| Video and screen sharing | Partial | Send and receive over libwebrtc H264, source requests through `applyChannelParameters`, stage, strip, self view, share banner. Sent frames acknowledged by the mixer; receive only checked by a local loopback, not with a second person |171
| Meeting extras | Partial | Share menu switch "Include computer sound" (remembered, mixed into the one audio track with the mic, own playback excluded on Windows 10 build 20348+), raise hand with queue badge, lower hand and Lower all hands for organizers, reactions on the sender's tile for 3 s, meeting chat in a 320 px side panel with unread badge. Checked with synthetic sources and the demo only; not yet live in a meeting or with a second person |171
| Meeting extras | Partial | Share menu switch "Include computer sound" (remembered, mixed into the one audio track with the mic, own playback excluded on Windows 10 build 20348+), raise hand with queue badge, lower hand and Lower all hands for organizers, reactions on the sender's tile for 3 s, meeting chat in a 320 px side panel with unread badge. Checked with synthetic sources and the demo only; not yet live in a meeting or with a second person |172
| Organizer controls | Partial | Amber lobby banner with View (Admit, Deny per person) and Admit all, tile menu (right-click or "..." on hover): Pin for me, Spotlight for everyone, Mute, Lower hand, Remove from meeting with a confirm dialog, "..." controls menu with Mute all. Request bodies built from the Teams code and unit tested; demo checked, not yet live with a second person |172
| Organizer controls | Partial | Amber lobby banner with View (Admit, Deny per person) and Admit all, tile menu (right-click or "..." on hover): Pin for me, Spotlight for everyone, Mute, Lower hand, Remove from meeting with a confirm dialog, "..." controls menu with Mute all. Request bodies built from the Teams code and unit tested; demo checked, not yet live with a second person |173
| Live captions | Partial | "..." > Turn on live captions: recorder bot joins, start command with a skype token, captions arrive on the SCTP data channel (data id 3), 2-line overlay with bold speaker that fades after 4 s. Message framing and parsing from the Teams code; not yet seen with real speech |173
| Live captions | Partial | "..." > Turn on live captions: recorder bot joins, start command with a skype token, captions arrive on the SCTP data channel (data id 3), 2-line overlay with bold speaker that fades after 4 s. "Captions settings": spoken language (`setLanguage`), size S/M/L, position bottom/top (size and position remembered). "Show transcript": 320 px side panel with the whole call (speaker, mm:ss, text), search, Jump to latest. Message framing and parsing from the Teams code; `setLanguage` body from capture, not sent live; not yet seen with real speech |174
| 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
| 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 |175
| Camera effects | Partial | Camera menu "Effects" and Settings > Devices: Mirror my video (self view and camera test only, default on), Auto framing, Adjust brightness, Soft focus (Low / Medium / High in Settings). Framing, brightness and soft focus run on the send path, so others see them; one segmentation mask per frame is shared with the background. Crop planner, gamma and blend are unit tested; not yet checked on a real camera |175
| Camera effects | Partial | Camera menu "Effects" and Settings > Devices: Mirror my video (self view and camera test only, default on), Auto framing, Adjust brightness, Soft focus (Low / Medium / High in Settings). Framing, brightness and soft focus run on the send path, so others see them; one segmentation mask per frame is shared with the background. Crop planner, gamma and blend are unit tested; not yet checked on a real camera |176
| 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 |176
| 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 |177
| 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 |177
| Recording | Partial | Organizer "..." > Record and transcribe: Start recording, Record audio only, Start transcription only; Stop recording / Stop transcription / Stop both (confirm) through the recorder bot; header chip red "Recording" / "Recording audio" or blue "Transcribing" for everyone from the meeting state, consent notice that keeps mic and camera off until OK. Bodies unit tested; video start and stop run live through `meet_now --record` (audio only, transcription only and the stop variants are from capture, not run live), consent needs a tenant with the policy on and a second person |178
| 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 |178
| 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 |179
| 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 |179
| 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 |180
| Noise suppression, music mode | Partial | Mic menu and Settings > Devices: Auto (device track with WebRTC echo cancellation, AGC, NS) or Off, Music mode keeps echo cancellation only. No Low/High, the APM has on/off flags only. Off and Music mode run a cpal mic through our own APM; checked with synthetic sources only, not with a real mic in a call |180
| Noise suppression, music mode | Partial | Mic menu and Settings > Devices: Auto (device track with WebRTC echo cancellation, AGC, NS) or Off, Music mode keeps echo cancellation only. No Low/High, the APM has on/off flags only. Off and Music mode run a cpal mic through our own APM; checked with synthetic sources only, not with a real mic in a call |@@ -132,6 +132,7 @@ pub struct AppState {
132
132
pub meet_now_pending: bool,
133
133
pub call_backgrounds: crate::call::BackgroundLibrary,
134
134
pub transfer_picker: Option<Entity<crate::views::transfer_picker::TransferPicker>>,
135
pub transcript_panel: Option<Entity<crate::views::call_transcript::TranscriptPanel>>,
135
136
pub rings: Rings,
136
137
pub live_meetings: HashMap<String, LiveMeeting>,
137
138
pub live_refreshing: HashSet<String>,
@@ -236,6 +237,7 @@ impl AppState {
236
237
crate::call::BackgroundLibrary::new(crate::call::default_cache_directory())
237
238
},
238
239
transfer_picker: None,
240
transcript_panel: None,
239
241
rings: Rings::default(),
240
242
live_meetings: HashMap::new(),
241
243
live_refreshing: HashSet::new(),
@@ -132,6 +132,7 @@ pub struct AppState {132
pub meet_now_pending: bool,132
pub meet_now_pending: bool,133
pub call_backgrounds: crate::call::BackgroundLibrary,133
pub call_backgrounds: crate::call::BackgroundLibrary,134
pub transfer_picker: Option<Entity<crate::views::transfer_picker::TransferPicker>>,134
pub transfer_picker: Option<Entity<crate::views::transfer_picker::TransferPicker>>,135
pub transcript_panel: Option<Entity<crate::views::call_transcript::TranscriptPanel>>,135
pub rings: Rings,136
pub rings: Rings,136
pub live_meetings: HashMap<String, LiveMeeting>,137
pub live_meetings: HashMap<String, LiveMeeting>,137
pub live_refreshing: HashSet<String>,138
pub live_refreshing: HashSet<String>,@@ -236,6 +237,7 @@ impl AppState {236
crate::call::BackgroundLibrary::new(crate::call::default_cache_directory())237
crate::call::BackgroundLibrary::new(crate::call::default_cache_directory())237
},238
},238
transfer_picker: None,239
transfer_picker: None,240
transcript_panel: None,239
rings: Rings::default(),241
rings: Rings::default(),240
live_meetings: HashMap::new(),242
live_meetings: HashMap::new(),241
live_refreshing: HashSet::new(),243
live_refreshing: HashSet::new(),@@ -350,6 +350,9 @@ impl AppState {
350
350
crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);
351
351
}
352
352
call.model.apply(update);
353
if let Some(language) = call.model.take_ready_caption_language() {
354
let _ = call.commands.send(CallCommand::SetCaptionLanguage(language));
355
}
353
356
if call.model.screen_sharer.is_none() {
354
357
call.stage_fullscreen = false;
355
358
call.pictures.forget(&VideoKey::Screen, cx);
@@ -374,6 +377,7 @@ impl AppState {
374
377
crate::agent_api::clear_captions(thread, cx);
375
378
}
376
379
self.call = None;
380
self.transcript_panel = None;
377
381
if let Some(consult) = consult {
378
382
let _ = consult.commands.send(CallCommand::Hangup);
379
383
}
@@ -516,6 +520,10 @@ impl AppState {
516
520
return;
517
521
};
518
522
call.chat_open = !call.chat_open;
523
if call.chat_open {
524
call.transcript_open = false;
525
self.transcript_panel = None;
526
}
519
527
cx.emit(AppEvent::Call);
520
528
cx.notify();
521
529
}
@@ -1129,7 +1137,8 @@ mod tests {
1129
1137
1130
1138
use calling::{
1131
1139
BackgroundChoice, CallCommand, CallControl, CallState, CallUpdate, CameraEffects,
1132
DeviceChoice, EndKind, EndReason, EngineEvent, HoldState, Reaction, call_channel,
1140
DeviceChoice, EndKind, EndReason, EngineEvent, HoldState, Reaction, RecordingKind,
1141
StopScope, call_channel,
1133
1142
};
1134
1143
use gpui_kit::{AppContext as _, Entity, TestAppContext};
1135
1144
use store::{ChatRecord, MemberRecord, Store};
@@ -1138,6 +1147,7 @@ mod tests {
1138
1147
use crate::app_state::{AppEvent, AppState, Mode, Selection};
1139
1148
use crate::call::TransferCandidate;
1140
1149
use crate::call::background::BackgroundPick;
1150
use crate::call::{CaptionPosition, CaptionSize, RecordAction, ViewSettings};
1141
1151
use crate::call::demo::demo_ring;
1142
1152
use crate::call::features::room_closed_move;
1143
1153
use crate::call::model::{BreakoutState, ConsultCall};
@@ -1569,7 +1579,7 @@ mod tests {
1569
1579
let (attendee, mut attendee_control) = app_with_commands(cx, live_meeting(false), None);
1570
1580
cx.update(|cx| {
1571
1581
attendee.update(cx, |state, cx| {
1572
state.set_call_recording(true, cx);
1582
state.run_call_record_action(RecordAction::Start(RecordingKind::Video), cx);
1573
1583
state.accept_recording_notice(cx);
1574
1584
})
1575
1585
});
@@ -1577,9 +1587,9 @@ mod tests {
1577
1587
let (organizer, mut control) = app_with_commands(cx, live_meeting(true), None);
1578
1588
cx.update(|cx| {
1579
1589
organizer.update(cx, |state, cx| {
1580
state.set_call_recording(true, cx);
1590
state.run_call_record_action(RecordAction::Start(RecordingKind::Video), cx);
1581
1591
state.apply_call_update(7, CallUpdate::Recording(true), cx);
1582
state.set_call_recording(false, cx);
1592
state.run_call_record_action(RecordAction::Stop(StopScope::Both), cx);
1583
1593
state.accept_recording_notice(cx);
1584
1594
state.apply_call_update(7, CallUpdate::ConsentRequired(true), cx);
1585
1595
state.accept_recording_notice(cx);
@@ -1587,16 +1597,15 @@ mod tests {
1587
1597
});
1588
1598
assert_eq!(
1589
1599
control.try_recv_command(),
1590
Some(CallCommand::SetRecording {
1591
on: true,
1600
Some(CallCommand::StartRecording {
1601
kind: RecordingKind::Video,
1592
1602
title: "Standup".into()
1593
1603
})
1594
1604
);
1595
1605
assert_eq!(
1596
1606
control.try_recv_command(),
1597
Some(CallCommand::SetRecording {
1598
on: false,
1599
title: "Standup".into()
1607
Some(CallCommand::StopRecording {
1608
scope: StopScope::Both
1600
1609
})
1601
1610
);
1602
1611
assert_eq!(
@@ -1606,6 +1615,95 @@ mod tests {
1606
1615
assert_eq!(control.try_recv_command(), None);
1607
1616
}
1608
1617
1618
#[gpui_kit::test]
1619
fn every_record_action_becomes_its_own_command_for_the_organizer(cx: &mut TestAppContext) {
1620
let (organizer, mut control) = app_with_commands(cx, live_meeting(true), None);
1621
cx.update(|cx| {
1622
organizer.update(cx, |state, cx| {
1623
state.run_call_record_action(RecordAction::Start(RecordingKind::AudioOnly), cx);
1624
state.run_call_record_action(RecordAction::Start(RecordingKind::TranscriptOnly), cx);
1625
state.run_call_record_action(RecordAction::Stop(StopScope::RecordingOnly), cx);
1626
state.run_call_record_action(RecordAction::Stop(StopScope::TranscriptionOnly), cx);
1627
})
1628
});
1629
let title = "Standup".to_owned();
1630
assert_eq!(control.try_recv_command(), Some(CallCommand::StartRecording { kind: RecordingKind::AudioOnly, title: title.clone() }));
1631
assert_eq!(control.try_recv_command(), Some(CallCommand::StartRecording { kind: RecordingKind::TranscriptOnly, title }));
1632
assert_eq!(control.try_recv_command(), Some(CallCommand::StopRecording { scope: StopScope::RecordingOnly }));
1633
assert_eq!(control.try_recv_command(), Some(CallCommand::StopRecording { scope: StopScope::TranscriptionOnly }));
1634
assert_eq!(control.try_recv_command(), None);
1635
}
1636
1637
#[gpui_kit::test]
1638
fn the_transcript_turns_captions_on_and_excludes_the_chat_panel(cx: &mut TestAppContext) {
1639
let (app, mut control) = app_with_commands(cx, live_meeting(false), None);
1640
cx.update(|cx| {
1641
app.update(cx, |state, cx| {
1642
state.apply_call_update(7, CallUpdate::MeetingChat("19:meeting_x@thread.v2".into()), cx);
1643
state.toggle_call_chat(cx);
1644
state.show_call_transcript(cx);
1645
})
1646
});
1647
let (chat_open, transcript_open) = cx.update(|cx| {
1648
let call = app.read(cx).call.as_ref().unwrap();
1649
(call.chat_open, call.transcript_open)
1650
});
1651
assert!(!chat_open && transcript_open);
1652
assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptions(true)));
1653
cx.update(|cx| {
1654
app.update(cx, |state, cx| {
1655
state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::On), cx);
1656
state.show_call_transcript(cx);
1657
state.toggle_call_chat(cx);
1658
})
1659
});
1660
let (chat_open, transcript_open) = cx.update(|cx| {
1661
let call = app.read(cx).call.as_ref().unwrap();
1662
(call.chat_open, call.transcript_open)
1663
});
1664
assert!(chat_open && !transcript_open);
1665
assert_eq!(control.try_recv_command(), None);
1666
}
1667
1668
#[gpui_kit::test]
1669
fn a_spoken_language_picked_while_captions_are_off_is_sent_once_they_are_on(cx: &mut TestAppContext) {
1670
let (app, mut control) = app_with_commands(cx, live_meeting(false), None);
1671
cx.update(|cx| {
1672
app.update(cx, |state, cx| {
1673
state.choose_call_caption_language("de-DE", cx);
1674
state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::Starting), cx);
1675
})
1676
});
1677
assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptions(true)));
1678
assert_eq!(control.try_recv_command(), None);
1679
cx.update(|cx| {
1680
app.update(cx, |state, cx| {
1681
state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::On), cx);
1682
state.choose_call_caption_language("fr-FR", cx);
1683
})
1684
});
1685
assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptionLanguage("de-DE".into())));
1686
assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptionLanguage("fr-FR".into())));
1687
assert_eq!(control.try_recv_command(), None);
1688
}
1689
1690
#[gpui_kit::test]
1691
fn caption_size_and_position_are_stored_and_reach_the_call_model(cx: &mut TestAppContext) {
1692
let (app, _control) = app_with_commands(cx, live_meeting(false), None);
1693
cx.update(|cx| {
1694
app.update(cx, |state, cx| {
1695
state.set_call_caption_size(CaptionSize::Large, cx);
1696
state.set_call_caption_position(CaptionPosition::Top, cx);
1697
})
1698
});
1699
let (view, stored) = cx.update(|cx| {
1700
let state = app.read(cx);
1701
(state.call.as_ref().unwrap().model.view, ViewSettings::load(&state.store))
1702
});
1703
assert_eq!((view.caption_size, view.caption_position), (CaptionSize::Large, CaptionPosition::Top));
1704
assert_eq!((stored.caption_size, stored.caption_position), (CaptionSize::Large, CaptionPosition::Top));
1705
}
1706
1609
1707
fn live_one_to_one() -> CallModel {
1610
1708
let mut model = CallModel::people("Bea", &[("8:orgid:bea".into(), "Bea".into())]);
1611
1709
model.apply(CallUpdate::State(CallState::Connected {
@@ -350,6 +350,9 @@ impl AppState {350
crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);350
crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);351
}351
}352
call.model.apply(update);352
call.model.apply(update);353
if let Some(language) = call.model.take_ready_caption_language() {354
let _ = call.commands.send(CallCommand::SetCaptionLanguage(language));355
}353
if call.model.screen_sharer.is_none() {356
if call.model.screen_sharer.is_none() {354
call.stage_fullscreen = false;357
call.stage_fullscreen = false;355
call.pictures.forget(&VideoKey::Screen, cx);358
call.pictures.forget(&VideoKey::Screen, cx);@@ -374,6 +377,7 @@ impl AppState {374
crate::agent_api::clear_captions(thread, cx);377
crate::agent_api::clear_captions(thread, cx);375
}378
}376
self.call = None;379
self.call = None;380
self.transcript_panel = None;377
if let Some(consult) = consult {381
if let Some(consult) = consult {378
let _ = consult.commands.send(CallCommand::Hangup);382
let _ = consult.commands.send(CallCommand::Hangup);379
}383
}@@ -516,6 +520,10 @@ impl AppState {516
return;520
return;517
};521
};518
call.chat_open = !call.chat_open;522
call.chat_open = !call.chat_open;523
if call.chat_open {524
call.transcript_open = false;525
self.transcript_panel = None;526
}519
cx.emit(AppEvent::Call);527
cx.emit(AppEvent::Call);520
cx.notify();528
cx.notify();521
}529
}@@ -1129,7 +1137,8 @@ mod tests {1129
1137
1130
use calling::{1138
use calling::{1131
BackgroundChoice, CallCommand, CallControl, CallState, CallUpdate, CameraEffects,1139
BackgroundChoice, CallCommand, CallControl, CallState, CallUpdate, CameraEffects,1132
DeviceChoice, EndKind, EndReason, EngineEvent, HoldState, Reaction, call_channel,1140
DeviceChoice, EndKind, EndReason, EngineEvent, HoldState, Reaction, RecordingKind,1141
StopScope, call_channel,1133
};1142
};1134
use gpui_kit::{AppContext as _, Entity, TestAppContext};1143
use gpui_kit::{AppContext as _, Entity, TestAppContext};1135
use store::{ChatRecord, MemberRecord, Store};1144
use store::{ChatRecord, MemberRecord, Store};@@ -1138,6 +1147,7 @@ mod tests {1138
use crate::app_state::{AppEvent, AppState, Mode, Selection};1147
use crate::app_state::{AppEvent, AppState, Mode, Selection};1139
use crate::call::TransferCandidate;1148
use crate::call::TransferCandidate;1140
use crate::call::background::BackgroundPick;1149
use crate::call::background::BackgroundPick;1150
use crate::call::{CaptionPosition, CaptionSize, RecordAction, ViewSettings};1141
use crate::call::demo::demo_ring;1151
use crate::call::demo::demo_ring;1142
use crate::call::features::room_closed_move;1152
use crate::call::features::room_closed_move;1143
use crate::call::model::{BreakoutState, ConsultCall};1153
use crate::call::model::{BreakoutState, ConsultCall};@@ -1569,7 +1579,7 @@ mod tests {1569
let (attendee, mut attendee_control) = app_with_commands(cx, live_meeting(false), None);1579
let (attendee, mut attendee_control) = app_with_commands(cx, live_meeting(false), None);1570
cx.update(|cx| {1580
cx.update(|cx| {1571
attendee.update(cx, |state, cx| {1581
attendee.update(cx, |state, cx| {1572
state.set_call_recording(true, cx);1582
state.run_call_record_action(RecordAction::Start(RecordingKind::Video), cx);1573
state.accept_recording_notice(cx);1583
state.accept_recording_notice(cx);1574
})1584
})1575
});1585
});@@ -1577,9 +1587,9 @@ mod tests {1577
let (organizer, mut control) = app_with_commands(cx, live_meeting(true), None);1587
let (organizer, mut control) = app_with_commands(cx, live_meeting(true), None);1578
cx.update(|cx| {1588
cx.update(|cx| {1579
organizer.update(cx, |state, cx| {1589
organizer.update(cx, |state, cx| {1580
state.set_call_recording(true, cx);1590
state.run_call_record_action(RecordAction::Start(RecordingKind::Video), cx);1581
state.apply_call_update(7, CallUpdate::Recording(true), cx);1591
state.apply_call_update(7, CallUpdate::Recording(true), cx);1582
state.set_call_recording(false, cx);1592
state.run_call_record_action(RecordAction::Stop(StopScope::Both), cx);1583
state.accept_recording_notice(cx);1593
state.accept_recording_notice(cx);1584
state.apply_call_update(7, CallUpdate::ConsentRequired(true), cx);1594
state.apply_call_update(7, CallUpdate::ConsentRequired(true), cx);1585
state.accept_recording_notice(cx);1595
state.accept_recording_notice(cx);@@ -1587,16 +1597,15 @@ mod tests {1587
});1597
});1588
assert_eq!(1598
assert_eq!(1589
control.try_recv_command(),1599
control.try_recv_command(),1590
Some(CallCommand::SetRecording {1600
Some(CallCommand::StartRecording {1591
on: true,1601
kind: RecordingKind::Video,1592
title: "Standup".into()1602
title: "Standup".into()1593
})1603
})1594
);1604
);1595
assert_eq!(1605
assert_eq!(1596
control.try_recv_command(),1606
control.try_recv_command(),1597
Some(CallCommand::SetRecording {1607
Some(CallCommand::StopRecording {1598
on: false,1608
scope: StopScope::Both1599
title: "Standup".into()1600
})1609
})1601
);1610
);1602
assert_eq!(1611
assert_eq!(@@ -1606,6 +1615,95 @@ mod tests {1606
assert_eq!(control.try_recv_command(), None);1615
assert_eq!(control.try_recv_command(), None);1607
}1616
}1608
1617
1618
#[gpui_kit::test]1619
fn every_record_action_becomes_its_own_command_for_the_organizer(cx: &mut TestAppContext) {1620
let (organizer, mut control) = app_with_commands(cx, live_meeting(true), None);1621
cx.update(|cx| {1622
organizer.update(cx, |state, cx| {1623
state.run_call_record_action(RecordAction::Start(RecordingKind::AudioOnly), cx);1624
state.run_call_record_action(RecordAction::Start(RecordingKind::TranscriptOnly), cx);1625
state.run_call_record_action(RecordAction::Stop(StopScope::RecordingOnly), cx);1626
state.run_call_record_action(RecordAction::Stop(StopScope::TranscriptionOnly), cx);1627
})1628
});1629
let title = "Standup".to_owned();1630
assert_eq!(control.try_recv_command(), Some(CallCommand::StartRecording { kind: RecordingKind::AudioOnly, title: title.clone() }));1631
assert_eq!(control.try_recv_command(), Some(CallCommand::StartRecording { kind: RecordingKind::TranscriptOnly, title }));1632
assert_eq!(control.try_recv_command(), Some(CallCommand::StopRecording { scope: StopScope::RecordingOnly }));1633
assert_eq!(control.try_recv_command(), Some(CallCommand::StopRecording { scope: StopScope::TranscriptionOnly }));1634
assert_eq!(control.try_recv_command(), None);1635
}1636
1637
#[gpui_kit::test]1638
fn the_transcript_turns_captions_on_and_excludes_the_chat_panel(cx: &mut TestAppContext) {1639
let (app, mut control) = app_with_commands(cx, live_meeting(false), None);1640
cx.update(|cx| {1641
app.update(cx, |state, cx| {1642
state.apply_call_update(7, CallUpdate::MeetingChat("19:meeting_x@thread.v2".into()), cx);1643
state.toggle_call_chat(cx);1644
state.show_call_transcript(cx);1645
})1646
});1647
let (chat_open, transcript_open) = cx.update(|cx| {1648
let call = app.read(cx).call.as_ref().unwrap();1649
(call.chat_open, call.transcript_open)1650
});1651
assert!(!chat_open && transcript_open);1652
assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptions(true)));1653
cx.update(|cx| {1654
app.update(cx, |state, cx| {1655
state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::On), cx);1656
state.show_call_transcript(cx);1657
state.toggle_call_chat(cx);1658
})1659
});1660
let (chat_open, transcript_open) = cx.update(|cx| {1661
let call = app.read(cx).call.as_ref().unwrap();1662
(call.chat_open, call.transcript_open)1663
});1664
assert!(chat_open && !transcript_open);1665
assert_eq!(control.try_recv_command(), None);1666
}1667
1668
#[gpui_kit::test]1669
fn a_spoken_language_picked_while_captions_are_off_is_sent_once_they_are_on(cx: &mut TestAppContext) {1670
let (app, mut control) = app_with_commands(cx, live_meeting(false), None);1671
cx.update(|cx| {1672
app.update(cx, |state, cx| {1673
state.choose_call_caption_language("de-DE", cx);1674
state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::Starting), cx);1675
})1676
});1677
assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptions(true)));1678
assert_eq!(control.try_recv_command(), None);1679
cx.update(|cx| {1680
app.update(cx, |state, cx| {1681
state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::On), cx);1682
state.choose_call_caption_language("fr-FR", cx);1683
})1684
});1685
assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptionLanguage("de-DE".into())));1686
assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptionLanguage("fr-FR".into())));1687
assert_eq!(control.try_recv_command(), None);1688
}1689
1690
#[gpui_kit::test]1691
fn caption_size_and_position_are_stored_and_reach_the_call_model(cx: &mut TestAppContext) {1692
let (app, _control) = app_with_commands(cx, live_meeting(false), None);1693
cx.update(|cx| {1694
app.update(cx, |state, cx| {1695
state.set_call_caption_size(CaptionSize::Large, cx);1696
state.set_call_caption_position(CaptionPosition::Top, cx);1697
})1698
});1699
let (view, stored) = cx.update(|cx| {1700
let state = app.read(cx);1701
(state.call.as_ref().unwrap().model.view, ViewSettings::load(&state.store))1702
});1703
assert_eq!((view.caption_size, view.caption_position), (CaptionSize::Large, CaptionPosition::Top));1704
assert_eq!((stored.caption_size, stored.caption_position), (CaptionSize::Large, CaptionPosition::Top));1705
}1706
1609
fn live_one_to_one() -> CallModel {1707
fn live_one_to_one() -> CallModel {1610
let mut model = CallModel::people("Bea", &[("8:orgid:bea".into(), "Bea".into())]);1708
let mut model = CallModel::people("Bea", &[("8:orgid:bea".into(), "Bea".into())]);1611
model.apply(CallUpdate::State(CallState::Connected {1709
model.apply(CallUpdate::State(CallState::Connected {@@ -0,0 +1,75 @@
1
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
2
pub enum CaptionSize {
3
Small,
4
#[default]
5
Medium,
6
Large,
7
}
8
9
impl CaptionSize {
10
pub const ALL: [CaptionSize; 3] = [CaptionSize::Small, CaptionSize::Medium, CaptionSize::Large];
11
12
pub fn label(self) -> &'static str {
13
match self {
14
CaptionSize::Small => "Small",
15
CaptionSize::Medium => "Medium",
16
CaptionSize::Large => "Large",
17
}
18
}
19
20
pub fn text_size(self) -> f32 {
21
match self {
22
CaptionSize::Small => 13.,
23
CaptionSize::Medium => 16.,
24
CaptionSize::Large => 21.,
25
}
26
}
27
28
pub fn meta(self) -> &'static str {
29
match self {
30
CaptionSize::Small => "small",
31
CaptionSize::Medium => "medium",
32
CaptionSize::Large => "large",
33
}
34
}
35
36
pub fn from_meta(value: &str) -> CaptionSize {
37
match value {
38
"small" => CaptionSize::Small,
39
"large" => CaptionSize::Large,
40
_ => CaptionSize::Medium,
41
}
42
}
43
}
44
45
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
46
pub enum CaptionPosition {
47
#[default]
48
Bottom,
49
Top,
50
}
51
52
impl CaptionPosition {
53
pub const ALL: [CaptionPosition; 2] = [CaptionPosition::Bottom, CaptionPosition::Top];
54
55
pub fn label(self) -> &'static str {
56
match self {
57
CaptionPosition::Bottom => "Bottom",
58
CaptionPosition::Top => "Top",
59
}
60
}
61
62
pub fn meta(self) -> &'static str {
63
match self {
64
CaptionPosition::Bottom => "bottom",
65
CaptionPosition::Top => "top",
66
}
67
}
68
69
pub fn from_meta(value: &str) -> CaptionPosition {
70
match value {
71
"top" => CaptionPosition::Top,
72
_ => CaptionPosition::Bottom,
73
}
74
}
75
}
@@ -0,0 +1,75 @@1
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]2
pub enum CaptionSize {3
Small,4
#[default]5
Medium,6
Large,7
}8
9
impl CaptionSize {10
pub const ALL: [CaptionSize; 3] = [CaptionSize::Small, CaptionSize::Medium, CaptionSize::Large];11
12
pub fn label(self) -> &'static str {13
match self {14
CaptionSize::Small => "Small",15
CaptionSize::Medium => "Medium",16
CaptionSize::Large => "Large",17
}18
}19
20
pub fn text_size(self) -> f32 {21
match self {22
CaptionSize::Small => 13.,23
CaptionSize::Medium => 16.,24
CaptionSize::Large => 21.,25
}26
}27
28
pub fn meta(self) -> &'static str {29
match self {30
CaptionSize::Small => "small",31
CaptionSize::Medium => "medium",32
CaptionSize::Large => "large",33
}34
}35
36
pub fn from_meta(value: &str) -> CaptionSize {37
match value {38
"small" => CaptionSize::Small,39
"large" => CaptionSize::Large,40
_ => CaptionSize::Medium,41
}42
}43
}44
45
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]46
pub enum CaptionPosition {47
#[default]48
Bottom,49
Top,50
}51
52
impl CaptionPosition {53
pub const ALL: [CaptionPosition; 2] = [CaptionPosition::Bottom, CaptionPosition::Top];54
55
pub fn label(self) -> &'static str {56
match self {57
CaptionPosition::Bottom => "Bottom",58
CaptionPosition::Top => "Top",59
}60
}61
62
pub fn meta(self) -> &'static str {63
match self {64
CaptionPosition::Bottom => "bottom",65
CaptionPosition::Top => "top",66
}67
}68
69
pub fn from_meta(value: &str) -> CaptionPosition {70
match value {71
"top" => CaptionPosition::Top,72
_ => CaptionPosition::Bottom,73
}74
}75
}@@ -8,7 +8,7 @@ use calling::{
8
8
CallState, CallUpdate, Caller, CaptionEntry, CaptionState, ContentShare, DeviceChoice,
9
9
DeviceLists, EndReason, HealthSample, HoldState, IncomingRing, Limitation, MediaPath,
10
10
MeetingTarget, NetworkLevel, Progress, PublishedState, RaisedHand, Reaction, RosterEntry,
11
ShareKind, ShareSource, TransportDetails, VideoKey, call_channel,
11
RecordingKind, ShareKind, ShareSource, StopScope, TransportDetails, VideoKey, call_channel,
12
12
};
13
13
14
14
use super::demo_scene::self_view;
@@ -384,7 +384,11 @@ fn publish_demo_video(
384
384
385
385
fn start_scene(control: &CallControl, scene: DemoScene) {
386
386
match scene {
387
DemoScene::Recording => control.send(CallUpdate::Recording(true)),
387
DemoScene::Recording => {
388
control.send(CallUpdate::Recording(true));
389
control.send(CallUpdate::Transcribing(true));
390
control.send(CallUpdate::Captions(CaptionState::On));
391
}
388
392
DemoScene::Consent => {
389
393
control.send(CallUpdate::Recording(true));
390
394
control.send(CallUpdate::ConsentRequired(true));
@@ -465,7 +469,9 @@ async fn speak_until_hangup(
465
469
let mut camera_on = false;
466
470
let mut incoming_video = true;
467
471
let mut blur = false;
468
let mut captions_on = false;
472
let mut captions_on = scene == DemoScene::Recording;
473
let mut recording_on = matches!(scene, DemoScene::Recording | DemoScene::Consent);
474
let mut transcribing_on = scene == DemoScene::Recording;
469
475
let mut caption_ticks = 0usize;
470
476
let mut video_tick = interval(VIDEO_PERIOD);
471
477
let mut muted = false;
@@ -597,7 +603,20 @@ async fn speak_until_hangup(
597
603
control.send(CallUpdate::IncomingVideo(enabled));
598
604
}
599
605
Some(CallCommand::SetCameraEffects(_)) => {}
600
Some(CallCommand::SetRecording { on, .. }) => control.send(CallUpdate::Recording(on)),
606
Some(CallCommand::StartRecording { kind, .. }) => {
607
recording_on = kind != RecordingKind::TranscriptOnly;
608
transcribing_on = true;
609
control.send(CallUpdate::Recording(recording_on));
610
control.send(CallUpdate::RecordingAudioOnly(kind == RecordingKind::AudioOnly));
611
control.send(CallUpdate::Transcribing(true));
612
}
613
Some(CallCommand::StopRecording { scope }) => {
614
recording_on = recording_on && scope == StopScope::TranscriptionOnly;
615
transcribing_on = transcribing_on && scope == StopScope::RecordingOnly;
616
control.send(CallUpdate::Recording(recording_on));
617
control.send(CallUpdate::Transcribing(transcribing_on));
618
}
619
Some(CallCommand::SetCaptionLanguage(_)) => {}
601
620
Some(CallCommand::ConsentToRecording) => control.send(CallUpdate::ConsentRequired(false)),
602
621
Some(CallCommand::Hold(hold)) => control.send(CallUpdate::Hold(if hold { HoldState::Local } else { HoldState::Active })),
603
622
Some(CallCommand::Transfer { .. }) => {
@@ -8,7 +8,7 @@ use calling::{8
CallState, CallUpdate, Caller, CaptionEntry, CaptionState, ContentShare, DeviceChoice,8
CallState, CallUpdate, Caller, CaptionEntry, CaptionState, ContentShare, DeviceChoice,9
DeviceLists, EndReason, HealthSample, HoldState, IncomingRing, Limitation, MediaPath,9
DeviceLists, EndReason, HealthSample, HoldState, IncomingRing, Limitation, MediaPath,10
MeetingTarget, NetworkLevel, Progress, PublishedState, RaisedHand, Reaction, RosterEntry,10
MeetingTarget, NetworkLevel, Progress, PublishedState, RaisedHand, Reaction, RosterEntry,11
ShareKind, ShareSource, TransportDetails, VideoKey, call_channel,11
RecordingKind, ShareKind, ShareSource, StopScope, TransportDetails, VideoKey, call_channel,12
};12
};13
13
14
use super::demo_scene::self_view;14
use super::demo_scene::self_view;@@ -384,7 +384,11 @@ fn publish_demo_video(384
384
385
fn start_scene(control: &CallControl, scene: DemoScene) {385
fn start_scene(control: &CallControl, scene: DemoScene) {386
match scene {386
match scene {387
DemoScene::Recording => control.send(CallUpdate::Recording(true)),387
DemoScene::Recording => {388
control.send(CallUpdate::Recording(true));389
control.send(CallUpdate::Transcribing(true));390
control.send(CallUpdate::Captions(CaptionState::On));391
}388
DemoScene::Consent => {392
DemoScene::Consent => {389
control.send(CallUpdate::Recording(true));393
control.send(CallUpdate::Recording(true));390
control.send(CallUpdate::ConsentRequired(true));394
control.send(CallUpdate::ConsentRequired(true));@@ -465,7 +469,9 @@ async fn speak_until_hangup(465
let mut camera_on = false;469
let mut camera_on = false;466
let mut incoming_video = true;470
let mut incoming_video = true;467
let mut blur = false;471
let mut blur = false;468
let mut captions_on = false;472
let mut captions_on = scene == DemoScene::Recording;473
let mut recording_on = matches!(scene, DemoScene::Recording | DemoScene::Consent);474
let mut transcribing_on = scene == DemoScene::Recording;469
let mut caption_ticks = 0usize;475
let mut caption_ticks = 0usize;470
let mut video_tick = interval(VIDEO_PERIOD);476
let mut video_tick = interval(VIDEO_PERIOD);471
let mut muted = false;477
let mut muted = false;@@ -597,7 +603,20 @@ async fn speak_until_hangup(597
control.send(CallUpdate::IncomingVideo(enabled));603
control.send(CallUpdate::IncomingVideo(enabled));598
}604
}599
Some(CallCommand::SetCameraEffects(_)) => {}605
Some(CallCommand::SetCameraEffects(_)) => {}600
Some(CallCommand::SetRecording { on, .. }) => control.send(CallUpdate::Recording(on)),606
Some(CallCommand::StartRecording { kind, .. }) => {607
recording_on = kind != RecordingKind::TranscriptOnly;608
transcribing_on = true;609
control.send(CallUpdate::Recording(recording_on));610
control.send(CallUpdate::RecordingAudioOnly(kind == RecordingKind::AudioOnly));611
control.send(CallUpdate::Transcribing(true));612
}613
Some(CallCommand::StopRecording { scope }) => {614
recording_on = recording_on && scope == StopScope::TranscriptionOnly;615
transcribing_on = transcribing_on && scope == StopScope::RecordingOnly;616
control.send(CallUpdate::Recording(recording_on));617
control.send(CallUpdate::Transcribing(transcribing_on));618
}619
Some(CallCommand::SetCaptionLanguage(_)) => {}601
Some(CallCommand::ConsentToRecording) => control.send(CallUpdate::ConsentRequired(false)),620
Some(CallCommand::ConsentToRecording) => control.send(CallUpdate::ConsentRequired(false)),602
Some(CallCommand::Hold(hold)) => control.send(CallUpdate::Hold(if hold { HoldState::Local } else { HoldState::Active })),621
Some(CallCommand::Hold(hold)) => control.send(CallUpdate::Hold(if hold { HoldState::Local } else { HoldState::Active })),603
Some(CallCommand::Transfer { .. }) => {622
Some(CallCommand::Transfer { .. }) => {@@ -6,10 +6,12 @@ use gpui_kit::*;
6
6
use super::background::BackgroundPick;
7
7
use super::demo::{DemoCall, start_demo_call};
8
8
use super::health::HealthBanner;
9
use super::model::{ActiveCall, BreakoutState, CallModel, ConsultCall, PendingMove};
9
use super::model::{ActiveCall, BreakoutState, CallKind, CallModel, ConsultCall, PendingMove};
10
use super::recording_menu::RecordAction;
10
11
use super::target::plan_for_chat;
11
use crate::app_state::AppState;
12
use crate::app_state::{AppEvent, AppState};
12
13
use crate::data::is_one_on_one;
14
use crate::views::call_transcript::TranscriptPanel;
13
15
14
16
const DEMO_ROOM_GUESTS: usize = 3;
15
17
@@ -38,12 +40,81 @@ fn return_move(room: &BreakoutState) -> PendingMove {
38
40
}
39
41
40
42
impl AppState {
41
pub fn set_call_recording(&mut self, on: bool, _cx: &mut Context<Self>) {
43
pub fn run_call_record_action(&mut self, action: RecordAction, _cx: &mut Context<Self>) {
42
44
let Some(call) = self.call.as_ref().filter(|call| call.model.can_record()) else {
43
45
return;
44
46
};
45
let title = call.model.title.clone();
46
self.send_call_command(CallCommand::SetRecording { on, title });
47
let command = match action {
48
RecordAction::Start(kind) => CallCommand::StartRecording {
49
kind,
50
title: call.model.title.clone(),
51
},
52
RecordAction::Stop(scope) => CallCommand::StopRecording { scope },
53
};
54
self.send_call_command(command);
55
}
56
57
pub fn open_call_transcript(
58
&mut self,
59
panel: Entity<TranscriptPanel>,
60
cx: &mut Context<Self>,
61
) {
62
self.transcript_panel = Some(panel);
63
self.show_call_transcript(cx);
64
}
65
66
pub(super) fn show_call_transcript(&mut self, cx: &mut Context<Self>) {
67
let Some(call) = self
68
.call
69
.as_mut()
70
.filter(|call| call.model.kind == CallKind::Meeting)
71
else {
72
return;
73
};
74
call.chat_open = false;
75
call.transcript_open = true;
76
let captions_off = !call.model.captions_on();
77
if captions_off {
78
self.send_call_command(CallCommand::SetCaptions(true));
79
}
80
cx.emit(AppEvent::Call);
81
cx.notify();
82
}
83
84
pub fn close_call_transcript(&mut self, cx: &mut Context<Self>) {
85
if let Some(call) = self.call.as_mut() {
86
call.transcript_open = false;
87
}
88
self.transcript_panel = None;
89
cx.emit(AppEvent::Call);
90
cx.notify();
91
}
92
93
pub fn choose_call_caption_language(&mut self, tag: &str, cx: &mut Context<Self>) {
94
let Some(call) = self
95
.call
96
.as_mut()
97
.filter(|call| call.model.is_active() && call.model.kind == CallKind::Meeting)
98
else {
99
return;
100
};
101
call.model.choose_caption_language(tag);
102
let captions_off = !call.model.captions_on();
103
if captions_off {
104
self.send_call_command(CallCommand::SetCaptions(true));
105
}
106
self.send_ready_caption_language();
107
cx.notify();
108
}
109
110
fn send_ready_caption_language(&mut self) {
111
let language = self
112
.call
113
.as_mut()
114
.and_then(|call| call.model.take_ready_caption_language());
115
if let Some(language) = language {
116
self.send_call_command(CallCommand::SetCaptionLanguage(language));
117
}
47
118
}
48
119
49
120
pub fn accept_recording_notice(&mut self, _cx: &mut Context<Self>) {
@@ -6,10 +6,12 @@ use gpui_kit::*;6
use super::background::BackgroundPick;6
use super::background::BackgroundPick;7
use super::demo::{DemoCall, start_demo_call};7
use super::demo::{DemoCall, start_demo_call};8
use super::health::HealthBanner;8
use super::health::HealthBanner;9
use super::model::{ActiveCall, BreakoutState, CallModel, ConsultCall, PendingMove};9
use super::model::{ActiveCall, BreakoutState, CallKind, CallModel, ConsultCall, PendingMove};10
use super::recording_menu::RecordAction;10
use super::target::plan_for_chat;11
use super::target::plan_for_chat;11
use crate::app_state::AppState;12
use crate::app_state::{AppEvent, AppState};12
use crate::data::is_one_on_one;13
use crate::data::is_one_on_one;14
use crate::views::call_transcript::TranscriptPanel;13
15
14
const DEMO_ROOM_GUESTS: usize = 3;16
const DEMO_ROOM_GUESTS: usize = 3;15
17
@@ -38,12 +40,81 @@ fn return_move(room: &BreakoutState) -> PendingMove {38
}40
}39
41
40
impl AppState {42
impl AppState {41
pub fn set_call_recording(&mut self, on: bool, _cx: &mut Context<Self>) {43
pub fn run_call_record_action(&mut self, action: RecordAction, _cx: &mut Context<Self>) {42
let Some(call) = self.call.as_ref().filter(|call| call.model.can_record()) else {44
let Some(call) = self.call.as_ref().filter(|call| call.model.can_record()) else {43
return;45
return;44
};46
};45
let title = call.model.title.clone();47
let command = match action {46
self.send_call_command(CallCommand::SetRecording { on, title });48
RecordAction::Start(kind) => CallCommand::StartRecording {49
kind,50
title: call.model.title.clone(),51
},52
RecordAction::Stop(scope) => CallCommand::StopRecording { scope },53
};54
self.send_call_command(command);55
}56
57
pub fn open_call_transcript(58
&mut self,59
panel: Entity<TranscriptPanel>,60
cx: &mut Context<Self>,61
) {62
self.transcript_panel = Some(panel);63
self.show_call_transcript(cx);64
}65
66
pub(super) fn show_call_transcript(&mut self, cx: &mut Context<Self>) {67
let Some(call) = self68
.call69
.as_mut()70
.filter(|call| call.model.kind == CallKind::Meeting)71
else {72
return;73
};74
call.chat_open = false;75
call.transcript_open = true;76
let captions_off = !call.model.captions_on();77
if captions_off {78
self.send_call_command(CallCommand::SetCaptions(true));79
}80
cx.emit(AppEvent::Call);81
cx.notify();82
}83
84
pub fn close_call_transcript(&mut self, cx: &mut Context<Self>) {85
if let Some(call) = self.call.as_mut() {86
call.transcript_open = false;87
}88
self.transcript_panel = None;89
cx.emit(AppEvent::Call);90
cx.notify();91
}92
93
pub fn choose_call_caption_language(&mut self, tag: &str, cx: &mut Context<Self>) {94
let Some(call) = self95
.call96
.as_mut()97
.filter(|call| call.model.is_active() && call.model.kind == CallKind::Meeting)98
else {99
return;100
};101
call.model.choose_caption_language(tag);102
let captions_off = !call.model.captions_on();103
if captions_off {104
self.send_call_command(CallCommand::SetCaptions(true));105
}106
self.send_ready_caption_language();107
cx.notify();108
}109
110
fn send_ready_caption_language(&mut self) {111
let language = self112
.call113
.as_mut()114
.and_then(|call| call.model.take_ready_caption_language());115
if let Some(language) = language {116
self.send_call_command(CallCommand::SetCaptionLanguage(language));117
}47
}118
}48
119
49
pub fn accept_recording_notice(&mut self, _cx: &mut Context<Self>) {120
pub fn accept_recording_notice(&mut self, _cx: &mut Context<Self>) {@@ -3,6 +3,7 @@ mod agenda;
3
3
mod background;
4
4
mod bubbles;
5
5
mod calendar;
6
mod caption_style;
6
7
mod demo;
7
8
mod demo_scene;
8
9
mod features;
@@ -20,15 +21,18 @@ mod overlay_layout;
20
21
mod pictures;
21
22
mod preview;
22
23
mod push_to_talk;
24
mod recording_menu;
23
25
mod ring;
24
26
mod stage_layout;
25
27
mod target;
28
mod transcript;
26
29
mod view_actions;
27
30
mod view_settings;
28
31
29
32
pub use actions::{load_camera, load_camera_effects, load_share_sound};
30
33
pub use mic::load_mic;
31
34
pub use agenda::{AgendaRow, fetch_window, join_available};
35
pub use caption_style::{CaptionPosition, CaptionSize};
32
36
pub use background::{
33
37
BackgroundLibrary, BackgroundPick, default_cache_directory, demo_library, load_background,
34
38
load_custom_backgrounds,
@@ -52,5 +56,7 @@ pub use overlay::CallWindows;
52
56
pub use preview::{CameraPreview, preview_backgrounds};
53
57
pub use ring::{MissedCall, RingEntry, Rings};
54
58
pub use stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, filmstrip, gallery_grid, split_overflow};
59
pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};
55
60
pub use target::plan_for_chat;
61
pub use transcript::clock_label;
56
62
pub use view_settings::{CallLayout, ViewSettings};
@@ -3,6 +3,7 @@ mod agenda;3
mod background;3
mod background;4
mod bubbles;4
mod bubbles;5
mod calendar;5
mod calendar;6
mod caption_style;6
mod demo;7
mod demo;7
mod demo_scene;8
mod demo_scene;8
mod features;9
mod features;@@ -20,15 +21,18 @@ mod overlay_layout;20
mod pictures;21
mod pictures;21
mod preview;22
mod preview;22
mod push_to_talk;23
mod push_to_talk;24
mod recording_menu;23
mod ring;25
mod ring;24
mod stage_layout;26
mod stage_layout;25
mod target;27
mod target;28
mod transcript;26
mod view_actions;29
mod view_actions;27
mod view_settings;30
mod view_settings;28
31
29
pub use actions::{load_camera, load_camera_effects, load_share_sound};32
pub use actions::{load_camera, load_camera_effects, load_share_sound};30
pub use mic::load_mic;33
pub use mic::load_mic;31
pub use agenda::{AgendaRow, fetch_window, join_available};34
pub use agenda::{AgendaRow, fetch_window, join_available};35
pub use caption_style::{CaptionPosition, CaptionSize};32
pub use background::{36
pub use background::{33
BackgroundLibrary, BackgroundPick, default_cache_directory, demo_library, load_background,37
BackgroundLibrary, BackgroundPick, default_cache_directory, demo_library, load_background,34
load_custom_backgrounds,38
load_custom_backgrounds,@@ -52,5 +56,7 @@ pub use overlay::CallWindows;52
pub use preview::{CameraPreview, preview_backgrounds};56
pub use preview::{CameraPreview, preview_backgrounds};53
pub use ring::{MissedCall, RingEntry, Rings};57
pub use ring::{MissedCall, RingEntry, Rings};54
pub use stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, filmstrip, gallery_grid, split_overflow};58
pub use stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, filmstrip, gallery_grid, split_overflow};59
pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};55
pub use target::plan_for_chat;60
pub use target::plan_for_chat;61
pub use transcript::clock_label;56
pub use view_settings::{CallLayout, ViewSettings};62
pub use view_settings::{CallLayout, ViewSettings};@@ -16,6 +16,7 @@ use super::bubbles::ChatBubble;
16
16
use super::fullscreen::FullscreenState;
17
17
use super::pictures::CallPictures;
18
18
use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};
19
use super::transcript::{Transcript, TranscriptEntry};
19
20
use super::view_settings::{CallLayout, ViewSettings};
20
21
use super::push_to_talk::PushToTalk;
21
22
@@ -46,6 +47,7 @@ pub struct ActiveCall {
46
47
pub share_menu_open: bool,
47
48
pub lobby_list_open: bool,
48
49
pub chat_open: bool,
50
pub transcript_open: bool,
49
51
pub meeting_target: Option<MeetingTarget>,
50
52
pub pending_move: Option<PendingMove>,
51
53
pub consult: Option<ConsultCall>,
@@ -109,6 +111,7 @@ impl ActiveCall {
109
111
share_menu_open: false,
110
112
lobby_list_open: false,
111
113
chat_open: false,
114
transcript_open: false,
112
115
meeting_target: None,
113
116
pending_move: None,
114
117
consult: None,
@@ -264,8 +267,13 @@ pub struct CallModel {
264
267
pub pinned: Option<String>,
265
268
pub captions: CaptionState,
266
269
pub caption_lines: Vec<CaptionLine>,
270
pub transcript: Transcript,
271
pub caption_language: Option<String>,
272
language_pending: bool,
267
273
pub background: BackgroundPick,
268
274
pub recording: bool,
275
pub recording_audio_only: bool,
276
pub transcribing: bool,
269
277
pub consent_required: bool,
270
278
pub hold: HoldState,
271
279
pub health: HealthState,
@@ -318,8 +326,13 @@ impl CallModel {
318
326
pinned: None,
319
327
captions: CaptionState::Off,
320
328
caption_lines: Vec::new(),
329
transcript: Transcript::default(),
330
caption_language: None,
331
language_pending: false,
321
332
background: BackgroundPick::None,
322
333
recording: false,
334
recording_audio_only: false,
335
transcribing: false,
323
336
consent_required: false,
324
337
hold: HoldState::Active,
325
338
health: HealthState::default(),
@@ -449,6 +462,8 @@ impl CallModel {
449
462
}
450
463
CallUpdate::Caption(entry) => self.note_caption(entry, Instant::now()),
451
464
CallUpdate::Recording(on) => self.recording = on,
465
CallUpdate::RecordingAudioOnly(audio_only) => self.recording_audio_only = audio_only,
466
CallUpdate::Transcribing(on) => self.transcribing = on,
452
467
CallUpdate::ConsentRequired(required) => self.consent_required = required,
453
468
CallUpdate::Hold(hold) => self.hold = hold,
454
469
CallUpdate::Health(health) => self.health.apply(health),
@@ -472,6 +487,15 @@ impl CallModel {
472
487
} else {
473
488
entry.display_name
474
489
};
490
let offset = self
491
.connected_since
492
.map_or(Duration::ZERO, |since| at.saturating_duration_since(since));
493
self.transcript.note(TranscriptEntry {
494
id: entry.id.clone(),
495
speaker: speaker.clone(),
496
text: entry.text.clone(),
497
offset,
498
});
475
499
let line = CaptionLine {
476
500
id: entry.id,
477
501
speaker,
@@ -493,6 +517,19 @@ impl CallModel {
493
517
.collect()
494
518
}
495
519
520
pub fn choose_caption_language(&mut self, tag: &str) {
521
self.caption_language = Some(tag.to_owned());
522
self.language_pending = true;
523
}
524
525
pub fn take_ready_caption_language(&mut self) -> Option<String> {
526
if self.language_pending && self.captions == CaptionState::On {
527
self.language_pending = false;
528
return self.caption_language.clone();
529
}
530
None
531
}
532
496
533
pub fn captions_on(&self) -> bool {
497
534
matches!(self.captions, CaptionState::Starting | CaptionState::On)
498
535
}
@@ -1939,6 +1976,48 @@ mod tests {
1939
1976
);
1940
1977
}
1941
1978
1979
#[test]
1980
fn the_transcript_keeps_every_caption_with_its_offset_while_the_overlay_keeps_two() {
1981
let mut model = meeting_with_me();
1982
let start = Instant::now();
1983
model.apply(CallUpdate::State(CallState::Connected { since: start }));
1984
model.apply(CallUpdate::Captions(CaptionState::On));
1985
model.note_caption(caption("1", "Ana Example", "One", true), start + Duration::from_secs(5));
1986
model.note_caption(caption("2", "Bo Sample", "Two", true), start + Duration::from_secs(65));
1987
model.note_caption(caption("3", "Ana Example", "Three", true), start + Duration::from_secs(70));
1988
assert_eq!(model.caption_lines.len(), 2);
1989
assert_eq!(model.transcript.filtered("").len(), 3);
1990
assert_eq!(model.transcript.filtered("")[1].offset, Duration::from_secs(65));
1991
model.apply(CallUpdate::Captions(CaptionState::Off));
1992
model.note_caption(caption("4", "Bo Sample", "Ignored", true), start + Duration::from_secs(80));
1993
assert!(model.caption_lines.is_empty());
1994
assert_eq!(model.transcript.filtered("").len(), 3);
1995
}
1996
1997
#[test]
1998
fn a_chosen_spoken_language_is_handed_out_once_the_captions_are_on() {
1999
let mut model = meeting_with_me();
2000
model.choose_caption_language("de-DE");
2001
model.apply(CallUpdate::Captions(CaptionState::Starting));
2002
assert_eq!(model.take_ready_caption_language(), None);
2003
model.apply(CallUpdate::Captions(CaptionState::On));
2004
assert_eq!(model.take_ready_caption_language().as_deref(), Some("de-DE"));
2005
assert_eq!(model.take_ready_caption_language(), None);
2006
assert_eq!(model.caption_language.as_deref(), Some("de-DE"));
2007
}
2008
2009
#[test]
2010
fn audio_only_and_transcription_follow_their_own_updates() {
2011
let mut model = meeting_with_me();
2012
model.apply(CallUpdate::Transcribing(true));
2013
assert!(model.transcribing && !model.recording);
2014
model.apply(CallUpdate::Recording(true));
2015
model.apply(CallUpdate::RecordingAudioOnly(true));
2016
assert!(model.recording && model.recording_audio_only);
2017
model.apply(CallUpdate::Transcribing(false));
2018
assert!(!model.transcribing && model.recording);
2019
}
2020
1942
2021
#[test]
1943
2022
fn recording_and_consent_follow_the_call_updates_and_only_organizers_may_record() {
1944
2023
let mut model = meeting_with_me();
@@ -16,6 +16,7 @@ use super::bubbles::ChatBubble;16
use super::fullscreen::FullscreenState;16
use super::fullscreen::FullscreenState;17
use super::pictures::CallPictures;17
use super::pictures::CallPictures;18
use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};18
use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};19
use super::transcript::{Transcript, TranscriptEntry};19
use super::view_settings::{CallLayout, ViewSettings};20
use super::view_settings::{CallLayout, ViewSettings};20
use super::push_to_talk::PushToTalk;21
use super::push_to_talk::PushToTalk;21
22
@@ -46,6 +47,7 @@ pub struct ActiveCall {46
pub share_menu_open: bool,47
pub share_menu_open: bool,47
pub lobby_list_open: bool,48
pub lobby_list_open: bool,48
pub chat_open: bool,49
pub chat_open: bool,50
pub transcript_open: bool,49
pub meeting_target: Option<MeetingTarget>,51
pub meeting_target: Option<MeetingTarget>,50
pub pending_move: Option<PendingMove>,52
pub pending_move: Option<PendingMove>,51
pub consult: Option<ConsultCall>,53
pub consult: Option<ConsultCall>,@@ -109,6 +111,7 @@ impl ActiveCall {109
share_menu_open: false,111
share_menu_open: false,110
lobby_list_open: false,112
lobby_list_open: false,111
chat_open: false,113
chat_open: false,114
transcript_open: false,112
meeting_target: None,115
meeting_target: None,113
pending_move: None,116
pending_move: None,114
consult: None,117
consult: None,@@ -264,8 +267,13 @@ pub struct CallModel {264
pub pinned: Option<String>,267
pub pinned: Option<String>,265
pub captions: CaptionState,268
pub captions: CaptionState,266
pub caption_lines: Vec<CaptionLine>,269
pub caption_lines: Vec<CaptionLine>,270
pub transcript: Transcript,271
pub caption_language: Option<String>,272
language_pending: bool,267
pub background: BackgroundPick,273
pub background: BackgroundPick,268
pub recording: bool,274
pub recording: bool,275
pub recording_audio_only: bool,276
pub transcribing: bool,269
pub consent_required: bool,277
pub consent_required: bool,270
pub hold: HoldState,278
pub hold: HoldState,271
pub health: HealthState,279
pub health: HealthState,@@ -318,8 +326,13 @@ impl CallModel {318
pinned: None,326
pinned: None,319
captions: CaptionState::Off,327
captions: CaptionState::Off,320
caption_lines: Vec::new(),328
caption_lines: Vec::new(),329
transcript: Transcript::default(),330
caption_language: None,331
language_pending: false,321
background: BackgroundPick::None,332
background: BackgroundPick::None,322
recording: false,333
recording: false,334
recording_audio_only: false,335
transcribing: false,323
consent_required: false,336
consent_required: false,324
hold: HoldState::Active,337
hold: HoldState::Active,325
health: HealthState::default(),338
health: HealthState::default(),@@ -449,6 +462,8 @@ impl CallModel {449
}462
}450
CallUpdate::Caption(entry) => self.note_caption(entry, Instant::now()),463
CallUpdate::Caption(entry) => self.note_caption(entry, Instant::now()),451
CallUpdate::Recording(on) => self.recording = on,464
CallUpdate::Recording(on) => self.recording = on,465
CallUpdate::RecordingAudioOnly(audio_only) => self.recording_audio_only = audio_only,466
CallUpdate::Transcribing(on) => self.transcribing = on,452
CallUpdate::ConsentRequired(required) => self.consent_required = required,467
CallUpdate::ConsentRequired(required) => self.consent_required = required,453
CallUpdate::Hold(hold) => self.hold = hold,468
CallUpdate::Hold(hold) => self.hold = hold,454
CallUpdate::Health(health) => self.health.apply(health),469
CallUpdate::Health(health) => self.health.apply(health),@@ -472,6 +487,15 @@ impl CallModel {472
} else {487
} else {473
entry.display_name488
entry.display_name474
};489
};490
let offset = self491
.connected_since492
.map_or(Duration::ZERO, |since| at.saturating_duration_since(since));493
self.transcript.note(TranscriptEntry {494
id: entry.id.clone(),495
speaker: speaker.clone(),496
text: entry.text.clone(),497
offset,498
});475
let line = CaptionLine {499
let line = CaptionLine {476
id: entry.id,500
id: entry.id,477
speaker,501
speaker,@@ -493,6 +517,19 @@ impl CallModel {493
.collect()517
.collect()494
}518
}495
519
520
pub fn choose_caption_language(&mut self, tag: &str) {521
self.caption_language = Some(tag.to_owned());522
self.language_pending = true;523
}524
525
pub fn take_ready_caption_language(&mut self) -> Option<String> {526
if self.language_pending && self.captions == CaptionState::On {527
self.language_pending = false;528
return self.caption_language.clone();529
}530
None531
}532
496
pub fn captions_on(&self) -> bool {533
pub fn captions_on(&self) -> bool {497
matches!(self.captions, CaptionState::Starting | CaptionState::On)534
matches!(self.captions, CaptionState::Starting | CaptionState::On)498
}535
}@@ -1939,6 +1976,48 @@ mod tests {1939
);1976
);1940
}1977
}1941
1978
1979
#[test]1980
fn the_transcript_keeps_every_caption_with_its_offset_while_the_overlay_keeps_two() {1981
let mut model = meeting_with_me();1982
let start = Instant::now();1983
model.apply(CallUpdate::State(CallState::Connected { since: start }));1984
model.apply(CallUpdate::Captions(CaptionState::On));1985
model.note_caption(caption("1", "Ana Example", "One", true), start + Duration::from_secs(5));1986
model.note_caption(caption("2", "Bo Sample", "Two", true), start + Duration::from_secs(65));1987
model.note_caption(caption("3", "Ana Example", "Three", true), start + Duration::from_secs(70));1988
assert_eq!(model.caption_lines.len(), 2);1989
assert_eq!(model.transcript.filtered("").len(), 3);1990
assert_eq!(model.transcript.filtered("")[1].offset, Duration::from_secs(65));1991
model.apply(CallUpdate::Captions(CaptionState::Off));1992
model.note_caption(caption("4", "Bo Sample", "Ignored", true), start + Duration::from_secs(80));1993
assert!(model.caption_lines.is_empty());1994
assert_eq!(model.transcript.filtered("").len(), 3);1995
}1996
1997
#[test]1998
fn a_chosen_spoken_language_is_handed_out_once_the_captions_are_on() {1999
let mut model = meeting_with_me();2000
model.choose_caption_language("de-DE");2001
model.apply(CallUpdate::Captions(CaptionState::Starting));2002
assert_eq!(model.take_ready_caption_language(), None);2003
model.apply(CallUpdate::Captions(CaptionState::On));2004
assert_eq!(model.take_ready_caption_language().as_deref(), Some("de-DE"));2005
assert_eq!(model.take_ready_caption_language(), None);2006
assert_eq!(model.caption_language.as_deref(), Some("de-DE"));2007
}2008
2009
#[test]2010
fn audio_only_and_transcription_follow_their_own_updates() {2011
let mut model = meeting_with_me();2012
model.apply(CallUpdate::Transcribing(true));2013
assert!(model.transcribing && !model.recording);2014
model.apply(CallUpdate::Recording(true));2015
model.apply(CallUpdate::RecordingAudioOnly(true));2016
assert!(model.recording && model.recording_audio_only);2017
model.apply(CallUpdate::Transcribing(false));2018
assert!(!model.transcribing && model.recording);2019
}2020
1942
#[test]2021
#[test]1943
fn recording_and_consent_follow_the_call_updates_and_only_organizers_may_record() {2022
fn recording_and_consent_follow_the_call_updates_and_only_organizers_may_record() {1944
let mut model = meeting_with_me();2023
let mut model = meeting_with_me();@@ -0,0 +1,121 @@
1
use std::time::Duration;
2
3
const RECENT_WINDOW: usize = 16;
4
5
#[derive(Debug, Clone, PartialEq, Eq)]
6
pub struct TranscriptEntry {
7
pub id: String,
8
pub speaker: String,
9
pub text: String,
10
pub offset: Duration,
11
}
12
13
#[derive(Debug, Clone, Default)]
14
pub struct Transcript {
15
entries: Vec<TranscriptEntry>,
16
}
17
18
impl Transcript {
19
pub fn note(&mut self, entry: TranscriptEntry) {
20
let start = self.entries.len().saturating_sub(RECENT_WINDOW);
21
let known = self.entries[start..]
22
.iter()
23
.rposition(|existing| existing.id == entry.id);
24
match known {
25
Some(position) => {
26
let existing = &mut self.entries[start + position];
27
existing.speaker = entry.speaker;
28
existing.text = entry.text;
29
}
30
None => self.entries.push(entry),
31
}
32
}
33
34
pub fn is_empty(&self) -> bool {
35
self.entries.is_empty()
36
}
37
38
pub fn filtered(&self, query: &str) -> Vec<&TranscriptEntry> {
39
let needle = query.trim().to_lowercase();
40
self.entries
41
.iter()
42
.filter(|entry| {
43
needle.is_empty()
44
|| entry.text.to_lowercase().contains(&needle)
45
|| entry.speaker.to_lowercase().contains(&needle)
46
})
47
.collect()
48
}
49
}
50
51
pub fn clock_label(offset: Duration) -> String {
52
let seconds = offset.as_secs();
53
format!("{:02}:{:02}", seconds / 60, seconds % 60)
54
}
55
56
#[cfg(test)]
57
mod tests {
58
use super::*;
59
60
fn entry(id: &str, speaker: &str, text: &str, seconds: u64) -> TranscriptEntry {
61
TranscriptEntry {
62
id: id.into(),
63
speaker: speaker.into(),
64
text: text.into(),
65
offset: Duration::from_secs(seconds),
66
}
67
}
68
69
fn sample() -> Transcript {
70
let mut transcript = Transcript::default();
71
transcript.note(entry("a", "Ana Example", "Welcome to the standup", 3));
72
transcript.note(entry("b", "Bo Sample", "The build is green", 9));
73
transcript.note(entry("c", "Ana Example", "Great, then we ship", 14));
74
transcript
75
}
76
77
#[test]
78
fn entries_keep_the_order_they_first_arrived_in() {
79
let transcript = sample();
80
let ids: Vec<&str> = transcript.filtered("").iter().map(|entry| entry.id.as_str()).collect();
81
assert_eq!(ids, ["a", "b", "c"]);
82
assert_eq!(transcript.filtered("").len(), 3);
83
}
84
85
#[test]
86
fn a_growing_partial_updates_its_entry_and_keeps_its_time_and_place() {
87
let mut transcript = sample();
88
transcript.note(entry("b", "Bo Sample", "The build is green again", 20));
89
assert_eq!(transcript.filtered("").len(), 3);
90
let updated = &transcript.filtered("")[1];
91
assert_eq!(updated.text, "The build is green again");
92
assert_eq!(updated.offset, Duration::from_secs(9));
93
}
94
95
#[test]
96
fn an_old_id_far_back_is_a_new_entry() {
97
let mut transcript = sample();
98
for index in 0..RECENT_WINDOW {
99
transcript.note(entry(&format!("x{index}"), "Ana Example", "filler", 30));
100
}
101
transcript.note(entry("a", "Ana Example", "again", 99));
102
assert_eq!(transcript.filtered("").len(), 3 + RECENT_WINDOW + 1);
103
}
104
105
#[test]
106
fn the_filter_matches_text_and_speaker_ignoring_case() {
107
let transcript = sample();
108
assert_eq!(transcript.filtered("BUILD").len(), 1);
109
assert_eq!(transcript.filtered("ana").len(), 2);
110
assert_eq!(transcript.filtered(" ship ").len(), 1);
111
assert!(transcript.filtered("nothing like this").is_empty());
112
assert_eq!(transcript.filtered(" ").len(), 3);
113
}
114
115
#[test]
116
fn the_clock_counts_minutes_and_seconds_since_the_call_start() {
117
assert_eq!(clock_label(Duration::from_secs(5)), "00:05");
118
assert_eq!(clock_label(Duration::from_secs(75)), "01:15");
119
assert_eq!(clock_label(Duration::from_secs(4_503)), "75:03");
120
}
121
}
@@ -0,0 +1,121 @@1
use std::time::Duration;2
3
const RECENT_WINDOW: usize = 16;4
5
#[derive(Debug, Clone, PartialEq, Eq)]6
pub struct TranscriptEntry {7
pub id: String,8
pub speaker: String,9
pub text: String,10
pub offset: Duration,11
}12
13
#[derive(Debug, Clone, Default)]14
pub struct Transcript {15
entries: Vec<TranscriptEntry>,16
}17
18
impl Transcript {19
pub fn note(&mut self, entry: TranscriptEntry) {20
let start = self.entries.len().saturating_sub(RECENT_WINDOW);21
let known = self.entries[start..]22
.iter()23
.rposition(|existing| existing.id == entry.id);24
match known {25
Some(position) => {26
let existing = &mut self.entries[start + position];27
existing.speaker = entry.speaker;28
existing.text = entry.text;29
}30
None => self.entries.push(entry),31
}32
}33
34
pub fn is_empty(&self) -> bool {35
self.entries.is_empty()36
}37
38
pub fn filtered(&self, query: &str) -> Vec<&TranscriptEntry> {39
let needle = query.trim().to_lowercase();40
self.entries41
.iter()42
.filter(|entry| {43
needle.is_empty()44
|| entry.text.to_lowercase().contains(&needle)45
|| entry.speaker.to_lowercase().contains(&needle)46
})47
.collect()48
}49
}50
51
pub fn clock_label(offset: Duration) -> String {52
let seconds = offset.as_secs();53
format!("{:02}:{:02}", seconds / 60, seconds % 60)54
}55
56
#[cfg(test)]57
mod tests {58
use super::*;59
60
fn entry(id: &str, speaker: &str, text: &str, seconds: u64) -> TranscriptEntry {61
TranscriptEntry {62
id: id.into(),63
speaker: speaker.into(),64
text: text.into(),65
offset: Duration::from_secs(seconds),66
}67
}68
69
fn sample() -> Transcript {70
let mut transcript = Transcript::default();71
transcript.note(entry("a", "Ana Example", "Welcome to the standup", 3));72
transcript.note(entry("b", "Bo Sample", "The build is green", 9));73
transcript.note(entry("c", "Ana Example", "Great, then we ship", 14));74
transcript75
}76
77
#[test]78
fn entries_keep_the_order_they_first_arrived_in() {79
let transcript = sample();80
let ids: Vec<&str> = transcript.filtered("").iter().map(|entry| entry.id.as_str()).collect();81
assert_eq!(ids, ["a", "b", "c"]);82
assert_eq!(transcript.filtered("").len(), 3);83
}84
85
#[test]86
fn a_growing_partial_updates_its_entry_and_keeps_its_time_and_place() {87
let mut transcript = sample();88
transcript.note(entry("b", "Bo Sample", "The build is green again", 20));89
assert_eq!(transcript.filtered("").len(), 3);90
let updated = &transcript.filtered("")[1];91
assert_eq!(updated.text, "The build is green again");92
assert_eq!(updated.offset, Duration::from_secs(9));93
}94
95
#[test]96
fn an_old_id_far_back_is_a_new_entry() {97
let mut transcript = sample();98
for index in 0..RECENT_WINDOW {99
transcript.note(entry(&format!("x{index}"), "Ana Example", "filler", 30));100
}101
transcript.note(entry("a", "Ana Example", "again", 99));102
assert_eq!(transcript.filtered("").len(), 3 + RECENT_WINDOW + 1);103
}104
105
#[test]106
fn the_filter_matches_text_and_speaker_ignoring_case() {107
let transcript = sample();108
assert_eq!(transcript.filtered("BUILD").len(), 1);109
assert_eq!(transcript.filtered("ana").len(), 2);110
assert_eq!(transcript.filtered(" ship ").len(), 1);111
assert!(transcript.filtered("nothing like this").is_empty());112
assert_eq!(transcript.filtered(" ").len(), 3);113
}114
115
#[test]116
fn the_clock_counts_minutes_and_seconds_since_the_call_start() {117
assert_eq!(clock_label(Duration::from_secs(5)), "00:05");118
assert_eq!(clock_label(Duration::from_secs(75)), "01:15");119
assert_eq!(clock_label(Duration::from_secs(4_503)), "75:03");120
}121
}@@ -2,6 +2,7 @@ use std::time::{Duration, Instant};
2
2
3
3
use gpui_kit::*;
4
4
5
use super::caption_style::{CaptionPosition, CaptionSize};
5
6
use super::bubbles::{BUBBLE_SHOWN, ChatBubble, push_bubble};
6
7
use super::fullscreen::{FullscreenState, HINT_SHOWN};
7
8
use super::view_settings::{CallLayout, ViewSettings};
@@ -43,6 +44,14 @@ impl AppState {
43
44
self.change_call_view(|view| view.hide_no_video = !view.hide_no_video, cx);
44
45
}
45
46
47
pub fn set_call_caption_size(&mut self, size: CaptionSize, cx: &mut Context<Self>) {
48
self.change_call_view(|view| view.caption_size = size, cx);
49
}
50
51
pub fn set_call_caption_position(&mut self, position: CaptionPosition, cx: &mut Context<Self>) {
52
self.change_call_view(|view| view.caption_position = position, cx);
53
}
54
46
55
pub fn toggle_call_chat_bubbles(&mut self, cx: &mut Context<Self>) {
47
56
self.change_call_view(|view| view.chat_bubbles = !view.chat_bubbles, cx);
48
57
}
@@ -2,6 +2,7 @@ use std::time::{Duration, Instant};2
2
3
use gpui_kit::*;3
use gpui_kit::*;4
4
5
use super::caption_style::{CaptionPosition, CaptionSize};5
use super::bubbles::{BUBBLE_SHOWN, ChatBubble, push_bubble};6
use super::bubbles::{BUBBLE_SHOWN, ChatBubble, push_bubble};6
use super::fullscreen::{FullscreenState, HINT_SHOWN};7
use super::fullscreen::{FullscreenState, HINT_SHOWN};7
use super::view_settings::{CallLayout, ViewSettings};8
use super::view_settings::{CallLayout, ViewSettings};@@ -43,6 +44,14 @@ impl AppState {43
self.change_call_view(|view| view.hide_no_video = !view.hide_no_video, cx);44
self.change_call_view(|view| view.hide_no_video = !view.hide_no_video, cx);44
}45
}45
46
47
pub fn set_call_caption_size(&mut self, size: CaptionSize, cx: &mut Context<Self>) {48
self.change_call_view(|view| view.caption_size = size, cx);49
}50
51
pub fn set_call_caption_position(&mut self, position: CaptionPosition, cx: &mut Context<Self>) {52
self.change_call_view(|view| view.caption_position = position, cx);53
}54
46
pub fn toggle_call_chat_bubbles(&mut self, cx: &mut Context<Self>) {55
pub fn toggle_call_chat_bubbles(&mut self, cx: &mut Context<Self>) {47
self.change_call_view(|view| view.chat_bubbles = !view.chat_bubbles, cx);56
self.change_call_view(|view| view.chat_bubbles = !view.chat_bubbles, cx);48
}57
}@@ -1,6 +1,10 @@
1
use super::caption_style::{CaptionPosition, CaptionSize};
2
1
3
const LAYOUT_META_KEY: &str = "call_layout";
2
4
const HIDE_NO_VIDEO_META_KEY: &str = "call_hide_no_video";
3
5
const CHAT_BUBBLES_META_KEY: &str = "call_chat_bubbles";
6
const CAPTION_SIZE_META_KEY: &str = "call_caption_size";
7
const CAPTION_POSITION_META_KEY: &str = "call_caption_position";
4
8
5
9
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
6
10
pub enum CallLayout {
@@ -43,6 +47,8 @@ pub struct ViewSettings {
43
47
pub hide_no_video: bool,
44
48
pub chat_bubbles: bool,
45
49
pub hide_me: bool,
50
pub caption_size: CaptionSize,
51
pub caption_position: CaptionPosition,
46
52
}
47
53
48
54
impl Default for ViewSettings {
@@ -53,6 +59,8 @@ impl Default for ViewSettings {
53
59
hide_no_video: false,
54
60
chat_bubbles: true,
55
61
hide_me: false,
62
caption_size: CaptionSize::Medium,
63
caption_position: CaptionPosition::Bottom,
56
64
}
57
65
}
58
66
}
@@ -73,6 +81,16 @@ impl ViewSettings {
73
81
layout,
74
82
hide_no_video: flag(HIDE_NO_VIDEO_META_KEY, false),
75
83
chat_bubbles: flag(CHAT_BUBBLES_META_KEY, true),
84
caption_size: store
85
.meta(CAPTION_SIZE_META_KEY)
86
.ok()
87
.flatten()
88
.map_or(CaptionSize::default(), |value| CaptionSize::from_meta(&value)),
89
caption_position: store
90
.meta(CAPTION_POSITION_META_KEY)
91
.ok()
92
.flatten()
93
.map_or(CaptionPosition::default(), |value| CaptionPosition::from_meta(&value)),
76
94
..ViewSettings::default()
77
95
}
78
96
}
@@ -87,6 +105,8 @@ impl ViewSettings {
87
105
CHAT_BUBBLES_META_KEY,
88
106
if self.chat_bubbles { "1" } else { "0" },
89
107
);
108
let _ = store.set_meta(CAPTION_SIZE_META_KEY, self.caption_size.meta());
109
let _ = store.set_meta(CAPTION_POSITION_META_KEY, self.caption_position.meta());
90
110
}
91
111
92
112
pub fn choose(&mut self, layout: CallLayout) {
@@ -109,6 +129,8 @@ mod tests {
109
129
assert!(settings.chat_bubbles);
110
130
assert!(!settings.hide_no_video);
111
131
assert!(!settings.hide_me);
132
assert_eq!(settings.caption_size, CaptionSize::Medium);
133
assert_eq!(settings.caption_position, CaptionPosition::Bottom);
112
134
}
113
135
114
136
#[test]
@@ -119,12 +141,16 @@ mod tests {
119
141
settings.hide_no_video = true;
120
142
settings.chat_bubbles = false;
121
143
settings.hide_me = true;
144
settings.caption_size = CaptionSize::Large;
145
settings.caption_position = CaptionPosition::Top;
122
146
settings.save(&store);
123
147
let loaded = ViewSettings::load(&store);
124
148
assert_eq!(loaded.layout, CallLayout::Speaker);
125
149
assert!(loaded.hide_no_video);
126
150
assert!(!loaded.chat_bubbles);
127
151
assert!(!loaded.hide_me);
152
assert_eq!(loaded.caption_size, CaptionSize::Large);
153
assert_eq!(loaded.caption_position, CaptionPosition::Top);
128
154
}
129
155
130
156
#[test]
@@ -1,6 +1,10 @@1
use super::caption_style::{CaptionPosition, CaptionSize};2
1
const LAYOUT_META_KEY: &str = "call_layout";3
const LAYOUT_META_KEY: &str = "call_layout";2
const HIDE_NO_VIDEO_META_KEY: &str = "call_hide_no_video";4
const HIDE_NO_VIDEO_META_KEY: &str = "call_hide_no_video";3
const CHAT_BUBBLES_META_KEY: &str = "call_chat_bubbles";5
const CHAT_BUBBLES_META_KEY: &str = "call_chat_bubbles";6
const CAPTION_SIZE_META_KEY: &str = "call_caption_size";7
const CAPTION_POSITION_META_KEY: &str = "call_caption_position";4
8
5
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]9
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]6
pub enum CallLayout {10
pub enum CallLayout {@@ -43,6 +47,8 @@ pub struct ViewSettings {43
pub hide_no_video: bool,47
pub hide_no_video: bool,44
pub chat_bubbles: bool,48
pub chat_bubbles: bool,45
pub hide_me: bool,49
pub hide_me: bool,50
pub caption_size: CaptionSize,51
pub caption_position: CaptionPosition,46
}52
}47
53
48
impl Default for ViewSettings {54
impl Default for ViewSettings {@@ -53,6 +59,8 @@ impl Default for ViewSettings {53
hide_no_video: false,59
hide_no_video: false,54
chat_bubbles: true,60
chat_bubbles: true,55
hide_me: false,61
hide_me: false,62
caption_size: CaptionSize::Medium,63
caption_position: CaptionPosition::Bottom,56
}64
}57
}65
}58
}66
}@@ -73,6 +81,16 @@ impl ViewSettings {73
layout,81
layout,74
hide_no_video: flag(HIDE_NO_VIDEO_META_KEY, false),82
hide_no_video: flag(HIDE_NO_VIDEO_META_KEY, false),75
chat_bubbles: flag(CHAT_BUBBLES_META_KEY, true),83
chat_bubbles: flag(CHAT_BUBBLES_META_KEY, true),84
caption_size: store85
.meta(CAPTION_SIZE_META_KEY)86
.ok()87
.flatten()88
.map_or(CaptionSize::default(), |value| CaptionSize::from_meta(&value)),89
caption_position: store90
.meta(CAPTION_POSITION_META_KEY)91
.ok()92
.flatten()93
.map_or(CaptionPosition::default(), |value| CaptionPosition::from_meta(&value)),76
..ViewSettings::default()94
..ViewSettings::default()77
}95
}78
}96
}@@ -87,6 +105,8 @@ impl ViewSettings {87
CHAT_BUBBLES_META_KEY,105
CHAT_BUBBLES_META_KEY,88
if self.chat_bubbles { "1" } else { "0" },106
if self.chat_bubbles { "1" } else { "0" },89
);107
);108
let _ = store.set_meta(CAPTION_SIZE_META_KEY, self.caption_size.meta());109
let _ = store.set_meta(CAPTION_POSITION_META_KEY, self.caption_position.meta());90
}110
}91
111
92
pub fn choose(&mut self, layout: CallLayout) {112
pub fn choose(&mut self, layout: CallLayout) {@@ -109,6 +129,8 @@ mod tests {109
assert!(settings.chat_bubbles);129
assert!(settings.chat_bubbles);110
assert!(!settings.hide_no_video);130
assert!(!settings.hide_no_video);111
assert!(!settings.hide_me);131
assert!(!settings.hide_me);132
assert_eq!(settings.caption_size, CaptionSize::Medium);133
assert_eq!(settings.caption_position, CaptionPosition::Bottom);112
}134
}113
135
114
#[test]136
#[test]@@ -119,12 +141,16 @@ mod tests {119
settings.hide_no_video = true;141
settings.hide_no_video = true;120
settings.chat_bubbles = false;142
settings.chat_bubbles = false;121
settings.hide_me = true;143
settings.hide_me = true;144
settings.caption_size = CaptionSize::Large;145
settings.caption_position = CaptionPosition::Top;122
settings.save(&store);146
settings.save(&store);123
let loaded = ViewSettings::load(&store);147
let loaded = ViewSettings::load(&store);124
assert_eq!(loaded.layout, CallLayout::Speaker);148
assert_eq!(loaded.layout, CallLayout::Speaker);125
assert!(loaded.hide_no_video);149
assert!(loaded.hide_no_video);126
assert!(!loaded.chat_bubbles);150
assert!(!loaded.chat_bubbles);127
assert!(!loaded.hide_me);151
assert!(!loaded.hide_me);152
assert_eq!(loaded.caption_size, CaptionSize::Large);153
assert_eq!(loaded.caption_position, CaptionPosition::Top);128
}154
}129
155
130
#[test]156
#[test]@@ -122,13 +122,14 @@ mod frames {
122
122
123
123
use std::time::Instant;
124
124
125
use calling::{CallState, CallUpdate, RosterEntry, call_channel};
125
use calling::{CallState, CallUpdate, CaptionEntry, CaptionState, RosterEntry, call_channel};
126
126
use gpui_kit::Entity;
127
127
128
128
use crate::app_state::{AppState, Mode, Selection};
129
129
use crate::call::{ActiveCall, CallModel};
130
130
use crate::demo;
131
131
use crate::user_activity::UserInput;
132
use crate::views::call_transcript::TranscriptPanel;
132
133
use crate::views::recap_tab::RECAP_REGION;
133
134
use crate::views::shell::{AppShell, Startup, bind_keys, install_globals};
134
135
use crate::views::shortcuts::{OpenActivity, OpenCallsTab, OpenChannelsTab, OpenSaved};
@@ -150,6 +151,7 @@ mod frames {
150
151
"shell/islands/main/call-stage",
151
152
"shell/islands/main/call-controls",
152
153
];
154
const CALL_TRANSCRIPT: &str = "shell/islands/main/call-transcript";
153
155
const MENU: &str = "popup-menu";
154
156
const OWN_STATUS: &str = "shell/title-bar/own-status";
155
157
const RECAP_TAB: &str = "shell/islands/main/recap-tab";
@@ -164,6 +166,7 @@ mod frames {
164
166
Tab(&'static str, Option<fn(&mut VisualTestContext)>),
165
167
StatusMenu,
166
168
Call,
169
CallTranscript,
167
170
}
168
171
169
172
fn parent_of(path: &str) -> Option<&str> {
@@ -279,7 +282,7 @@ mod frames {
279
282
GUARDED
280
283
.iter()
281
284
.chain(CALL_GUARDED)
282
.chain([&MENU, &RECAP_TAB, &RECAP_REGION])
285
.chain([&CALL_TRANSCRIPT, &MENU, &RECAP_TAB, &RECAP_REGION])
283
286
.filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))
284
287
.collect()
285
288
}
@@ -395,6 +398,7 @@ mod frames {
395
398
Screen::Tab("calls", Some(|visual| visual.dispatch_action(OpenCallsTab))),
396
399
Screen::StatusMenu,
397
400
Screen::Call,
401
Screen::CallTranscript,
398
402
];
399
403
for screen in screens {
400
404
let (screen_name, status_menu) = match screen {
@@ -413,6 +417,32 @@ mod frames {
413
417
});
414
418
("call", false)
415
419
}
420
Screen::CallTranscript => {
421
visual.update(|window, cx| {
422
app.update(cx, |state, cx| {
423
let mut call = gallery_call();
424
call.model.apply(CallUpdate::Captions(CaptionState::On));
425
for index in 0..40 {
426
call.model.note_caption(
427
CaptionEntry {
428
id: format!("guard-{index}"),
429
user_id: "8:orgid:guard-0".into(),
430
display_name: "Guest 0".into(),
431
text: "A long guarded sentence that has to wrap inside the panel".into(),
432
is_final: true,
433
},
434
Instant::now(),
435
);
436
}
437
call.transcript_open = true;
438
state.call = Some(call);
439
let app_entity = cx.entity();
440
state.transcript_panel = Some(cx.new(|cx| TranscriptPanel::new(app_entity, window, cx)));
441
cx.notify();
442
})
443
});
444
("call-transcript", false)
445
}
416
446
Screen::StatusMenu => {
417
447
let tags = collect(&mut visual, None);
418
448
let button = tags
@@ -426,9 +456,12 @@ mod frames {
426
456
};
427
457
let tags = collect(&mut visual, status_menu.then_some(MENU));
428
458
let mut expected = GUARDED.to_vec();
429
if screen_name == "call" {
459
if screen_name == "call" || screen_name == "call-transcript" {
430
460
expected.extend(CALL_GUARDED);
431
461
}
462
if screen_name == "call-transcript" {
463
expected.push(CALL_TRANSCRIPT);
464
}
432
465
if status_menu {
433
466
expected.push(MENU);
434
467
}
@@ -457,7 +490,7 @@ mod frames {
457
490
visual.simulate_keystrokes("escape");
458
491
visual.run_until_parked();
459
492
}
460
if screen_name == "call" {
493
if screen_name == "call" || screen_name == "call-transcript" {
461
494
visual.update(|_, cx| {
462
495
app.update(cx, |state, cx| {
463
496
state.call = None;
@@ -122,13 +122,14 @@ mod frames {122
122
123
use std::time::Instant;123
use std::time::Instant;124
124
125
use calling::{CallState, CallUpdate, RosterEntry, call_channel};125
use calling::{CallState, CallUpdate, CaptionEntry, CaptionState, RosterEntry, call_channel};126
use gpui_kit::Entity;126
use gpui_kit::Entity;127
127
128
use crate::app_state::{AppState, Mode, Selection};128
use crate::app_state::{AppState, Mode, Selection};129
use crate::call::{ActiveCall, CallModel};129
use crate::call::{ActiveCall, CallModel};130
use crate::demo;130
use crate::demo;131
use crate::user_activity::UserInput;131
use crate::user_activity::UserInput;132
use crate::views::call_transcript::TranscriptPanel;132
use crate::views::recap_tab::RECAP_REGION;133
use crate::views::recap_tab::RECAP_REGION;133
use crate::views::shell::{AppShell, Startup, bind_keys, install_globals};134
use crate::views::shell::{AppShell, Startup, bind_keys, install_globals};134
use crate::views::shortcuts::{OpenActivity, OpenCallsTab, OpenChannelsTab, OpenSaved};135
use crate::views::shortcuts::{OpenActivity, OpenCallsTab, OpenChannelsTab, OpenSaved};@@ -150,6 +151,7 @@ mod frames {150
"shell/islands/main/call-stage",151
"shell/islands/main/call-stage",151
"shell/islands/main/call-controls",152
"shell/islands/main/call-controls",152
];153
];154
const CALL_TRANSCRIPT: &str = "shell/islands/main/call-transcript";153
const MENU: &str = "popup-menu";155
const MENU: &str = "popup-menu";154
const OWN_STATUS: &str = "shell/title-bar/own-status";156
const OWN_STATUS: &str = "shell/title-bar/own-status";155
const RECAP_TAB: &str = "shell/islands/main/recap-tab";157
const RECAP_TAB: &str = "shell/islands/main/recap-tab";@@ -164,6 +166,7 @@ mod frames {164
Tab(&'static str, Option<fn(&mut VisualTestContext)>),166
Tab(&'static str, Option<fn(&mut VisualTestContext)>),165
StatusMenu,167
StatusMenu,166
Call,168
Call,169
CallTranscript,167
}170
}168
171
169
fn parent_of(path: &str) -> Option<&str> {172
fn parent_of(path: &str) -> Option<&str> {@@ -279,7 +282,7 @@ mod frames {279
GUARDED282
GUARDED280
.iter()283
.iter()281
.chain(CALL_GUARDED)284
.chain(CALL_GUARDED)282
.chain([&MENU, &RECAP_TAB, &RECAP_REGION])285
.chain([&CALL_TRANSCRIPT, &MENU, &RECAP_TAB, &RECAP_REGION])283
.filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))286
.filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))284
.collect()287
.collect()285
}288
}@@ -395,6 +398,7 @@ mod frames {395
Screen::Tab("calls", Some(|visual| visual.dispatch_action(OpenCallsTab))),398
Screen::Tab("calls", Some(|visual| visual.dispatch_action(OpenCallsTab))),396
Screen::StatusMenu,399
Screen::StatusMenu,397
Screen::Call,400
Screen::Call,401
Screen::CallTranscript,398
];402
];399
for screen in screens {403
for screen in screens {400
let (screen_name, status_menu) = match screen {404
let (screen_name, status_menu) = match screen {@@ -413,6 +417,32 @@ mod frames {413
});417
});414
("call", false)418
("call", false)415
}419
}420
Screen::CallTranscript => {421
visual.update(|window, cx| {422
app.update(cx, |state, cx| {423
let mut call = gallery_call();424
call.model.apply(CallUpdate::Captions(CaptionState::On));425
for index in 0..40 {426
call.model.note_caption(427
CaptionEntry {428
id: format!("guard-{index}"),429
user_id: "8:orgid:guard-0".into(),430
display_name: "Guest 0".into(),431
text: "A long guarded sentence that has to wrap inside the panel".into(),432
is_final: true,433
},434
Instant::now(),435
);436
}437
call.transcript_open = true;438
state.call = Some(call);439
let app_entity = cx.entity();440
state.transcript_panel = Some(cx.new(|cx| TranscriptPanel::new(app_entity, window, cx)));441
cx.notify();442
})443
});444
("call-transcript", false)445
}416
Screen::StatusMenu => {446
Screen::StatusMenu => {417
let tags = collect(&mut visual, None);447
let tags = collect(&mut visual, None);418
let button = tags448
let button = tags@@ -426,9 +456,12 @@ mod frames {426
};456
};427
let tags = collect(&mut visual, status_menu.then_some(MENU));457
let tags = collect(&mut visual, status_menu.then_some(MENU));428
let mut expected = GUARDED.to_vec();458
let mut expected = GUARDED.to_vec();429
if screen_name == "call" {459
if screen_name == "call" || screen_name == "call-transcript" {430
expected.extend(CALL_GUARDED);460
expected.extend(CALL_GUARDED);431
}461
}462
if screen_name == "call-transcript" {463
expected.push(CALL_TRANSCRIPT);464
}432
if status_menu {465
if status_menu {433
expected.push(MENU);466
expected.push(MENU);434
}467
}@@ -457,7 +490,7 @@ mod frames {457
visual.simulate_keystrokes("escape");490
visual.simulate_keystrokes("escape");458
visual.run_until_parked();491
visual.run_until_parked();459
}492
}460
if screen_name == "call" {493
if screen_name == "call" || screen_name == "call-transcript" {461
visual.update(|_, cx| {494
visual.update(|_, cx| {462
app.update(cx, |state, cx| {495
app.update(cx, |state, cx| {463
state.call = None;496
state.call = None;@@ -15,7 +15,7 @@ use super::call_view::{BANNER_HEIGHT, MENU_WIDTH};
15
15
use super::transfer_picker::TransferPicker;
16
16
use super::widgets::icon;
17
17
use crate::app_state::AppState;
18
use crate::call::{BackgroundPick, CallModel};
18
use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};
19
19
use crate::theme;
20
20
21
21
const STAGE_RADIUS: f32 = 12.;
@@ -31,7 +31,12 @@ fn dark_text() -> Hsla {
31
31
}
32
32
33
33
pub fn recording_chip(model: &CallModel) -> Option<AnyElement> {
34
model.recording.then(|| {
34
let chip = crate::call::recording_chip(model.recording, model.recording_audio_only, model.transcribing)?;
35
let color = match chip {
36
RecordingChip::Transcribing => theme::accent_text(),
37
RecordingChip::Recording | RecordingChip::RecordingAudio => theme::red(),
38
};
39
Some(
35
40
h_flex()
36
41
.id("call-recording")
37
42
.flex_none()
@@ -39,11 +44,11 @@ pub fn recording_chip(model: &CallModel) -> Option<AnyElement> {
39
44
.items_center()
40
45
.text_size(px(13.))
41
46
.font_weight(FontWeight::SEMIBOLD)
42
.text_color(theme::red())
43
.child(div().size(px(9.)).rounded_full().bg(theme::red()))
44
.child("Recording")
45
.into_any_element()
46
})
47
.text_color(color)
48
.child(div().size(px(9.)).rounded_full().bg(color))
49
.child(chip.label())
50
.into_any_element(),
51
)
47
52
}
48
53
49
54
pub fn return_button(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElement> {
@@ -264,18 +269,22 @@ pub fn consent_overlay(app: &Entity<AppState>, model: &CallModel) -> Option<AnyE
264
269
)
265
270
}
266
271
267
pub fn confirm_stop_recording(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {
272
pub fn confirm_record_action(app: &Entity<AppState>, action: RecordAction, window: &mut Window, cx: &mut App) {
273
let Some(title) = action.confirm_title() else {
274
app.update(cx, |state, cx| state.run_call_record_action(action, cx));
275
return;
276
};
268
277
let app = app.clone();
269
278
window.open_alert_dialog(cx, move |alert, _, _| {
270
279
let app = app.clone();
271
280
let cancel = Button::new("recording-cancel").label("Cancel").on_click(|_, window, cx| window.close_dialog(cx));
272
281
let stop = Button::new("recording-stop").label("Stop").danger().on_click(move |_, window, cx| {
273
app.update(cx, |state, cx| state.set_call_recording(false, cx));
282
app.update(cx, |state, cx| state.run_call_record_action(action, cx));
274
283
window.close_dialog(cx);
275
284
});
276
285
alert
277
.title("Stop recording and transcription?")
278
.description("The recording is saved to the organizer's OneDrive and the link arrives in the meeting chat.")
286
.title(title)
287
.description("The file is saved to the organizer's OneDrive and the link arrives in the meeting chat.")
279
288
.footer(DialogFooter::new().child(cancel).child(stop))
280
289
.on_ok(|_, _, _| false)
281
290
});
@@ -15,7 +15,7 @@ use super::call_view::{BANNER_HEIGHT, MENU_WIDTH};15
use super::transfer_picker::TransferPicker;15
use super::transfer_picker::TransferPicker;16
use super::widgets::icon;16
use super::widgets::icon;17
use crate::app_state::AppState;17
use crate::app_state::AppState;18
use crate::call::{BackgroundPick, CallModel};18
use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};19
use crate::theme;19
use crate::theme;20
20
21
const STAGE_RADIUS: f32 = 12.;21
const STAGE_RADIUS: f32 = 12.;@@ -31,7 +31,12 @@ fn dark_text() -> Hsla {31
}31
}32
32
33
pub fn recording_chip(model: &CallModel) -> Option<AnyElement> {33
pub fn recording_chip(model: &CallModel) -> Option<AnyElement> {34
model.recording.then(|| {34
let chip = crate::call::recording_chip(model.recording, model.recording_audio_only, model.transcribing)?;35
let color = match chip {36
RecordingChip::Transcribing => theme::accent_text(),37
RecordingChip::Recording | RecordingChip::RecordingAudio => theme::red(),38
};39
Some(35
h_flex()40
h_flex()36
.id("call-recording")41
.id("call-recording")37
.flex_none()42
.flex_none()@@ -39,11 +44,11 @@ pub fn recording_chip(model: &CallModel) -> Option<AnyElement> {39
.items_center()44
.items_center()40
.text_size(px(13.))45
.text_size(px(13.))41
.font_weight(FontWeight::SEMIBOLD)46
.font_weight(FontWeight::SEMIBOLD)42
.text_color(theme::red())47
.text_color(color)43
.child(div().size(px(9.)).rounded_full().bg(theme::red()))48
.child(div().size(px(9.)).rounded_full().bg(color))44
.child("Recording")49
.child(chip.label())45
.into_any_element()50
.into_any_element(),46
})51
)47
}52
}48
53
49
pub fn return_button(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElement> {54
pub fn return_button(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElement> {@@ -264,18 +269,22 @@ pub fn consent_overlay(app: &Entity<AppState>, model: &CallModel) -> Option<AnyE264
)269
)265
}270
}266
271
267
pub fn confirm_stop_recording(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {272
pub fn confirm_record_action(app: &Entity<AppState>, action: RecordAction, window: &mut Window, cx: &mut App) {273
let Some(title) = action.confirm_title() else {274
app.update(cx, |state, cx| state.run_call_record_action(action, cx));275
return;276
};268
let app = app.clone();277
let app = app.clone();269
window.open_alert_dialog(cx, move |alert, _, _| {278
window.open_alert_dialog(cx, move |alert, _, _| {270
let app = app.clone();279
let app = app.clone();271
let cancel = Button::new("recording-cancel").label("Cancel").on_click(|_, window, cx| window.close_dialog(cx));280
let cancel = Button::new("recording-cancel").label("Cancel").on_click(|_, window, cx| window.close_dialog(cx));272
let stop = Button::new("recording-stop").label("Stop").danger().on_click(move |_, window, cx| {281
let stop = Button::new("recording-stop").label("Stop").danger().on_click(move |_, window, cx| {273
app.update(cx, |state, cx| state.set_call_recording(false, cx));282
app.update(cx, |state, cx| state.run_call_record_action(action, cx));274
window.close_dialog(cx);283
window.close_dialog(cx);275
});284
});276
alert285
alert277
.title("Stop recording and transcription?")286
.title(title)278
.description("The recording is saved to the organizer's OneDrive and the link arrives in the meeting chat.")287
.description("The file is saved to the organizer's OneDrive and the link arrives in the meeting chat.")279
.footer(DialogFooter::new().child(cancel).child(stop))288
.footer(DialogFooter::new().child(cancel).child(stop))280
.on_ok(|_, _, _| false)289
.on_ok(|_, _, _| false)281
});290
});@@ -13,12 +13,13 @@ use gpui_kit::*;
13
13
14
14
use super::avatar::person_avatar;
15
15
use super::call_extras::{
16
CameraMenu, background_items, confirm_stop_recording, effect_items, open_transfer_picker,
16
CameraMenu, background_items, effect_items, open_transfer_picker,
17
17
};
18
use super::call_record::{record_submenu, transcript_and_settings_items};
18
19
use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};
19
20
use super::widgets::icon;
20
21
use crate::app_state::AppState;
21
use crate::call::{CAPTION_SHOWN, CallModel, Focus};
22
use crate::call::{CAPTION_SHOWN, CallModel, CaptionPosition, Focus};
22
23
use crate::notice::truncated;
23
24
use crate::theme;
24
25
@@ -28,6 +29,7 @@ const LOBBY_LIST_WIDTH: f32 = 340.;
28
29
const LOBBY_NAME_LIMIT: usize = 28;
29
30
const CAPTION_WIDTH: f32 = 720.;
30
31
const CAPTION_BOTTOM: f32 = 2. * 16. + CONTROL_SIZE + 16.;
32
const CAPTION_TOP: f32 = 72.;
31
33
const CAPTION_FADE_SECONDS: f32 = 1.;
32
34
const CAPTION_BACKGROUND: f32 = 0.72;
33
35
const FOCUS_RADIUS: f32 = 12.;
@@ -387,19 +389,25 @@ pub fn more_button(app: &Entity<AppState>, model: &CallModel) -> Option<AnyEleme
387
389
theme::surface_raised(),
388
390
theme::text(),
389
391
))
390
.dropdown_menu_with_anchor(Anchor::BottomRight, move |popup, _, _| {
391
more_menu(popup, &app, &model)
392
.dropdown_menu_with_anchor(Anchor::BottomRight, move |popup, window, cx| {
393
more_menu(popup, window, cx, &app, &model)
392
394
})
393
395
.into_any_element(),
394
396
)
395
397
}
396
398
397
fn more_menu(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {
399
fn more_menu(
400
popup: PopupMenu,
401
window: &mut Window,
402
cx: &mut Context<PopupMenu>,
403
app: &Entity<AppState>,
404
model: &CallModel,
405
) -> PopupMenu {
398
406
let popup = popup.min_w(px(MENU_WIDTH));
399
407
let popup = if model.is_one_to_one() {
400
408
one_to_one_items(popup, app, model)
401
409
} else {
402
meeting_items(popup, app, model)
410
meeting_items(popup, window, cx, app, model)
403
411
};
404
412
incoming_video_item(popup, app, model)
405
413
}
@@ -436,9 +444,14 @@ fn one_to_one_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallMo
436
444
)
437
445
}
438
446
439
fn meeting_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {
440
let (mute_app, captions_app, record_app, board_app) =
441
(app.clone(), app.clone(), app.clone(), app.clone());
447
fn meeting_items(
448
mut popup: PopupMenu,
449
window: &mut Window,
450
cx: &mut Context<PopupMenu>,
451
app: &Entity<AppState>,
452
model: &CallModel,
453
) -> PopupMenu {
454
let (mute_app, captions_app, board_app) = (app.clone(), app.clone(), app.clone());
442
455
let captions_on = model.captions_on();
443
456
if model.organizes_meeting() {
444
457
popup = popup.item(
@@ -448,22 +461,7 @@ fn meeting_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallModel
448
461
);
449
462
}
450
463
if model.can_record() {
451
let recording = model.recording;
452
popup = popup.item(
453
PopupMenuItem::new(if recording {
454
"Stop recording"
455
} else {
456
"Start recording"
457
})
458
.icon(IconName::Video)
459
.on_click(move |_, window, cx| {
460
if recording {
461
confirm_stop_recording(&record_app, window, cx);
462
} else {
463
record_app.update(cx, |state, cx| state.set_call_recording(true, cx));
464
}
465
}),
466
);
464
popup = record_submenu(popup, window, cx, app, model);
467
465
}
468
466
if model.can_open_whiteboard() {
469
467
popup = popup.item(
@@ -474,7 +472,7 @@ fn meeting_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallModel
474
472
}),
475
473
);
476
474
}
477
popup.item(
475
let popup = popup.item(
478
476
PopupMenuItem::new(if captions_on {
479
477
"Turn off live captions"
480
478
} else {
@@ -488,7 +486,8 @@ fn meeting_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallModel
488
486
.on_click(move |_, _, cx| {
489
487
captions_app.update(cx, |state, cx| state.toggle_call_captions(cx))
490
488
}),
491
)
489
);
490
transcript_and_settings_items(popup, app)
492
491
}
493
492
494
493
pub fn chevron_button(button_id: &'static str, face_id: &'static str) -> Button {
@@ -568,7 +567,10 @@ pub fn captions_overlay(model: &CallModel, now: Instant) -> Option<AnyElement> {
568
567
.absolute()
569
568
.left_0()
570
569
.right_0()
571
.bottom(px(CAPTION_BOTTOM))
570
.map(|overlay| match model.view.caption_position {
571
CaptionPosition::Bottom => overlay.bottom(px(CAPTION_BOTTOM)),
572
CaptionPosition::Top => overlay.top(px(CAPTION_TOP)),
573
})
572
574
.flex()
573
575
.justify_center()
574
576
.px(px(24.))
@@ -582,7 +584,7 @@ pub fn captions_overlay(model: &CallModel, now: Instant) -> Option<AnyElement> {
582
584
.rounded(px(10.))
583
585
.bg(hsla(0., 0., 0., CAPTION_BACKGROUND))
584
586
.text_color(theme::white())
585
.text_size(px(16.))
587
.text_size(px(model.view.caption_size.text_size()))
586
588
.children(lines.into_iter().map(|line| {
587
589
let age = now.saturating_duration_since(line.at).as_secs_f32();
588
590
let fade = ((shown - age) / CAPTION_FADE_SECONDS).clamp(0., 1.);
@@ -13,12 +13,13 @@ use gpui_kit::*;13
13
14
use super::avatar::person_avatar;14
use super::avatar::person_avatar;15
use super::call_extras::{15
use super::call_extras::{16
CameraMenu, background_items, confirm_stop_recording, effect_items, open_transfer_picker,16
CameraMenu, background_items, effect_items, open_transfer_picker,17
};17
};18
use super::call_record::{record_submenu, transcript_and_settings_items};18
use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};19
use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};19
use super::widgets::icon;20
use super::widgets::icon;20
use crate::app_state::AppState;21
use crate::app_state::AppState;21
use crate::call::{CAPTION_SHOWN, CallModel, Focus};22
use crate::call::{CAPTION_SHOWN, CallModel, CaptionPosition, Focus};22
use crate::notice::truncated;23
use crate::notice::truncated;23
use crate::theme;24
use crate::theme;24
25
@@ -28,6 +29,7 @@ const LOBBY_LIST_WIDTH: f32 = 340.;28
const LOBBY_NAME_LIMIT: usize = 28;29
const LOBBY_NAME_LIMIT: usize = 28;29
const CAPTION_WIDTH: f32 = 720.;30
const CAPTION_WIDTH: f32 = 720.;30
const CAPTION_BOTTOM: f32 = 2. * 16. + CONTROL_SIZE + 16.;31
const CAPTION_BOTTOM: f32 = 2. * 16. + CONTROL_SIZE + 16.;32
const CAPTION_TOP: f32 = 72.;31
const CAPTION_FADE_SECONDS: f32 = 1.;33
const CAPTION_FADE_SECONDS: f32 = 1.;32
const CAPTION_BACKGROUND: f32 = 0.72;34
const CAPTION_BACKGROUND: f32 = 0.72;33
const FOCUS_RADIUS: f32 = 12.;35
const FOCUS_RADIUS: f32 = 12.;@@ -387,19 +389,25 @@ pub fn more_button(app: &Entity<AppState>, model: &CallModel) -> Option<AnyEleme387
theme::surface_raised(),389
theme::surface_raised(),388
theme::text(),390
theme::text(),389
))391
))390
.dropdown_menu_with_anchor(Anchor::BottomRight, move |popup, _, _| {392
.dropdown_menu_with_anchor(Anchor::BottomRight, move |popup, window, cx| {391
more_menu(popup, &app, &model)393
more_menu(popup, window, cx, &app, &model)392
})394
})393
.into_any_element(),395
.into_any_element(),394
)396
)395
}397
}396
398
397
fn more_menu(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {399
fn more_menu(400
popup: PopupMenu,401
window: &mut Window,402
cx: &mut Context<PopupMenu>,403
app: &Entity<AppState>,404
model: &CallModel,405
) -> PopupMenu {398
let popup = popup.min_w(px(MENU_WIDTH));406
let popup = popup.min_w(px(MENU_WIDTH));399
let popup = if model.is_one_to_one() {407
let popup = if model.is_one_to_one() {400
one_to_one_items(popup, app, model)408
one_to_one_items(popup, app, model)401
} else {409
} else {402
meeting_items(popup, app, model)410
meeting_items(popup, window, cx, app, model)403
};411
};404
incoming_video_item(popup, app, model)412
incoming_video_item(popup, app, model)405
}413
}@@ -436,9 +444,14 @@ fn one_to_one_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallMo436
)444
)437
}445
}438
446
439
fn meeting_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {447
fn meeting_items(440
let (mute_app, captions_app, record_app, board_app) =448
mut popup: PopupMenu,441
(app.clone(), app.clone(), app.clone(), app.clone());449
window: &mut Window,450
cx: &mut Context<PopupMenu>,451
app: &Entity<AppState>,452
model: &CallModel,453
) -> PopupMenu {454
let (mute_app, captions_app, board_app) = (app.clone(), app.clone(), app.clone());442
let captions_on = model.captions_on();455
let captions_on = model.captions_on();443
if model.organizes_meeting() {456
if model.organizes_meeting() {444
popup = popup.item(457
popup = popup.item(@@ -448,22 +461,7 @@ fn meeting_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallModel448
);461
);449
}462
}450
if model.can_record() {463
if model.can_record() {451
let recording = model.recording;464
popup = record_submenu(popup, window, cx, app, model);452
popup = popup.item(453
PopupMenuItem::new(if recording {454
"Stop recording"455
} else {456
"Start recording"457
})458
.icon(IconName::Video)459
.on_click(move |_, window, cx| {460
if recording {461
confirm_stop_recording(&record_app, window, cx);462
} else {463
record_app.update(cx, |state, cx| state.set_call_recording(true, cx));464
}465
}),466
);467
}465
}468
if model.can_open_whiteboard() {466
if model.can_open_whiteboard() {469
popup = popup.item(467
popup = popup.item(@@ -474,7 +472,7 @@ fn meeting_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallModel474
}),472
}),475
);473
);476
}474
}477
popup.item(475
let popup = popup.item(478
PopupMenuItem::new(if captions_on {476
PopupMenuItem::new(if captions_on {479
"Turn off live captions"477
"Turn off live captions"480
} else {478
} else {@@ -488,7 +486,8 @@ fn meeting_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallModel488
.on_click(move |_, _, cx| {486
.on_click(move |_, _, cx| {489
captions_app.update(cx, |state, cx| state.toggle_call_captions(cx))487
captions_app.update(cx, |state, cx| state.toggle_call_captions(cx))490
}),488
}),491
)489
);490
transcript_and_settings_items(popup, app)492
}491
}493
492
494
pub fn chevron_button(button_id: &'static str, face_id: &'static str) -> Button {493
pub fn chevron_button(button_id: &'static str, face_id: &'static str) -> Button {@@ -568,7 +567,10 @@ pub fn captions_overlay(model: &CallModel, now: Instant) -> Option<AnyElement> {568
.absolute()567
.absolute()569
.left_0()568
.left_0()570
.right_0()569
.right_0()571
.bottom(px(CAPTION_BOTTOM))570
.map(|overlay| match model.view.caption_position {571
CaptionPosition::Bottom => overlay.bottom(px(CAPTION_BOTTOM)),572
CaptionPosition::Top => overlay.top(px(CAPTION_TOP)),573
})572
.flex()574
.flex()573
.justify_center()575
.justify_center()574
.px(px(24.))576
.px(px(24.))@@ -582,7 +584,7 @@ pub fn captions_overlay(model: &CallModel, now: Instant) -> Option<AnyElement> {582
.rounded(px(10.))584
.rounded(px(10.))583
.bg(hsla(0., 0., 0., CAPTION_BACKGROUND))585
.bg(hsla(0., 0., 0., CAPTION_BACKGROUND))584
.text_color(theme::white())586
.text_color(theme::white())585
.text_size(px(16.))587
.text_size(px(model.view.caption_size.text_size()))586
.children(lines.into_iter().map(|line| {588
.children(lines.into_iter().map(|line| {587
let age = now.saturating_duration_since(line.at).as_secs_f32();589
let age = now.saturating_duration_since(line.at).as_secs_f32();588
let fade = ((shown - age) / CAPTION_FADE_SECONDS).clamp(0., 1.);590
let fade = ((shown - age) / CAPTION_FADE_SECONDS).clamp(0., 1.);@@ -0,0 +1,175 @@
1
use calling::SPOKEN_LANGUAGES;
2
use gpui_kit::assets::IconName;
3
use gpui_kit::component::button::{Button, ButtonVariants as _};
4
use gpui_kit::component::dialog::{Dialog, DialogFooter};
5
use gpui_kit::component::menu::{PopupMenu, PopupMenuItem};
6
use gpui_kit::component::{Icon, WindowExt as _, h_flex, v_flex};
7
use gpui_kit::prelude::FluentBuilder as _;
8
use gpui_kit::*;
9
10
use super::call_extras::confirm_record_action;
11
use super::call_transcript::TranscriptPanel;
12
use crate::app_state::AppState;
13
use crate::call::{CallModel, CaptionPosition, CaptionSize, record_actions};
14
use crate::theme;
15
16
const SETTINGS_WIDTH: f32 = 460.;
17
const CHIP_HEIGHT: f32 = 30.;
18
const SECTION_GAP: f32 = 14.;
19
20
pub fn record_submenu(
21
popup: PopupMenu,
22
window: &mut Window,
23
cx: &mut Context<PopupMenu>,
24
app: &Entity<AppState>,
25
model: &CallModel,
26
) -> PopupMenu {
27
let actions = record_actions(model.recording, model.transcribing);
28
let app = app.clone();
29
popup.submenu_with_icon(
30
Some(Icon::new(IconName::Video)),
31
"Record and transcribe",
32
window,
33
cx,
34
move |mut menu, _, _| {
35
for (action, label) in actions.clone() {
36
let app = app.clone();
37
menu = menu.item(PopupMenuItem::new(label).on_click(move |_, window, cx| {
38
confirm_record_action(&app, action, window, cx)
39
}));
40
}
41
menu
42
},
43
)
44
}
45
46
pub fn transcript_and_settings_items(popup: PopupMenu, app: &Entity<AppState>) -> PopupMenu {
47
let (transcript_app, settings_app) = (app.clone(), app.clone());
48
popup
49
.item(
50
PopupMenuItem::new("Show transcript")
51
.icon(IconName::LayoutList)
52
.on_click(move |_, window, cx| open_transcript(&transcript_app, window, cx)),
53
)
54
.item(
55
PopupMenuItem::new("Captions settings")
56
.icon(IconName::Settings)
57
.on_click(move |_, window, cx| open_captions_settings(&settings_app, window, cx)),
58
)
59
}
60
61
fn open_transcript(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {
62
let panel_app = app.clone();
63
let panel = cx.new(|cx| TranscriptPanel::new(panel_app, window, cx));
64
app.update(cx, |state, cx| state.open_call_transcript(panel, cx));
65
}
66
67
fn choice_chip(
68
id: String,
69
label: &str,
70
selected: bool,
71
on_click: impl Fn(&mut App) + 'static,
72
) -> Stateful<Div> {
73
let (background, foreground) = if selected {
74
(theme::accent(), theme::white())
75
} else {
76
(theme::surface_raised(), theme::text())
77
};
78
div()
79
.id(ElementId::Name(id.into()))
80
.h(px(CHIP_HEIGHT))
81
.px(px(12.))
82
.flex()
83
.items_center()
84
.rounded_full()
85
.bg(background)
86
.text_color(foreground)
87
.text_size(px(13.))
88
.when(!selected, |chip| chip.hover(|chip| chip.bg(theme::row_hover())))
89
.cursor_pointer()
90
.child(label.to_owned())
91
.on_click(move |_, _, cx| on_click(cx))
92
}
93
94
fn section(title: &'static str, chips: Vec<Stateful<Div>>) -> Div {
95
v_flex()
96
.gap(px(8.))
97
.child(
98
div()
99
.text_size(px(12.))
100
.font_weight(FontWeight::SEMIBOLD)
101
.text_color(theme::text_muted())
102
.child(title),
103
)
104
.child(h_flex().flex_wrap().gap(px(8.)).children(chips))
105
}
106
107
pub fn open_captions_settings(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {
108
let app = app.clone();
109
window.open_dialog(cx, move |dialog: Dialog, _, cx| {
110
let state = app.read(cx);
111
let language = state
112
.call
113
.as_ref()
114
.and_then(|call| call.model.caption_language.clone());
115
let (size, position) = (state.call_view.caption_size, state.call_view.caption_position);
116
let languages = SPOKEN_LANGUAGES
117
.iter()
118
.map(|(tag, label)| {
119
let app = app.clone();
120
let chosen = *tag;
121
choice_chip(
122
format!("captions-language-{tag}"),
123
label,
124
language.as_deref() == Some(tag),
125
move |cx| app.update(cx, |state, cx| state.choose_call_caption_language(chosen, cx)),
126
)
127
})
128
.collect();
129
let sizes = CaptionSize::ALL
130
.iter()
131
.map(|choice| {
132
let app = app.clone();
133
let choice = *choice;
134
choice_chip(
135
format!("captions-size-{}", choice.meta()),
136
choice.label(),
137
size == choice,
138
move |cx| app.update(cx, |state, cx| state.set_call_caption_size(choice, cx)),
139
)
140
})
141
.collect();
142
let positions = CaptionPosition::ALL
143
.iter()
144
.map(|choice| {
145
let app = app.clone();
146
let choice = *choice;
147
choice_chip(
148
format!("captions-position-{}", choice.meta()),
149
choice.label(),
150
position == choice,
151
move |cx| app.update(cx, |state, cx| state.set_call_caption_position(choice, cx)),
152
)
153
})
154
.collect();
155
dialog
156
.title("Captions settings")
157
.w(px(SETTINGS_WIDTH))
158
.child(
159
v_flex()
160
.id("captions-settings")
161
.gap(px(SECTION_GAP))
162
.child(section("Spoken language", languages))
163
.child(section("Size", sizes))
164
.child(section("Position", positions)),
165
)
166
.footer(
167
DialogFooter::new().child(
168
Button::new("captions-settings-done")
169
.primary()
170
.label("Done")
171
.on_click(|_, window, cx| window.close_dialog(cx)),
172
),
173
)
174
});
175
}
@@ -0,0 +1,175 @@1
use calling::SPOKEN_LANGUAGES;2
use gpui_kit::assets::IconName;3
use gpui_kit::component::button::{Button, ButtonVariants as _};4
use gpui_kit::component::dialog::{Dialog, DialogFooter};5
use gpui_kit::component::menu::{PopupMenu, PopupMenuItem};6
use gpui_kit::component::{Icon, WindowExt as _, h_flex, v_flex};7
use gpui_kit::prelude::FluentBuilder as _;8
use gpui_kit::*;9
10
use super::call_extras::confirm_record_action;11
use super::call_transcript::TranscriptPanel;12
use crate::app_state::AppState;13
use crate::call::{CallModel, CaptionPosition, CaptionSize, record_actions};14
use crate::theme;15
16
const SETTINGS_WIDTH: f32 = 460.;17
const CHIP_HEIGHT: f32 = 30.;18
const SECTION_GAP: f32 = 14.;19
20
pub fn record_submenu(21
popup: PopupMenu,22
window: &mut Window,23
cx: &mut Context<PopupMenu>,24
app: &Entity<AppState>,25
model: &CallModel,26
) -> PopupMenu {27
let actions = record_actions(model.recording, model.transcribing);28
let app = app.clone();29
popup.submenu_with_icon(30
Some(Icon::new(IconName::Video)),31
"Record and transcribe",32
window,33
cx,34
move |mut menu, _, _| {35
for (action, label) in actions.clone() {36
let app = app.clone();37
menu = menu.item(PopupMenuItem::new(label).on_click(move |_, window, cx| {38
confirm_record_action(&app, action, window, cx)39
}));40
}41
menu42
},43
)44
}45
46
pub fn transcript_and_settings_items(popup: PopupMenu, app: &Entity<AppState>) -> PopupMenu {47
let (transcript_app, settings_app) = (app.clone(), app.clone());48
popup49
.item(50
PopupMenuItem::new("Show transcript")51
.icon(IconName::LayoutList)52
.on_click(move |_, window, cx| open_transcript(&transcript_app, window, cx)),53
)54
.item(55
PopupMenuItem::new("Captions settings")56
.icon(IconName::Settings)57
.on_click(move |_, window, cx| open_captions_settings(&settings_app, window, cx)),58
)59
}60
61
fn open_transcript(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {62
let panel_app = app.clone();63
let panel = cx.new(|cx| TranscriptPanel::new(panel_app, window, cx));64
app.update(cx, |state, cx| state.open_call_transcript(panel, cx));65
}66
67
fn choice_chip(68
id: String,69
label: &str,70
selected: bool,71
on_click: impl Fn(&mut App) + 'static,72
) -> Stateful<Div> {73
let (background, foreground) = if selected {74
(theme::accent(), theme::white())75
} else {76
(theme::surface_raised(), theme::text())77
};78
div()79
.id(ElementId::Name(id.into()))80
.h(px(CHIP_HEIGHT))81
.px(px(12.))82
.flex()83
.items_center()84
.rounded_full()85
.bg(background)86
.text_color(foreground)87
.text_size(px(13.))88
.when(!selected, |chip| chip.hover(|chip| chip.bg(theme::row_hover())))89
.cursor_pointer()90
.child(label.to_owned())91
.on_click(move |_, _, cx| on_click(cx))92
}93
94
fn section(title: &'static str, chips: Vec<Stateful<Div>>) -> Div {95
v_flex()96
.gap(px(8.))97
.child(98
div()99
.text_size(px(12.))100
.font_weight(FontWeight::SEMIBOLD)101
.text_color(theme::text_muted())102
.child(title),103
)104
.child(h_flex().flex_wrap().gap(px(8.)).children(chips))105
}106
107
pub fn open_captions_settings(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {108
let app = app.clone();109
window.open_dialog(cx, move |dialog: Dialog, _, cx| {110
let state = app.read(cx);111
let language = state112
.call113
.as_ref()114
.and_then(|call| call.model.caption_language.clone());115
let (size, position) = (state.call_view.caption_size, state.call_view.caption_position);116
let languages = SPOKEN_LANGUAGES117
.iter()118
.map(|(tag, label)| {119
let app = app.clone();120
let chosen = *tag;121
choice_chip(122
format!("captions-language-{tag}"),123
label,124
language.as_deref() == Some(tag),125
move |cx| app.update(cx, |state, cx| state.choose_call_caption_language(chosen, cx)),126
)127
})128
.collect();129
let sizes = CaptionSize::ALL130
.iter()131
.map(|choice| {132
let app = app.clone();133
let choice = *choice;134
choice_chip(135
format!("captions-size-{}", choice.meta()),136
choice.label(),137
size == choice,138
move |cx| app.update(cx, |state, cx| state.set_call_caption_size(choice, cx)),139
)140
})141
.collect();142
let positions = CaptionPosition::ALL143
.iter()144
.map(|choice| {145
let app = app.clone();146
let choice = *choice;147
choice_chip(148
format!("captions-position-{}", choice.meta()),149
choice.label(),150
position == choice,151
move |cx| app.update(cx, |state, cx| state.set_call_caption_position(choice, cx)),152
)153
})154
.collect();155
dialog156
.title("Captions settings")157
.w(px(SETTINGS_WIDTH))158
.child(159
v_flex()160
.id("captions-settings")161
.gap(px(SECTION_GAP))162
.child(section("Spoken language", languages))163
.child(section("Size", sizes))164
.child(section("Position", positions)),165
)166
.footer(167
DialogFooter::new().child(168
Button::new("captions-settings-done")169
.primary()170
.label("Done")171
.on_click(|_, window, cx| window.close_dialog(cx)),172
),173
)174
});175
}@@ -0,0 +1,198 @@
1
use gpui_kit::assets::IconName;
2
use gpui_kit::component::{
3
h_flex,
4
input::{Input, InputEvent, InputState},
5
v_flex,
6
};
7
use gpui_kit::prelude::FluentBuilder as _;
8
use gpui_kit::*;
9
10
use super::call_view::side_panel;
11
use super::widgets::icon;
12
use crate::app_state::AppState;
13
use crate::call::clock_label;
14
use crate::theme;
15
16
const SEARCH_HEIGHT: f32 = 34.;
17
const AT_BOTTOM_SLACK: f32 = 4.;
18
const EMPTY_TEXT: &str = "Nothing said yet. Spoken words appear here.";
19
const NO_MATCH_TEXT: &str = "No entry matches the search.";
20
21
pub struct TranscriptPanel {
22
app: Entity<AppState>,
23
search: Entity<InputState>,
24
scroll: ScrollHandle,
25
following: bool,
26
scrolled: bool,
27
_subscriptions: Vec<Subscription>,
28
}
29
30
impl TranscriptPanel {
31
pub fn new(app: Entity<AppState>, window: &mut Window, cx: &mut Context<Self>) -> Self {
32
let search = cx.new(|cx| InputState::new(window, cx).placeholder("Search transcript"));
33
let subscriptions = vec![
34
cx.observe(&app, |_, _, cx| cx.notify()),
35
cx.subscribe_in(&search, window, |_, _, event: &InputEvent, _, cx| {
36
if matches!(event, InputEvent::Change) {
37
cx.notify();
38
}
39
}),
40
];
41
TranscriptPanel {
42
app,
43
search,
44
scroll: ScrollHandle::new(),
45
following: true,
46
scrolled: false,
47
_subscriptions: subscriptions,
48
}
49
}
50
51
fn at_bottom(&self) -> bool {
52
let offset = self.scroll.offset().y;
53
let reach = self.scroll.max_offset().y;
54
f32::from(offset + reach) <= AT_BOTTOM_SLACK
55
}
56
57
fn jump_to_latest(&mut self, cx: &mut Context<Self>) {
58
self.following = true;
59
self.scroll.scroll_to_bottom();
60
cx.notify();
61
}
62
63
fn jump_chip(&self, cx: &mut Context<Self>) -> Stateful<Div> {
64
div()
65
.id("call-transcript-jump")
66
.absolute()
67
.bottom(px(12.))
68
.left_0()
69
.right_0()
70
.flex()
71
.justify_center()
72
.child(
73
h_flex()
74
.id("call-transcript-jump-chip")
75
.h(px(28.))
76
.px(px(12.))
77
.gap(px(6.))
78
.items_center()
79
.rounded_full()
80
.bg(theme::accent())
81
.text_color(theme::white())
82
.text_size(px(12.))
83
.font_weight(FontWeight::SEMIBOLD)
84
.cursor_pointer()
85
.child(icon(IconName::ArrowDown, 13., theme::white()))
86
.child("Jump to latest")
87
.on_click(cx.listener(|this, _, _, cx| this.jump_to_latest(cx))),
88
)
89
}
90
}
91
92
impl Render for TranscriptPanel {
93
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
94
if std::mem::take(&mut self.scrolled) {
95
self.following = self.at_bottom();
96
}
97
if self.following {
98
self.scroll.scroll_to_bottom();
99
}
100
let query = self.search.read(cx).value().to_string();
101
let state = self.app.read(cx);
102
let transcript = state.call.as_ref().map(|call| &call.model.transcript);
103
let empty = transcript.is_none_or(|transcript| transcript.is_empty());
104
let rows: Vec<AnyElement> = transcript
105
.map(|transcript| transcript.filtered(&query))
106
.unwrap_or_default()
107
.into_iter()
108
.map(|entry| {
109
v_flex()
110
.gap(px(2.))
111
.child(
112
h_flex()
113
.gap(px(8.))
114
.items_baseline()
115
.child(
116
div()
117
.min_w_0()
118
.truncate()
119
.text_size(px(13.))
120
.font_weight(FontWeight::BOLD)
121
.child(entry.speaker.clone()),
122
)
123
.child(
124
div()
125
.flex_none()
126
.text_size(px(11.))
127
.text_color(theme::text_muted())
128
.child(clock_label(entry.offset)),
129
),
130
)
131
.child(div().text_size(px(13.)).child(entry.text.clone()))
132
.into_any_element()
133
})
134
.collect();
135
let hint = rows.is_empty().then_some(if empty { EMPTY_TEXT } else { NO_MATCH_TEXT });
136
let app = self.app.clone();
137
let search = h_flex()
138
.h(px(SEARCH_HEIGHT))
139
.mx(px(12.))
140
.px(px(10.))
141
.gap(px(8.))
142
.flex_none()
143
.items_center()
144
.rounded(px(6.))
145
.border_1()
146
.border_color(theme::border())
147
.child(icon(IconName::Search, 14., theme::text_muted()))
148
.child(
149
div()
150
.flex_1()
151
.child(Input::new(&self.search).appearance(false).bordered(false)),
152
);
153
let list = div()
154
.id("call-transcript-list")
155
.flex_1()
156
.min_h_0()
157
.overflow_y_scroll()
158
.track_scroll(&self.scroll)
159
.on_scroll_wheel(cx.listener(|this, _, _, cx| {
160
this.scrolled = true;
161
cx.notify();
162
}))
163
.child(
164
v_flex()
165
.px(px(20.))
166
.py(px(12.))
167
.gap(px(12.))
168
.children(rows)
169
.children(hint.map(|text| {
170
div()
171
.text_size(px(13.))
172
.text_color(theme::text_muted())
173
.child(text)
174
})),
175
);
176
let body = v_flex()
177
.size_full()
178
.min_h_0()
179
.gap(px(8.))
180
.child(search)
181
.child(
182
div()
183
.relative()
184
.flex_1()
185
.min_h_0()
186
.child(list)
187
.when(!self.following, |area| area.child(self.jump_chip(cx))),
188
);
189
side_panel(
190
"call-transcript-panel",
191
"Transcript",
192
"Close the transcript",
193
move |cx| app.update(cx, |state, cx| state.close_call_transcript(cx)),
194
body,
195
)
196
.debug_selector(|| "shell/islands/main/call-transcript".into())
197
}
198
}
@@ -0,0 +1,198 @@1
use gpui_kit::assets::IconName;2
use gpui_kit::component::{3
h_flex,4
input::{Input, InputEvent, InputState},5
v_flex,6
};7
use gpui_kit::prelude::FluentBuilder as _;8
use gpui_kit::*;9
10
use super::call_view::side_panel;11
use super::widgets::icon;12
use crate::app_state::AppState;13
use crate::call::clock_label;14
use crate::theme;15
16
const SEARCH_HEIGHT: f32 = 34.;17
const AT_BOTTOM_SLACK: f32 = 4.;18
const EMPTY_TEXT: &str = "Nothing said yet. Spoken words appear here.";19
const NO_MATCH_TEXT: &str = "No entry matches the search.";20
21
pub struct TranscriptPanel {22
app: Entity<AppState>,23
search: Entity<InputState>,24
scroll: ScrollHandle,25
following: bool,26
scrolled: bool,27
_subscriptions: Vec<Subscription>,28
}29
30
impl TranscriptPanel {31
pub fn new(app: Entity<AppState>, window: &mut Window, cx: &mut Context<Self>) -> Self {32
let search = cx.new(|cx| InputState::new(window, cx).placeholder("Search transcript"));33
let subscriptions = vec![34
cx.observe(&app, |_, _, cx| cx.notify()),35
cx.subscribe_in(&search, window, |_, _, event: &InputEvent, _, cx| {36
if matches!(event, InputEvent::Change) {37
cx.notify();38
}39
}),40
];41
TranscriptPanel {42
app,43
search,44
scroll: ScrollHandle::new(),45
following: true,46
scrolled: false,47
_subscriptions: subscriptions,48
}49
}50
51
fn at_bottom(&self) -> bool {52
let offset = self.scroll.offset().y;53
let reach = self.scroll.max_offset().y;54
f32::from(offset + reach) <= AT_BOTTOM_SLACK55
}56
57
fn jump_to_latest(&mut self, cx: &mut Context<Self>) {58
self.following = true;59
self.scroll.scroll_to_bottom();60
cx.notify();61
}62
63
fn jump_chip(&self, cx: &mut Context<Self>) -> Stateful<Div> {64
div()65
.id("call-transcript-jump")66
.absolute()67
.bottom(px(12.))68
.left_0()69
.right_0()70
.flex()71
.justify_center()72
.child(73
h_flex()74
.id("call-transcript-jump-chip")75
.h(px(28.))76
.px(px(12.))77
.gap(px(6.))78
.items_center()79
.rounded_full()80
.bg(theme::accent())81
.text_color(theme::white())82
.text_size(px(12.))83
.font_weight(FontWeight::SEMIBOLD)84
.cursor_pointer()85
.child(icon(IconName::ArrowDown, 13., theme::white()))86
.child("Jump to latest")87
.on_click(cx.listener(|this, _, _, cx| this.jump_to_latest(cx))),88
)89
}90
}91
92
impl Render for TranscriptPanel {93
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {94
if std::mem::take(&mut self.scrolled) {95
self.following = self.at_bottom();96
}97
if self.following {98
self.scroll.scroll_to_bottom();99
}100
let query = self.search.read(cx).value().to_string();101
let state = self.app.read(cx);102
let transcript = state.call.as_ref().map(|call| &call.model.transcript);103
let empty = transcript.is_none_or(|transcript| transcript.is_empty());104
let rows: Vec<AnyElement> = transcript105
.map(|transcript| transcript.filtered(&query))106
.unwrap_or_default()107
.into_iter()108
.map(|entry| {109
v_flex()110
.gap(px(2.))111
.child(112
h_flex()113
.gap(px(8.))114
.items_baseline()115
.child(116
div()117
.min_w_0()118
.truncate()119
.text_size(px(13.))120
.font_weight(FontWeight::BOLD)121
.child(entry.speaker.clone()),122
)123
.child(124
div()125
.flex_none()126
.text_size(px(11.))127
.text_color(theme::text_muted())128
.child(clock_label(entry.offset)),129
),130
)131
.child(div().text_size(px(13.)).child(entry.text.clone()))132
.into_any_element()133
})134
.collect();135
let hint = rows.is_empty().then_some(if empty { EMPTY_TEXT } else { NO_MATCH_TEXT });136
let app = self.app.clone();137
let search = h_flex()138
.h(px(SEARCH_HEIGHT))139
.mx(px(12.))140
.px(px(10.))141
.gap(px(8.))142
.flex_none()143
.items_center()144
.rounded(px(6.))145
.border_1()146
.border_color(theme::border())147
.child(icon(IconName::Search, 14., theme::text_muted()))148
.child(149
div()150
.flex_1()151
.child(Input::new(&self.search).appearance(false).bordered(false)),152
);153
let list = div()154
.id("call-transcript-list")155
.flex_1()156
.min_h_0()157
.overflow_y_scroll()158
.track_scroll(&self.scroll)159
.on_scroll_wheel(cx.listener(|this, _, _, cx| {160
this.scrolled = true;161
cx.notify();162
}))163
.child(164
v_flex()165
.px(px(20.))166
.py(px(12.))167
.gap(px(12.))168
.children(rows)169
.children(hint.map(|text| {170
div()171
.text_size(px(13.))172
.text_color(theme::text_muted())173
.child(text)174
})),175
);176
let body = v_flex()177
.size_full()178
.min_h_0()179
.gap(px(8.))180
.child(search)181
.child(182
div()183
.relative()184
.flex_1()185
.min_h_0()186
.child(list)187
.when(!self.following, |area| area.child(self.jump_chip(cx))),188
);189
side_panel(190
"call-transcript-panel",191
"Transcript",192
"Close the transcript",193
move |cx| app.update(cx, |state, cx| state.close_call_transcript(cx)),194
body,195
)196
.debug_selector(|| "shell/islands/main/call-transcript".into())197
}198
}@@ -1171,6 +1171,7 @@ pub fn render_call_view(
1171
1171
.gap(px(ISLAND_GAP))
1172
1172
.child(column)
1173
1173
.children(chat.map(|chat| chat_panel(app, chat)))
1174
.children(call.transcript_open.then(|| state.transcript_panel.clone()).flatten())
1174
1175
.into_any_element(),
1175
1176
)
1176
1177
}
@@ -1189,11 +1190,29 @@ fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) ->
1189
1190
1190
1191
fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElement {
1191
1192
let app = app.clone();
1193
side_panel(
1194
"call-chat-panel",
1195
"Chat",
1196
"Close the chat",
1197
move |cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)),
1198
chat,
1199
)
1200
.into_any_element()
1201
}
1202
1203
pub fn side_panel(
1204
panel_id: &'static str,
1205
title: &'static str,
1206
close_tooltip: &'static str,
1207
on_close: impl Fn(&mut App) + 'static,
1208
body: impl IntoElement,
1209
) -> Stateful<Div> {
1192
1210
v_flex()
1193
.id("call-chat-panel")
1211
.id(panel_id)
1194
1212
.w(px(CHAT_PANEL_WIDTH))
1195
1213
.h_full()
1196
.flex_none()
1214
.flex_shrink(1.)
1215
.min_w_0()
1197
1216
.rounded(px(10.))
1198
1217
.overflow_hidden()
1199
1218
.bg(theme::surface())
@@ -1210,11 +1229,11 @@ fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElem
1210
1229
div()
1211
1230
.text_size(px(15.))
1212
1231
.font_weight(FontWeight::SEMIBOLD)
1213
.child("Chat"),
1232
.child(title),
1214
1233
)
1215
1234
.child(
1216
1235
div()
1217
.id("call-chat-close")
1236
.id(ElementId::Name(format!("{panel_id}-close").into()))
1218
1237
.size(px(28.))
1219
1238
.flex()
1220
1239
.items_center()
@@ -1222,13 +1241,10 @@ fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElem
1222
1241
.rounded(px(7.))
1223
1242
.cursor_pointer()
1224
1243
.hover(|button| button.bg(theme::row_hover()))
1225
.tooltip(|window, cx| Tooltip::new("Close the chat").build(window, cx))
1244
.tooltip(move |window, cx| Tooltip::new(close_tooltip).build(window, cx))
1226
1245
.child(icon(IconName::Close, 14., theme::text_muted()))
1227
.on_click(move |_, _, cx| {
1228
app.update(cx, |state, cx| state.toggle_call_chat(cx))
1229
}),
1246
.on_click(move |_, _, cx| on_close(cx)),
1230
1247
),
1231
1248
)
1232
.child(chat)
1233
.into_any_element()
1249
.child(body)
1234
1250
}
@@ -1171,6 +1171,7 @@ pub fn render_call_view(1171
.gap(px(ISLAND_GAP))1171
.gap(px(ISLAND_GAP))1172
.child(column)1172
.child(column)1173
.children(chat.map(|chat| chat_panel(app, chat)))1173
.children(chat.map(|chat| chat_panel(app, chat)))1174
.children(call.transcript_open.then(|| state.transcript_panel.clone()).flatten())1174
.into_any_element(),1175
.into_any_element(),1175
)1176
)1176
}1177
}@@ -1189,11 +1190,29 @@ fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) ->1189
1190
1190
fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElement {1191
fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElement {1191
let app = app.clone();1192
let app = app.clone();1193
side_panel(1194
"call-chat-panel",1195
"Chat",1196
"Close the chat",1197
move |cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)),1198
chat,1199
)1200
.into_any_element()1201
}1202
1203
pub fn side_panel(1204
panel_id: &'static str,1205
title: &'static str,1206
close_tooltip: &'static str,1207
on_close: impl Fn(&mut App) + 'static,1208
body: impl IntoElement,1209
) -> Stateful<Div> {1192
v_flex()1210
v_flex()1193
.id("call-chat-panel")1211
.id(panel_id)1194
.w(px(CHAT_PANEL_WIDTH))1212
.w(px(CHAT_PANEL_WIDTH))1195
.h_full()1213
.h_full()1196
.flex_none()1214
.flex_shrink(1.)1215
.min_w_0()1197
.rounded(px(10.))1216
.rounded(px(10.))1198
.overflow_hidden()1217
.overflow_hidden()1199
.bg(theme::surface())1218
.bg(theme::surface())@@ -1210,11 +1229,11 @@ fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElem1210
div()1229
div()1211
.text_size(px(15.))1230
.text_size(px(15.))1212
.font_weight(FontWeight::SEMIBOLD)1231
.font_weight(FontWeight::SEMIBOLD)1213
.child("Chat"),1232
.child(title),1214
)1233
)1215
.child(1234
.child(1216
div()1235
div()1217
.id("call-chat-close")1236
.id(ElementId::Name(format!("{panel_id}-close").into()))1218
.size(px(28.))1237
.size(px(28.))1219
.flex()1238
.flex()1220
.items_center()1239
.items_center()@@ -1222,13 +1241,10 @@ fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElem1222
.rounded(px(7.))1241
.rounded(px(7.))1223
.cursor_pointer()1242
.cursor_pointer()1224
.hover(|button| button.bg(theme::row_hover()))1243
.hover(|button| button.bg(theme::row_hover()))1225
.tooltip(|window, cx| Tooltip::new("Close the chat").build(window, cx))1244
.tooltip(move |window, cx| Tooltip::new(close_tooltip).build(window, cx))1226
.child(icon(IconName::Close, 14., theme::text_muted()))1245
.child(icon(IconName::Close, 14., theme::text_muted()))1227
.on_click(move |_, _, cx| {1246
.on_click(move |_, _, cx| on_close(cx)),1228
app.update(cx, |state, cx| state.toggle_call_chat(cx))1229
}),1230
),1247
),1231
)1248
)1232
.child(chat)1249
.child(body)1233
.into_any_element()1234
}1250
}@@ -10,7 +10,9 @@ pub mod call_layouts;
10
10
pub mod call_mini;
11
11
pub mod call_mini_window;
12
12
pub mod call_organizer;
13
pub mod call_record;
13
14
pub mod call_stage;
15
pub mod call_transcript;
14
16
pub mod call_view;
15
17
pub mod call_view_menu;
16
18
pub mod calls_tab;
@@ -10,7 +10,9 @@ pub mod call_layouts;10
pub mod call_mini;10
pub mod call_mini;11
pub mod call_mini_window;11
pub mod call_mini_window;12
pub mod call_organizer;12
pub mod call_organizer;13
pub mod call_record;13
pub mod call_stage;14
pub mod call_stage;15
pub mod call_transcript;14
pub mod call_view;16
pub mod call_view;15
pub mod call_view_menu;17
pub mod call_view_menu;16
pub mod calls_tab;18
pub mod calls_tab;@@ -5,8 +5,8 @@ use calling::meeting::fetch_live_meeting;
5
5
use calling::relay::ic3_scope;
6
6
use calling::signaling::{CHATSVC_REGION, fetch_self};
7
7
use calling::{
8
BackgroundCache, BackgroundChoice, CallCommand, CallEngine, CallSpec, CallState, CallUpdate, CaptionState, EngineConfig, MeetingTarget, Reaction, ShareKind,
9
ShareSource,
8
BackgroundCache, BackgroundChoice, CallCommand, CallEngine, CallSpec, CallState, CallUpdate, CaptionState, EngineConfig, MeetingTarget, Reaction, RecordingKind, ShareKind,
9
ShareSource, StopScope,
10
10
};
11
11
use chatsvc::InstanceNames;
12
12
use serde_json::{Value, json};
@@ -386,7 +386,7 @@ async fn run() {
386
386
}
387
387
if features.recording_stop_due.is_some_and(|due| Instant::now() >= due) {
388
388
features.recording_stop_due = None;
389
let _ = handle.commands.send(CallCommand::SetRecording { on: false, title: SUBJECT.to_owned() });
389
let _ = handle.commands.send(CallCommand::StopRecording { scope: StopScope::Both });
390
390
}
391
391
if hand_lower_due.is_some_and(|due| Instant::now() >= due) {
392
392
hand_lower_due = None;
@@ -423,7 +423,7 @@ async fn run() {
423
423
let _ = handle.commands.send(CallCommand::SetBackground(BackgroundChoice::Blur));
424
424
}
425
425
if arguments.record {
426
let _ = handle.commands.send(CallCommand::SetRecording { on: true, title: SUBJECT.to_owned() });
426
let _ = handle.commands.send(CallCommand::StartRecording { kind: RecordingKind::Video, title: SUBJECT.to_owned() });
427
427
}
428
428
if arguments.whiteboard_state {
429
429
features.whiteboard_wait_until = Some(Instant::now() + WHITEBOARD_WAIT);
@@ -5,8 +5,8 @@ use calling::meeting::fetch_live_meeting;5
use calling::relay::ic3_scope;5
use calling::relay::ic3_scope;6
use calling::signaling::{CHATSVC_REGION, fetch_self};6
use calling::signaling::{CHATSVC_REGION, fetch_self};7
use calling::{7
use calling::{8
BackgroundCache, BackgroundChoice, CallCommand, CallEngine, CallSpec, CallState, CallUpdate, CaptionState, EngineConfig, MeetingTarget, Reaction, ShareKind,8
BackgroundCache, BackgroundChoice, CallCommand, CallEngine, CallSpec, CallState, CallUpdate, CaptionState, EngineConfig, MeetingTarget, Reaction, RecordingKind, ShareKind,9
ShareSource,9
ShareSource, StopScope,10
};10
};11
use chatsvc::InstanceNames;11
use chatsvc::InstanceNames;12
use serde_json::{Value, json};12
use serde_json::{Value, json};@@ -386,7 +386,7 @@ async fn run() {386
}386
}387
if features.recording_stop_due.is_some_and(|due| Instant::now() >= due) {387
if features.recording_stop_due.is_some_and(|due| Instant::now() >= due) {388
features.recording_stop_due = None;388
features.recording_stop_due = None;389
let _ = handle.commands.send(CallCommand::SetRecording { on: false, title: SUBJECT.to_owned() });389
let _ = handle.commands.send(CallCommand::StopRecording { scope: StopScope::Both });390
}390
}391
if hand_lower_due.is_some_and(|due| Instant::now() >= due) {391
if hand_lower_due.is_some_and(|due| Instant::now() >= due) {392
hand_lower_due = None;392
hand_lower_due = None;@@ -423,7 +423,7 @@ async fn run() {423
let _ = handle.commands.send(CallCommand::SetBackground(BackgroundChoice::Blur));423
let _ = handle.commands.send(CallCommand::SetBackground(BackgroundChoice::Blur));424
}424
}425
if arguments.record {425
if arguments.record {426
let _ = handle.commands.send(CallCommand::SetRecording { on: true, title: SUBJECT.to_owned() });426
let _ = handle.commands.send(CallCommand::StartRecording { kind: RecordingKind::Video, title: SUBJECT.to_owned() });427
}427
}428
if arguments.whiteboard_state {428
if arguments.whiteboard_state {429
features.whiteboard_wait_until = Some(Instant::now() + WHITEBOARD_WAIT);429
features.whiteboard_wait_until = Some(Instant::now() + WHITEBOARD_WAIT);@@ -41,7 +41,7 @@ use crate::push::CallNotification;
41
41
use crate::relay::{DEFAULT_RELAY_HOST, RelayGrant, fetch_relay_grant};
42
42
use crate::renegotiation::{MediaAction, MediaNegotiator, MediaPath};
43
43
use crate::organizer::Target;
44
use crate::recording::{Consent, RecordingStatus};
44
use crate::recording::{Consent, RecordingPlan, RecordingStatus};
45
45
use crate::roster::Roster;
46
46
use crate::sdp::{LineRole, OfferPlan, RemoteOffer, SignaledOffer, from_teams_offer, stream_lines, to_browser_answer, to_teams_answer, to_teams_offer};
47
47
use crate::signaling::{
@@ -821,7 +821,8 @@ async fn drive(
821
821
let mut caption_deadline: Option<Instant> = None;
822
822
let mut recording_flow = CaptionFlow::default();
823
823
let mut recording_deadline: Option<Instant> = None;
824
let mut recording_title = String::new();
824
let mut recording_plan = RecordingPlan::default();
825
let mut recording_audio_only = false;
825
826
let mut recording_status = RecordingStatus::default();
826
827
let mut bot_pending = false;
827
828
let mut consent_pending = false;
@@ -1020,14 +1021,19 @@ async fn drive(
1020
1021
if roster.caption_bot().is_some() {
1021
1022
bot_pending = false;
1022
1023
}
1024
let audio_only = roster.caption_bot().is_some_and(|bot| bot.recording && bot.audio_only);
1025
if audio_only != recording_audio_only {
1026
recording_audio_only = audio_only;
1027
control.send(CallUpdate::RecordingAudioOnly(audio_only));
1028
}
1023
1029
if caption_flow.wanted() {
1024
run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), "", &mut bot_pending, control, timeline).await;
1030
run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), &RecordingPlan::default(), &mut bot_pending, control, timeline).await;
1025
1031
if caption_flow.on() {
1026
1032
caption_deadline = None;
1027
1033
}
1028
1034
}
1029
1035
if recording_flow.wanted() {
1030
run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_title, &mut bot_pending, control, timeline).await;
1036
run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1031
1037
}
1032
1038
}
1033
1039
}
@@ -1062,6 +1068,12 @@ async fn drive(
1062
1068
recording_deadline = None;
1063
1069
}
1064
1070
}
1071
if let Some(on) = change.transcription {
1072
control.send(CallUpdate::Transcribing(on));
1073
if on {
1074
recording_deadline = None;
1075
}
1076
}
1065
1077
if let Some(required) = change.consent_required {
1066
1078
consent_pending = required;
1067
1079
control.send(CallUpdate::ConsentRequired(required));
@@ -1450,17 +1462,33 @@ async fn drive(
1450
1462
caption_deadline = None;
1451
1463
control.send(CallUpdate::Captions(CaptionState::Off));
1452
1464
}
1453
run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), "", &mut bot_pending, control, timeline).await;
1465
run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), &RecordingPlan::default(), &mut bot_pending, control, timeline).await;
1454
1466
if caption_flow.on() {
1455
1467
caption_deadline = None;
1456
1468
}
1457
1469
}
1458
Some(CallCommand::SetRecording { on, title }) => {
1470
Some(CallCommand::StartRecording { kind, title }) => {
1459
1471
if is_meeting {
1460
recording_title = title;
1461
recording_flow.want(on);
1462
recording_deadline = on.then(|| Instant::now() + RECORDING_START_LIMIT);
1463
run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_title, &mut bot_pending, control, timeline).await;
1472
recording_plan = RecordingPlan { title, kind, ..RecordingPlan::default() };
1473
recording_flow.want(true);
1474
recording_deadline = Some(Instant::now() + RECORDING_START_LIMIT);
1475
run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1476
}
1477
}
1478
Some(CallCommand::StopRecording { scope }) => {
1479
if is_meeting {
1480
recording_plan.scope = scope;
1481
recording_flow.stop();
1482
recording_deadline = None;
1483
run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1484
}
1485
}
1486
Some(CallCommand::SetCaptionLanguage(language)) => {
1487
if let Some(url) = roster.caption_bot().and_then(|bot| bot.command_url.clone())
1488
&& let Err(error) = remote.signaling.caption_language_command(&url, &remote.participant, &language).await
1489
{
1490
timeline.record("caption language failed", error.to_string());
1491
control.send(CallUpdate::Notice("Could not change the spoken language".into()));
1464
1492
}
1465
1493
}
1466
1494
Some(CallCommand::ConsentToRecording) => {
@@ -2022,7 +2050,7 @@ async fn run_bot_steps(
2022
2050
remote: &RemoteCall,
2023
2051
links: &CallbackLinks,
2024
2052
meeting_chat: Option<&str>,
2025
title: &str,
2053
plan: &RecordingPlan,
2026
2054
bot_pending: &mut bool,
2027
2055
control: &CallControl,
2028
2056
timeline: &Timeline,
@@ -2076,7 +2104,7 @@ async fn run_bot_steps(
2076
2104
}
2077
2105
}
2078
2106
BotJob::Recording => {
2079
let started = remote.signaling.recording_command(&url, BotAction::Start, &remote.participant, title).await;
2107
let started = remote.signaling.recording_command(&url, plan.start(), &remote.participant, &plan.title).await;
2080
2108
let failed = started.is_err();
2081
2109
report_organizer_result(started, "recording start", start_failure, control, timeline);
2082
2110
if failed {
@@ -2097,7 +2125,7 @@ async fn run_bot_steps(
2097
2125
}
2098
2126
}
2099
2127
BotJob::Recording => {
2100
let stopped = remote.signaling.recording_command(&url, BotAction::Stop, &remote.participant, title).await;
2128
let stopped = remote.signaling.recording_command(&url, plan.stop(), &remote.participant, &plan.title).await;
2101
2129
report_organizer_result(stopped, "recording stop", "The recording could not be stopped", control, timeline);
2102
2130
}
2103
2131
}
@@ -41,7 +41,7 @@ use crate::push::CallNotification;41
use crate::relay::{DEFAULT_RELAY_HOST, RelayGrant, fetch_relay_grant};41
use crate::relay::{DEFAULT_RELAY_HOST, RelayGrant, fetch_relay_grant};42
use crate::renegotiation::{MediaAction, MediaNegotiator, MediaPath};42
use crate::renegotiation::{MediaAction, MediaNegotiator, MediaPath};43
use crate::organizer::Target;43
use crate::organizer::Target;44
use crate::recording::{Consent, RecordingStatus};44
use crate::recording::{Consent, RecordingPlan, RecordingStatus};45
use crate::roster::Roster;45
use crate::roster::Roster;46
use crate::sdp::{LineRole, OfferPlan, RemoteOffer, SignaledOffer, from_teams_offer, stream_lines, to_browser_answer, to_teams_answer, to_teams_offer};46
use crate::sdp::{LineRole, OfferPlan, RemoteOffer, SignaledOffer, from_teams_offer, stream_lines, to_browser_answer, to_teams_answer, to_teams_offer};47
use crate::signaling::{47
use crate::signaling::{@@ -821,7 +821,8 @@ async fn drive(821
let mut caption_deadline: Option<Instant> = None;821
let mut caption_deadline: Option<Instant> = None;822
let mut recording_flow = CaptionFlow::default();822
let mut recording_flow = CaptionFlow::default();823
let mut recording_deadline: Option<Instant> = None;823
let mut recording_deadline: Option<Instant> = None;824
let mut recording_title = String::new();824
let mut recording_plan = RecordingPlan::default();825
let mut recording_audio_only = false;825
let mut recording_status = RecordingStatus::default();826
let mut recording_status = RecordingStatus::default();826
let mut bot_pending = false;827
let mut bot_pending = false;827
let mut consent_pending = false;828
let mut consent_pending = false;@@ -1020,14 +1021,19 @@ async fn drive(1020
if roster.caption_bot().is_some() {1021
if roster.caption_bot().is_some() {1021
bot_pending = false;1022
bot_pending = false;1022
}1023
}1024
let audio_only = roster.caption_bot().is_some_and(|bot| bot.recording && bot.audio_only);1025
if audio_only != recording_audio_only {1026
recording_audio_only = audio_only;1027
control.send(CallUpdate::RecordingAudioOnly(audio_only));1028
}1023
if caption_flow.wanted() {1029
if caption_flow.wanted() {1024
run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), "", &mut bot_pending, control, timeline).await;1030
run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), &RecordingPlan::default(), &mut bot_pending, control, timeline).await;1025
if caption_flow.on() {1031
if caption_flow.on() {1026
caption_deadline = None;1032
caption_deadline = None;1027
}1033
}1028
}1034
}1029
if recording_flow.wanted() {1035
if recording_flow.wanted() {1030
run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_title, &mut bot_pending, control, timeline).await;1036
run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;1031
}1037
}1032
}1038
}1033
}1039
}@@ -1062,6 +1068,12 @@ async fn drive(1062
recording_deadline = None;1068
recording_deadline = None;1063
}1069
}1064
}1070
}1071
if let Some(on) = change.transcription {1072
control.send(CallUpdate::Transcribing(on));1073
if on {1074
recording_deadline = None;1075
}1076
}1065
if let Some(required) = change.consent_required {1077
if let Some(required) = change.consent_required {1066
consent_pending = required;1078
consent_pending = required;1067
control.send(CallUpdate::ConsentRequired(required));1079
control.send(CallUpdate::ConsentRequired(required));@@ -1450,17 +1462,33 @@ async fn drive(1450
caption_deadline = None;1462
caption_deadline = None;1451
control.send(CallUpdate::Captions(CaptionState::Off));1463
control.send(CallUpdate::Captions(CaptionState::Off));1452
}1464
}1453
run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), "", &mut bot_pending, control, timeline).await;1465
run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), &RecordingPlan::default(), &mut bot_pending, control, timeline).await;1454
if caption_flow.on() {1466
if caption_flow.on() {1455
caption_deadline = None;1467
caption_deadline = None;1456
}1468
}1457
}1469
}1458
Some(CallCommand::SetRecording { on, title }) => {1470
Some(CallCommand::StartRecording { kind, title }) => {1459
if is_meeting {1471
if is_meeting {1460
recording_title = title;1472
recording_plan = RecordingPlan { title, kind, ..RecordingPlan::default() };1461
recording_flow.want(on);1473
recording_flow.want(true);1462
recording_deadline = on.then(|| Instant::now() + RECORDING_START_LIMIT);1474
recording_deadline = Some(Instant::now() + RECORDING_START_LIMIT);1463
run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_title, &mut bot_pending, control, timeline).await;1475
run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;1476
}1477
}1478
Some(CallCommand::StopRecording { scope }) => {1479
if is_meeting {1480
recording_plan.scope = scope;1481
recording_flow.stop();1482
recording_deadline = None;1483
run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;1484
}1485
}1486
Some(CallCommand::SetCaptionLanguage(language)) => {1487
if let Some(url) = roster.caption_bot().and_then(|bot| bot.command_url.clone())1488
&& let Err(error) = remote.signaling.caption_language_command(&url, &remote.participant, &language).await1489
{1490
timeline.record("caption language failed", error.to_string());1491
control.send(CallUpdate::Notice("Could not change the spoken language".into()));1464
}1492
}1465
}1493
}1466
Some(CallCommand::ConsentToRecording) => {1494
Some(CallCommand::ConsentToRecording) => {@@ -2022,7 +2050,7 @@ async fn run_bot_steps(2022
remote: &RemoteCall,2050
remote: &RemoteCall,2023
links: &CallbackLinks,2051
links: &CallbackLinks,2024
meeting_chat: Option<&str>,2052
meeting_chat: Option<&str>,2025
title: &str,2053
plan: &RecordingPlan,2026
bot_pending: &mut bool,2054
bot_pending: &mut bool,2027
control: &CallControl,2055
control: &CallControl,2028
timeline: &Timeline,2056
timeline: &Timeline,@@ -2076,7 +2104,7 @@ async fn run_bot_steps(2076
}2104
}2077
}2105
}2078
BotJob::Recording => {2106
BotJob::Recording => {2079
let started = remote.signaling.recording_command(&url, BotAction::Start, &remote.participant, title).await;2107
let started = remote.signaling.recording_command(&url, plan.start(), &remote.participant, &plan.title).await;2080
let failed = started.is_err();2108
let failed = started.is_err();2081
report_organizer_result(started, "recording start", start_failure, control, timeline);2109
report_organizer_result(started, "recording start", start_failure, control, timeline);2082
if failed {2110
if failed {@@ -2097,7 +2125,7 @@ async fn run_bot_steps(2097
}2125
}2098
}2126
}2099
BotJob::Recording => {2127
BotJob::Recording => {2100
let stopped = remote.signaling.recording_command(&url, BotAction::Stop, &remote.participant, title).await;2128
let stopped = remote.signaling.recording_command(&url, plan.stop(), &remote.participant, &plan.title).await;2101
report_organizer_result(stopped, "recording stop", "The recording could not be stopped", control, timeline);2129
report_organizer_result(stopped, "recording stop", "The recording could not be stopped", control, timeline);2102
}2130
}2103
}2131
}@@ -130,6 +130,33 @@ pub fn command_body(action: BotAction, own_mri: &str, participant_leg_id: &str,
130
130
})
131
131
}
132
132
133
pub const SPOKEN_LANGUAGES: [(&str, &str); 12] = [
134
("en-US", "English (US)"),
135
("en-GB", "English (UK)"),
136
("de-DE", "German"),
137
("fr-FR", "French"),
138
("es-ES", "Spanish"),
139
("it-IT", "Italian"),
140
("nl-NL", "Dutch"),
141
("pt-BR", "Portuguese (Brazil)"),
142
("ja-JP", "Japanese"),
143
("zh-CN", "Chinese (Simplified)"),
144
("sv-SE", "Swedish"),
145
("pl-PL", "Polish"),
146
];
147
148
pub fn language_body(own_mri: &str, participant_leg_id: &str, timestamp: &str, language_tag: &str) -> Value {
149
json!({
150
"timestamp": timestamp,
151
"participantMri": own_mri,
152
"participantLegId": participant_leg_id,
153
"action": "setLanguage",
154
"mode": COMMAND_MODE,
155
"processingModes": [CLOSED_CAPTIONS],
156
"actionParameters": {"spokenLanguage": language_tag.to_ascii_lowercase(), "type": "setLanguage"},
157
})
158
}
159
133
160
pub fn endpoint_metadata(captions: bool) -> Value {
134
161
json!({"holographicCapabilities": 3, "transcriptionPrefs": {"closedCaptions": captions}})
135
162
}
@@ -159,6 +186,12 @@ impl CaptionFlow {
159
186
}
160
187
}
161
188
189
pub fn stop(&mut self) {
190
self.wanted = false;
191
self.started = true;
192
self.reported = false;
193
}
194
162
195
pub fn wanted(&self) -> bool {
163
196
self.wanted
164
197
}
@@ -201,7 +234,7 @@ mod tests {
201
234
use super::*;
202
235
203
236
fn bot(command_url: bool, active: bool) -> CaptionBot {
204
CaptionBot { mri: RECORDING_BOT_MRI.into(), command_url: command_url.then(|| "https://x/v2/oncommand/1".into()), active, recording: false }
237
CaptionBot { mri: RECORDING_BOT_MRI.into(), command_url: command_url.then(|| "https://x/v2/oncommand/1".into()), active, recording: false, audio_only: false }
205
238
}
206
239
207
240
#[test]
@@ -255,6 +288,31 @@ mod tests {
255
288
assert_eq!(start["timestamp"], stop["timestamp"]);
256
289
}
257
290
291
#[test]
292
fn the_language_command_sets_a_lower_case_spoken_language() {
293
let body = language_body("8:orgid:me", "leg-1", "2026-10-10T08:44:12.705Z", "de-DE");
294
assert_eq!(body["action"], "setLanguage");
295
assert_eq!(body["mode"], "transcription");
296
assert_eq!(body["processingModes"], json!(["closedCaptions"]));
297
assert_eq!(body["actionParameters"], json!({"spokenLanguage": "de-de", "type": "setLanguage"}));
298
assert_eq!(body["participantLegId"], "leg-1");
299
assert!(body.get("participantSkypeToken").is_none());
300
}
301
302
#[test]
303
fn every_listed_language_is_a_region_tag_with_a_label() {
304
assert!(SPOKEN_LANGUAGES.iter().all(|(tag, label)| tag.len() == 5 && tag.contains('-') && !label.is_empty()));
305
assert!(SPOKEN_LANGUAGES.iter().any(|(tag, _)| *tag == "en-US"));
306
}
307
308
#[test]
309
fn a_forced_stop_reaches_the_bot_even_when_this_session_did_not_start_it() {
310
let mut flow = CaptionFlow::default();
311
flow.stop();
312
assert_eq!(flow.next(Some(&bot(true, true))), CaptionStep::Stop);
313
assert_eq!(flow.next(Some(&bot(true, true))), CaptionStep::Wait);
314
}
315
258
316
#[test]
259
317
fn the_endpoint_metadata_switches_the_caption_preference() {
260
318
assert_eq!(endpoint_metadata(true)["transcriptionPrefs"]["closedCaptions"], true);
@@ -130,6 +130,33 @@ pub fn command_body(action: BotAction, own_mri: &str, participant_leg_id: &str,130
})130
})131
}131
}132
132
133
pub const SPOKEN_LANGUAGES: [(&str, &str); 12] = [134
("en-US", "English (US)"),135
("en-GB", "English (UK)"),136
("de-DE", "German"),137
("fr-FR", "French"),138
("es-ES", "Spanish"),139
("it-IT", "Italian"),140
("nl-NL", "Dutch"),141
("pt-BR", "Portuguese (Brazil)"),142
("ja-JP", "Japanese"),143
("zh-CN", "Chinese (Simplified)"),144
("sv-SE", "Swedish"),145
("pl-PL", "Polish"),146
];147
148
pub fn language_body(own_mri: &str, participant_leg_id: &str, timestamp: &str, language_tag: &str) -> Value {149
json!({150
"timestamp": timestamp,151
"participantMri": own_mri,152
"participantLegId": participant_leg_id,153
"action": "setLanguage",154
"mode": COMMAND_MODE,155
"processingModes": [CLOSED_CAPTIONS],156
"actionParameters": {"spokenLanguage": language_tag.to_ascii_lowercase(), "type": "setLanguage"},157
})158
}159
133
pub fn endpoint_metadata(captions: bool) -> Value {160
pub fn endpoint_metadata(captions: bool) -> Value {134
json!({"holographicCapabilities": 3, "transcriptionPrefs": {"closedCaptions": captions}})161
json!({"holographicCapabilities": 3, "transcriptionPrefs": {"closedCaptions": captions}})135
}162
}@@ -159,6 +186,12 @@ impl CaptionFlow {159
}186
}160
}187
}161
188
189
pub fn stop(&mut self) {190
self.wanted = false;191
self.started = true;192
self.reported = false;193
}194
162
pub fn wanted(&self) -> bool {195
pub fn wanted(&self) -> bool {163
self.wanted196
self.wanted164
}197
}@@ -201,7 +234,7 @@ mod tests {201
use super::*;234
use super::*;202
235
203
fn bot(command_url: bool, active: bool) -> CaptionBot {236
fn bot(command_url: bool, active: bool) -> CaptionBot {204
CaptionBot { mri: RECORDING_BOT_MRI.into(), command_url: command_url.then(|| "https://x/v2/oncommand/1".into()), active, recording: false }237
CaptionBot { mri: RECORDING_BOT_MRI.into(), command_url: command_url.then(|| "https://x/v2/oncommand/1".into()), active, recording: false, audio_only: false }205
}238
}206
239
207
#[test]240
#[test]@@ -255,6 +288,31 @@ mod tests {255
assert_eq!(start["timestamp"], stop["timestamp"]);288
assert_eq!(start["timestamp"], stop["timestamp"]);256
}289
}257
290
291
#[test]292
fn the_language_command_sets_a_lower_case_spoken_language() {293
let body = language_body("8:orgid:me", "leg-1", "2026-10-10T08:44:12.705Z", "de-DE");294
assert_eq!(body["action"], "setLanguage");295
assert_eq!(body["mode"], "transcription");296
assert_eq!(body["processingModes"], json!(["closedCaptions"]));297
assert_eq!(body["actionParameters"], json!({"spokenLanguage": "de-de", "type": "setLanguage"}));298
assert_eq!(body["participantLegId"], "leg-1");299
assert!(body.get("participantSkypeToken").is_none());300
}301
302
#[test]303
fn every_listed_language_is_a_region_tag_with_a_label() {304
assert!(SPOKEN_LANGUAGES.iter().all(|(tag, label)| tag.len() == 5 && tag.contains('-') && !label.is_empty()));305
assert!(SPOKEN_LANGUAGES.iter().any(|(tag, _)| *tag == "en-US"));306
}307
308
#[test]309
fn a_forced_stop_reaches_the_bot_even_when_this_session_did_not_start_it() {310
let mut flow = CaptionFlow::default();311
flow.stop();312
assert_eq!(flow.next(Some(&bot(true, true))), CaptionStep::Stop);313
assert_eq!(flow.next(Some(&bot(true, true))), CaptionStep::Wait);314
}315
258
#[test]316
#[test]259
fn the_endpoint_metadata_switches_the_caption_preference() {317
fn the_endpoint_metadata_switches_the_caption_preference() {260
assert_eq!(endpoint_metadata(true)["transcriptionPrefs"]["closedCaptions"], true);318
assert_eq!(endpoint_metadata(true)["transcriptionPrefs"]["closedCaptions"], true);@@ -7,6 +7,7 @@ use crate::background::BackgroundChoice;
7
7
use crate::effects::CameraEffects;
8
8
use crate::breakout::BreakoutMove;
9
9
use crate::captions::{CaptionEntry, CaptionState};
10
use crate::recording::{RecordingKind, StopScope};
10
11
use crate::devices::{DeviceChoice, DeviceLists};
11
12
use crate::error::{Error, Result};
12
13
use crate::health::CallHealth;
@@ -51,7 +52,9 @@ pub enum CallCommand {
51
52
SetIncomingVideo(bool),
52
53
SetCameraEffects(CameraEffects),
53
54
SendReaction(Reaction),
54
SetRecording { on: bool, title: String },
55
StartRecording { kind: RecordingKind, title: String },
56
StopRecording { scope: StopScope },
57
SetCaptionLanguage(String),
55
58
ConsentToRecording,
56
59
Hold(bool),
57
60
Transfer { target: Callee, replaces: Option<String> },
@@ -95,6 +98,8 @@ pub enum CallUpdate {
95
98
Health(CallHealth),
96
99
IncomingVideo(bool),
97
100
Recording(bool),
101
RecordingAudioOnly(bool),
102
Transcribing(bool),
98
103
ConsentRequired(bool),
99
104
Hold(HoldState),
100
105
Whiteboard(Option<ContentShare>),
@@ -7,6 +7,7 @@ use crate::background::BackgroundChoice;7
use crate::effects::CameraEffects;7
use crate::effects::CameraEffects;8
use crate::breakout::BreakoutMove;8
use crate::breakout::BreakoutMove;9
use crate::captions::{CaptionEntry, CaptionState};9
use crate::captions::{CaptionEntry, CaptionState};10
use crate::recording::{RecordingKind, StopScope};10
use crate::devices::{DeviceChoice, DeviceLists};11
use crate::devices::{DeviceChoice, DeviceLists};11
use crate::error::{Error, Result};12
use crate::error::{Error, Result};12
use crate::health::CallHealth;13
use crate::health::CallHealth;@@ -51,7 +52,9 @@ pub enum CallCommand {51
SetIncomingVideo(bool),52
SetIncomingVideo(bool),52
SetCameraEffects(CameraEffects),53
SetCameraEffects(CameraEffects),53
SendReaction(Reaction),54
SendReaction(Reaction),54
SetRecording { on: bool, title: String },55
StartRecording { kind: RecordingKind, title: String },56
StopRecording { scope: StopScope },57
SetCaptionLanguage(String),55
ConsentToRecording,58
ConsentToRecording,56
Hold(bool),59
Hold(bool),57
Transfer { target: Callee, replaces: Option<String> },60
Transfer { target: Callee, replaces: Option<String> },@@ -95,6 +98,8 @@ pub enum CallUpdate {95
Health(CallHealth),98
Health(CallHealth),96
IncomingVideo(bool),99
IncomingVideo(bool),97
Recording(bool),100
Recording(bool),101
RecordingAudioOnly(bool),102
Transcribing(bool),98
ConsentRequired(bool),103
ConsentRequired(bool),99
Hold(HoldState),104
Hold(HoldState),100
Whiteboard(Option<ContentShare>),105
Whiteboard(Option<ContentShare>),@@ -66,7 +66,8 @@ pub use engine::{CallEngine, EngineConfig, EngineEvent, IncomingRing};
66
66
pub use push::Caller;
67
67
pub use ring::{RING_TIMEOUT, RingEnd, RingSignal, RingState};
68
68
pub use reaction::{Reaction, ReactionEvent};
69
pub use captions::{CaptionEntry, CaptionState};
69
pub use captions::{CaptionEntry, CaptionState, SPOKEN_LANGUAGES};
70
pub use recording::{RecordingKind, StopScope};
70
71
pub use roster::{PublishedState, RaisedHand, RosterEntry, Spotlight};
71
72
pub use sound_capture::LoopbackKind;
72
73
pub use renegotiation::MediaPath;
@@ -66,7 +66,8 @@ pub use engine::{CallEngine, EngineConfig, EngineEvent, IncomingRing};66
pub use push::Caller;66
pub use push::Caller;67
pub use ring::{RING_TIMEOUT, RingEnd, RingSignal, RingState};67
pub use ring::{RING_TIMEOUT, RingEnd, RingSignal, RingState};68
pub use reaction::{Reaction, ReactionEvent};68
pub use reaction::{Reaction, ReactionEvent};69
pub use captions::{CaptionEntry, CaptionState};69
pub use captions::{CaptionEntry, CaptionState, SPOKEN_LANGUAGES};70
pub use recording::{RecordingKind, StopScope};70
pub use roster::{PublishedState, RaisedHand, RosterEntry, Spotlight};71
pub use roster::{PublishedState, RaisedHand, RosterEntry, Spotlight};71
pub use sound_capture::LoopbackKind;72
pub use sound_capture::LoopbackKind;72
pub use renegotiation::MediaPath;73
pub use renegotiation::MediaPath;@@ -1,15 +1,21 @@
1
1
use serde_json::{Value, json};
2
2
3
use crate::captions::{BotAction, recorder_features};
3
use crate::captions::recorder_features;
4
4
use crate::trouter_events::find_key;
5
5
6
6
const CLOUD_RECORDING: &str = "cloudRecording";
7
const TRANSCRIPTION: &str = "transcription";
7
8
const CONSENT_DETAILS: &str = "recordingConsentDetails";
8
9
const ACTIVE: &str = "Active";
9
const PROCESSING_MODES: [&str; 2] = ["recording", "realTimeTranscript"];
10
const RECORDING_AND_TRANSCRIPT: [&str; 2] = ["recording", "realTimeTranscript"];
11
const RECORDING_ONLY: [&str; 1] = ["recording"];
12
const TRANSCRIPT_ONLY: [&str; 1] = ["realTimeTranscript"];
13
const TRANSCRIPTION_MODE: &str = "transcription";
14
const RECORDING_MODE_KEY: &str = "recording";
10
15
const STORAGE_TYPE: &str = "OnedriveForBusiness";
11
16
const STORAGE_LOCATION: &str = "Recordings";
12
const RECORDING_MODE: &str = "Normal";
17
const VIDEO_MODE: &str = "Normal";
18
const AUDIO_ONLY_MODE: &str = "AudioOnly";
13
19
const FILE_SUFFIX: &str = "Meeting Recording";
14
20
const CONSENT_STATE: &str = "consentToRecording";
15
21
const DENY_STATE: &str = "denyConsentToRecording";
@@ -17,20 +23,23 @@ const DENY_STATE: &str = "denyConsentToRecording";
17
23
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
18
24
pub struct StateChange {
19
25
pub recording: Option<bool>,
26
pub transcription: Option<bool>,
20
27
pub consent_required: Option<bool>,
21
28
}
22
29
23
30
impl StateChange {
24
31
pub fn is_empty(&self) -> bool {
25
self.recording.is_none() && self.consent_required.is_none()
32
self.recording.is_none() && self.transcription.is_none() && self.consent_required.is_none()
26
33
}
27
34
}
28
35
29
36
#[derive(Debug, Clone, Copy, Default)]
30
37
pub struct RecordingStatus {
31
38
active: bool,
39
transcribing: bool,
32
40
consent_required: bool,
33
41
sequence: u64,
42
transcription_sequence: u64,
34
43
}
35
44
36
45
impl RecordingStatus {
@@ -38,24 +47,37 @@ impl RecordingStatus {
38
47
self.active
39
48
}
40
49
50
pub fn transcribing(&self) -> bool {
51
self.transcribing
52
}
53
41
54
pub fn consent_required(&self) -> bool {
42
55
self.consent_required
43
56
}
44
57
58
fn newer_state(body: &Value, key: &str, last_sequence: &mut u64) -> Option<bool> {
59
let state = find_key(body, key)?;
60
let sequence = state["sequenceNumber"].as_u64().unwrap_or_default();
61
let current = state["value"]["State"].as_str().map(|name| name == ACTIVE)?;
62
(sequence >= *last_sequence).then(|| {
63
*last_sequence = sequence;
64
current
65
})
66
}
67
45
68
pub fn apply(&mut self, body: &Value) -> StateChange {
46
69
let mut change = StateChange::default();
47
if let Some(state) = find_key(body, CLOUD_RECORDING) {
48
let sequence = state["sequenceNumber"].as_u64().unwrap_or_default();
49
let current = state["value"]["State"].as_str().map(|name| name == ACTIVE);
50
if let Some(current) = current
51
&& sequence >= self.sequence
52
{
53
self.sequence = sequence;
54
if current != self.active {
55
self.active = current;
56
change.recording = Some(current);
57
}
58
}
70
if let Some(current) = Self::newer_state(body, CLOUD_RECORDING, &mut self.sequence)
71
&& current != self.active
72
{
73
self.active = current;
74
change.recording = Some(current);
75
}
76
if let Some(current) = Self::newer_state(body, TRANSCRIPTION, &mut self.transcription_sequence)
77
&& current != self.transcribing
78
{
79
self.transcribing = current;
80
change.transcription = Some(current);
59
81
}
60
82
if let Some(required) = find_key(body, CONSENT_DETAILS).and_then(|details| details["consentActivelyRequired"].as_bool())
61
83
&& required != self.consent_required
@@ -67,6 +89,45 @@ impl RecordingStatus {
67
89
}
68
90
}
69
91
92
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
93
pub enum RecordingKind {
94
#[default]
95
Video,
96
AudioOnly,
97
TranscriptOnly,
98
}
99
100
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
101
pub enum StopScope {
102
#[default]
103
Both,
104
RecordingOnly,
105
TranscriptionOnly,
106
}
107
108
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
109
pub enum RecordingCommand {
110
Start(RecordingKind),
111
Stop(StopScope),
112
}
113
114
#[derive(Debug, Clone, Default)]
115
pub struct RecordingPlan {
116
pub title: String,
117
pub kind: RecordingKind,
118
pub scope: StopScope,
119
}
120
121
impl RecordingPlan {
122
pub fn start(&self) -> RecordingCommand {
123
RecordingCommand::Start(self.kind)
124
}
125
126
pub fn stop(&self) -> RecordingCommand {
127
RecordingCommand::Stop(self.scope)
128
}
129
}
130
70
131
#[derive(Debug, Clone, Copy)]
71
132
pub struct StartDetails<'a> {
72
133
pub own_mri: &'a str,
@@ -79,45 +140,65 @@ pub struct StartDetails<'a> {
79
140
}
80
141
81
142
/// The skype token is added inside the page, so the body travels without it.
82
pub fn start_body(details: StartDetails<'_>) -> Value {
83
json!({
143
pub fn start_body(kind: RecordingKind, details: StartDetails<'_>) -> Value {
144
let mut parameters = json!({
145
"recordingFeatures": recorder_features(),
146
"recordingStorageSettings": [{
147
"StorageType": STORAGE_TYPE,
148
"StorageLocation": STORAGE_LOCATION,
149
"FileName": details.file_name,
150
}],
151
"correlationId": details.correlation_id,
152
"meetingTitle": details.meeting_title,
153
"exchangeId": null,
154
"meetingOrganizer": details.organizer_name,
155
"spokenLanguage": "",
156
"type": "start",
157
});
158
let mut body = json!({
84
159
"timestamp": details.timestamp,
85
160
"participantMri": details.own_mri,
86
161
"participantLegId": details.participant_leg_id,
87
162
"action": "start",
88
"processingModes": PROCESSING_MODES,
89
"actionParameters": {
90
"recordingFeatures": recorder_features(),
91
"recordingStorageSettings": [{
92
"StorageType": STORAGE_TYPE,
93
"StorageLocation": STORAGE_LOCATION,
94
"FileName": details.file_name,
95
}],
96
"correlationId": details.correlation_id,
97
"meetingTitle": details.meeting_title,
98
"exchangeId": null,
99
"meetingOrganizer": details.organizer_name,
100
"recordingMode": RECORDING_MODE,
101
"spokenLanguage": "",
102
"type": "start",
103
},
104
})
163
});
164
match kind {
165
RecordingKind::Video => parameters["recordingMode"] = json!(VIDEO_MODE),
166
RecordingKind::AudioOnly => parameters["recordingMode"] = json!(AUDIO_ONLY_MODE),
167
RecordingKind::TranscriptOnly => body["mode"] = json!(TRANSCRIPTION_MODE),
168
}
169
body["processingModes"] = match kind {
170
RecordingKind::TranscriptOnly => json!(TRANSCRIPT_ONLY),
171
RecordingKind::Video | RecordingKind::AudioOnly => json!(RECORDING_AND_TRANSCRIPT),
172
};
173
body["actionParameters"] = parameters;
174
body
105
175
}
106
176
107
pub fn stop_body(own_mri: &str, participant_leg_id: &str, timestamp: &str) -> Value {
108
json!({
177
pub fn stop_body(scope: StopScope, own_mri: &str, participant_leg_id: &str, timestamp: &str) -> Value {
178
let mut body = json!({
109
179
"timestamp": timestamp,
110
180
"participantMri": own_mri,
111
181
"participantLegId": participant_leg_id,
112
182
"action": "stop",
113
"processingModes": PROCESSING_MODES,
114
})
183
});
184
match scope {
185
StopScope::Both => body["processingModes"] = json!(RECORDING_AND_TRANSCRIPT),
186
StopScope::RecordingOnly => {
187
body["mode"] = json!(RECORDING_MODE_KEY);
188
body["processingModes"] = json!(RECORDING_ONLY);
189
}
190
StopScope::TranscriptionOnly => {
191
body["mode"] = json!(TRANSCRIPTION_MODE);
192
body["processingModes"] = json!(TRANSCRIPT_ONLY);
193
}
194
}
195
body
115
196
}
116
197
117
pub fn command_body(action: BotAction, details: StartDetails<'_>) -> Value {
118
match action {
119
BotAction::Start => start_body(details),
120
BotAction::Stop => stop_body(details.own_mri, details.participant_leg_id, details.timestamp),
198
pub fn command_body(command: RecordingCommand, details: StartDetails<'_>) -> Value {
199
match command {
200
RecordingCommand::Start(kind) => start_body(kind, details),
201
RecordingCommand::Stop(scope) => stop_body(scope, details.own_mri, details.participant_leg_id, details.timestamp),
121
202
}
122
203
}
123
204
@@ -164,7 +245,7 @@ mod tests {
164
245
#[test]
165
246
fn the_recording_state_follows_the_meeting_state_and_ignores_stale_updates() {
166
247
let mut status = RecordingStatus::default();
167
assert_eq!(status.apply(&update("Active", 3)), StateChange { recording: Some(true), consent_required: None });
248
assert_eq!(status.apply(&update("Active", 3)), StateChange { recording: Some(true), transcription: Some(true), consent_required: None });
168
249
assert!(status.active());
169
250
assert!(status.apply(&update("Active", 3)).is_empty());
170
251
assert!(status.apply(&update("Inactive", 2)).is_empty());
@@ -173,6 +254,18 @@ mod tests {
173
254
assert!(!status.active());
174
255
}
175
256
257
#[test]
258
fn transcription_runs_on_its_own_state_and_sequence() {
259
let mut status = RecordingStatus::default();
260
let transcript_only = json!({"meetingStates": {"transcription": {"value": {"State": "Active"}, "sequenceNumber": 2}}});
261
assert_eq!(status.apply(&transcript_only), StateChange { recording: None, transcription: Some(true), consent_required: None });
262
assert!(status.transcribing() && !status.active());
263
let stale = json!({"meetingStates": {"transcription": {"value": {"State": "Inactive"}, "sequenceNumber": 1}}});
264
assert!(status.apply(&stale).is_empty());
265
let stopped = json!({"meetingStates": {"transcription": {"value": {"State": "Inactive"}, "sequenceNumber": 3}}});
266
assert_eq!(status.apply(&stopped).transcription, Some(false));
267
}
268
176
269
#[test]
177
270
fn unrelated_updates_change_nothing() {
178
271
let mut status = RecordingStatus::default();
@@ -184,7 +277,7 @@ mod tests {
184
277
fn consent_is_required_when_the_meeting_says_so() {
185
278
let mut status = RecordingStatus::default();
186
279
assert!(status.apply(&consent(false)).is_empty());
187
assert_eq!(status.apply(&consent(true)), StateChange { recording: None, consent_required: Some(true) });
280
assert_eq!(status.apply(&consent(true)), StateChange { recording: None, transcription: None, consent_required: Some(true) });
188
281
assert!(status.consent_required());
189
282
assert!(status.apply(&consent(true)).is_empty());
190
283
assert_eq!(status.apply(&consent(false)).consent_required, Some(false));
@@ -195,7 +288,7 @@ mod tests {
195
288
let mut both = update("Active", 1);
196
289
both["meetingDetails"] = consent(true)["meetingDetails"].clone();
197
290
let change = RecordingStatus::default().apply(&both);
198
assert_eq!(change, StateChange { recording: Some(true), consent_required: Some(true) });
291
assert_eq!(change, StateChange { recording: Some(true), transcription: Some(true), consent_required: Some(true) });
199
292
}
200
293
201
294
fn details() -> StartDetails<'static> {
@@ -211,8 +304,8 @@ mod tests {
211
304
}
212
305
213
306
#[test]
214
fn the_start_command_records_to_onedrive_without_a_mode_key() {
215
let body = command_body(BotAction::Start, details());
307
fn the_start_command_records_video_to_onedrive_without_a_mode_key() {
308
let body = command_body(RecordingCommand::Start(RecordingKind::Video), details());
216
309
assert_eq!(body["action"], "start");
217
310
assert_eq!(body["processingModes"], json!(["recording", "realTimeTranscript"]));
218
311
assert!(body.get("mode").is_none());
@@ -228,12 +321,47 @@ mod tests {
228
321
}
229
322
230
323
#[test]
231
fn the_stop_command_is_short() {
232
let body = command_body(BotAction::Stop, details());
233
assert_eq!(body["action"], "stop");
234
assert_eq!(body["processingModes"], json!(["recording", "realTimeTranscript"]));
235
assert!(body.get("actionParameters").is_none());
236
assert_eq!(body["timestamp"], "2026-10-10T08:44:12.705Z");
324
fn audio_only_differs_from_video_in_the_recording_mode_alone() {
325
let video = start_body(RecordingKind::Video, details());
326
let mut audio = start_body(RecordingKind::AudioOnly, details());
327
assert_eq!(audio["actionParameters"]["recordingMode"], "AudioOnly");
328
audio["actionParameters"]["recordingMode"] = video["actionParameters"]["recordingMode"].clone();
329
assert_eq!(audio, video);
330
}
331
332
#[test]
333
fn transcription_only_has_a_mode_one_processing_mode_and_no_recording_mode() {
334
let body = start_body(RecordingKind::TranscriptOnly, details());
335
assert_eq!(body["action"], "start");
336
assert_eq!(body["mode"], "transcription");
337
assert_eq!(body["processingModes"], json!(["realTimeTranscript"]));
338
assert!(body["actionParameters"].get("recordingMode").is_none());
339
assert_eq!(body["actionParameters"]["type"], "start");
340
assert_eq!(body["actionParameters"]["meetingTitle"], "Standup");
341
}
342
343
#[test]
344
fn the_three_stop_variants_match_the_capture() {
345
let stop = |scope| command_body(RecordingCommand::Stop(scope), details());
346
let both = stop(StopScope::Both);
347
assert_eq!(both["action"], "stop");
348
assert_eq!(both["processingModes"], json!(["recording", "realTimeTranscript"]));
349
assert!(both.get("mode").is_none());
350
assert!(both.get("actionParameters").is_none());
351
assert_eq!(both["timestamp"], "2026-10-10T08:44:12.705Z");
352
let recording = stop(StopScope::RecordingOnly);
353
assert_eq!(recording["mode"], "recording");
354
assert_eq!(recording["processingModes"], json!(["recording"]));
355
let transcription = stop(StopScope::TranscriptionOnly);
356
assert_eq!(transcription["mode"], "transcription");
357
assert_eq!(transcription["processingModes"], json!(["realTimeTranscript"]));
358
}
359
360
#[test]
361
fn a_plan_names_its_start_and_stop_commands() {
362
let plan = RecordingPlan { title: "Standup".into(), kind: RecordingKind::AudioOnly, scope: StopScope::RecordingOnly };
363
assert_eq!(plan.start(), RecordingCommand::Start(RecordingKind::AudioOnly));
364
assert_eq!(plan.stop(), RecordingCommand::Stop(StopScope::RecordingOnly));
237
365
}
238
366
239
367
#[test]
@@ -1,15 +1,21 @@1
use serde_json::{Value, json};1
use serde_json::{Value, json};2
2
3
use crate::captions::{BotAction, recorder_features};3
use crate::captions::recorder_features;4
use crate::trouter_events::find_key;4
use crate::trouter_events::find_key;5
5
6
const CLOUD_RECORDING: &str = "cloudRecording";6
const CLOUD_RECORDING: &str = "cloudRecording";7
const TRANSCRIPTION: &str = "transcription";7
const CONSENT_DETAILS: &str = "recordingConsentDetails";8
const CONSENT_DETAILS: &str = "recordingConsentDetails";8
const ACTIVE: &str = "Active";9
const ACTIVE: &str = "Active";9
const PROCESSING_MODES: [&str; 2] = ["recording", "realTimeTranscript"];10
const RECORDING_AND_TRANSCRIPT: [&str; 2] = ["recording", "realTimeTranscript"];11
const RECORDING_ONLY: [&str; 1] = ["recording"];12
const TRANSCRIPT_ONLY: [&str; 1] = ["realTimeTranscript"];13
const TRANSCRIPTION_MODE: &str = "transcription";14
const RECORDING_MODE_KEY: &str = "recording";10
const STORAGE_TYPE: &str = "OnedriveForBusiness";15
const STORAGE_TYPE: &str = "OnedriveForBusiness";11
const STORAGE_LOCATION: &str = "Recordings";16
const STORAGE_LOCATION: &str = "Recordings";12
const RECORDING_MODE: &str = "Normal";17
const VIDEO_MODE: &str = "Normal";18
const AUDIO_ONLY_MODE: &str = "AudioOnly";13
const FILE_SUFFIX: &str = "Meeting Recording";19
const FILE_SUFFIX: &str = "Meeting Recording";14
const CONSENT_STATE: &str = "consentToRecording";20
const CONSENT_STATE: &str = "consentToRecording";15
const DENY_STATE: &str = "denyConsentToRecording";21
const DENY_STATE: &str = "denyConsentToRecording";@@ -17,20 +23,23 @@ const DENY_STATE: &str = "denyConsentToRecording";17
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]23
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]18
pub struct StateChange {24
pub struct StateChange {19
pub recording: Option<bool>,25
pub recording: Option<bool>,26
pub transcription: Option<bool>,20
pub consent_required: Option<bool>,27
pub consent_required: Option<bool>,21
}28
}22
29
23
impl StateChange {30
impl StateChange {24
pub fn is_empty(&self) -> bool {31
pub fn is_empty(&self) -> bool {25
self.recording.is_none() && self.consent_required.is_none()32
self.recording.is_none() && self.transcription.is_none() && self.consent_required.is_none()26
}33
}27
}34
}28
35
29
#[derive(Debug, Clone, Copy, Default)]36
#[derive(Debug, Clone, Copy, Default)]30
pub struct RecordingStatus {37
pub struct RecordingStatus {31
active: bool,38
active: bool,39
transcribing: bool,32
consent_required: bool,40
consent_required: bool,33
sequence: u64,41
sequence: u64,42
transcription_sequence: u64,34
}43
}35
44
36
impl RecordingStatus {45
impl RecordingStatus {@@ -38,24 +47,37 @@ impl RecordingStatus {38
self.active47
self.active39
}48
}40
49
50
pub fn transcribing(&self) -> bool {51
self.transcribing52
}53
41
pub fn consent_required(&self) -> bool {54
pub fn consent_required(&self) -> bool {42
self.consent_required55
self.consent_required43
}56
}44
57
58
fn newer_state(body: &Value, key: &str, last_sequence: &mut u64) -> Option<bool> {59
let state = find_key(body, key)?;60
let sequence = state["sequenceNumber"].as_u64().unwrap_or_default();61
let current = state["value"]["State"].as_str().map(|name| name == ACTIVE)?;62
(sequence >= *last_sequence).then(|| {63
*last_sequence = sequence;64
current65
})66
}67
45
pub fn apply(&mut self, body: &Value) -> StateChange {68
pub fn apply(&mut self, body: &Value) -> StateChange {46
let mut change = StateChange::default();69
let mut change = StateChange::default();47
if let Some(state) = find_key(body, CLOUD_RECORDING) {70
if let Some(current) = Self::newer_state(body, CLOUD_RECORDING, &mut self.sequence)48
let sequence = state["sequenceNumber"].as_u64().unwrap_or_default();71
&& current != self.active49
let current = state["value"]["State"].as_str().map(|name| name == ACTIVE);72
{50
if let Some(current) = current73
self.active = current;51
&& sequence >= self.sequence74
change.recording = Some(current);52
{75
}53
self.sequence = sequence;76
if let Some(current) = Self::newer_state(body, TRANSCRIPTION, &mut self.transcription_sequence)54
if current != self.active {77
&& current != self.transcribing55
self.active = current;78
{56
change.recording = Some(current);79
self.transcribing = current;57
}80
change.transcription = Some(current);58
}59
}81
}60
if let Some(required) = find_key(body, CONSENT_DETAILS).and_then(|details| details["consentActivelyRequired"].as_bool())82
if let Some(required) = find_key(body, CONSENT_DETAILS).and_then(|details| details["consentActivelyRequired"].as_bool())61
&& required != self.consent_required83
&& required != self.consent_required@@ -67,6 +89,45 @@ impl RecordingStatus {67
}89
}68
}90
}69
91
92
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]93
pub enum RecordingKind {94
#[default]95
Video,96
AudioOnly,97
TranscriptOnly,98
}99
100
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]101
pub enum StopScope {102
#[default]103
Both,104
RecordingOnly,105
TranscriptionOnly,106
}107
108
#[derive(Debug, Clone, Copy, PartialEq, Eq)]109
pub enum RecordingCommand {110
Start(RecordingKind),111
Stop(StopScope),112
}113
114
#[derive(Debug, Clone, Default)]115
pub struct RecordingPlan {116
pub title: String,117
pub kind: RecordingKind,118
pub scope: StopScope,119
}120
121
impl RecordingPlan {122
pub fn start(&self) -> RecordingCommand {123
RecordingCommand::Start(self.kind)124
}125
126
pub fn stop(&self) -> RecordingCommand {127
RecordingCommand::Stop(self.scope)128
}129
}130
70
#[derive(Debug, Clone, Copy)]131
#[derive(Debug, Clone, Copy)]71
pub struct StartDetails<'a> {132
pub struct StartDetails<'a> {72
pub own_mri: &'a str,133
pub own_mri: &'a str,@@ -79,45 +140,65 @@ pub struct StartDetails<'a> {79
}140
}80
141
81
/// The skype token is added inside the page, so the body travels without it.142
/// The skype token is added inside the page, so the body travels without it.82
pub fn start_body(details: StartDetails<'_>) -> Value {143
pub fn start_body(kind: RecordingKind, details: StartDetails<'_>) -> Value {83
json!({144
let mut parameters = json!({145
"recordingFeatures": recorder_features(),146
"recordingStorageSettings": [{147
"StorageType": STORAGE_TYPE,148
"StorageLocation": STORAGE_LOCATION,149
"FileName": details.file_name,150
}],151
"correlationId": details.correlation_id,152
"meetingTitle": details.meeting_title,153
"exchangeId": null,154
"meetingOrganizer": details.organizer_name,155
"spokenLanguage": "",156
"type": "start",157
});158
let mut body = json!({84
"timestamp": details.timestamp,159
"timestamp": details.timestamp,85
"participantMri": details.own_mri,160
"participantMri": details.own_mri,86
"participantLegId": details.participant_leg_id,161
"participantLegId": details.participant_leg_id,87
"action": "start",162
"action": "start",88
"processingModes": PROCESSING_MODES,163
});89
"actionParameters": {164
match kind {90
"recordingFeatures": recorder_features(),165
RecordingKind::Video => parameters["recordingMode"] = json!(VIDEO_MODE),91
"recordingStorageSettings": [{166
RecordingKind::AudioOnly => parameters["recordingMode"] = json!(AUDIO_ONLY_MODE),92
"StorageType": STORAGE_TYPE,167
RecordingKind::TranscriptOnly => body["mode"] = json!(TRANSCRIPTION_MODE),93
"StorageLocation": STORAGE_LOCATION,168
}94
"FileName": details.file_name,169
body["processingModes"] = match kind {95
}],170
RecordingKind::TranscriptOnly => json!(TRANSCRIPT_ONLY),96
"correlationId": details.correlation_id,171
RecordingKind::Video | RecordingKind::AudioOnly => json!(RECORDING_AND_TRANSCRIPT),97
"meetingTitle": details.meeting_title,172
};98
"exchangeId": null,173
body["actionParameters"] = parameters;99
"meetingOrganizer": details.organizer_name,174
body100
"recordingMode": RECORDING_MODE,101
"spokenLanguage": "",102
"type": "start",103
},104
})105
}175
}106
176
107
pub fn stop_body(own_mri: &str, participant_leg_id: &str, timestamp: &str) -> Value {177
pub fn stop_body(scope: StopScope, own_mri: &str, participant_leg_id: &str, timestamp: &str) -> Value {108
json!({178
let mut body = json!({109
"timestamp": timestamp,179
"timestamp": timestamp,110
"participantMri": own_mri,180
"participantMri": own_mri,111
"participantLegId": participant_leg_id,181
"participantLegId": participant_leg_id,112
"action": "stop",182
"action": "stop",113
"processingModes": PROCESSING_MODES,183
});114
})184
match scope {185
StopScope::Both => body["processingModes"] = json!(RECORDING_AND_TRANSCRIPT),186
StopScope::RecordingOnly => {187
body["mode"] = json!(RECORDING_MODE_KEY);188
body["processingModes"] = json!(RECORDING_ONLY);189
}190
StopScope::TranscriptionOnly => {191
body["mode"] = json!(TRANSCRIPTION_MODE);192
body["processingModes"] = json!(TRANSCRIPT_ONLY);193
}194
}195
body115
}196
}116
197
117
pub fn command_body(action: BotAction, details: StartDetails<'_>) -> Value {198
pub fn command_body(command: RecordingCommand, details: StartDetails<'_>) -> Value {118
match action {199
match command {119
BotAction::Start => start_body(details),200
RecordingCommand::Start(kind) => start_body(kind, details),120
BotAction::Stop => stop_body(details.own_mri, details.participant_leg_id, details.timestamp),201
RecordingCommand::Stop(scope) => stop_body(scope, details.own_mri, details.participant_leg_id, details.timestamp),121
}202
}122
}203
}123
204
@@ -164,7 +245,7 @@ mod tests {164
#[test]245
#[test]165
fn the_recording_state_follows_the_meeting_state_and_ignores_stale_updates() {246
fn the_recording_state_follows_the_meeting_state_and_ignores_stale_updates() {166
let mut status = RecordingStatus::default();247
let mut status = RecordingStatus::default();167
assert_eq!(status.apply(&update("Active", 3)), StateChange { recording: Some(true), consent_required: None });248
assert_eq!(status.apply(&update("Active", 3)), StateChange { recording: Some(true), transcription: Some(true), consent_required: None });168
assert!(status.active());249
assert!(status.active());169
assert!(status.apply(&update("Active", 3)).is_empty());250
assert!(status.apply(&update("Active", 3)).is_empty());170
assert!(status.apply(&update("Inactive", 2)).is_empty());251
assert!(status.apply(&update("Inactive", 2)).is_empty());@@ -173,6 +254,18 @@ mod tests {173
assert!(!status.active());254
assert!(!status.active());174
}255
}175
256
257
#[test]258
fn transcription_runs_on_its_own_state_and_sequence() {259
let mut status = RecordingStatus::default();260
let transcript_only = json!({"meetingStates": {"transcription": {"value": {"State": "Active"}, "sequenceNumber": 2}}});261
assert_eq!(status.apply(&transcript_only), StateChange { recording: None, transcription: Some(true), consent_required: None });262
assert!(status.transcribing() && !status.active());263
let stale = json!({"meetingStates": {"transcription": {"value": {"State": "Inactive"}, "sequenceNumber": 1}}});264
assert!(status.apply(&stale).is_empty());265
let stopped = json!({"meetingStates": {"transcription": {"value": {"State": "Inactive"}, "sequenceNumber": 3}}});266
assert_eq!(status.apply(&stopped).transcription, Some(false));267
}268
176
#[test]269
#[test]177
fn unrelated_updates_change_nothing() {270
fn unrelated_updates_change_nothing() {178
let mut status = RecordingStatus::default();271
let mut status = RecordingStatus::default();@@ -184,7 +277,7 @@ mod tests {184
fn consent_is_required_when_the_meeting_says_so() {277
fn consent_is_required_when_the_meeting_says_so() {185
let mut status = RecordingStatus::default();278
let mut status = RecordingStatus::default();186
assert!(status.apply(&consent(false)).is_empty());279
assert!(status.apply(&consent(false)).is_empty());187
assert_eq!(status.apply(&consent(true)), StateChange { recording: None, consent_required: Some(true) });280
assert_eq!(status.apply(&consent(true)), StateChange { recording: None, transcription: None, consent_required: Some(true) });188
assert!(status.consent_required());281
assert!(status.consent_required());189
assert!(status.apply(&consent(true)).is_empty());282
assert!(status.apply(&consent(true)).is_empty());190
assert_eq!(status.apply(&consent(false)).consent_required, Some(false));283
assert_eq!(status.apply(&consent(false)).consent_required, Some(false));@@ -195,7 +288,7 @@ mod tests {195
let mut both = update("Active", 1);288
let mut both = update("Active", 1);196
both["meetingDetails"] = consent(true)["meetingDetails"].clone();289
both["meetingDetails"] = consent(true)["meetingDetails"].clone();197
let change = RecordingStatus::default().apply(&both);290
let change = RecordingStatus::default().apply(&both);198
assert_eq!(change, StateChange { recording: Some(true), consent_required: Some(true) });291
assert_eq!(change, StateChange { recording: Some(true), transcription: Some(true), consent_required: Some(true) });199
}292
}200
293
201
fn details() -> StartDetails<'static> {294
fn details() -> StartDetails<'static> {@@ -211,8 +304,8 @@ mod tests {211
}304
}212
305
213
#[test]306
#[test]214
fn the_start_command_records_to_onedrive_without_a_mode_key() {307
fn the_start_command_records_video_to_onedrive_without_a_mode_key() {215
let body = command_body(BotAction::Start, details());308
let body = command_body(RecordingCommand::Start(RecordingKind::Video), details());216
assert_eq!(body["action"], "start");309
assert_eq!(body["action"], "start");217
assert_eq!(body["processingModes"], json!(["recording", "realTimeTranscript"]));310
assert_eq!(body["processingModes"], json!(["recording", "realTimeTranscript"]));218
assert!(body.get("mode").is_none());311
assert!(body.get("mode").is_none());@@ -228,12 +321,47 @@ mod tests {228
}321
}229
322
230
#[test]323
#[test]231
fn the_stop_command_is_short() {324
fn audio_only_differs_from_video_in_the_recording_mode_alone() {232
let body = command_body(BotAction::Stop, details());325
let video = start_body(RecordingKind::Video, details());233
assert_eq!(body["action"], "stop");326
let mut audio = start_body(RecordingKind::AudioOnly, details());234
assert_eq!(body["processingModes"], json!(["recording", "realTimeTranscript"]));327
assert_eq!(audio["actionParameters"]["recordingMode"], "AudioOnly");235
assert!(body.get("actionParameters").is_none());328
audio["actionParameters"]["recordingMode"] = video["actionParameters"]["recordingMode"].clone();236
assert_eq!(body["timestamp"], "2026-10-10T08:44:12.705Z");329
assert_eq!(audio, video);330
}331
332
#[test]333
fn transcription_only_has_a_mode_one_processing_mode_and_no_recording_mode() {334
let body = start_body(RecordingKind::TranscriptOnly, details());335
assert_eq!(body["action"], "start");336
assert_eq!(body["mode"], "transcription");337
assert_eq!(body["processingModes"], json!(["realTimeTranscript"]));338
assert!(body["actionParameters"].get("recordingMode").is_none());339
assert_eq!(body["actionParameters"]["type"], "start");340
assert_eq!(body["actionParameters"]["meetingTitle"], "Standup");341
}342
343
#[test]344
fn the_three_stop_variants_match_the_capture() {345
let stop = |scope| command_body(RecordingCommand::Stop(scope), details());346
let both = stop(StopScope::Both);347
assert_eq!(both["action"], "stop");348
assert_eq!(both["processingModes"], json!(["recording", "realTimeTranscript"]));349
assert!(both.get("mode").is_none());350
assert!(both.get("actionParameters").is_none());351
assert_eq!(both["timestamp"], "2026-10-10T08:44:12.705Z");352
let recording = stop(StopScope::RecordingOnly);353
assert_eq!(recording["mode"], "recording");354
assert_eq!(recording["processingModes"], json!(["recording"]));355
let transcription = stop(StopScope::TranscriptionOnly);356
assert_eq!(transcription["mode"], "transcription");357
assert_eq!(transcription["processingModes"], json!(["realTimeTranscript"]));358
}359
360
#[test]361
fn a_plan_names_its_start_and_stop_commands() {362
let plan = RecordingPlan { title: "Standup".into(), kind: RecordingKind::AudioOnly, scope: StopScope::RecordingOnly };363
assert_eq!(plan.start(), RecordingCommand::Start(RecordingKind::AudioOnly));364
assert_eq!(plan.stop(), RecordingCommand::Stop(StopScope::RecordingOnly));237
}365
}238
366
239
#[test]367
#[test]@@ -25,6 +25,7 @@ pub struct CaptionBot {
25
25
pub command_url: Option<String>,
26
26
pub active: bool,
27
27
pub recording: bool,
28
pub audio_only: bool,
28
29
}
29
30
30
31
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -224,7 +225,8 @@ fn caption_bot(mri: &str, endpoints: &[&Value]) -> Option<CaptionBot> {
224
225
let known = command_url.is_some() || metadata.iter().any(|metadata| metadata["processingModes"].is_object());
225
226
let active = metadata.iter().any(|metadata| metadata["processingModes"]["closedCaptions"]["state"].as_str() == Some("Active"));
226
227
let recording = metadata.iter().any(|metadata| metadata["processingModes"]["recording"]["state"].as_str() == Some("Active"));
227
known.then(|| CaptionBot { mri: mri.to_owned(), command_url, active, recording })
228
let audio_only = metadata.iter().any(|metadata| metadata["processingModes"]["recording"]["properties"]["recordVideo"].as_str() == Some("False"));
229
known.then(|| CaptionBot { mri: mri.to_owned(), command_url, active, recording, audio_only })
228
230
}
229
231
230
232
fn published_state(participant: &Value, endpoints: &[&Value], state_type: &str) -> Option<PublishedState> {
@@ -543,6 +545,18 @@ mod tests {
543
545
assert_eq!(roster.caption_bot(), None);
544
546
}
545
547
548
#[test]
549
fn an_audio_only_recording_shows_in_the_bot_properties() {
550
let mut bot = recorder_bot(1, false);
551
bot["endpoints"]["ep"]["endpointMetadata"]["processingModes"]["recording"] = json!({"state": "Active", "properties": {"recordVideo": "False", "exportFormatType": "Mp4"}});
552
let mut roster = Roster::default();
553
roster.apply(&delta(json!({"28:bot": bot})));
554
let found = roster.caption_bot().unwrap();
555
assert!(found.recording && found.audio_only);
556
roster.apply(&delta(json!({"28:bot": recorder_bot(2, false)})));
557
assert!(!roster.caption_bot().unwrap().audio_only);
558
}
559
546
560
#[test]
547
561
fn caption_speakers_resolve_by_mri_or_object_id() {
548
562
let mut roster = Roster::default();
@@ -25,6 +25,7 @@ pub struct CaptionBot {25
pub command_url: Option<String>,25
pub command_url: Option<String>,26
pub active: bool,26
pub active: bool,27
pub recording: bool,27
pub recording: bool,28
pub audio_only: bool,28
}29
}29
30
30
#[derive(Debug, Clone, PartialEq, Eq)]31
#[derive(Debug, Clone, PartialEq, Eq)]@@ -224,7 +225,8 @@ fn caption_bot(mri: &str, endpoints: &[&Value]) -> Option<CaptionBot> {224
let known = command_url.is_some() || metadata.iter().any(|metadata| metadata["processingModes"].is_object());225
let known = command_url.is_some() || metadata.iter().any(|metadata| metadata["processingModes"].is_object());225
let active = metadata.iter().any(|metadata| metadata["processingModes"]["closedCaptions"]["state"].as_str() == Some("Active"));226
let active = metadata.iter().any(|metadata| metadata["processingModes"]["closedCaptions"]["state"].as_str() == Some("Active"));226
let recording = metadata.iter().any(|metadata| metadata["processingModes"]["recording"]["state"].as_str() == Some("Active"));227
let recording = metadata.iter().any(|metadata| metadata["processingModes"]["recording"]["state"].as_str() == Some("Active"));227
known.then(|| CaptionBot { mri: mri.to_owned(), command_url, active, recording })228
let audio_only = metadata.iter().any(|metadata| metadata["processingModes"]["recording"]["properties"]["recordVideo"].as_str() == Some("False"));229
known.then(|| CaptionBot { mri: mri.to_owned(), command_url, active, recording, audio_only })228
}230
}229
231
230
fn published_state(participant: &Value, endpoints: &[&Value], state_type: &str) -> Option<PublishedState> {232
fn published_state(participant: &Value, endpoints: &[&Value], state_type: &str) -> Option<PublishedState> {@@ -543,6 +545,18 @@ mod tests {543
assert_eq!(roster.caption_bot(), None);545
assert_eq!(roster.caption_bot(), None);544
}546
}545
547
548
#[test]549
fn an_audio_only_recording_shows_in_the_bot_properties() {550
let mut bot = recorder_bot(1, false);551
bot["endpoints"]["ep"]["endpointMetadata"]["processingModes"]["recording"] = json!({"state": "Active", "properties": {"recordVideo": "False", "exportFormatType": "Mp4"}});552
let mut roster = Roster::default();553
roster.apply(&delta(json!({"28:bot": bot})));554
let found = roster.caption_bot().unwrap();555
assert!(found.recording && found.audio_only);556
roster.apply(&delta(json!({"28:bot": recorder_bot(2, false)})));557
assert!(!roster.caption_bot().unwrap().audio_only);558
}559
546
#[test]560
#[test]547
fn caption_speakers_resolve_by_mri_or_object_id() {561
fn caption_speakers_resolve_by_mri_or_object_id() {548
let mut roster = Roster::default();562
let mut roster = Roster::default();@@ -4,7 +4,7 @@ use serde_json::{Map, Value, json};
4
4
use session::{ApiResponse, App, GRAPH, Method, Request, SPACES, Scope, Session};
5
5
6
6
use crate::captions::{self, BotAction};
7
use crate::recording::{self, Consent, StartDetails};
7
use crate::recording::{self, Consent, RecordingCommand, StartDetails};
8
8
use crate::transfer::{self, TransferTarget};
9
9
use crate::error::{Error, Result};
10
10
use crate::organizer::{self, Target};
@@ -469,6 +469,13 @@ impl Signaling {
469
469
self.bot_command(command_url, body, "caption command").await.map(|_| ())
470
470
}
471
471
472
pub async fn caption_language_command(&self, command_url: &str, from: &Participant, language_tag: &str) -> Result<()> {
473
ensure_teams_url(command_url)?;
474
let timestamp = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Millis, true);
475
let body = captions::language_body(&from.mri, &from.participant_id, ×tamp, language_tag);
476
self.bot_command(command_url, body, "caption language command").await.map(|_| ())
477
}
478
472
479
async fn bot_command(&self, command_url: &str, body: Value, label: &str) -> Result<u16> {
473
480
let arguments = json!({
474
481
"url": command_url,
@@ -488,7 +495,7 @@ impl Signaling {
488
495
Err(Error::Signaling(format!("{label} answered HTTP {status} {reason}")))
489
496
}
490
497
491
pub async fn recording_command(&self, command_url: &str, action: BotAction, from: &Participant, title: &str) -> Result<u16> {
498
pub async fn recording_command(&self, command_url: &str, command: RecordingCommand, from: &Participant, title: &str) -> Result<u16> {
492
499
ensure_teams_url(command_url)?;
493
500
let now = chrono::Utc::now();
494
501
let timestamp = now.to_rfc3339_opts(chrono::SecondsFormat::Millis, true);
@@ -503,7 +510,7 @@ impl Signaling {
503
510
organizer_name: &from.display_name,
504
511
correlation_id: &correlation_id,
505
512
};
506
self.bot_command(command_url, recording::command_body(action, details), "recording command").await
513
self.bot_command(command_url, recording::command_body(command, details), "recording command").await
507
514
}
508
515
509
516
pub async fn consent_to_recording(&self, conversation: &Conversation, from: &Participant, consent: Consent) -> Result<u16> {
@@ -4,7 +4,7 @@ use serde_json::{Map, Value, json};4
use session::{ApiResponse, App, GRAPH, Method, Request, SPACES, Scope, Session};4
use session::{ApiResponse, App, GRAPH, Method, Request, SPACES, Scope, Session};5
5
6
use crate::captions::{self, BotAction};6
use crate::captions::{self, BotAction};7
use crate::recording::{self, Consent, StartDetails};7
use crate::recording::{self, Consent, RecordingCommand, StartDetails};8
use crate::transfer::{self, TransferTarget};8
use crate::transfer::{self, TransferTarget};9
use crate::error::{Error, Result};9
use crate::error::{Error, Result};10
use crate::organizer::{self, Target};10
use crate::organizer::{self, Target};@@ -469,6 +469,13 @@ impl Signaling {469
self.bot_command(command_url, body, "caption command").await.map(|_| ())469
self.bot_command(command_url, body, "caption command").await.map(|_| ())470
}470
}471
471
472
pub async fn caption_language_command(&self, command_url: &str, from: &Participant, language_tag: &str) -> Result<()> {473
ensure_teams_url(command_url)?;474
let timestamp = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Millis, true);475
let body = captions::language_body(&from.mri, &from.participant_id, ×tamp, language_tag);476
self.bot_command(command_url, body, "caption language command").await.map(|_| ())477
}478
472
async fn bot_command(&self, command_url: &str, body: Value, label: &str) -> Result<u16> {479
async fn bot_command(&self, command_url: &str, body: Value, label: &str) -> Result<u16> {473
let arguments = json!({480
let arguments = json!({474
"url": command_url,481
"url": command_url,@@ -488,7 +495,7 @@ impl Signaling {488
Err(Error::Signaling(format!("{label} answered HTTP {status} {reason}")))495
Err(Error::Signaling(format!("{label} answered HTTP {status} {reason}")))489
}496
}490
497
491
pub async fn recording_command(&self, command_url: &str, action: BotAction, from: &Participant, title: &str) -> Result<u16> {498
pub async fn recording_command(&self, command_url: &str, command: RecordingCommand, from: &Participant, title: &str) -> Result<u16> {492
ensure_teams_url(command_url)?;499
ensure_teams_url(command_url)?;493
let now = chrono::Utc::now();500
let now = chrono::Utc::now();494
let timestamp = now.to_rfc3339_opts(chrono::SecondsFormat::Millis, true);501
let timestamp = now.to_rfc3339_opts(chrono::SecondsFormat::Millis, true);@@ -503,7 +510,7 @@ impl Signaling {503
organizer_name: &from.display_name,510
organizer_name: &from.display_name,504
correlation_id: &correlation_id,511
correlation_id: &correlation_id,505
};512
};506
self.bot_command(command_url, recording::command_body(action, details), "recording command").await513
self.bot_command(command_url, recording::command_body(command, details), "recording command").await507
}514
}508
515
509
pub async fn consent_to_recording(&self, conversation: &Conversation, from: &Participant, consent: Consent) -> Result<u16> {516
pub async fn consent_to_recording(&self, conversation: &Conversation, from: &Participant, consent: Consent) -> Result<u16> {