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

+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"
);
}