voelin-gpui: the tree marks who talks again, the ring on the avatar and the bars on the row

The gate ruled for parity: the tree cleared `talking` on every row to keep its
pane from being drawn with each start and stop of someone's voice, and the
Slint tree (channels.slint) has the speaking ring on the avatar and the bars
on the row. The model keeps the flag now and client_row draws the ring
(Avatar::speaking) and the bars, 14 pixels as SpeakingBars is, after the badges
and before the LIVE mark, as the Slint row orders them.

The cost was measured with the meter at 10 starts and stops a second (the
sample server, release build, lavapipe on Xvfb :231): the tree pane is
rendered once for each, 9.97 a second for 9.97 events, as the members panel is,
and the rail, the top bar and the main area not at all; 102 % of a core in
all, 5.0 % of it GPUI's thread, which is what the run before the change had
(3.1 % to 5.0 %). docs/ui.md replaces the paragraph that said the tree carries
no talking with the figure; the tests that counted the tree as not drawn count
it as drawn once (a talker changes one row and draws the tree once; the tree
and the members panel and no other pane), and the sample server's tree marks
Kairo.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-28 07:42:20 +03:00
1 parent 6b01e25391
commit 122b2d29fa
6 files changed
+100 -52

No files matched your search

+13 -2
View File
@@ -29,7 +29,7 @@ use super::actions::{
EditChannel, JoinChannel, MoveClient, OpenClient, OpenMember, SelectChannel, ToggleChannel,
};
use super::tree_model::{Emptiness, TreeEvent, TreeModel, debug_check};
use super::widgets::{Avatar, banner_scrim, icon, live_badge, small_picture};
use super::widgets::{Avatar, banner_scrim, icon, live_badge, small_picture, speaking_bars};
use crate::meter::Counters;
use crate::pictures::{PictureKey, picture};
use crate::theme::{VoelinTheme, hsla};
@@ -336,7 +336,8 @@ fn client_row(theme: &VoelinTheme, item: &TreeItem) -> AnyElement {
.gap(px(m.space_3))
.child(
Avatar::new(("tree-avatar", id), 22.0, &item.initials, item.tint)
.image(item.avatar.clone()),
.image(item.avatar.clone())
.speaking(item.talking),
)
.child(
div()
@@ -355,6 +356,16 @@ fn client_row(theme: &VoelinTheme, item: &TreeItem) -> AnyElement {
.filter_map(|badge| small_picture(badge, 14.0)),
),
)
// The Slint bars move; these stand still (nothing here draws the window
// anew with the clock).
.when(item.talking, |row| {
row.child(
div()
.debug_selector(move || format!("tree-speaking-{id}"))
.flex_none()
.child(speaking_bars(theme, 14.0)),
)
})
.when(item.streaming, |row| row.child(live_badge(theme)))
.when(item.local_muted, |row| row.child(mark("volume-x", c.warning)))
.when(!item.local_muted && item.local_volume != 100, |row| {
+3 -3
View File
@@ -5,9 +5,9 @@
//!
//! [`MembersPane`] is a cached pane over a virtual list that follows
//! [`TreeModel`] as the tree does ([`TreeEvent::People`]: the row operations
//! the list applies). It is the pane a talker redraws: a person's row has the
//! speaking ring, "Speaking" and the bars, and nothing else of the window is
//! told. [`MemberCardView`] is the card, a card over the window with a scrim
//! the list applies). A talker redraws it, with the tree: a person's row has
//! the speaking ring, "Speaking" and the bars, and no other pane of the window
//! is told. [`MemberCardView`] is the card, a card over the window with a scrim
//! that a click outside closes; its buttons (the volume, a message, a poke,
//! friends, blocking) come with the slices that have those dialogs.
+6 -9
View File
@@ -11,11 +11,11 @@
//! inserted, not a list that starts again at the top. A change that moves none
//! of what a pane shows emits nothing.
//!
//! **The tree does not mark who is talking.** Its rows are built with
//! `talking` cleared: a talker changes the rows of the members panel (and the
//! sidebar's own card), not the tree's, which therefore is not drawn again
//! with every start and stop of someone's voice. The Slint tree draws speaking
//! bars on the row; docs/ui.md records the difference.
//! **The tree marks who is talking**, as the Slint tree does (the ring on the
//! avatar and the speaking bars on the row): someone who starts or stops
//! talking changes one row of the tree and one of the members panel, so each
//! of the two panes is drawn again once for it, and no other pane is
//! (docs/ui.md, "What a change costs").
use std::sync::Arc;
@@ -124,13 +124,10 @@ impl Snapshot {
fn of(app: &AppState) -> Self {
let vm = &app.vm;
let view = vm.current.and_then(|id| vm.sessions.get(&id));
let (mut rows, people, total) = match logic::tree_view(vm, false) {
let (rows, people, total) = match logic::tree_view(vm, false) {
Some(tree) => (tree.rows, tree.server_members, tree.member_total),
None => (Vec::new(), Vec::new(), 0),
};
for row in &mut rows {
row.talking = false;
}
Self {
rows,
people,
+36 -18
View File
@@ -975,7 +975,8 @@ mod tests {
/// The sample server's channels and people are the rows of the tree, in
/// the Slint tree's order and nesting, with its spacers, the locked
/// channel and the counts, each on screen; none of them marks a talker.
/// channel and the counts, each on screen; Kairo, who talks as the sample
/// starts, is marked.
#[gpui::test]
fn a_server_with_channels_and_people_fills_the_tree_with_its_rows(cx: &mut TestAppContext) {
let (shell, cx) = open(cx, Backend::in_memory().unwrap(), Switches::default());
@@ -1012,7 +1013,8 @@ mod tests {
assert_eq!((channel("Gaming").spacer, channel("Staff").spacer), (2, 3), "centred, right");
assert_eq!(rows.iter().find(|r| r.spacer == 4).map(|r| r.is_channel), Some(true));
assert!(channel("Officers").locked && !channel("Lobby").locked);
assert!(rows.iter().all(|r| !r.talking), "Kairo talks; the tree does not say so");
let talking: Vec<&str> = rows.iter().filter(|r| r.talking).map(|r| &*r.name).collect();
assert_eq!(talking, ["Kairo"], "Kairo talks, and the tree says so");
assert!(at(cx, "tree-empty").is_none());
for row in rows.iter() {
let selector = if row.is_channel {
@@ -1338,26 +1340,41 @@ mod tests {
assert!(at(cx, "tree-empty").is_some(), "the tree says it is loading");
}
/// Who talks changes the members panel and the sidebar's own card, not the
/// tree: its pane is not drawn for a talker, and its rows stay as they
/// were.
/// Who talks is marked on the tree's row, as the Slint tree marks it (the
/// ring on the avatar, the bars on the row): each start and stop changes
/// exactly that person's row, the tree pane is drawn once for it, and the
/// row says so on screen.
#[gpui::test]
fn a_talker_does_not_draw_the_tree_again(cx: &mut TestAppContext) {
fn a_talker_changes_one_row_and_draws_the_tree_once(cx: &mut TestAppContext) {
let (shell, cx) = open(cx, Backend::in_memory().unwrap(), Switches::default());
sample_server(&shell, cx);
let rows = tree_rows(&shell, cx);
let kairo = |shell: &Shell, cx: &mut VisualTestContext| {
shell.view.read_with(cx, |view, cx| {
let tree = view.channel_tree().read(cx);
tree.rows().iter().position(|r| !r.is_channel && r.id == 3).unwrap()
})
};
let place = kairo(&shell, cx);
assert!(tree_rows(&shell, cx)[place].talking, "Kairo talks as the sample starts");
let (log, _subscription) = tree_events(&shell, cx);
let drawn = |shell: &Shell| shell.counters.panes.tree.get();
let before = drawn(&shell);
for talking in [false, true, false, true] {
let before = drawn(&shell);
log.borrow_mut().clear();
let event = Event::Talking { session: sample::DEMO as u64, client: 3, talking };
shell.events.send(event).unwrap();
frame(cx);
let told = rows_told(&log);
let [(changes, carried)] = &told[..] else { panic!("{:?}", log.borrow()) };
assert_eq!(*changes, Changes(vec![Change::Update(place)]), "only Kairo's row");
assert_eq!(carried[place].talking, talking);
assert_eq!(drawn(&shell), before + 1, "the tree pane was drawn once");
let pane = shell
.view
.read_with(cx, |view, cx| view.channel_tree().read(cx).rows()[place].talking);
assert_eq!(pane, talking, "the pane has it");
assert_eq!(at(cx, "tree-speaking-3").is_some(), talking, "and the bars are on screen");
}
assert!(rows_told(&log).is_empty(), "the model told the tree nothing: {:?}", log.borrow());
assert_eq!(log.borrow().len(), 4, "and the members panel four times");
assert_eq!(drawn(&shell), before, "the tree pane was not rendered");
assert_eq!(tree_rows(&shell, cx), rows);
assert!(
shell.app.read_with(cx, |app, _| app.vm.sessions[&sample::DEMO].talking.contains(&3))
);
@@ -1426,11 +1443,11 @@ mod tests {
assert_eq!(shell.app.read_with(cx, |app, _| app.vm.member_filter.clone()), "");
}
/// Someone who starts or stops talking redraws the members panel and no
/// other pane: not the tree, the rail, the top bar nor the main area. The
/// Someone who starts or stops talking redraws the members panel and the
/// tree and no other pane: not the rail, the top bar nor the main area. The
/// row says so while they talk.
#[gpui::test]
fn a_talker_redraws_the_members_panel_and_no_other_pane(cx: &mut TestAppContext) {
fn a_talker_redraws_the_tree_and_the_members_panel_and_no_other_pane(cx: &mut TestAppContext) {
let (shell, cx) = open(cx, Backend::in_memory().unwrap(), Switches::default());
sample_server(&shell, cx);
let panes = &shell.counters.panes;
@@ -1453,10 +1470,11 @@ mod tests {
}
let after = seen();
assert!(after[4] > before[4], "the members panel was drawn: {before:?} -> {after:?}");
assert!(after[2] > before[2], "and the tree: {before:?} -> {after:?}");
assert_eq!(
[after[0], after[1], after[2], after[3]],
[before[0], before[1], before[2], before[3]],
"the rail, the top bar, the tree and the main area were not"
[after[0], after[1], after[3]],
[before[0], before[1], before[3]],
"the rail, the top bar and the main area were not"
);
}