BlueGit

ict rusty-teams

fix(calls): speaker view holds the stage, no-video speakers stay briefly, bubbles bottom right

- Speaker stage switches only after 0.8 s of speech and holds 1.5 s after silence
- Hide people without video keeps a speaker visible 3 s after they stop
- Narrow filmstrip puts recent speakers first
- Esc that a menu handled no longer leaves full screen
- Chat bubbles move to the bottom right, clear of name plates

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
26cbacb1c915cd8f7f5692a48416a598d301c61d
Parent
7da9ed2a
5 files changed +80 −12
crates/app/src/call/mod.rs +1 −1
@@ -51,6 +51,6 @@ pub use model::{
51 51 pub use overlay::CallWindows;
52 52 pub use preview::{CameraPreview, preview_backgrounds};
53 53 pub use ring::{MissedCall, RingEntry, Rings};
54 pub use stage_layout::{GALLERY_MAX, filmstrip, gallery_grid, split_overflow};
54 pub use stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, filmstrip, gallery_grid, split_overflow};
55 55 pub use target::plan_for_chat;
56 56 pub use view_settings::{CallLayout, ViewSettings};
@@ -51,6 +51,6 @@ pub use model::{
51pub use overlay::CallWindows;
51pub use overlay::CallWindows;
52pub use preview::{CameraPreview, preview_backgrounds};
52pub use preview::{CameraPreview, preview_backgrounds};
53pub use ring::{MissedCall, RingEntry, Rings};
53pub use ring::{MissedCall, RingEntry, Rings};
54pub use stage_layout::{GALLERY_MAX, filmstrip, gallery_grid, split_overflow};
54pub use stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, filmstrip, gallery_grid, split_overflow};
55pub use target::plan_for_chat;
55pub use target::plan_for_chat;
56pub use view_settings::{CallLayout, ViewSettings};
56pub use view_settings::{CallLayout, ViewSettings};
crates/app/src/call/model.rs +37 −7
@@ -15,7 +15,7 @@ use super::health::{HealthBanner, HealthState};
15 15 use super::bubbles::ChatBubble;
16 16 use super::fullscreen::FullscreenState;
17 17 use super::pictures::CallPictures;
18 use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, VisibleRotation, split_overflow};
18 use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};
19 19 use super::view_settings::{CallLayout, ViewSettings};
20 20 use super::push_to_talk::PushToTalk;
21 21
@@ -277,6 +277,8 @@ pub struct CallModel {
277 277 pub meeting_chat: Option<String>,
278 278 pub view: ViewSettings,
279 279 rotation: VisibleRotation,
280 stage_speaker: Option<String>,
281 recent_speakers: Vec<String>,
280 282 local_detector: SpeakingDetector,
281 283 remote_detector: SpeakingDetector,
282 284 }
@@ -329,6 +331,8 @@ impl CallModel {
329 331 meeting_chat: None,
330 332 view: ViewSettings::default(),
331 333 rotation: VisibleRotation::default(),
334 stage_speaker: None,
335 recent_speakers: Vec::new(),
332 336 local_detector: SpeakingDetector::default(),
333 337 remote_detector: SpeakingDetector::default(),
334 338 }
@@ -765,6 +769,7 @@ impl CallModel {
765 769 && !tile.has_video
766 770 && !self.is_pinned(&tile.mri)
767 771 && !self.tile_speaking(tile)
772 && !self.recent_speakers.contains(&tile.mri)
768 773 }
769 774
770 775 pub fn hidden_without_video(&self) -> usize {
@@ -800,6 +805,10 @@ impl CallModel {
800 805 ordered
801 806 }
802 807
808 pub fn is_recent_speaker(&self, mri: &str) -> bool {
809 self.recent_speakers.iter().any(|recent| recent == mri)
810 }
811
803 812 pub fn own_cells(&self) -> usize {
804 813 usize::from(!self.view.hide_me)
805 814 }
@@ -827,8 +836,30 @@ impl CallModel {
827 836 .collect();
828 837 let capacity = self.rotation_capacity(members.len());
829 838 let speaking = self.speaking_mris.clone();
830 self.rotation
831 .update(now, &members, &priority, &speaking, capacity)
839 let reordered = self
840 .rotation
841 .update(now, &members, &priority, &speaking, capacity);
842 let recent: Vec<String> = self
843 .tiles
844 .iter()
845 .filter(|tile| self.rotation.spoke_within(&tile.mri, now, RECENT_SPEAKER))
846 .map(|tile| tile.mri.clone())
847 .collect();
848 let held = self.stage_speaker.as_deref().is_some_and(|mri| {
849 members.iter().any(|member| member == mri) && self.rotation.spoke_within(mri, now, SPEAKER_HOLD)
850 });
851 let stage_speaker = if held {
852 self.stage_speaker.clone()
853 } else {
854 self.rotation
855 .steady_speaker(now, &members)
856 .map(str::to_owned)
857 .or_else(|| self.stage_speaker.clone().filter(|mri| members.contains(mri)))
858 };
859 let changed = reordered || recent != self.recent_speakers || stage_speaker != self.stage_speaker;
860 self.recent_speakers = recent;
861 self.stage_speaker = stage_speaker;
862 changed
832 863 }
833 864
834 865 pub fn speaker_focus(&self) -> Option<Focus> {
@@ -837,10 +868,9 @@ impl CallModel {
837 868 }
838 869 let tiles = self.layout_tiles();
839 870 let spoken = self
840 .speaking_mris
841 .iter()
842 .find(|mri| tiles.iter().any(|tile| &tile.mri == *mri))
843 .map(String::as_str)
871 .stage_speaker
872 .as_deref()
873 .filter(|mri| tiles.iter().any(|tile| tile.mri == *mri))
844 874 .or_else(|| {
845 875 self.rotation
846 876 .last_speaker()
@@ -15,7 +15,7 @@ use super::health::{HealthBanner, HealthState};
15use super::bubbles::ChatBubble;
15use 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, VisibleRotation, split_overflow};
18use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};
19use super::view_settings::{CallLayout, ViewSettings};
19use super::view_settings::{CallLayout, ViewSettings};
20use super::push_to_talk::PushToTalk;
20use super::push_to_talk::PushToTalk;
21
21
@@ -277,6 +277,8 @@ pub struct CallModel {
277 pub meeting_chat: Option<String>,
277 pub meeting_chat: Option<String>,
278 pub view: ViewSettings,
278 pub view: ViewSettings,
279 rotation: VisibleRotation,
279 rotation: VisibleRotation,
280 stage_speaker: Option<String>,
281 recent_speakers: Vec<String>,
280 local_detector: SpeakingDetector,
282 local_detector: SpeakingDetector,
281 remote_detector: SpeakingDetector,
283 remote_detector: SpeakingDetector,
282}
284}
@@ -329,6 +331,8 @@ impl CallModel {
329 meeting_chat: None,
331 meeting_chat: None,
330 view: ViewSettings::default(),
332 view: ViewSettings::default(),
331 rotation: VisibleRotation::default(),
333 rotation: VisibleRotation::default(),
334 stage_speaker: None,
335 recent_speakers: Vec::new(),
332 local_detector: SpeakingDetector::default(),
336 local_detector: SpeakingDetector::default(),
333 remote_detector: SpeakingDetector::default(),
337 remote_detector: SpeakingDetector::default(),
334 }
338 }
@@ -765,6 +769,7 @@ impl CallModel {
765 && !tile.has_video
769 && !tile.has_video
766 && !self.is_pinned(&tile.mri)
770 && !self.is_pinned(&tile.mri)
767 && !self.tile_speaking(tile)
771 && !self.tile_speaking(tile)
772 && !self.recent_speakers.contains(&tile.mri)
768 }
773 }
769
774
770 pub fn hidden_without_video(&self) -> usize {
775 pub fn hidden_without_video(&self) -> usize {
@@ -800,6 +805,10 @@ impl CallModel {
800 ordered
805 ordered
801 }
806 }
802
807
808 pub fn is_recent_speaker(&self, mri: &str) -> bool {
809 self.recent_speakers.iter().any(|recent| recent == mri)
810 }
811
803 pub fn own_cells(&self) -> usize {
812 pub fn own_cells(&self) -> usize {
804 usize::from(!self.view.hide_me)
813 usize::from(!self.view.hide_me)
805 }
814 }
@@ -827,8 +836,30 @@ impl CallModel {
827 .collect();
836 .collect();
828 let capacity = self.rotation_capacity(members.len());
837 let capacity = self.rotation_capacity(members.len());
829 let speaking = self.speaking_mris.clone();
838 let speaking = self.speaking_mris.clone();
830 self.rotation
839 let reordered = self
831 .update(now, &members, &priority, &speaking, capacity)
840 .rotation
841 .update(now, &members, &priority, &speaking, capacity);
842 let recent: Vec<String> = self
843 .tiles
844 .iter()
845 .filter(|tile| self.rotation.spoke_within(&tile.mri, now, RECENT_SPEAKER))
846 .map(|tile| tile.mri.clone())
847 .collect();
848 let held = self.stage_speaker.as_deref().is_some_and(|mri| {
849 members.iter().any(|member| member == mri) && self.rotation.spoke_within(mri, now, SPEAKER_HOLD)
850 });
851 let stage_speaker = if held {
852 self.stage_speaker.clone()
853 } else {
854 self.rotation
855 .steady_speaker(now, &members)
856 .map(str::to_owned)
857 .or_else(|| self.stage_speaker.clone().filter(|mri| members.contains(mri)))
858 };
859 let changed = reordered || recent != self.recent_speakers || stage_speaker != self.stage_speaker;
860 self.recent_speakers = recent;
861 self.stage_speaker = stage_speaker;
862 changed
832 }
863 }
833
864
834 pub fn speaker_focus(&self) -> Option<Focus> {
865 pub fn speaker_focus(&self) -> Option<Focus> {
@@ -837,10 +868,9 @@ impl CallModel {
837 }
868 }
838 let tiles = self.layout_tiles();
869 let tiles = self.layout_tiles();
839 let spoken = self
870 let spoken = self
840 .speaking_mris
871 .stage_speaker
841 .iter()
872 .as_deref()
842 .find(|mri| tiles.iter().any(|tile| &tile.mri == *mri))
873 .filter(|mri| tiles.iter().any(|tile| tile.mri == *mri))
843 .map(String::as_str)
844 .or_else(|| {
874 .or_else(|| {
845 self.rotation
875 self.rotation
846 .last_speaker()
876 .last_speaker()
crates/app/src/call/stage_layout.rs +34 −0
@@ -6,6 +6,9 @@ pub const FILMSTRIP_MAX: usize = 6;
6 6 pub const FILMSTRIP_MIN_WIDTH: f32 = 160.;
7 7 pub const SWAP_AFTER_SPEAKING: Duration = Duration::from_secs(2);
8 8 pub const SWAP_INTERVAL: Duration = Duration::from_secs(5);
9 pub const SPEAKER_HOLD: Duration = Duration::from_millis(1500);
10 pub const SPEAKER_SWITCH_AFTER: Duration = Duration::from_millis(800);
11 pub const RECENT_SPEAKER: Duration = Duration::from_secs(3);
9 12 const TILE_ASPECT: f32 = 16. / 9.;
10 13
11 14 #[derive(Debug, Clone, Copy, PartialEq)]
@@ -106,6 +109,22 @@ impl VisibleRotation {
106 109 .map(|(mri, _)| mri.as_str())
107 110 }
108 111
112 pub fn spoke_within(&self, mri: &str, now: Instant, window: Duration) -> bool {
113 self.last_spoke
114 .get(mri)
115 .is_some_and(|spoke| now.saturating_duration_since(*spoke) <= window)
116 }
117
118 pub fn steady_speaker(&self, now: Instant, members: &[String]) -> Option<&str> {
119 self.speaking_since
120 .iter()
121 .filter(|(mri, since)| {
122 members.contains(mri) && now.saturating_duration_since(**since) >= SPEAKER_SWITCH_AFTER
123 })
124 .min_by_key(|(_, since)| **since)
125 .map(|(mri, _)| mri.as_str())
126 }
127
109 128 pub fn update(
110 129 &mut self,
111 130 now: Instant,
@@ -212,6 +231,21 @@ mod tests {
212 231 mris.iter().map(|mri| (*mri).to_owned()).collect()
213 232 }
214 233
234 #[test]
235 fn steady_speaker_needs_a_moment_of_speech_and_stays_recent_after() {
236 let start = Instant::now();
237 let members = names(4);
238 let mut rotation = VisibleRotation::default();
239 rotation.update(start, &members, &[], &speak(&["p2"]), 4);
240 assert_eq!(rotation.steady_speaker(start + Duration::from_millis(300), &members), None);
241 rotation.update(start + SPEAKER_SWITCH_AFTER, &members, &[], &speak(&["p2"]), 4);
242 assert_eq!(rotation.steady_speaker(start + SPEAKER_SWITCH_AFTER, &members), Some("p2"));
243 let silent = start + SPEAKER_SWITCH_AFTER + Duration::from_secs(1);
244 rotation.update(silent, &members, &[], &[], 4);
245 assert!(rotation.spoke_within("p2", silent, SPEAKER_HOLD));
246 assert!(!rotation.spoke_within("p2", silent + RECENT_SPEAKER, RECENT_SPEAKER));
247 }
248
215 249 #[test]
216 250 fn a_single_tile_takes_the_whole_stage() {
217 251 let grid = gallery_grid(1, 1600., 900., 20.);
@@ -6,6 +6,9 @@ pub const FILMSTRIP_MAX: usize = 6;
6pub const FILMSTRIP_MIN_WIDTH: f32 = 160.;
6pub const FILMSTRIP_MIN_WIDTH: f32 = 160.;
7pub const SWAP_AFTER_SPEAKING: Duration = Duration::from_secs(2);
7pub const SWAP_AFTER_SPEAKING: Duration = Duration::from_secs(2);
8pub const SWAP_INTERVAL: Duration = Duration::from_secs(5);
8pub const SWAP_INTERVAL: Duration = Duration::from_secs(5);
9pub const SPEAKER_HOLD: Duration = Duration::from_millis(1500);
10pub const SPEAKER_SWITCH_AFTER: Duration = Duration::from_millis(800);
11pub const RECENT_SPEAKER: Duration = Duration::from_secs(3);
9const TILE_ASPECT: f32 = 16. / 9.;
12const TILE_ASPECT: f32 = 16. / 9.;
10
13
11#[derive(Debug, Clone, Copy, PartialEq)]
14#[derive(Debug, Clone, Copy, PartialEq)]
@@ -106,6 +109,22 @@ impl VisibleRotation {
106 .map(|(mri, _)| mri.as_str())
109 .map(|(mri, _)| mri.as_str())
107 }
110 }
108
111
112 pub fn spoke_within(&self, mri: &str, now: Instant, window: Duration) -> bool {
113 self.last_spoke
114 .get(mri)
115 .is_some_and(|spoke| now.saturating_duration_since(*spoke) <= window)
116 }
117
118 pub fn steady_speaker(&self, now: Instant, members: &[String]) -> Option<&str> {
119 self.speaking_since
120 .iter()
121 .filter(|(mri, since)| {
122 members.contains(mri) && now.saturating_duration_since(**since) >= SPEAKER_SWITCH_AFTER
123 })
124 .min_by_key(|(_, since)| **since)
125 .map(|(mri, _)| mri.as_str())
126 }
127
109 pub fn update(
128 pub fn update(
110 &mut self,
129 &mut self,
111 now: Instant,
130 now: Instant,
@@ -212,6 +231,21 @@ mod tests {
212 mris.iter().map(|mri| (*mri).to_owned()).collect()
231 mris.iter().map(|mri| (*mri).to_owned()).collect()
213 }
232 }
214
233
234 #[test]
235 fn steady_speaker_needs_a_moment_of_speech_and_stays_recent_after() {
236 let start = Instant::now();
237 let members = names(4);
238 let mut rotation = VisibleRotation::default();
239 rotation.update(start, &members, &[], &speak(&["p2"]), 4);
240 assert_eq!(rotation.steady_speaker(start + Duration::from_millis(300), &members), None);
241 rotation.update(start + SPEAKER_SWITCH_AFTER, &members, &[], &speak(&["p2"]), 4);
242 assert_eq!(rotation.steady_speaker(start + SPEAKER_SWITCH_AFTER, &members), Some("p2"));
243 let silent = start + SPEAKER_SWITCH_AFTER + Duration::from_secs(1);
244 rotation.update(silent, &members, &[], &[], 4);
245 assert!(rotation.spoke_within("p2", silent, SPEAKER_HOLD));
246 assert!(!rotation.spoke_within("p2", silent + RECENT_SPEAKER, RECENT_SPEAKER));
247 }
248
215 #[test]
249 #[test]
216 fn a_single_tile_takes_the_whole_stage() {
250 fn a_single_tile_takes_the_whole_stage() {
217 let grid = gallery_grid(1, 1600., 900., 20.);
251 let grid = gallery_grid(1, 1600., 900., 20.);
crates/app/src/views/call_layouts.rs +7 −3
@@ -19,7 +19,7 @@ use super::call_view::{
19 19 use super::widgets::icon;
20 20 use crate::app_state::AppState;
21 21 use crate::call::{
22 ActiveCall, CallLayout, CallModel, GALLERY_MAX, Tile, TileSize, filmstrip, gallery_grid,
22 ActiveCall, CallLayout, CallModel, FILMSTRIP_MAX, GALLERY_MAX, Tile, TileSize, filmstrip, gallery_grid,
23 23 shown_bubbles, split_overflow,
24 24 };
25 25 use crate::theme;
@@ -159,8 +159,9 @@ fn chat_bubbles(
159 159 Some(
160 160 v_flex()
161 161 .absolute()
162 .left(px(OVERLAY_INSET))
162 .right(px(OVERLAY_INSET))
163 163 .bottom(px(bottom))
164 .items_end()
164 165 .gap(px(BUBBLE_GAP))
165 166 .children(bubbles.into_iter().map(|bubble| {
166 167 let app = app.clone();
@@ -410,7 +411,7 @@ fn speaker_body(
410 411 let main = focus
411 412 .as_ref()
412 413 .and_then(|focus| render_focus_stage(app, state, focus, now));
413 let others: Vec<&Tile> = model
414 let mut others: Vec<&Tile> = model
414 415 .layout_tiles()
415 416 .into_iter()
416 417 .filter(|tile| Some(tile.mri.as_str()) != focus_mri)
@@ -423,6 +424,9 @@ fn speaker_body(
423 424 TILE_GAP,
424 425 FILMSTRIP_TILE_MAX,
425 426 );
427 if plan.overflow.shown < FILMSTRIP_MAX.min(others.len()) {
428 others.sort_by_key(|tile| !model.is_recent_speaker(&tile.mri));
429 }
426 430 let size = TileSize::sixteen_by_nine(plan.tile_width.floor());
427 431 let shown = &others[..plan.overflow.shown];
428 432 let mut tiles: Vec<AnyElement> = shown
@@ -19,7 +19,7 @@ use super::call_view::{
19use super::widgets::icon;
19use super::widgets::icon;
20use crate::app_state::AppState;
20use crate::app_state::AppState;
21use crate::call::{
21use crate::call::{
22 ActiveCall, CallLayout, CallModel, GALLERY_MAX, Tile, TileSize, filmstrip, gallery_grid,
22 ActiveCall, CallLayout, CallModel, FILMSTRIP_MAX, GALLERY_MAX, Tile, TileSize, filmstrip, gallery_grid,
23 shown_bubbles, split_overflow,
23 shown_bubbles, split_overflow,
24};
24};
25use crate::theme;
25use crate::theme;
@@ -159,8 +159,9 @@ fn chat_bubbles(
159 Some(
159 Some(
160 v_flex()
160 v_flex()
161 .absolute()
161 .absolute()
162 .left(px(OVERLAY_INSET))
162 .right(px(OVERLAY_INSET))
163 .bottom(px(bottom))
163 .bottom(px(bottom))
164 .items_end()
164 .gap(px(BUBBLE_GAP))
165 .gap(px(BUBBLE_GAP))
165 .children(bubbles.into_iter().map(|bubble| {
166 .children(bubbles.into_iter().map(|bubble| {
166 let app = app.clone();
167 let app = app.clone();
@@ -410,7 +411,7 @@ fn speaker_body(
410 let main = focus
411 let main = focus
411 .as_ref()
412 .as_ref()
412 .and_then(|focus| render_focus_stage(app, state, focus, now));
413 .and_then(|focus| render_focus_stage(app, state, focus, now));
413 let others: Vec<&Tile> = model
414 let mut others: Vec<&Tile> = model
414 .layout_tiles()
415 .layout_tiles()
415 .into_iter()
416 .into_iter()
416 .filter(|tile| Some(tile.mri.as_str()) != focus_mri)
417 .filter(|tile| Some(tile.mri.as_str()) != focus_mri)
@@ -423,6 +424,9 @@ fn speaker_body(
423 TILE_GAP,
424 TILE_GAP,
424 FILMSTRIP_TILE_MAX,
425 FILMSTRIP_TILE_MAX,
425 );
426 );
427 if plan.overflow.shown < FILMSTRIP_MAX.min(others.len()) {
428 others.sort_by_key(|tile| !model.is_recent_speaker(&tile.mri));
429 }
426 let size = TileSize::sixteen_by_nine(plan.tile_width.floor());
430 let size = TileSize::sixteen_by_nine(plan.tile_width.floor());
427 let shown = &others[..plan.overflow.shown];
431 let shown = &others[..plan.overflow.shown];
428 let mut tiles: Vec<AnyElement> = shown
432 let mut tiles: Vec<AnyElement> = shown
crates/app/src/views/shell.rs +1 −1
@@ -207,7 +207,7 @@ impl AppShell {
207 207 let user_input = cx.global::<UserInputHandle>().0.clone();
208 208 let escape_observation = cx.observe_keystrokes(|this, event, _, cx| {
209 209 this.user_input.touch();
210 if event.keystroke.key == "escape" {
210 if event.keystroke.key == "escape" && event.action.is_none() {
211 211 this.state
212 212 .update(cx, |state, cx| state.escape_call_fullscreen(cx));
213 213 }
@@ -207,7 +207,7 @@ impl AppShell {
207 let user_input = cx.global::<UserInputHandle>().0.clone();
207 let user_input = cx.global::<UserInputHandle>().0.clone();
208 let escape_observation = cx.observe_keystrokes(|this, event, _, cx| {
208 let escape_observation = cx.observe_keystrokes(|this, event, _, cx| {
209 this.user_input.touch();
209 this.user_input.touch();
210 if event.keystroke.key == "escape" {
210 if event.keystroke.key == "escape" && event.action.is_none() {
211 this.state
211 this.state
212 .update(cx, |state, cx| state.escape_call_fullscreen(cx));
212 .update(cx, |state, cx| state.escape_call_fullscreen(cx));
213 }
213 }