diff --git a/crates/voelin-gpui/src/shell/voice.rs b/crates/voelin-gpui/src/shell/voice.rs index 868d479..327c86f 100644 --- a/crates/voelin-gpui/src/shell/voice.rs +++ b/crates/voelin-gpui/src/shell/voice.rs @@ -597,9 +597,12 @@ impl Render for VoicePage { .h(px(112.0)) .flex_none() .overflow_x_scroll() + .flex() + .flex_row() .child( div() .h_full() + .flex_none() .mx_auto() .flex() .flex_row() diff --git a/crates/voelin-gpui/src/view/voice_tests.rs b/crates/voelin-gpui/src/view/voice_tests.rs index 94f176f..27730cb 100644 --- a/crates/voelin-gpui/src/view/voice_tests.rs +++ b/crates/voelin-gpui/src/view/voice_tests.rs @@ -939,3 +939,78 @@ fn many_people_scroll_and_the_call_bar_stays_on_the_page(cx: &mut TestAppContext let header = at(cx, "voice-header").expect("the header"); assert!(header.bottom() <= stage.top(), "the header stays on top"); } + +/// On the smaller stage, a small channel (2–5 people) is centred horizontally +/// inside `"voice-people"`, while a crowded channel (20+ people) overflows +/// sideways starting cleanly at the left edge without clipping the first person. +#[gpui::test] +fn the_smaller_stage_centres_few_people_and_does_not_clip_many(cx: &mut TestAppContext) { + let (shell, cx) = on_the_voice_page(cx, Switches::default()); + click(cx, "voice-stage"); + assert!(shell.view.read_with(cx, |view, cx| view.voice_page().read(cx).compact_shown())); + + let check_centred = |shell: &Shell, cx: &mut VisualTestContext, expected_len: usize| { + let list = people(shell, cx); + assert_eq!(list.len(), expected_len); + let stage = at(cx, "voice-people").expect("compact stage"); + let first = at(cx, &format!("voice-member-{}", list.first().unwrap().id)).unwrap(); + let last = at(cx, &format!("voice-member-{}", list.last().unwrap().id)).unwrap(); + let left_gap = f32::from(first.left() - stage.left()); + let right_gap = f32::from(stage.right() - last.right()); + assert!( + (left_gap - right_gap).abs() < 2.0, + "{expected_len} people should be centred: left_gap={left_gap}, right_gap={right_gap}, stage={stage:?}, first={first:?}, last={last:?}" + ); + assert!(left_gap > 50.0, "{expected_len} people should not sit flush left: {left_gap}"); + assert!(first.left() >= stage.left() && last.right() <= stage.right()); + }; + + // Five people (the sample channel). + check_centred(&shell, cx, 5); + + // Two people: still centred with wider margins. + shell + .events + .send(sample_presence!(p => { + for id in [3u16, 4, 5] { + p.clients.remove(&id); + } + })) + .unwrap(); + frame(cx); + check_centred(&shell, cx, 2); + + // Twenty-five people: overflows sideways without clipping the first person off the left edge. + shell + .events + .send(sample_presence!(p => { + for id in 100..120u16 { + let mut person = p.clients[&1].clone(); + person.id = id; + person.nickname = format!("Guest {id}"); + person.uid = Some(format!("guest-{id}")); + p.clients.insert(id, person); + } + })) + .unwrap(); + frame(cx); + let list = people(&shell, cx); + assert_eq!(list.len(), 25); + let stage = at(cx, "voice-people").expect("compact stage"); + let first = at(cx, &format!("voice-member-{}", list.first().unwrap().id)).unwrap(); + let last = at(cx, &format!("voice-member-{}", list.last().unwrap().id)).unwrap(); + assert_eq!(stage.size.height, px(112.0)); + assert_eq!(first.top(), last.top(), "stays one horizontal row"); + assert!( + first.left() >= stage.left(), + "first participant must not be clipped left: first={first:?}, stage={stage:?}" + ); + assert!( + f32::from(first.left() - stage.left()) <= 32.0, + "overflowing row starts at left padding: first={first:?}, stage={stage:?}" + ); + assert!( + last.right() > stage.right(), + "25 people overflow horizontally to scroll: last={last:?}, stage={stage:?}" + ); +} diff --git a/docs/ui/gpui-voice-compact-dark.png b/docs/ui/gpui-voice-compact-dark.png index 34a578d..a532b89 100644 Binary files a/docs/ui/gpui-voice-compact-dark.png and b/docs/ui/gpui-voice-compact-dark.png differ diff --git a/docs/ui/gpui-voice-compact-light.png b/docs/ui/gpui-voice-compact-light.png index fa43e8b..dc98a3e 100644 Binary files a/docs/ui/gpui-voice-compact-light.png and b/docs/ui/gpui-voice-compact-light.png differ