BlueGit

ict rusty-teams

merge: recording modes, transcript panel, caption settings

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

metis Daniel Däschle · pushed by metis

Authored 2026-10-13 · 7 weeks ago

Hash
cac160c6b2bd0b54ba240a815fb9aaa704647939
27 files changed +1452 −152
ROADMAP.md +2 −2
@@ -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 |
crates/app/src/app_state.rs +2 −0
@@ -139,6 +139,7 @@ pub struct AppState {
139 139 pub demo_meetings: Vec<chatsvc::CalendarEvent>,
140 140 pub call_backgrounds: crate::call::BackgroundLibrary,
141 141 pub transfer_picker: Option<Entity<crate::views::transfer_picker::TransferPicker>>,
142 pub transcript_panel: Option<Entity<crate::views::call_transcript::TranscriptPanel>>,
142 143 pub rings: Rings,
143 144 pub live_meetings: HashMap<String, LiveMeeting>,
144 145 pub live_refreshing: HashSet<String>,
@@ -249,6 +250,7 @@ impl AppState {
249 250 crate::call::BackgroundLibrary::new(crate::call::default_cache_directory())
250 251 },
251 252 transfer_picker: None,
253 transcript_panel: None,
252 254 rings: Rings::default(),
253 255 live_meetings: HashMap::new(),
254 256 live_refreshing: HashSet::new(),
@@ -139,6 +139,7 @@ pub struct AppState {
139 pub demo_meetings: Vec<chatsvc::CalendarEvent>,
139 pub demo_meetings: Vec<chatsvc::CalendarEvent>,
140 pub call_backgrounds: crate::call::BackgroundLibrary,
140 pub call_backgrounds: crate::call::BackgroundLibrary,
141 pub transfer_picker: Option<Entity<crate::views::transfer_picker::TransferPicker>>,
141 pub transfer_picker: Option<Entity<crate::views::transfer_picker::TransferPicker>>,
142 pub transcript_panel: Option<Entity<crate::views::call_transcript::TranscriptPanel>>,
142 pub rings: Rings,
143 pub rings: Rings,
143 pub live_meetings: HashMap<String, LiveMeeting>,
144 pub live_meetings: HashMap<String, LiveMeeting>,
144 pub live_refreshing: HashSet<String>,
145 pub live_refreshing: HashSet<String>,
@@ -249,6 +250,7 @@ impl AppState {
249 crate::call::BackgroundLibrary::new(crate::call::default_cache_directory())
250 crate::call::BackgroundLibrary::new(crate::call::default_cache_directory())
250 },
251 },
251 transfer_picker: None,
252 transfer_picker: None,
253 transcript_panel: None,
252 rings: Rings::default(),
254 rings: Rings::default(),
253 live_meetings: HashMap::new(),
255 live_meetings: HashMap::new(),
254 live_refreshing: HashSet::new(),
256 live_refreshing: HashSet::new(),
crates/app/src/call/actions.rs +107 −9
@@ -349,6 +349,9 @@ impl AppState {
349 349 crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);
350 350 }
351 351 call.model.apply(update);
352 if let Some(language) = call.model.take_ready_caption_language() {
353 let _ = call.commands.send(CallCommand::SetCaptionLanguage(language));
354 }
352 355 if call.model.screen_sharer.is_none() {
353 356 call.stage_fullscreen = false;
354 357 call.pictures.forget(&VideoKey::Screen, cx);
@@ -373,6 +376,7 @@ impl AppState {
373 376 crate::agent_api::clear_captions(thread, cx);
374 377 }
375 378 self.call = None;
379 self.transcript_panel = None;
376 380 if let Some(consult) = consult {
377 381 let _ = consult.commands.send(CallCommand::Hangup);
378 382 }
@@ -515,6 +519,10 @@ impl AppState {
515 519 return;
516 520 };
517 521 call.chat_open = !call.chat_open;
522 if call.chat_open {
523 call.transcript_open = false;
524 self.transcript_panel = None;
525 }
518 526 cx.emit(AppEvent::Call);
519 527 cx.notify();
520 528 }
@@ -1128,7 +1136,8 @@ mod tests {
1128 1136
1129 1137 use calling::{
1130 1138 BackgroundChoice, CallCommand, CallControl, CallState, CallUpdate, CameraEffects,
1131 DeviceChoice, EndKind, EndReason, EngineEvent, HoldState, Reaction, call_channel,
1139 DeviceChoice, EndKind, EndReason, EngineEvent, HoldState, Reaction, RecordingKind,
1140 StopScope, call_channel,
1132 1141 };
1133 1142 use gpui_kit::{AppContext as _, Entity, TestAppContext};
1134 1143 use store::{ChatRecord, MemberRecord, Store};
@@ -1137,6 +1146,7 @@ mod tests {
1137 1146 use crate::app_state::{AppEvent, AppState, Mode, Selection};
1138 1147 use crate::call::TransferCandidate;
1139 1148 use crate::call::background::BackgroundPick;
1149 use crate::call::{CaptionPosition, CaptionSize, RecordAction, ViewSettings};
1140 1150 use crate::call::demo::demo_ring;
1141 1151 use crate::call::features::room_closed_move;
1142 1152 use crate::call::model::{BreakoutState, ConsultCall};
@@ -1568,7 +1578,7 @@ mod tests {
1568 1578 let (attendee, mut attendee_control) = app_with_commands(cx, live_meeting(false), None);
1569 1579 cx.update(|cx| {
1570 1580 attendee.update(cx, |state, cx| {
1571 state.set_call_recording(true, cx);
1581 state.run_call_record_action(RecordAction::Start(RecordingKind::Video), cx);
1572 1582 state.accept_recording_notice(cx);
1573 1583 })
1574 1584 });
@@ -1576,9 +1586,9 @@ mod tests {
1576 1586 let (organizer, mut control) = app_with_commands(cx, live_meeting(true), None);
1577 1587 cx.update(|cx| {
1578 1588 organizer.update(cx, |state, cx| {
1579 state.set_call_recording(true, cx);
1589 state.run_call_record_action(RecordAction::Start(RecordingKind::Video), cx);
1580 1590 state.apply_call_update(7, CallUpdate::Recording(true), cx);
1581 state.set_call_recording(false, cx);
1591 state.run_call_record_action(RecordAction::Stop(StopScope::Both), cx);
1582 1592 state.accept_recording_notice(cx);
1583 1593 state.apply_call_update(7, CallUpdate::ConsentRequired(true), cx);
1584 1594 state.accept_recording_notice(cx);
@@ -1586,16 +1596,15 @@ mod tests {
1586 1596 });
1587 1597 assert_eq!(
1588 1598 control.try_recv_command(),
1589 Some(CallCommand::SetRecording {
1590 on: true,
1599 Some(CallCommand::StartRecording {
1600 kind: RecordingKind::Video,
1591 1601 title: "Standup".into()
1592 1602 })
1593 1603 );
1594 1604 assert_eq!(
1595 1605 control.try_recv_command(),
1596 Some(CallCommand::SetRecording {
1597 on: false,
1598 title: "Standup".into()
1606 Some(CallCommand::StopRecording {
1607 scope: StopScope::Both
1599 1608 })
1600 1609 );
1601 1610 assert_eq!(
@@ -1605,6 +1614,95 @@ mod tests {
1605 1614 assert_eq!(control.try_recv_command(), None);
1606 1615 }
1607 1616
1617 #[gpui_kit::test]
1618 fn every_record_action_becomes_its_own_command_for_the_organizer(cx: &mut TestAppContext) {
1619 let (organizer, mut control) = app_with_commands(cx, live_meeting(true), None);
1620 cx.update(|cx| {
1621 organizer.update(cx, |state, cx| {
1622 state.run_call_record_action(RecordAction::Start(RecordingKind::AudioOnly), cx);
1623 state.run_call_record_action(RecordAction::Start(RecordingKind::TranscriptOnly), cx);
1624 state.run_call_record_action(RecordAction::Stop(StopScope::RecordingOnly), cx);
1625 state.run_call_record_action(RecordAction::Stop(StopScope::TranscriptionOnly), cx);
1626 })
1627 });
1628 let title = "Standup".to_owned();
1629 assert_eq!(control.try_recv_command(), Some(CallCommand::StartRecording { kind: RecordingKind::AudioOnly, title: title.clone() }));
1630 assert_eq!(control.try_recv_command(), Some(CallCommand::StartRecording { kind: RecordingKind::TranscriptOnly, title }));
1631 assert_eq!(control.try_recv_command(), Some(CallCommand::StopRecording { scope: StopScope::RecordingOnly }));
1632 assert_eq!(control.try_recv_command(), Some(CallCommand::StopRecording { scope: StopScope::TranscriptionOnly }));
1633 assert_eq!(control.try_recv_command(), None);
1634 }
1635
1636 #[gpui_kit::test]
1637 fn the_transcript_turns_captions_on_and_excludes_the_chat_panel(cx: &mut TestAppContext) {
1638 let (app, mut control) = app_with_commands(cx, live_meeting(false), None);
1639 cx.update(|cx| {
1640 app.update(cx, |state, cx| {
1641 state.apply_call_update(7, CallUpdate::MeetingChat("19:meeting_x@thread.v2".into()), cx);
1642 state.toggle_call_chat(cx);
1643 state.show_call_transcript(cx);
1644 })
1645 });
1646 let (chat_open, transcript_open) = cx.update(|cx| {
1647 let call = app.read(cx).call.as_ref().unwrap();
1648 (call.chat_open, call.transcript_open)
1649 });
1650 assert!(!chat_open && transcript_open);
1651 assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptions(true)));
1652 cx.update(|cx| {
1653 app.update(cx, |state, cx| {
1654 state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::On), cx);
1655 state.show_call_transcript(cx);
1656 state.toggle_call_chat(cx);
1657 })
1658 });
1659 let (chat_open, transcript_open) = cx.update(|cx| {
1660 let call = app.read(cx).call.as_ref().unwrap();
1661 (call.chat_open, call.transcript_open)
1662 });
1663 assert!(chat_open && !transcript_open);
1664 assert_eq!(control.try_recv_command(), None);
1665 }
1666
1667 #[gpui_kit::test]
1668 fn a_spoken_language_picked_while_captions_are_off_is_sent_once_they_are_on(cx: &mut TestAppContext) {
1669 let (app, mut control) = app_with_commands(cx, live_meeting(false), None);
1670 cx.update(|cx| {
1671 app.update(cx, |state, cx| {
1672 state.choose_call_caption_language("de-DE", cx);
1673 state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::Starting), cx);
1674 })
1675 });
1676 assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptions(true)));
1677 assert_eq!(control.try_recv_command(), None);
1678 cx.update(|cx| {
1679 app.update(cx, |state, cx| {
1680 state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::On), cx);
1681 state.choose_call_caption_language("fr-FR", cx);
1682 })
1683 });
1684 assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptionLanguage("de-DE".into())));
1685 assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptionLanguage("fr-FR".into())));
1686 assert_eq!(control.try_recv_command(), None);
1687 }
1688
1689 #[gpui_kit::test]
1690 fn caption_size_and_position_are_stored_and_reach_the_call_model(cx: &mut TestAppContext) {
1691 let (app, _control) = app_with_commands(cx, live_meeting(false), None);
1692 cx.update(|cx| {
1693 app.update(cx, |state, cx| {
1694 state.set_call_caption_size(CaptionSize::Large, cx);
1695 state.set_call_caption_position(CaptionPosition::Top, cx);
1696 })
1697 });
1698 let (view, stored) = cx.update(|cx| {
1699 let state = app.read(cx);
1700 (state.call.as_ref().unwrap().model.view, ViewSettings::load(&state.store))
1701 });
1702 assert_eq!((view.caption_size, view.caption_position), (CaptionSize::Large, CaptionPosition::Top));
1703 assert_eq!((stored.caption_size, stored.caption_position), (CaptionSize::Large, CaptionPosition::Top));
1704 }
1705
1608 1706 fn live_one_to_one() -> CallModel {
1609 1707 let mut model = CallModel::people("Bea", &[("8:orgid:bea".into(), "Bea".into())]);
1610 1708 model.apply(CallUpdate::State(CallState::Connected {
@@ -349,6 +349,9 @@ impl AppState {
349 crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);
349 crate::agent_api::note_caption(thread, &entry.id, speaker, &entry.text, cx);
350 }
350 }
351 call.model.apply(update);
351 call.model.apply(update);
352 if let Some(language) = call.model.take_ready_caption_language() {
353 let _ = call.commands.send(CallCommand::SetCaptionLanguage(language));
354 }
352 if call.model.screen_sharer.is_none() {
355 if call.model.screen_sharer.is_none() {
353 call.stage_fullscreen = false;
356 call.stage_fullscreen = false;
354 call.pictures.forget(&VideoKey::Screen, cx);
357 call.pictures.forget(&VideoKey::Screen, cx);
@@ -373,6 +376,7 @@ impl AppState {
373 crate::agent_api::clear_captions(thread, cx);
376 crate::agent_api::clear_captions(thread, cx);
374 }
377 }
375 self.call = None;
378 self.call = None;
379 self.transcript_panel = None;
376 if let Some(consult) = consult {
380 if let Some(consult) = consult {
377 let _ = consult.commands.send(CallCommand::Hangup);
381 let _ = consult.commands.send(CallCommand::Hangup);
378 }
382 }
@@ -515,6 +519,10 @@ impl AppState {
515 return;
519 return;
516 };
520 };
517 call.chat_open = !call.chat_open;
521 call.chat_open = !call.chat_open;
522 if call.chat_open {
523 call.transcript_open = false;
524 self.transcript_panel = None;
525 }
518 cx.emit(AppEvent::Call);
526 cx.emit(AppEvent::Call);
519 cx.notify();
527 cx.notify();
520 }
528 }
@@ -1128,7 +1136,8 @@ mod tests {
1128
1136
1129 use calling::{
1137 use calling::{
1130 BackgroundChoice, CallCommand, CallControl, CallState, CallUpdate, CameraEffects,
1138 BackgroundChoice, CallCommand, CallControl, CallState, CallUpdate, CameraEffects,
1131 DeviceChoice, EndKind, EndReason, EngineEvent, HoldState, Reaction, call_channel,
1139 DeviceChoice, EndKind, EndReason, EngineEvent, HoldState, Reaction, RecordingKind,
1140 StopScope, call_channel,
1132 };
1141 };
1133 use gpui_kit::{AppContext as _, Entity, TestAppContext};
1142 use gpui_kit::{AppContext as _, Entity, TestAppContext};
1134 use store::{ChatRecord, MemberRecord, Store};
1143 use store::{ChatRecord, MemberRecord, Store};
@@ -1137,6 +1146,7 @@ mod tests {
1137 use crate::app_state::{AppEvent, AppState, Mode, Selection};
1146 use crate::app_state::{AppEvent, AppState, Mode, Selection};
1138 use crate::call::TransferCandidate;
1147 use crate::call::TransferCandidate;
1139 use crate::call::background::BackgroundPick;
1148 use crate::call::background::BackgroundPick;
1149 use crate::call::{CaptionPosition, CaptionSize, RecordAction, ViewSettings};
1140 use crate::call::demo::demo_ring;
1150 use crate::call::demo::demo_ring;
1141 use crate::call::features::room_closed_move;
1151 use crate::call::features::room_closed_move;
1142 use crate::call::model::{BreakoutState, ConsultCall};
1152 use crate::call::model::{BreakoutState, ConsultCall};
@@ -1568,7 +1578,7 @@ mod tests {
1568 let (attendee, mut attendee_control) = app_with_commands(cx, live_meeting(false), None);
1578 let (attendee, mut attendee_control) = app_with_commands(cx, live_meeting(false), None);
1569 cx.update(|cx| {
1579 cx.update(|cx| {
1570 attendee.update(cx, |state, cx| {
1580 attendee.update(cx, |state, cx| {
1571 state.set_call_recording(true, cx);
1581 state.run_call_record_action(RecordAction::Start(RecordingKind::Video), cx);
1572 state.accept_recording_notice(cx);
1582 state.accept_recording_notice(cx);
1573 })
1583 })
1574 });
1584 });
@@ -1576,9 +1586,9 @@ mod tests {
1576 let (organizer, mut control) = app_with_commands(cx, live_meeting(true), None);
1586 let (organizer, mut control) = app_with_commands(cx, live_meeting(true), None);
1577 cx.update(|cx| {
1587 cx.update(|cx| {
1578 organizer.update(cx, |state, cx| {
1588 organizer.update(cx, |state, cx| {
1579 state.set_call_recording(true, cx);
1589 state.run_call_record_action(RecordAction::Start(RecordingKind::Video), cx);
1580 state.apply_call_update(7, CallUpdate::Recording(true), cx);
1590 state.apply_call_update(7, CallUpdate::Recording(true), cx);
1581 state.set_call_recording(false, cx);
1591 state.run_call_record_action(RecordAction::Stop(StopScope::Both), cx);
1582 state.accept_recording_notice(cx);
1592 state.accept_recording_notice(cx);
1583 state.apply_call_update(7, CallUpdate::ConsentRequired(true), cx);
1593 state.apply_call_update(7, CallUpdate::ConsentRequired(true), cx);
1584 state.accept_recording_notice(cx);
1594 state.accept_recording_notice(cx);
@@ -1586,16 +1596,15 @@ mod tests {
1586 });
1596 });
1587 assert_eq!(
1597 assert_eq!(
1588 control.try_recv_command(),
1598 control.try_recv_command(),
1589 Some(CallCommand::SetRecording {
1599 Some(CallCommand::StartRecording {
1590 on: true,
1600 kind: RecordingKind::Video,
1591 title: "Standup".into()
1601 title: "Standup".into()
1592 })
1602 })
1593 );
1603 );
1594 assert_eq!(
1604 assert_eq!(
1595 control.try_recv_command(),
1605 control.try_recv_command(),
1596 Some(CallCommand::SetRecording {
1606 Some(CallCommand::StopRecording {
1597 on: false,
1607 scope: StopScope::Both
1598 title: "Standup".into()
1599 })
1608 })
1600 );
1609 );
1601 assert_eq!(
1610 assert_eq!(
@@ -1605,6 +1614,95 @@ mod tests {
1605 assert_eq!(control.try_recv_command(), None);
1614 assert_eq!(control.try_recv_command(), None);
1606 }
1615 }
1607
1616
1617 #[gpui_kit::test]
1618 fn every_record_action_becomes_its_own_command_for_the_organizer(cx: &mut TestAppContext) {
1619 let (organizer, mut control) = app_with_commands(cx, live_meeting(true), None);
1620 cx.update(|cx| {
1621 organizer.update(cx, |state, cx| {
1622 state.run_call_record_action(RecordAction::Start(RecordingKind::AudioOnly), cx);
1623 state.run_call_record_action(RecordAction::Start(RecordingKind::TranscriptOnly), cx);
1624 state.run_call_record_action(RecordAction::Stop(StopScope::RecordingOnly), cx);
1625 state.run_call_record_action(RecordAction::Stop(StopScope::TranscriptionOnly), cx);
1626 })
1627 });
1628 let title = "Standup".to_owned();
1629 assert_eq!(control.try_recv_command(), Some(CallCommand::StartRecording { kind: RecordingKind::AudioOnly, title: title.clone() }));
1630 assert_eq!(control.try_recv_command(), Some(CallCommand::StartRecording { kind: RecordingKind::TranscriptOnly, title }));
1631 assert_eq!(control.try_recv_command(), Some(CallCommand::StopRecording { scope: StopScope::RecordingOnly }));
1632 assert_eq!(control.try_recv_command(), Some(CallCommand::StopRecording { scope: StopScope::TranscriptionOnly }));
1633 assert_eq!(control.try_recv_command(), None);
1634 }
1635
1636 #[gpui_kit::test]
1637 fn the_transcript_turns_captions_on_and_excludes_the_chat_panel(cx: &mut TestAppContext) {
1638 let (app, mut control) = app_with_commands(cx, live_meeting(false), None);
1639 cx.update(|cx| {
1640 app.update(cx, |state, cx| {
1641 state.apply_call_update(7, CallUpdate::MeetingChat("19:meeting_x@thread.v2".into()), cx);
1642 state.toggle_call_chat(cx);
1643 state.show_call_transcript(cx);
1644 })
1645 });
1646 let (chat_open, transcript_open) = cx.update(|cx| {
1647 let call = app.read(cx).call.as_ref().unwrap();
1648 (call.chat_open, call.transcript_open)
1649 });
1650 assert!(!chat_open && transcript_open);
1651 assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptions(true)));
1652 cx.update(|cx| {
1653 app.update(cx, |state, cx| {
1654 state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::On), cx);
1655 state.show_call_transcript(cx);
1656 state.toggle_call_chat(cx);
1657 })
1658 });
1659 let (chat_open, transcript_open) = cx.update(|cx| {
1660 let call = app.read(cx).call.as_ref().unwrap();
1661 (call.chat_open, call.transcript_open)
1662 });
1663 assert!(chat_open && !transcript_open);
1664 assert_eq!(control.try_recv_command(), None);
1665 }
1666
1667 #[gpui_kit::test]
1668 fn a_spoken_language_picked_while_captions_are_off_is_sent_once_they_are_on(cx: &mut TestAppContext) {
1669 let (app, mut control) = app_with_commands(cx, live_meeting(false), None);
1670 cx.update(|cx| {
1671 app.update(cx, |state, cx| {
1672 state.choose_call_caption_language("de-DE", cx);
1673 state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::Starting), cx);
1674 })
1675 });
1676 assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptions(true)));
1677 assert_eq!(control.try_recv_command(), None);
1678 cx.update(|cx| {
1679 app.update(cx, |state, cx| {
1680 state.apply_call_update(7, CallUpdate::Captions(calling::CaptionState::On), cx);
1681 state.choose_call_caption_language("fr-FR", cx);
1682 })
1683 });
1684 assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptionLanguage("de-DE".into())));
1685 assert_eq!(control.try_recv_command(), Some(CallCommand::SetCaptionLanguage("fr-FR".into())));
1686 assert_eq!(control.try_recv_command(), None);
1687 }
1688
1689 #[gpui_kit::test]
1690 fn caption_size_and_position_are_stored_and_reach_the_call_model(cx: &mut TestAppContext) {
1691 let (app, _control) = app_with_commands(cx, live_meeting(false), None);
1692 cx.update(|cx| {
1693 app.update(cx, |state, cx| {
1694 state.set_call_caption_size(CaptionSize::Large, cx);
1695 state.set_call_caption_position(CaptionPosition::Top, cx);
1696 })
1697 });
1698 let (view, stored) = cx.update(|cx| {
1699 let state = app.read(cx);
1700 (state.call.as_ref().unwrap().model.view, ViewSettings::load(&state.store))
1701 });
1702 assert_eq!((view.caption_size, view.caption_position), (CaptionSize::Large, CaptionPosition::Top));
1703 assert_eq!((stored.caption_size, stored.caption_position), (CaptionSize::Large, CaptionPosition::Top));
1704 }
1705
1608 fn live_one_to_one() -> CallModel {
1706 fn live_one_to_one() -> CallModel {
1609 let mut model = CallModel::people("Bea", &[("8:orgid:bea".into(), "Bea".into())]);
1707 let mut model = CallModel::people("Bea", &[("8:orgid:bea".into(), "Bea".into())]);
1610 model.apply(CallUpdate::State(CallState::Connected {
1708 model.apply(CallUpdate::State(CallState::Connected {
crates/app/src/call/caption_style.rs added +75 −0
@@ -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)]
2pub enum CaptionSize {
3 Small,
4 #[default]
5 Medium,
6 Large,
7}
8
9impl 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)]
46pub enum CaptionPosition {
47 #[default]
48 Bottom,
49 Top,
50}
51
52impl 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}
crates/app/src/call/demo.rs +23 −4
@@ -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;
@@ -601,7 +607,20 @@ async fn speak_until_hangup(
601 607 control.send(CallUpdate::IncomingVideo(enabled));
602 608 }
603 609 Some(CallCommand::SetCameraEffects(_)) => {}
604 Some(CallCommand::SetRecording { on, .. }) => control.send(CallUpdate::Recording(on)),
610 Some(CallCommand::StartRecording { kind, .. }) => {
611 recording_on = kind != RecordingKind::TranscriptOnly;
612 transcribing_on = true;
613 control.send(CallUpdate::Recording(recording_on));
614 control.send(CallUpdate::RecordingAudioOnly(kind == RecordingKind::AudioOnly));
615 control.send(CallUpdate::Transcribing(true));
616 }
617 Some(CallCommand::StopRecording { scope }) => {
618 recording_on = recording_on && scope == StopScope::TranscriptionOnly;
619 transcribing_on = transcribing_on && scope == StopScope::RecordingOnly;
620 control.send(CallUpdate::Recording(recording_on));
621 control.send(CallUpdate::Transcribing(transcribing_on));
622 }
623 Some(CallCommand::SetCaptionLanguage(_)) => {}
605 624 Some(CallCommand::ConsentToRecording) => control.send(CallUpdate::ConsentRequired(false)),
606 625 Some(CallCommand::Hold(hold)) => control.send(CallUpdate::Hold(if hold { HoldState::Local } else { HoldState::Active })),
607 626 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
14use super::demo_scene::self_view;
14use super::demo_scene::self_view;
@@ -384,7 +384,11 @@ fn publish_demo_video(
384
384
385fn start_scene(control: &CallControl, scene: DemoScene) {
385fn 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;
@@ -601,7 +607,20 @@ async fn speak_until_hangup(
601 control.send(CallUpdate::IncomingVideo(enabled));
607 control.send(CallUpdate::IncomingVideo(enabled));
602 }
608 }
603 Some(CallCommand::SetCameraEffects(_)) => {}
609 Some(CallCommand::SetCameraEffects(_)) => {}
604 Some(CallCommand::SetRecording { on, .. }) => control.send(CallUpdate::Recording(on)),
610 Some(CallCommand::StartRecording { kind, .. }) => {
611 recording_on = kind != RecordingKind::TranscriptOnly;
612 transcribing_on = true;
613 control.send(CallUpdate::Recording(recording_on));
614 control.send(CallUpdate::RecordingAudioOnly(kind == RecordingKind::AudioOnly));
615 control.send(CallUpdate::Transcribing(true));
616 }
617 Some(CallCommand::StopRecording { scope }) => {
618 recording_on = recording_on && scope == StopScope::TranscriptionOnly;
619 transcribing_on = transcribing_on && scope == StopScope::RecordingOnly;
620 control.send(CallUpdate::Recording(recording_on));
621 control.send(CallUpdate::Transcribing(transcribing_on));
622 }
623 Some(CallCommand::SetCaptionLanguage(_)) => {}
605 Some(CallCommand::ConsentToRecording) => control.send(CallUpdate::ConsentRequired(false)),
624 Some(CallCommand::ConsentToRecording) => control.send(CallUpdate::ConsentRequired(false)),
606 Some(CallCommand::Hold(hold)) => control.send(CallUpdate::Hold(if hold { HoldState::Local } else { HoldState::Active })),
625 Some(CallCommand::Hold(hold)) => control.send(CallUpdate::Hold(if hold { HoldState::Local } else { HoldState::Active })),
607 Some(CallCommand::Transfer { .. }) => {
626 Some(CallCommand::Transfer { .. }) => {
crates/app/src/call/features.rs +76 −5
@@ -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::*;
6use super::background::BackgroundPick;
6use super::background::BackgroundPick;
7use super::demo::{DemoCall, start_demo_call};
7use super::demo::{DemoCall, start_demo_call};
8use super::health::HealthBanner;
8use super::health::HealthBanner;
9use super::model::{ActiveCall, BreakoutState, CallModel, ConsultCall, PendingMove};
9use super::model::{ActiveCall, BreakoutState, CallKind, CallModel, ConsultCall, PendingMove};
10use super::recording_menu::RecordAction;
10use super::target::plan_for_chat;
11use super::target::plan_for_chat;
11use crate::app_state::AppState;
12use crate::app_state::{AppEvent, AppState};
12use crate::data::is_one_on_one;
13use crate::data::is_one_on_one;
14use crate::views::call_transcript::TranscriptPanel;
13
15
14const DEMO_ROOM_GUESTS: usize = 3;
16const DEMO_ROOM_GUESTS: usize = 3;
15
17
@@ -38,12 +40,81 @@ fn return_move(room: &BreakoutState) -> PendingMove {
38}
40}
39
41
40impl AppState {
42impl 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) = 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 pub fn accept_recording_notice(&mut self, _cx: &mut Context<Self>) {
120 pub fn accept_recording_notice(&mut self, _cx: &mut Context<Self>) {
crates/app/src/call/mod.rs +6 −0
@@ -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;
@@ -21,17 +22,20 @@ mod pictures;
21 22 mod prejoin;
22 23 mod preview;
23 24 mod push_to_talk;
25 mod recording_menu;
24 26 mod reminder;
25 27 mod ring;
26 28 mod schedule;
27 29 mod stage_layout;
28 30 mod target;
31 mod transcript;
29 32 mod view_actions;
30 33 mod view_settings;
31 34
32 35 pub use actions::{load_camera, load_camera_effects, load_share_sound};
33 36 pub use mic::load_mic;
34 37 pub use agenda::{AgendaRow, fetch_window, join_available, response_label};
38 pub use caption_style::{CaptionPosition, CaptionSize};
35 39 pub use background::{
36 40 BackgroundLibrary, BackgroundPick, default_cache_directory, demo_library, load_background,
37 41 load_custom_backgrounds,
@@ -58,5 +62,7 @@ pub use reminder::{MeetingToasts, subtitle as meeting_subtitle};
58 62 pub use ring::{MissedCall, RingEntry, Rings};
59 63 pub use stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, filmstrip, gallery_grid, split_overflow};
60 64 pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
65 pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};
61 66 pub use target::plan_for_chat;
67 pub use transcript::clock_label;
62 68 pub use view_settings::{CallLayout, ViewSettings};
@@ -3,6 +3,7 @@ mod agenda;
3mod background;
3mod background;
4mod bubbles;
4mod bubbles;
5mod calendar;
5mod calendar;
6mod caption_style;
6mod demo;
7mod demo;
7mod demo_scene;
8mod demo_scene;
8mod features;
9mod features;
@@ -21,17 +22,20 @@ mod pictures;
21mod prejoin;
22mod prejoin;
22mod preview;
23mod preview;
23mod push_to_talk;
24mod push_to_talk;
25mod recording_menu;
24mod reminder;
26mod reminder;
25mod ring;
27mod ring;
26mod schedule;
28mod schedule;
27mod stage_layout;
29mod stage_layout;
28mod target;
30mod target;
31mod transcript;
29mod view_actions;
32mod view_actions;
30mod view_settings;
33mod view_settings;
31
34
32pub use actions::{load_camera, load_camera_effects, load_share_sound};
35pub use actions::{load_camera, load_camera_effects, load_share_sound};
33pub use mic::load_mic;
36pub use mic::load_mic;
34pub use agenda::{AgendaRow, fetch_window, join_available, response_label};
37pub use agenda::{AgendaRow, fetch_window, join_available, response_label};
38pub use caption_style::{CaptionPosition, CaptionSize};
35pub use background::{
39pub use background::{
36 BackgroundLibrary, BackgroundPick, default_cache_directory, demo_library, load_background,
40 BackgroundLibrary, BackgroundPick, default_cache_directory, demo_library, load_background,
37 load_custom_backgrounds,
41 load_custom_backgrounds,
@@ -58,5 +62,7 @@ pub use reminder::{MeetingToasts, subtitle as meeting_subtitle};
58pub use ring::{MissedCall, RingEntry, Rings};
62pub use ring::{MissedCall, RingEntry, Rings};
59pub use stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, filmstrip, gallery_grid, split_overflow};
63pub use stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, filmstrip, gallery_grid, split_overflow};
60pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
64pub use schedule::{FormValues, Invitee, default_window, draft_from_form};
65pub use recording_menu::{RecordAction, RecordingChip, record_actions, recording_chip};
61pub use target::plan_for_chat;
66pub use target::plan_for_chat;
67pub use transcript::clock_label;
62pub use view_settings::{CallLayout, ViewSettings};
68pub use view_settings::{CallLayout, ViewSettings};
crates/app/src/call/model.rs +79 −0
@@ -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,
@@ -265,8 +268,13 @@ pub struct CallModel {
265 268 pub pinned: Option<String>,
266 269 pub captions: CaptionState,
267 270 pub caption_lines: Vec<CaptionLine>,
271 pub transcript: Transcript,
272 pub caption_language: Option<String>,
273 language_pending: bool,
268 274 pub background: BackgroundPick,
269 275 pub recording: bool,
276 pub recording_audio_only: bool,
277 pub transcribing: bool,
270 278 pub consent_required: bool,
271 279 pub hold: HoldState,
272 280 pub health: HealthState,
@@ -320,8 +328,13 @@ impl CallModel {
320 328 pinned: None,
321 329 captions: CaptionState::Off,
322 330 caption_lines: Vec::new(),
331 transcript: Transcript::default(),
332 caption_language: None,
333 language_pending: false,
323 334 background: BackgroundPick::None,
324 335 recording: false,
336 recording_audio_only: false,
337 transcribing: false,
325 338 consent_required: false,
326 339 hold: HoldState::Active,
327 340 health: HealthState::default(),
@@ -451,6 +464,8 @@ impl CallModel {
451 464 }
452 465 CallUpdate::Caption(entry) => self.note_caption(entry, Instant::now()),
453 466 CallUpdate::Recording(on) => self.recording = on,
467 CallUpdate::RecordingAudioOnly(audio_only) => self.recording_audio_only = audio_only,
468 CallUpdate::Transcribing(on) => self.transcribing = on,
454 469 CallUpdate::ConsentRequired(required) => self.consent_required = required,
455 470 CallUpdate::Hold(hold) => self.hold = hold,
456 471 CallUpdate::Health(health) => self.health.apply(health),
@@ -474,6 +489,15 @@ impl CallModel {
474 489 } else {
475 490 entry.display_name
476 491 };
492 let offset = self
493 .connected_since
494 .map_or(Duration::ZERO, |since| at.saturating_duration_since(since));
495 self.transcript.note(TranscriptEntry {
496 id: entry.id.clone(),
497 speaker: speaker.clone(),
498 text: entry.text.clone(),
499 offset,
500 });
477 501 let line = CaptionLine {
478 502 id: entry.id,
479 503 speaker,
@@ -495,6 +519,19 @@ impl CallModel {
495 519 .collect()
496 520 }
497 521
522 pub fn choose_caption_language(&mut self, tag: &str) {
523 self.caption_language = Some(tag.to_owned());
524 self.language_pending = true;
525 }
526
527 pub fn take_ready_caption_language(&mut self) -> Option<String> {
528 if self.language_pending && self.captions == CaptionState::On {
529 self.language_pending = false;
530 return self.caption_language.clone();
531 }
532 None
533 }
534
498 535 pub fn captions_on(&self) -> bool {
499 536 matches!(self.captions, CaptionState::Starting | CaptionState::On)
500 537 }
@@ -1948,6 +1985,48 @@ mod tests {
1948 1985 );
1949 1986 }
1950 1987
1988 #[test]
1989 fn the_transcript_keeps_every_caption_with_its_offset_while_the_overlay_keeps_two() {
1990 let mut model = meeting_with_me();
1991 let start = Instant::now();
1992 model.apply(CallUpdate::State(CallState::Connected { since: start }));
1993 model.apply(CallUpdate::Captions(CaptionState::On));
1994 model.note_caption(caption("1", "Ana Example", "One", true), start + Duration::from_secs(5));
1995 model.note_caption(caption("2", "Bo Sample", "Two", true), start + Duration::from_secs(65));
1996 model.note_caption(caption("3", "Ana Example", "Three", true), start + Duration::from_secs(70));
1997 assert_eq!(model.caption_lines.len(), 2);
1998 assert_eq!(model.transcript.filtered("").len(), 3);
1999 assert_eq!(model.transcript.filtered("")[1].offset, Duration::from_secs(65));
2000 model.apply(CallUpdate::Captions(CaptionState::Off));
2001 model.note_caption(caption("4", "Bo Sample", "Ignored", true), start + Duration::from_secs(80));
2002 assert!(model.caption_lines.is_empty());
2003 assert_eq!(model.transcript.filtered("").len(), 3);
2004 }
2005
2006 #[test]
2007 fn a_chosen_spoken_language_is_handed_out_once_the_captions_are_on() {
2008 let mut model = meeting_with_me();
2009 model.choose_caption_language("de-DE");
2010 model.apply(CallUpdate::Captions(CaptionState::Starting));
2011 assert_eq!(model.take_ready_caption_language(), None);
2012 model.apply(CallUpdate::Captions(CaptionState::On));
2013 assert_eq!(model.take_ready_caption_language().as_deref(), Some("de-DE"));
2014 assert_eq!(model.take_ready_caption_language(), None);
2015 assert_eq!(model.caption_language.as_deref(), Some("de-DE"));
2016 }
2017
2018 #[test]
2019 fn audio_only_and_transcription_follow_their_own_updates() {
2020 let mut model = meeting_with_me();
2021 model.apply(CallUpdate::Transcribing(true));
2022 assert!(model.transcribing && !model.recording);
2023 model.apply(CallUpdate::Recording(true));
2024 model.apply(CallUpdate::RecordingAudioOnly(true));
2025 assert!(model.recording && model.recording_audio_only);
2026 model.apply(CallUpdate::Transcribing(false));
2027 assert!(!model.transcribing && model.recording);
2028 }
2029
1951 2030 #[test]
1952 2031 fn recording_and_consent_follow_the_call_updates_and_only_organizers_may_record() {
1953 2032 let mut model = meeting_with_me();
@@ -16,6 +16,7 @@ use super::bubbles::ChatBubble;
16use super::fullscreen::FullscreenState;
16use super::fullscreen::FullscreenState;
17use super::pictures::CallPictures;
17use super::pictures::CallPictures;
18use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};
18use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};
19use super::transcript::{Transcript, TranscriptEntry};
19use super::view_settings::{CallLayout, ViewSettings};
20use super::view_settings::{CallLayout, ViewSettings};
20use super::push_to_talk::PushToTalk;
21use 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,
@@ -265,8 +268,13 @@ pub struct CallModel {
265 pub pinned: Option<String>,
268 pub pinned: Option<String>,
266 pub captions: CaptionState,
269 pub captions: CaptionState,
267 pub caption_lines: Vec<CaptionLine>,
270 pub caption_lines: Vec<CaptionLine>,
271 pub transcript: Transcript,
272 pub caption_language: Option<String>,
273 language_pending: bool,
268 pub background: BackgroundPick,
274 pub background: BackgroundPick,
269 pub recording: bool,
275 pub recording: bool,
276 pub recording_audio_only: bool,
277 pub transcribing: bool,
270 pub consent_required: bool,
278 pub consent_required: bool,
271 pub hold: HoldState,
279 pub hold: HoldState,
272 pub health: HealthState,
280 pub health: HealthState,
@@ -320,8 +328,13 @@ impl CallModel {
320 pinned: None,
328 pinned: None,
321 captions: CaptionState::Off,
329 captions: CaptionState::Off,
322 caption_lines: Vec::new(),
330 caption_lines: Vec::new(),
331 transcript: Transcript::default(),
332 caption_language: None,
333 language_pending: false,
323 background: BackgroundPick::None,
334 background: BackgroundPick::None,
324 recording: false,
335 recording: false,
336 recording_audio_only: false,
337 transcribing: false,
325 consent_required: false,
338 consent_required: false,
326 hold: HoldState::Active,
339 hold: HoldState::Active,
327 health: HealthState::default(),
340 health: HealthState::default(),
@@ -451,6 +464,8 @@ impl CallModel {
451 }
464 }
452 CallUpdate::Caption(entry) => self.note_caption(entry, Instant::now()),
465 CallUpdate::Caption(entry) => self.note_caption(entry, Instant::now()),
453 CallUpdate::Recording(on) => self.recording = on,
466 CallUpdate::Recording(on) => self.recording = on,
467 CallUpdate::RecordingAudioOnly(audio_only) => self.recording_audio_only = audio_only,
468 CallUpdate::Transcribing(on) => self.transcribing = on,
454 CallUpdate::ConsentRequired(required) => self.consent_required = required,
469 CallUpdate::ConsentRequired(required) => self.consent_required = required,
455 CallUpdate::Hold(hold) => self.hold = hold,
470 CallUpdate::Hold(hold) => self.hold = hold,
456 CallUpdate::Health(health) => self.health.apply(health),
471 CallUpdate::Health(health) => self.health.apply(health),
@@ -474,6 +489,15 @@ impl CallModel {
474 } else {
489 } else {
475 entry.display_name
490 entry.display_name
476 };
491 };
492 let offset = self
493 .connected_since
494 .map_or(Duration::ZERO, |since| at.saturating_duration_since(since));
495 self.transcript.note(TranscriptEntry {
496 id: entry.id.clone(),
497 speaker: speaker.clone(),
498 text: entry.text.clone(),
499 offset,
500 });
477 let line = CaptionLine {
501 let line = CaptionLine {
478 id: entry.id,
502 id: entry.id,
479 speaker,
503 speaker,
@@ -495,6 +519,19 @@ impl CallModel {
495 .collect()
519 .collect()
496 }
520 }
497
521
522 pub fn choose_caption_language(&mut self, tag: &str) {
523 self.caption_language = Some(tag.to_owned());
524 self.language_pending = true;
525 }
526
527 pub fn take_ready_caption_language(&mut self) -> Option<String> {
528 if self.language_pending && self.captions == CaptionState::On {
529 self.language_pending = false;
530 return self.caption_language.clone();
531 }
532 None
533 }
534
498 pub fn captions_on(&self) -> bool {
535 pub fn captions_on(&self) -> bool {
499 matches!(self.captions, CaptionState::Starting | CaptionState::On)
536 matches!(self.captions, CaptionState::Starting | CaptionState::On)
500 }
537 }
@@ -1948,6 +1985,48 @@ mod tests {
1948 );
1985 );
1949 }
1986 }
1950
1987
1988 #[test]
1989 fn the_transcript_keeps_every_caption_with_its_offset_while_the_overlay_keeps_two() {
1990 let mut model = meeting_with_me();
1991 let start = Instant::now();
1992 model.apply(CallUpdate::State(CallState::Connected { since: start }));
1993 model.apply(CallUpdate::Captions(CaptionState::On));
1994 model.note_caption(caption("1", "Ana Example", "One", true), start + Duration::from_secs(5));
1995 model.note_caption(caption("2", "Bo Sample", "Two", true), start + Duration::from_secs(65));
1996 model.note_caption(caption("3", "Ana Example", "Three", true), start + Duration::from_secs(70));
1997 assert_eq!(model.caption_lines.len(), 2);
1998 assert_eq!(model.transcript.filtered("").len(), 3);
1999 assert_eq!(model.transcript.filtered("")[1].offset, Duration::from_secs(65));
2000 model.apply(CallUpdate::Captions(CaptionState::Off));
2001 model.note_caption(caption("4", "Bo Sample", "Ignored", true), start + Duration::from_secs(80));
2002 assert!(model.caption_lines.is_empty());
2003 assert_eq!(model.transcript.filtered("").len(), 3);
2004 }
2005
2006 #[test]
2007 fn a_chosen_spoken_language_is_handed_out_once_the_captions_are_on() {
2008 let mut model = meeting_with_me();
2009 model.choose_caption_language("de-DE");
2010 model.apply(CallUpdate::Captions(CaptionState::Starting));
2011 assert_eq!(model.take_ready_caption_language(), None);
2012 model.apply(CallUpdate::Captions(CaptionState::On));
2013 assert_eq!(model.take_ready_caption_language().as_deref(), Some("de-DE"));
2014 assert_eq!(model.take_ready_caption_language(), None);
2015 assert_eq!(model.caption_language.as_deref(), Some("de-DE"));
2016 }
2017
2018 #[test]
2019 fn audio_only_and_transcription_follow_their_own_updates() {
2020 let mut model = meeting_with_me();
2021 model.apply(CallUpdate::Transcribing(true));
2022 assert!(model.transcribing && !model.recording);
2023 model.apply(CallUpdate::Recording(true));
2024 model.apply(CallUpdate::RecordingAudioOnly(true));
2025 assert!(model.recording && model.recording_audio_only);
2026 model.apply(CallUpdate::Transcribing(false));
2027 assert!(!model.transcribing && model.recording);
2028 }
2029
1951 #[test]
2030 #[test]
1952 fn recording_and_consent_follow_the_call_updates_and_only_organizers_may_record() {
2031 fn recording_and_consent_follow_the_call_updates_and_only_organizers_may_record() {
1953 let mut model = meeting_with_me();
2032 let mut model = meeting_with_me();
crates/app/src/call/recording_menu.rs added +118 −0
@@ -0,0 +1,118 @@
1 use calling::{RecordingKind, StopScope};
2
3 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4 pub enum RecordAction {
5 Start(RecordingKind),
6 Stop(StopScope),
7 }
8
9 impl RecordAction {
10 pub fn label(self) -> &'static str {
11 match self {
12 RecordAction::Start(RecordingKind::Video) => "Start recording",
13 RecordAction::Start(RecordingKind::AudioOnly) => "Record audio only",
14 RecordAction::Start(RecordingKind::TranscriptOnly) => "Start transcription only",
15 RecordAction::Stop(StopScope::Both | StopScope::RecordingOnly) => "Stop recording",
16 RecordAction::Stop(StopScope::TranscriptionOnly) => "Stop transcription",
17 }
18 }
19
20 pub fn confirm_title(self) -> Option<&'static str> {
21 match self {
22 RecordAction::Start(_) => None,
23 RecordAction::Stop(StopScope::Both) => Some("Stop recording and transcription?"),
24 RecordAction::Stop(StopScope::RecordingOnly) => Some("Stop recording?"),
25 RecordAction::Stop(StopScope::TranscriptionOnly) => Some("Stop transcription?"),
26 }
27 }
28 }
29
30 pub fn record_actions(recording: bool, transcribing: bool) -> Vec<(RecordAction, &'static str)> {
31 let labelled = |action: RecordAction| (action, action.label());
32 match (recording, transcribing) {
33 (false, false) => vec![
34 labelled(RecordAction::Start(RecordingKind::Video)),
35 labelled(RecordAction::Start(RecordingKind::AudioOnly)),
36 labelled(RecordAction::Start(RecordingKind::TranscriptOnly)),
37 ],
38 (true, true) => vec![
39 labelled(RecordAction::Stop(StopScope::RecordingOnly)),
40 labelled(RecordAction::Stop(StopScope::TranscriptionOnly)),
41 (RecordAction::Stop(StopScope::Both), "Stop both"),
42 ],
43 (true, false) => vec![labelled(RecordAction::Stop(StopScope::Both))],
44 (false, true) => vec![labelled(RecordAction::Stop(StopScope::TranscriptionOnly))],
45 }
46 }
47
48 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
49 pub enum RecordingChip {
50 Recording,
51 RecordingAudio,
52 Transcribing,
53 }
54
55 impl RecordingChip {
56 pub fn label(self) -> &'static str {
57 match self {
58 RecordingChip::Recording => "Recording",
59 RecordingChip::RecordingAudio => "Recording audio",
60 RecordingChip::Transcribing => "Transcribing",
61 }
62 }
63 }
64
65 pub fn recording_chip(recording: bool, audio_only: bool, transcribing: bool) -> Option<RecordingChip> {
66 match (recording, audio_only, transcribing) {
67 (true, true, _) => Some(RecordingChip::RecordingAudio),
68 (true, false, _) => Some(RecordingChip::Recording),
69 (false, _, true) => Some(RecordingChip::Transcribing),
70 (false, _, false) => None,
71 }
72 }
73
74 #[cfg(test)]
75 mod tests {
76 use super::*;
77
78 fn labels(recording: bool, transcribing: bool) -> Vec<&'static str> {
79 record_actions(recording, transcribing).into_iter().map(|(_, label)| label).collect()
80 }
81
82 #[test]
83 fn nothing_running_offers_the_three_starts() {
84 assert_eq!(labels(false, false), ["Start recording", "Record audio only", "Start transcription only"]);
85 }
86
87 #[test]
88 fn recording_with_transcript_offers_the_three_stop_variants() {
89 let actions = record_actions(true, true);
90 assert_eq!(actions[0].0, RecordAction::Stop(StopScope::RecordingOnly));
91 assert_eq!(actions[1].0, RecordAction::Stop(StopScope::TranscriptionOnly));
92 assert_eq!(actions[2].0, RecordAction::Stop(StopScope::Both));
93 assert_eq!(labels(true, true), ["Stop recording", "Stop transcription", "Stop both"]);
94 }
95
96 #[test]
97 fn a_single_running_part_offers_the_one_matching_stop() {
98 assert_eq!(record_actions(true, false), [(RecordAction::Stop(StopScope::Both), "Stop recording")]);
99 assert_eq!(record_actions(false, true), [(RecordAction::Stop(StopScope::TranscriptionOnly), "Stop transcription")]);
100 }
101
102 #[test]
103 fn only_stops_ask_for_confirmation() {
104 assert_eq!(RecordAction::Start(RecordingKind::Video).confirm_title(), None);
105 assert_eq!(RecordAction::Stop(StopScope::Both).confirm_title(), Some("Stop recording and transcription?"));
106 assert_eq!(RecordAction::Stop(StopScope::RecordingOnly).confirm_title(), Some("Stop recording?"));
107 assert_eq!(RecordAction::Stop(StopScope::TranscriptionOnly).confirm_title(), Some("Stop transcription?"));
108 }
109
110 #[test]
111 fn the_chip_names_what_is_running() {
112 assert_eq!(recording_chip(true, false, true), Some(RecordingChip::Recording));
113 assert_eq!(recording_chip(true, true, true), Some(RecordingChip::RecordingAudio));
114 assert_eq!(recording_chip(false, false, true), Some(RecordingChip::Transcribing));
115 assert_eq!(recording_chip(false, false, false), None);
116 assert_eq!(RecordingChip::RecordingAudio.label(), "Recording audio");
117 }
118 }
@@ -0,0 +1,118 @@
1use calling::{RecordingKind, StopScope};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum RecordAction {
5 Start(RecordingKind),
6 Stop(StopScope),
7}
8
9impl RecordAction {
10 pub fn label(self) -> &'static str {
11 match self {
12 RecordAction::Start(RecordingKind::Video) => "Start recording",
13 RecordAction::Start(RecordingKind::AudioOnly) => "Record audio only",
14 RecordAction::Start(RecordingKind::TranscriptOnly) => "Start transcription only",
15 RecordAction::Stop(StopScope::Both | StopScope::RecordingOnly) => "Stop recording",
16 RecordAction::Stop(StopScope::TranscriptionOnly) => "Stop transcription",
17 }
18 }
19
20 pub fn confirm_title(self) -> Option<&'static str> {
21 match self {
22 RecordAction::Start(_) => None,
23 RecordAction::Stop(StopScope::Both) => Some("Stop recording and transcription?"),
24 RecordAction::Stop(StopScope::RecordingOnly) => Some("Stop recording?"),
25 RecordAction::Stop(StopScope::TranscriptionOnly) => Some("Stop transcription?"),
26 }
27 }
28}
29
30pub fn record_actions(recording: bool, transcribing: bool) -> Vec<(RecordAction, &'static str)> {
31 let labelled = |action: RecordAction| (action, action.label());
32 match (recording, transcribing) {
33 (false, false) => vec![
34 labelled(RecordAction::Start(RecordingKind::Video)),
35 labelled(RecordAction::Start(RecordingKind::AudioOnly)),
36 labelled(RecordAction::Start(RecordingKind::TranscriptOnly)),
37 ],
38 (true, true) => vec![
39 labelled(RecordAction::Stop(StopScope::RecordingOnly)),
40 labelled(RecordAction::Stop(StopScope::TranscriptionOnly)),
41 (RecordAction::Stop(StopScope::Both), "Stop both"),
42 ],
43 (true, false) => vec![labelled(RecordAction::Stop(StopScope::Both))],
44 (false, true) => vec![labelled(RecordAction::Stop(StopScope::TranscriptionOnly))],
45 }
46}
47
48#[derive(Debug, Clone, Copy, PartialEq, Eq)]
49pub enum RecordingChip {
50 Recording,
51 RecordingAudio,
52 Transcribing,
53}
54
55impl RecordingChip {
56 pub fn label(self) -> &'static str {
57 match self {
58 RecordingChip::Recording => "Recording",
59 RecordingChip::RecordingAudio => "Recording audio",
60 RecordingChip::Transcribing => "Transcribing",
61 }
62 }
63}
64
65pub fn recording_chip(recording: bool, audio_only: bool, transcribing: bool) -> Option<RecordingChip> {
66 match (recording, audio_only, transcribing) {
67 (true, true, _) => Some(RecordingChip::RecordingAudio),
68 (true, false, _) => Some(RecordingChip::Recording),
69 (false, _, true) => Some(RecordingChip::Transcribing),
70 (false, _, false) => None,
71 }
72}
73
74#[cfg(test)]
75mod tests {
76 use super::*;
77
78 fn labels(recording: bool, transcribing: bool) -> Vec<&'static str> {
79 record_actions(recording, transcribing).into_iter().map(|(_, label)| label).collect()
80 }
81
82 #[test]
83 fn nothing_running_offers_the_three_starts() {
84 assert_eq!(labels(false, false), ["Start recording", "Record audio only", "Start transcription only"]);
85 }
86
87 #[test]
88 fn recording_with_transcript_offers_the_three_stop_variants() {
89 let actions = record_actions(true, true);
90 assert_eq!(actions[0].0, RecordAction::Stop(StopScope::RecordingOnly));
91 assert_eq!(actions[1].0, RecordAction::Stop(StopScope::TranscriptionOnly));
92 assert_eq!(actions[2].0, RecordAction::Stop(StopScope::Both));
93 assert_eq!(labels(true, true), ["Stop recording", "Stop transcription", "Stop both"]);
94 }
95
96 #[test]
97 fn a_single_running_part_offers_the_one_matching_stop() {
98 assert_eq!(record_actions(true, false), [(RecordAction::Stop(StopScope::Both), "Stop recording")]);
99 assert_eq!(record_actions(false, true), [(RecordAction::Stop(StopScope::TranscriptionOnly), "Stop transcription")]);
100 }
101
102 #[test]
103 fn only_stops_ask_for_confirmation() {
104 assert_eq!(RecordAction::Start(RecordingKind::Video).confirm_title(), None);
105 assert_eq!(RecordAction::Stop(StopScope::Both).confirm_title(), Some("Stop recording and transcription?"));
106 assert_eq!(RecordAction::Stop(StopScope::RecordingOnly).confirm_title(), Some("Stop recording?"));
107 assert_eq!(RecordAction::Stop(StopScope::TranscriptionOnly).confirm_title(), Some("Stop transcription?"));
108 }
109
110 #[test]
111 fn the_chip_names_what_is_running() {
112 assert_eq!(recording_chip(true, false, true), Some(RecordingChip::Recording));
113 assert_eq!(recording_chip(true, true, true), Some(RecordingChip::RecordingAudio));
114 assert_eq!(recording_chip(false, false, true), Some(RecordingChip::Transcribing));
115 assert_eq!(recording_chip(false, false, false), None);
116 assert_eq!(RecordingChip::RecordingAudio.label(), "Recording audio");
117 }
118}
crates/app/src/call/transcript.rs added +121 −0
@@ -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 @@
1use std::time::Duration;
2
3const RECENT_WINDOW: usize = 16;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub 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)]
14pub struct Transcript {
15 entries: Vec<TranscriptEntry>,
16}
17
18impl 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
51pub 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)]
57mod 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}
crates/app/src/call/view_actions.rs +9 −0
@@ -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
3use gpui_kit::*;
3use gpui_kit::*;
4
4
5use super::caption_style::{CaptionPosition, CaptionSize};
5use super::bubbles::{BUBBLE_SHOWN, ChatBubble, push_bubble};
6use super::bubbles::{BUBBLE_SHOWN, ChatBubble, push_bubble};
6use super::fullscreen::{FullscreenState, HINT_SHOWN};
7use super::fullscreen::{FullscreenState, HINT_SHOWN};
7use super::view_settings::{CallLayout, ViewSettings};
8use 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 }
crates/app/src/call/view_settings.rs +26 −0
@@ -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 @@
1use super::caption_style::{CaptionPosition, CaptionSize};
2
1const LAYOUT_META_KEY: &str = "call_layout";
3const LAYOUT_META_KEY: &str = "call_layout";
2const HIDE_NO_VIDEO_META_KEY: &str = "call_hide_no_video";
4const HIDE_NO_VIDEO_META_KEY: &str = "call_hide_no_video";
3const CHAT_BUBBLES_META_KEY: &str = "call_chat_bubbles";
5const CHAT_BUBBLES_META_KEY: &str = "call_chat_bubbles";
6const CAPTION_SIZE_META_KEY: &str = "call_caption_size";
7const 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)]
6pub enum CallLayout {
10pub 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
48impl Default for ViewSettings {
54impl 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: 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 ..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]
crates/app/src/layout_guard.rs +37 −4
@@ -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::{AppHandle, 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};
@@ -164,6 +165,7 @@ mod frames {
164 165 "shell/islands/main/prejoin/actions",
165 166 ];
166 167 const PREJOIN_LINK: &str = "https://teams.microsoft.com/l/meetup-join/19%3ameeting_guard%40thread.v2/0?context=%7b%22Tid%22%3a%22t%22%2c%22Oid%22%3a%22o%22%7d";
168 const CALL_TRANSCRIPT: &str = "shell/islands/main/call-transcript";
167 169 const MENU: &str = "popup-menu";
168 170 const OWN_STATUS: &str = "shell/title-bar/own-status";
169 171 const RECAP_TAB: &str = "shell/islands/main/recap-tab";
@@ -179,6 +181,7 @@ mod frames {
179 181 StatusMenu,
180 182 Call,
181 183 Prejoin,
184 CallTranscript,
182 185 }
183 186
184 187 fn parent_of(path: &str) -> Option<&str> {
@@ -296,7 +299,7 @@ mod frames {
296 299 .chain(CALL_GUARDED)
297 300 .chain(CALLS_TAGS)
298 301 .chain(PREJOIN_TAGS)
299 .chain([&MENU, &RECAP_TAB, &RECAP_REGION])
302 .chain([&CALL_TRANSCRIPT, &MENU, &RECAP_TAB, &RECAP_REGION])
300 303 .filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))
301 304 .collect()
302 305 }
@@ -413,6 +416,7 @@ mod frames {
413 416 Screen::Prejoin,
414 417 Screen::StatusMenu,
415 418 Screen::Call,
419 Screen::CallTranscript,
416 420 ];
417 421 for screen in screens {
418 422 let (screen_name, status_menu) = match screen {
@@ -438,6 +442,32 @@ mod frames {
438 442 });
439 443 ("prejoin", false)
440 444 }
445 Screen::CallTranscript => {
446 visual.update(|window, cx| {
447 app.update(cx, |state, cx| {
448 let mut call = gallery_call();
449 call.model.apply(CallUpdate::Captions(CaptionState::On));
450 for index in 0..40 {
451 call.model.note_caption(
452 CaptionEntry {
453 id: format!("guard-{index}"),
454 user_id: "8:orgid:guard-0".into(),
455 display_name: "Guest 0".into(),
456 text: "A long guarded sentence that has to wrap inside the panel".into(),
457 is_final: true,
458 },
459 Instant::now(),
460 );
461 }
462 call.transcript_open = true;
463 state.call = Some(call);
464 let app_entity = cx.entity();
465 state.transcript_panel = Some(cx.new(|cx| TranscriptPanel::new(app_entity, window, cx)));
466 cx.notify();
467 })
468 });
469 ("call-transcript", false)
470 }
441 471 Screen::StatusMenu => {
442 472 let tags = collect(&mut visual, None);
443 473 let button = tags
@@ -451,9 +481,12 @@ mod frames {
451 481 };
452 482 let tags = collect(&mut visual, status_menu.then_some(MENU));
453 483 let mut expected = GUARDED.to_vec();
454 if screen_name == "call" {
484 if screen_name == "call" || screen_name == "call-transcript" {
455 485 expected.extend(CALL_GUARDED);
456 486 }
487 if screen_name == "call-transcript" {
488 expected.push(CALL_TRANSCRIPT);
489 }
457 490 if status_menu {
458 491 expected.push(MENU);
459 492 }
@@ -487,7 +520,7 @@ mod frames {
487 520 visual.simulate_keystrokes("escape");
488 521 visual.run_until_parked();
489 522 }
490 if screen_name == "call" {
523 if screen_name == "call" || screen_name == "call-transcript" {
491 524 visual.update(|_, cx| {
492 525 app.update(cx, |state, cx| {
493 526 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::{AppHandle, AppState, Mode, Selection};
128 use crate::app_state::{AppHandle, 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};
@@ -164,6 +165,7 @@ mod frames {
164 "shell/islands/main/prejoin/actions",
165 "shell/islands/main/prejoin/actions",
165 ];
166 ];
166 const PREJOIN_LINK: &str = "https://teams.microsoft.com/l/meetup-join/19%3ameeting_guard%40thread.v2/0?context=%7b%22Tid%22%3a%22t%22%2c%22Oid%22%3a%22o%22%7d";
167 const PREJOIN_LINK: &str = "https://teams.microsoft.com/l/meetup-join/19%3ameeting_guard%40thread.v2/0?context=%7b%22Tid%22%3a%22t%22%2c%22Oid%22%3a%22o%22%7d";
168 const CALL_TRANSCRIPT: &str = "shell/islands/main/call-transcript";
167 const MENU: &str = "popup-menu";
169 const MENU: &str = "popup-menu";
168 const OWN_STATUS: &str = "shell/title-bar/own-status";
170 const OWN_STATUS: &str = "shell/title-bar/own-status";
169 const RECAP_TAB: &str = "shell/islands/main/recap-tab";
171 const RECAP_TAB: &str = "shell/islands/main/recap-tab";
@@ -179,6 +181,7 @@ mod frames {
179 StatusMenu,
181 StatusMenu,
180 Call,
182 Call,
181 Prejoin,
183 Prejoin,
184 CallTranscript,
182 }
185 }
183
186
184 fn parent_of(path: &str) -> Option<&str> {
187 fn parent_of(path: &str) -> Option<&str> {
@@ -296,7 +299,7 @@ mod frames {
296 .chain(CALL_GUARDED)
299 .chain(CALL_GUARDED)
297 .chain(CALLS_TAGS)
300 .chain(CALLS_TAGS)
298 .chain(PREJOIN_TAGS)
301 .chain(PREJOIN_TAGS)
299 .chain([&MENU, &RECAP_TAB, &RECAP_REGION])
302 .chain([&CALL_TRANSCRIPT, &MENU, &RECAP_TAB, &RECAP_REGION])
300 .filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))
303 .filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))
301 .collect()
304 .collect()
302 }
305 }
@@ -413,6 +416,7 @@ mod frames {
413 Screen::Prejoin,
416 Screen::Prejoin,
414 Screen::StatusMenu,
417 Screen::StatusMenu,
415 Screen::Call,
418 Screen::Call,
419 Screen::CallTranscript,
416 ];
420 ];
417 for screen in screens {
421 for screen in screens {
418 let (screen_name, status_menu) = match screen {
422 let (screen_name, status_menu) = match screen {
@@ -438,6 +442,32 @@ mod frames {
438 });
442 });
439 ("prejoin", false)
443 ("prejoin", false)
440 }
444 }
445 Screen::CallTranscript => {
446 visual.update(|window, cx| {
447 app.update(cx, |state, cx| {
448 let mut call = gallery_call();
449 call.model.apply(CallUpdate::Captions(CaptionState::On));
450 for index in 0..40 {
451 call.model.note_caption(
452 CaptionEntry {
453 id: format!("guard-{index}"),
454 user_id: "8:orgid:guard-0".into(),
455 display_name: "Guest 0".into(),
456 text: "A long guarded sentence that has to wrap inside the panel".into(),
457 is_final: true,
458 },
459 Instant::now(),
460 );
461 }
462 call.transcript_open = true;
463 state.call = Some(call);
464 let app_entity = cx.entity();
465 state.transcript_panel = Some(cx.new(|cx| TranscriptPanel::new(app_entity, window, cx)));
466 cx.notify();
467 })
468 });
469 ("call-transcript", false)
470 }
441 Screen::StatusMenu => {
471 Screen::StatusMenu => {
442 let tags = collect(&mut visual, None);
472 let tags = collect(&mut visual, None);
443 let button = tags
473 let button = tags
@@ -451,9 +481,12 @@ mod frames {
451 };
481 };
452 let tags = collect(&mut visual, status_menu.then_some(MENU));
482 let tags = collect(&mut visual, status_menu.then_some(MENU));
453 let mut expected = GUARDED.to_vec();
483 let mut expected = GUARDED.to_vec();
454 if screen_name == "call" {
484 if screen_name == "call" || screen_name == "call-transcript" {
455 expected.extend(CALL_GUARDED);
485 expected.extend(CALL_GUARDED);
456 }
486 }
487 if screen_name == "call-transcript" {
488 expected.push(CALL_TRANSCRIPT);
489 }
457 if status_menu {
490 if status_menu {
458 expected.push(MENU);
491 expected.push(MENU);
459 }
492 }
@@ -487,7 +520,7 @@ mod frames {
487 visual.simulate_keystrokes("escape");
520 visual.simulate_keystrokes("escape");
488 visual.run_until_parked();
521 visual.run_until_parked();
489 }
522 }
490 if screen_name == "call" {
523 if screen_name == "call" || screen_name == "call-transcript" {
491 visual.update(|_, cx| {
524 visual.update(|_, cx| {
492 app.update(cx, |state, cx| {
525 app.update(cx, |state, cx| {
493 state.call = None;
526 state.call = None;
crates/app/src/views/call_extras.rs +20 −11
@@ -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};
15use super::transfer_picker::TransferPicker;
15use super::transfer_picker::TransferPicker;
16use super::widgets::icon;
16use super::widgets::icon;
17use crate::app_state::AppState;
17use crate::app_state::AppState;
18use crate::call::{BackgroundPick, CallModel};
18use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};
19use crate::theme;
19use crate::theme;
20
20
21const STAGE_RADIUS: f32 = 12.;
21const STAGE_RADIUS: f32 = 12.;
@@ -31,7 +31,12 @@ fn dark_text() -> Hsla {
31}
31}
32
32
33pub fn recording_chip(model: &CallModel) -> Option<AnyElement> {
33pub 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
49pub fn return_button(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElement> {
54pub 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
267pub fn confirm_stop_recording(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {
272pub 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 alert
285 alert
277 .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 });
crates/app/src/views/call_organizer.rs +31 −29
@@ -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
14use super::avatar::person_avatar;
14use super::avatar::person_avatar;
15use super::call_extras::{
15use 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};
18use super::call_record::{record_submenu, transcript_and_settings_items};
18use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};
19use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};
19use super::widgets::icon;
20use super::widgets::icon;
20use crate::app_state::AppState;
21use crate::app_state::AppState;
21use crate::call::{CAPTION_SHOWN, CallModel, Focus};
22use crate::call::{CAPTION_SHOWN, CallModel, CaptionPosition, Focus};
22use crate::notice::truncated;
23use crate::notice::truncated;
23use crate::theme;
24use crate::theme;
24
25
@@ -28,6 +29,7 @@ const LOBBY_LIST_WIDTH: f32 = 340.;
28const LOBBY_NAME_LIMIT: usize = 28;
29const LOBBY_NAME_LIMIT: usize = 28;
29const CAPTION_WIDTH: f32 = 720.;
30const CAPTION_WIDTH: f32 = 720.;
30const CAPTION_BOTTOM: f32 = 2. * 16. + CONTROL_SIZE + 16.;
31const CAPTION_BOTTOM: f32 = 2. * 16. + CONTROL_SIZE + 16.;
32const CAPTION_TOP: f32 = 72.;
31const CAPTION_FADE_SECONDS: f32 = 1.;
33const CAPTION_FADE_SECONDS: f32 = 1.;
32const CAPTION_BACKGROUND: f32 = 0.72;
34const CAPTION_BACKGROUND: f32 = 0.72;
33const FOCUS_RADIUS: f32 = 12.;
35const FOCUS_RADIUS: f32 = 12.;
@@ -387,19 +389,25 @@ pub fn more_button(app: &Entity<AppState>, model: &CallModel) -> Option<AnyEleme
387 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
397fn more_menu(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {
399fn 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: &CallMo
436 )
444 )
437}
445}
438
446
439fn meeting_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {
447fn 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: &CallModel
448 );
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: &CallModel
474 }),
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: &CallModel
488 .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
494pub fn chevron_button(button_id: &'static str, face_id: &'static str) -> Button {
493pub 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.);
crates/app/src/views/call_record.rs added +175 −0
@@ -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 @@
1use calling::SPOKEN_LANGUAGES;
2use gpui_kit::assets::IconName;
3use gpui_kit::component::button::{Button, ButtonVariants as _};
4use gpui_kit::component::dialog::{Dialog, DialogFooter};
5use gpui_kit::component::menu::{PopupMenu, PopupMenuItem};
6use gpui_kit::component::{Icon, WindowExt as _, h_flex, v_flex};
7use gpui_kit::prelude::FluentBuilder as _;
8use gpui_kit::*;
9
10use super::call_extras::confirm_record_action;
11use super::call_transcript::TranscriptPanel;
12use crate::app_state::AppState;
13use crate::call::{CallModel, CaptionPosition, CaptionSize, record_actions};
14use crate::theme;
15
16const SETTINGS_WIDTH: f32 = 460.;
17const CHIP_HEIGHT: f32 = 30.;
18const SECTION_GAP: f32 = 14.;
19
20pub 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
46pub 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
61fn 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
67fn 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
94fn 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
107pub 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}
crates/app/src/views/call_transcript.rs added +198 −0
@@ -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 @@
1use gpui_kit::assets::IconName;
2use gpui_kit::component::{
3 h_flex,
4 input::{Input, InputEvent, InputState},
5 v_flex,
6};
7use gpui_kit::prelude::FluentBuilder as _;
8use gpui_kit::*;
9
10use super::call_view::side_panel;
11use super::widgets::icon;
12use crate::app_state::AppState;
13use crate::call::clock_label;
14use crate::theme;
15
16const SEARCH_HEIGHT: f32 = 34.;
17const AT_BOTTOM_SLACK: f32 = 4.;
18const EMPTY_TEXT: &str = "Nothing said yet. Spoken words appear here.";
19const NO_MATCH_TEXT: &str = "No entry matches the search.";
20
21pub 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
30impl 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
92impl 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}
crates/app/src/views/call_view.rs +26 −10
@@ -1180,6 +1180,7 @@ pub fn render_call_view(
1180 1180 .gap(px(ISLAND_GAP))
1181 1181 .child(column)
1182 1182 .children(chat.map(|chat| chat_panel(app, chat)))
1183 .children(call.transcript_open.then(|| state.transcript_panel.clone()).flatten())
1183 1184 .into_any_element(),
1184 1185 )
1185 1186 }
@@ -1198,11 +1199,29 @@ fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) ->
1198 1199
1199 1200 fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElement {
1200 1201 let app = app.clone();
1202 side_panel(
1203 "call-chat-panel",
1204 "Chat",
1205 "Close the chat",
1206 move |cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)),
1207 chat,
1208 )
1209 .into_any_element()
1210 }
1211
1212 pub fn side_panel(
1213 panel_id: &'static str,
1214 title: &'static str,
1215 close_tooltip: &'static str,
1216 on_close: impl Fn(&mut App) + 'static,
1217 body: impl IntoElement,
1218 ) -> Stateful<Div> {
1201 1219 v_flex()
1202 .id("call-chat-panel")
1220 .id(panel_id)
1203 1221 .w(px(CHAT_PANEL_WIDTH))
1204 1222 .h_full()
1205 .flex_none()
1223 .flex_shrink(1.)
1224 .min_w_0()
1206 1225 .rounded(px(10.))
1207 1226 .overflow_hidden()
1208 1227 .bg(theme::surface())
@@ -1219,11 +1238,11 @@ fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElem
1219 1238 div()
1220 1239 .text_size(px(15.))
1221 1240 .font_weight(FontWeight::SEMIBOLD)
1222 .child("Chat"),
1241 .child(title),
1223 1242 )
1224 1243 .child(
1225 1244 div()
1226 .id("call-chat-close")
1245 .id(ElementId::Name(format!("{panel_id}-close").into()))
1227 1246 .size(px(28.))
1228 1247 .flex()
1229 1248 .items_center()
@@ -1231,13 +1250,10 @@ fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElem
1231 1250 .rounded(px(7.))
1232 1251 .cursor_pointer()
1233 1252 .hover(|button| button.bg(theme::row_hover()))
1234 .tooltip(|window, cx| Tooltip::new("Close the chat").build(window, cx))
1253 .tooltip(move |window, cx| Tooltip::new(close_tooltip).build(window, cx))
1235 1254 .child(icon(IconName::Close, 14., theme::text_muted()))
1236 .on_click(move |_, _, cx| {
1237 app.update(cx, |state, cx| state.toggle_call_chat(cx))
1238 }),
1255 .on_click(move |_, _, cx| on_close(cx)),
1239 1256 ),
1240 1257 )
1241 .child(chat)
1242 .into_any_element()
1258 .child(body)
1243 1259 }
@@ -1180,6 +1180,7 @@ pub fn render_call_view(
1180 .gap(px(ISLAND_GAP))
1180 .gap(px(ISLAND_GAP))
1181 .child(column)
1181 .child(column)
1182 .children(chat.map(|chat| chat_panel(app, chat)))
1182 .children(chat.map(|chat| chat_panel(app, chat)))
1183 .children(call.transcript_open.then(|| state.transcript_panel.clone()).flatten())
1183 .into_any_element(),
1184 .into_any_element(),
1184 )
1185 )
1185}
1186}
@@ -1198,11 +1199,29 @@ fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) ->
1198
1199
1199fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElement {
1200fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElement {
1200 let app = app.clone();
1201 let app = app.clone();
1202 side_panel(
1203 "call-chat-panel",
1204 "Chat",
1205 "Close the chat",
1206 move |cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)),
1207 chat,
1208 )
1209 .into_any_element()
1210}
1211
1212pub fn side_panel(
1213 panel_id: &'static str,
1214 title: &'static str,
1215 close_tooltip: &'static str,
1216 on_close: impl Fn(&mut App) + 'static,
1217 body: impl IntoElement,
1218) -> Stateful<Div> {
1201 v_flex()
1219 v_flex()
1202 .id("call-chat-panel")
1220 .id(panel_id)
1203 .w(px(CHAT_PANEL_WIDTH))
1221 .w(px(CHAT_PANEL_WIDTH))
1204 .h_full()
1222 .h_full()
1205 .flex_none()
1223 .flex_shrink(1.)
1224 .min_w_0()
1206 .rounded(px(10.))
1225 .rounded(px(10.))
1207 .overflow_hidden()
1226 .overflow_hidden()
1208 .bg(theme::surface())
1227 .bg(theme::surface())
@@ -1219,11 +1238,11 @@ fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElem
1219 div()
1238 div()
1220 .text_size(px(15.))
1239 .text_size(px(15.))
1221 .font_weight(FontWeight::SEMIBOLD)
1240 .font_weight(FontWeight::SEMIBOLD)
1222 .child("Chat"),
1241 .child(title),
1223 )
1242 )
1224 .child(
1243 .child(
1225 div()
1244 div()
1226 .id("call-chat-close")
1245 .id(ElementId::Name(format!("{panel_id}-close").into()))
1227 .size(px(28.))
1246 .size(px(28.))
1228 .flex()
1247 .flex()
1229 .items_center()
1248 .items_center()
@@ -1231,13 +1250,10 @@ fn chat_panel(app: &Entity<AppState>, chat: Entity<ConversationView>) -> AnyElem
1231 .rounded(px(7.))
1250 .rounded(px(7.))
1232 .cursor_pointer()
1251 .cursor_pointer()
1233 .hover(|button| button.bg(theme::row_hover()))
1252 .hover(|button| button.bg(theme::row_hover()))
1234 .tooltip(|window, cx| Tooltip::new("Close the chat").build(window, cx))
1253 .tooltip(move |window, cx| Tooltip::new(close_tooltip).build(window, cx))
1235 .child(icon(IconName::Close, 14., theme::text_muted()))
1254 .child(icon(IconName::Close, 14., theme::text_muted()))
1236 .on_click(move |_, _, cx| {
1255 .on_click(move |_, _, cx| on_close(cx)),
1237 app.update(cx, |state, cx| state.toggle_call_chat(cx))
1238 }),
1239 ),
1256 ),
1240 )
1257 )
1241 .child(chat)
1258 .child(body)
1242 .into_any_element()
1243}
1259}
crates/app/src/views/mod.rs +2 −0
@@ -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;
10pub mod call_mini;
10pub mod call_mini;
11pub mod call_mini_window;
11pub mod call_mini_window;
12pub mod call_organizer;
12pub mod call_organizer;
13pub mod call_record;
13pub mod call_stage;
14pub mod call_stage;
15pub mod call_transcript;
14pub mod call_view;
16pub mod call_view;
15pub mod call_view_menu;
17pub mod call_view_menu;
16pub mod calls_tab;
18pub mod calls_tab;
crates/calling/examples/meet_now.rs +4 −4
@@ -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;
5use calling::relay::ic3_scope;
5use calling::relay::ic3_scope;
6use calling::signaling::{CHATSVC_REGION, fetch_self};
6use calling::signaling::{CHATSVC_REGION, fetch_self};
7use calling::{
7use 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};
11use chatsvc::InstanceNames;
11use chatsvc::InstanceNames;
12use serde_json::{Value, json};
12use 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);
crates/calling/src/call.rs +41 −13
@@ -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::{
@@ -822,7 +822,8 @@ async fn drive(
822 822 let mut caption_deadline: Option<Instant> = None;
823 823 let mut recording_flow = CaptionFlow::default();
824 824 let mut recording_deadline: Option<Instant> = None;
825 let mut recording_title = String::new();
825 let mut recording_plan = RecordingPlan::default();
826 let mut recording_audio_only = false;
826 827 let mut recording_status = RecordingStatus::default();
827 828 let mut bot_pending = false;
828 829 let mut consent_pending = false;
@@ -1021,14 +1022,19 @@ async fn drive(
1021 1022 if roster.caption_bot().is_some() {
1022 1023 bot_pending = false;
1023 1024 }
1025 let audio_only = roster.caption_bot().is_some_and(|bot| bot.recording && bot.audio_only);
1026 if audio_only != recording_audio_only {
1027 recording_audio_only = audio_only;
1028 control.send(CallUpdate::RecordingAudioOnly(audio_only));
1029 }
1024 1030 if caption_flow.wanted() {
1025 run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), "", &mut bot_pending, control, timeline).await;
1031 run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), &RecordingPlan::default(), &mut bot_pending, control, timeline).await;
1026 1032 if caption_flow.on() {
1027 1033 caption_deadline = None;
1028 1034 }
1029 1035 }
1030 1036 if recording_flow.wanted() {
1031 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_title, &mut bot_pending, control, timeline).await;
1037 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1032 1038 }
1033 1039 }
1034 1040 }
@@ -1063,6 +1069,12 @@ async fn drive(
1063 1069 recording_deadline = None;
1064 1070 }
1065 1071 }
1072 if let Some(on) = change.transcription {
1073 control.send(CallUpdate::Transcribing(on));
1074 if on {
1075 recording_deadline = None;
1076 }
1077 }
1066 1078 if let Some(required) = change.consent_required {
1067 1079 consent_pending = required;
1068 1080 control.send(CallUpdate::ConsentRequired(required));
@@ -1464,17 +1476,33 @@ async fn drive(
1464 1476 caption_deadline = None;
1465 1477 control.send(CallUpdate::Captions(CaptionState::Off));
1466 1478 }
1467 run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), "", &mut bot_pending, control, timeline).await;
1479 run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), &RecordingPlan::default(), &mut bot_pending, control, timeline).await;
1468 1480 if caption_flow.on() {
1469 1481 caption_deadline = None;
1470 1482 }
1471 1483 }
1472 Some(CallCommand::SetRecording { on, title }) => {
1484 Some(CallCommand::StartRecording { kind, title }) => {
1473 1485 if is_meeting {
1474 recording_title = title;
1475 recording_flow.want(on);
1476 recording_deadline = on.then(|| Instant::now() + RECORDING_START_LIMIT);
1477 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_title, &mut bot_pending, control, timeline).await;
1486 recording_plan = RecordingPlan { title, kind, ..RecordingPlan::default() };
1487 recording_flow.want(true);
1488 recording_deadline = Some(Instant::now() + RECORDING_START_LIMIT);
1489 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1490 }
1491 }
1492 Some(CallCommand::StopRecording { scope }) => {
1493 if is_meeting {
1494 recording_plan.scope = scope;
1495 recording_flow.stop();
1496 recording_deadline = None;
1497 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1498 }
1499 }
1500 Some(CallCommand::SetCaptionLanguage(language)) => {
1501 if let Some(url) = roster.caption_bot().and_then(|bot| bot.command_url.clone())
1502 && let Err(error) = remote.signaling.caption_language_command(&url, &remote.participant, &language).await
1503 {
1504 timeline.record("caption language failed", error.to_string());
1505 control.send(CallUpdate::Notice("Could not change the spoken language".into()));
1478 1506 }
1479 1507 }
1480 1508 Some(CallCommand::ConsentToRecording) => {
@@ -2036,7 +2064,7 @@ async fn run_bot_steps(
2036 2064 remote: &RemoteCall,
2037 2065 links: &CallbackLinks,
2038 2066 meeting_chat: Option<&str>,
2039 title: &str,
2067 plan: &RecordingPlan,
2040 2068 bot_pending: &mut bool,
2041 2069 control: &CallControl,
2042 2070 timeline: &Timeline,
@@ -2090,7 +2118,7 @@ async fn run_bot_steps(
2090 2118 }
2091 2119 }
2092 2120 BotJob::Recording => {
2093 let started = remote.signaling.recording_command(&url, BotAction::Start, &remote.participant, title).await;
2121 let started = remote.signaling.recording_command(&url, plan.start(), &remote.participant, &plan.title).await;
2094 2122 let failed = started.is_err();
2095 2123 report_organizer_result(started, "recording start", start_failure, control, timeline);
2096 2124 if failed {
@@ -2111,7 +2139,7 @@ async fn run_bot_steps(
2111 2139 }
2112 2140 }
2113 2141 BotJob::Recording => {
2114 let stopped = remote.signaling.recording_command(&url, BotAction::Stop, &remote.participant, title).await;
2142 let stopped = remote.signaling.recording_command(&url, plan.stop(), &remote.participant, &plan.title).await;
2115 2143 report_organizer_result(stopped, "recording stop", "The recording could not be stopped", control, timeline);
2116 2144 }
2117 2145 }
@@ -41,7 +41,7 @@ use crate::push::CallNotification;
41use crate::relay::{DEFAULT_RELAY_HOST, RelayGrant, fetch_relay_grant};
41use crate::relay::{DEFAULT_RELAY_HOST, RelayGrant, fetch_relay_grant};
42use crate::renegotiation::{MediaAction, MediaNegotiator, MediaPath};
42use crate::renegotiation::{MediaAction, MediaNegotiator, MediaPath};
43use crate::organizer::Target;
43use crate::organizer::Target;
44use crate::recording::{Consent, RecordingStatus};
44use crate::recording::{Consent, RecordingPlan, RecordingStatus};
45use crate::roster::Roster;
45use crate::roster::Roster;
46use crate::sdp::{LineRole, OfferPlan, RemoteOffer, SignaledOffer, from_teams_offer, stream_lines, to_browser_answer, to_teams_answer, to_teams_offer};
46use crate::sdp::{LineRole, OfferPlan, RemoteOffer, SignaledOffer, from_teams_offer, stream_lines, to_browser_answer, to_teams_answer, to_teams_offer};
47use crate::signaling::{
47use crate::signaling::{
@@ -822,7 +822,8 @@ async fn drive(
822 let mut caption_deadline: Option<Instant> = None;
822 let mut caption_deadline: Option<Instant> = None;
823 let mut recording_flow = CaptionFlow::default();
823 let mut recording_flow = CaptionFlow::default();
824 let mut recording_deadline: Option<Instant> = None;
824 let mut recording_deadline: Option<Instant> = None;
825 let mut recording_title = String::new();
825 let mut recording_plan = RecordingPlan::default();
826 let mut recording_audio_only = false;
826 let mut recording_status = RecordingStatus::default();
827 let mut recording_status = RecordingStatus::default();
827 let mut bot_pending = false;
828 let mut bot_pending = false;
828 let mut consent_pending = false;
829 let mut consent_pending = false;
@@ -1021,14 +1022,19 @@ async fn drive(
1021 if roster.caption_bot().is_some() {
1022 if roster.caption_bot().is_some() {
1022 bot_pending = false;
1023 bot_pending = false;
1023 }
1024 }
1025 let audio_only = roster.caption_bot().is_some_and(|bot| bot.recording && bot.audio_only);
1026 if audio_only != recording_audio_only {
1027 recording_audio_only = audio_only;
1028 control.send(CallUpdate::RecordingAudioOnly(audio_only));
1029 }
1024 if caption_flow.wanted() {
1030 if caption_flow.wanted() {
1025 run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), "", &mut bot_pending, control, timeline).await;
1031 run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), &RecordingPlan::default(), &mut bot_pending, control, timeline).await;
1026 if caption_flow.on() {
1032 if caption_flow.on() {
1027 caption_deadline = None;
1033 caption_deadline = None;
1028 }
1034 }
1029 }
1035 }
1030 if recording_flow.wanted() {
1036 if recording_flow.wanted() {
1031 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_title, &mut bot_pending, control, timeline).await;
1037 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1032 }
1038 }
1033 }
1039 }
1034 }
1040 }
@@ -1063,6 +1069,12 @@ async fn drive(
1063 recording_deadline = None;
1069 recording_deadline = None;
1064 }
1070 }
1065 }
1071 }
1072 if let Some(on) = change.transcription {
1073 control.send(CallUpdate::Transcribing(on));
1074 if on {
1075 recording_deadline = None;
1076 }
1077 }
1066 if let Some(required) = change.consent_required {
1078 if let Some(required) = change.consent_required {
1067 consent_pending = required;
1079 consent_pending = required;
1068 control.send(CallUpdate::ConsentRequired(required));
1080 control.send(CallUpdate::ConsentRequired(required));
@@ -1464,17 +1476,33 @@ async fn drive(
1464 caption_deadline = None;
1476 caption_deadline = None;
1465 control.send(CallUpdate::Captions(CaptionState::Off));
1477 control.send(CallUpdate::Captions(CaptionState::Off));
1466 }
1478 }
1467 run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), "", &mut bot_pending, control, timeline).await;
1479 run_bot_steps(BotJob::Captions, &mut caption_flow, &roster, &remote, &links, meeting_chat.as_deref(), &RecordingPlan::default(), &mut bot_pending, control, timeline).await;
1468 if caption_flow.on() {
1480 if caption_flow.on() {
1469 caption_deadline = None;
1481 caption_deadline = None;
1470 }
1482 }
1471 }
1483 }
1472 Some(CallCommand::SetRecording { on, title }) => {
1484 Some(CallCommand::StartRecording { kind, title }) => {
1473 if is_meeting {
1485 if is_meeting {
1474 recording_title = title;
1486 recording_plan = RecordingPlan { title, kind, ..RecordingPlan::default() };
1475 recording_flow.want(on);
1487 recording_flow.want(true);
1476 recording_deadline = on.then(|| Instant::now() + RECORDING_START_LIMIT);
1488 recording_deadline = Some(Instant::now() + RECORDING_START_LIMIT);
1477 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_title, &mut bot_pending, control, timeline).await;
1489 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1490 }
1491 }
1492 Some(CallCommand::StopRecording { scope }) => {
1493 if is_meeting {
1494 recording_plan.scope = scope;
1495 recording_flow.stop();
1496 recording_deadline = None;
1497 run_bot_steps(BotJob::Recording, &mut recording_flow, &roster, &remote, &links, meeting_chat.as_deref(), &recording_plan, &mut bot_pending, control, timeline).await;
1498 }
1499 }
1500 Some(CallCommand::SetCaptionLanguage(language)) => {
1501 if let Some(url) = roster.caption_bot().and_then(|bot| bot.command_url.clone())
1502 && let Err(error) = remote.signaling.caption_language_command(&url, &remote.participant, &language).await
1503 {
1504 timeline.record("caption language failed", error.to_string());
1505 control.send(CallUpdate::Notice("Could not change the spoken language".into()));
1478 }
1506 }
1479 }
1507 }
1480 Some(CallCommand::ConsentToRecording) => {
1508 Some(CallCommand::ConsentToRecording) => {
@@ -2036,7 +2064,7 @@ async fn run_bot_steps(
2036 remote: &RemoteCall,
2064 remote: &RemoteCall,
2037 links: &CallbackLinks,
2065 links: &CallbackLinks,
2038 meeting_chat: Option<&str>,
2066 meeting_chat: Option<&str>,
2039 title: &str,
2067 plan: &RecordingPlan,
2040 bot_pending: &mut bool,
2068 bot_pending: &mut bool,
2041 control: &CallControl,
2069 control: &CallControl,
2042 timeline: &Timeline,
2070 timeline: &Timeline,
@@ -2090,7 +2118,7 @@ async fn run_bot_steps(
2090 }
2118 }
2091 }
2119 }
2092 BotJob::Recording => {
2120 BotJob::Recording => {
2093 let started = remote.signaling.recording_command(&url, BotAction::Start, &remote.participant, title).await;
2121 let started = remote.signaling.recording_command(&url, plan.start(), &remote.participant, &plan.title).await;
2094 let failed = started.is_err();
2122 let failed = started.is_err();
2095 report_organizer_result(started, "recording start", start_failure, control, timeline);
2123 report_organizer_result(started, "recording start", start_failure, control, timeline);
2096 if failed {
2124 if failed {
@@ -2111,7 +2139,7 @@ async fn run_bot_steps(
2111 }
2139 }
2112 }
2140 }
2113 BotJob::Recording => {
2141 BotJob::Recording => {
2114 let stopped = remote.signaling.recording_command(&url, BotAction::Stop, &remote.participant, title).await;
2142 let stopped = remote.signaling.recording_command(&url, plan.stop(), &remote.participant, &plan.title).await;
2115 report_organizer_result(stopped, "recording stop", "The recording could not be stopped", control, timeline);
2143 report_organizer_result(stopped, "recording stop", "The recording could not be stopped", control, timeline);
2116 }
2144 }
2117 }
2145 }
crates/calling/src/captions.rs +59 −1
@@ -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
133pub 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
148pub 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
133pub fn endpoint_metadata(captions: bool) -> Value {
160pub 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.wanted
196 self.wanted
164 }
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);
crates/calling/src/control.rs +6 −1
@@ -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;
@@ -52,7 +53,9 @@ pub enum CallCommand {
52 53 SetIncomingVideo(bool),
53 54 SetCameraEffects(CameraEffects),
54 55 SendReaction(Reaction),
55 SetRecording { on: bool, title: String },
56 StartRecording { kind: RecordingKind, title: String },
57 StopRecording { scope: StopScope },
58 SetCaptionLanguage(String),
56 59 ConsentToRecording,
57 60 Hold(bool),
58 61 Transfer { target: Callee, replaces: Option<String> },
@@ -96,6 +99,8 @@ pub enum CallUpdate {
96 99 Health(CallHealth),
97 100 IncomingVideo(bool),
98 101 Recording(bool),
102 RecordingAudioOnly(bool),
103 Transcribing(bool),
99 104 ConsentRequired(bool),
100 105 Hold(HoldState),
101 106 Whiteboard(Option<ContentShare>),
@@ -7,6 +7,7 @@ use crate::background::BackgroundChoice;
7use crate::effects::CameraEffects;
7use crate::effects::CameraEffects;
8use crate::breakout::BreakoutMove;
8use crate::breakout::BreakoutMove;
9use crate::captions::{CaptionEntry, CaptionState};
9use crate::captions::{CaptionEntry, CaptionState};
10use crate::recording::{RecordingKind, StopScope};
10use crate::devices::{DeviceChoice, DeviceLists};
11use crate::devices::{DeviceChoice, DeviceLists};
11use crate::error::{Error, Result};
12use crate::error::{Error, Result};
12use crate::health::CallHealth;
13use crate::health::CallHealth;
@@ -52,7 +53,9 @@ pub enum CallCommand {
52 SetIncomingVideo(bool),
53 SetIncomingVideo(bool),
53 SetCameraEffects(CameraEffects),
54 SetCameraEffects(CameraEffects),
54 SendReaction(Reaction),
55 SendReaction(Reaction),
55 SetRecording { on: bool, title: String },
56 StartRecording { kind: RecordingKind, title: String },
57 StopRecording { scope: StopScope },
58 SetCaptionLanguage(String),
56 ConsentToRecording,
59 ConsentToRecording,
57 Hold(bool),
60 Hold(bool),
58 Transfer { target: Callee, replaces: Option<String> },
61 Transfer { target: Callee, replaces: Option<String> },
@@ -96,6 +99,8 @@ pub enum CallUpdate {
96 Health(CallHealth),
99 Health(CallHealth),
97 IncomingVideo(bool),
100 IncomingVideo(bool),
98 Recording(bool),
101 Recording(bool),
102 RecordingAudioOnly(bool),
103 Transcribing(bool),
99 ConsentRequired(bool),
104 ConsentRequired(bool),
100 Hold(HoldState),
105 Hold(HoldState),
101 Whiteboard(Option<ContentShare>),
106 Whiteboard(Option<ContentShare>),
crates/calling/src/lib.rs +2 −1
@@ -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};
66pub use push::Caller;
66pub use push::Caller;
67pub use ring::{RING_TIMEOUT, RingEnd, RingSignal, RingState};
67pub use ring::{RING_TIMEOUT, RingEnd, RingSignal, RingState};
68pub use reaction::{Reaction, ReactionEvent};
68pub use reaction::{Reaction, ReactionEvent};
69pub use captions::{CaptionEntry, CaptionState};
69pub use captions::{CaptionEntry, CaptionState, SPOKEN_LANGUAGES};
70pub use recording::{RecordingKind, StopScope};
70pub use roster::{PublishedState, RaisedHand, RosterEntry, Spotlight};
71pub use roster::{PublishedState, RaisedHand, RosterEntry, Spotlight};
71pub use sound_capture::LoopbackKind;
72pub use sound_capture::LoopbackKind;
72pub use renegotiation::MediaPath;
73pub use renegotiation::MediaPath;
crates/calling/src/recording.rs +182 −54
@@ -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 @@
1use serde_json::{Value, json};
1use serde_json::{Value, json};
2
2
3use crate::captions::{BotAction, recorder_features};
3use crate::captions::recorder_features;
4use crate::trouter_events::find_key;
4use crate::trouter_events::find_key;
5
5
6const CLOUD_RECORDING: &str = "cloudRecording";
6const CLOUD_RECORDING: &str = "cloudRecording";
7const TRANSCRIPTION: &str = "transcription";
7const CONSENT_DETAILS: &str = "recordingConsentDetails";
8const CONSENT_DETAILS: &str = "recordingConsentDetails";
8const ACTIVE: &str = "Active";
9const ACTIVE: &str = "Active";
9const PROCESSING_MODES: [&str; 2] = ["recording", "realTimeTranscript"];
10const RECORDING_AND_TRANSCRIPT: [&str; 2] = ["recording", "realTimeTranscript"];
11const RECORDING_ONLY: [&str; 1] = ["recording"];
12const TRANSCRIPT_ONLY: [&str; 1] = ["realTimeTranscript"];
13const TRANSCRIPTION_MODE: &str = "transcription";
14const RECORDING_MODE_KEY: &str = "recording";
10const STORAGE_TYPE: &str = "OnedriveForBusiness";
15const STORAGE_TYPE: &str = "OnedriveForBusiness";
11const STORAGE_LOCATION: &str = "Recordings";
16const STORAGE_LOCATION: &str = "Recordings";
12const RECORDING_MODE: &str = "Normal";
17const VIDEO_MODE: &str = "Normal";
18const AUDIO_ONLY_MODE: &str = "AudioOnly";
13const FILE_SUFFIX: &str = "Meeting Recording";
19const FILE_SUFFIX: &str = "Meeting Recording";
14const CONSENT_STATE: &str = "consentToRecording";
20const CONSENT_STATE: &str = "consentToRecording";
15const DENY_STATE: &str = "denyConsentToRecording";
21const 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)]
18pub struct StateChange {
24pub 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
23impl StateChange {
30impl 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)]
30pub struct RecordingStatus {
37pub 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
36impl RecordingStatus {
45impl RecordingStatus {
@@ -38,24 +47,37 @@ impl RecordingStatus {
38 self.active
47 self.active
39 }
48 }
40
49
50 pub fn transcribing(&self) -> bool {
51 self.transcribing
52 }
53
41 pub fn consent_required(&self) -> bool {
54 pub fn consent_required(&self) -> bool {
42 self.consent_required
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 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.active
49 let current = state["value"]["State"].as_str().map(|name| name == ACTIVE);
72 {
50 if let Some(current) = current
73 self.active = current;
51 && sequence >= self.sequence
74 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.transcribing
55 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_required
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)]
93pub enum RecordingKind {
94 #[default]
95 Video,
96 AudioOnly,
97 TranscriptOnly,
98}
99
100#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
101pub enum StopScope {
102 #[default]
103 Both,
104 RecordingOnly,
105 TranscriptionOnly,
106}
107
108#[derive(Debug, Clone, Copy, PartialEq, Eq)]
109pub enum RecordingCommand {
110 Start(RecordingKind),
111 Stop(StopScope),
112}
113
114#[derive(Debug, Clone, Default)]
115pub struct RecordingPlan {
116 pub title: String,
117 pub kind: RecordingKind,
118 pub scope: StopScope,
119}
120
121impl 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)]
71pub struct StartDetails<'a> {
132pub 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.
82pub fn start_body(details: StartDetails<'_>) -> Value {
143pub 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 body
100 "recordingMode": RECORDING_MODE,
101 "spokenLanguage": "",
102 "type": "start",
103 },
104 })
105}
175}
106
176
107pub fn stop_body(own_mri: &str, participant_leg_id: &str, timestamp: &str) -> Value {
177pub 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 body
115}
196}
116
197
117pub fn command_body(action: BotAction, details: StartDetails<'_>) -> Value {
198pub 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]
crates/calling/src/roster.rs +15 −1
@@ -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
230fn published_state(participant: &Value, endpoints: &[&Value], state_type: &str) -> Option<PublishedState> {
232fn 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();
crates/calling/src/signaling.rs +10 −3
@@ -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, &timestamp, 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};
4use session::{ApiResponse, App, GRAPH, Method, Request, SPACES, Scope, Session};
4use session::{ApiResponse, App, GRAPH, Method, Request, SPACES, Scope, Session};
5
5
6use crate::captions::{self, BotAction};
6use crate::captions::{self, BotAction};
7use crate::recording::{self, Consent, StartDetails};
7use crate::recording::{self, Consent, RecordingCommand, StartDetails};
8use crate::transfer::{self, TransferTarget};
8use crate::transfer::{self, TransferTarget};
9use crate::error::{Error, Result};
9use crate::error::{Error, Result};
10use crate::organizer::{self, Target};
10use 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, &timestamp, 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").await
513 self.bot_command(command_url, recording::command_body(command, details), "recording command").await
507 }
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> {