voelin-gpui: a search with no match says "Nobody matches."; connecting is loading

The members panel said "Connect to see who is here." for every empty list
that was not loading, so a search that matched nobody on a connected server
told the user to connect. Emptiness has NoMatch now ("Nobody matches."), for
a non-empty search over a server that has people and leaves none of them; it
is the panel's own (TreeModel::people_emptiness): the tree is not searched,
so the shared Emptiness::of never says it and the tree pane is not told when
the search comes to match nobody (a test counts its renders across the
change). A server whose voice is connecting is Loading, as one that is
observed is, in both panes: its channels and people are on the way.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-28 08:00:33 +03:00
1 parent f28c02a18c
commit c044f7279a
5 files changed
+147 -11

No files matched your search

+7
View File
@@ -101,6 +101,11 @@ impl ChannelTree {
self.selected
}
/// Why it shows no rows, were it empty.
pub fn emptiness(&self) -> Emptiness {
self.emptiness
}
/// Take the new rows in (the rows `changes` lead to, carried by the event),
/// telling the list which rows came, went or changed their height (a
/// channel row and a person's differ).
@@ -149,6 +154,8 @@ fn empty_words(emptiness: Emptiness) -> &'static str {
Emptiness::NoServer => "No server yet.",
Emptiness::Loading => "Loading the channels…",
Emptiness::Connect => "Connect to see the channels.",
// The tree is not searched; a server with people has channels.
Emptiness::NoMatch => "No channels here.",
}
}
+27 -2
View File
@@ -61,7 +61,12 @@ impl MembersPane {
) -> Self {
let (rows, total, emptiness, open) = {
let model = model.read(cx);
(model.people().clone(), model.total(), model.emptiness(), model.card().map(|c| c.id))
(
model.people().clone(),
model.total(),
model.people_emptiness(),
model.card().map(|c| c.id),
)
};
let search = cx.new(|cx| {
InputState::new(window, cx).placeholder(SharedString::from("Search members…"))
@@ -72,7 +77,7 @@ impl MembersPane {
TreeEvent::People(changes, rows) => this.apply(changes, rows.clone()),
TreeEvent::Lists => {
let model = model.read(cx);
let now = (model.total(), model.emptiness());
let now = (model.total(), model.people_emptiness());
if now == (this.total, this.emptiness) {
return;
}
@@ -114,6 +119,11 @@ impl MembersPane {
self.open
}
/// Why it shows no one, were it empty.
pub fn emptiness(&self) -> Emptiness {
self.emptiness
}
/// Whether the search box is shown.
pub fn searching(&self) -> bool {
self.searching
@@ -181,6 +191,7 @@ impl MembersPane {
fn empty_words(emptiness: Emptiness) -> &'static str {
match emptiness {
Emptiness::Loading => "Loading who is here…",
Emptiness::NoMatch => "Nobody matches.",
Emptiness::NoServer | Emptiness::Connect => "Connect to see who is here.",
}
}
@@ -623,3 +634,17 @@ impl Render for MemberCardView {
.into_any_element()
}
}
#[cfg(test)]
mod tests {
use super::*;
/// What an empty panel says for each reason it can be empty.
#[test]
fn an_empty_panel_says_why() {
assert_eq!(empty_words(Emptiness::NoServer), "Connect to see who is here.");
assert_eq!(empty_words(Emptiness::Connect), "Connect to see who is here.");
assert_eq!(empty_words(Emptiness::Loading), "Loading who is here…");
assert_eq!(empty_words(Emptiness::NoMatch), "Nobody matches.");
}
}
+43 -8
View File
@@ -20,7 +20,7 @@
use std::sync::Arc;
use gpui_kit::{Context, Entity, EventEmitter, Subscription};
use voelin_core::ObserveState;
use voelin_core::{ObserveState, VoiceState};
use voelin_ui_vm::bridge::{MemberCard, MemberItem, TreeItem};
use voelin_ui_vm::list::{Changes, diff};
use voelin_ui_vm::servers::logic;
@@ -34,23 +34,45 @@ use crate::signals::Area;
pub enum Emptiness {
/// No server is on screen.
NoServer,
/// The server is observed and its presence is on the way.
/// The server is observed or being connected to, and its presence is on
/// the way.
Loading,
/// Nothing is known of the server until it is connected.
Connect,
/// The server has people and the members' search matches none of them (the
/// members panel's only: the tree is not searched).
NoMatch,
}
impl Emptiness {
/// Why the lists of the server on screen are empty.
/// Why the lists of the server on screen are empty: never
/// [`Emptiness::NoMatch`], which is [`Emptiness::of_people`]'s.
pub fn of(vm: &VmState) -> Self {
match vm.current {
None => Self::NoServer,
Some(id) => match vm.sessions.get(&id) {
Some(view) if view.state.observe != ObserveState::Off => Self::Loading,
Some(view)
if view.state.observe != ObserveState::Off
|| view.state.voice == VoiceState::Connecting =>
{
Self::Loading
}
_ => Self::Connect,
},
}
}
/// Why the members panel is empty: as [`Emptiness::of`], except that a
/// search that leaves nobody of the `total` on the server (`shown` rows
/// are left) is [`Emptiness::NoMatch`], where "Connect to see who is here"
/// would be false.
pub fn of_people(vm: &VmState, shown: usize, total: i32) -> Self {
if shown == 0 && total > 0 && !vm.member_filter.trim().is_empty() {
Self::NoMatch
} else {
Self::of(vm)
}
}
}
/// What changed in the model, as the panes need it.
@@ -77,7 +99,8 @@ pub enum TreeEvent {
/// The selected channel ([`TreeModel::selected`]).
Selection,
/// Why the lists are empty, or how many people there are
/// ([`TreeModel::emptiness`], [`TreeModel::total`]).
/// ([`TreeModel::emptiness`], [`TreeModel::people_emptiness`],
/// [`TreeModel::total`]).
Lists,
}
@@ -91,6 +114,7 @@ pub struct TreeModel {
card: Option<MemberCard>,
selected: Option<ChannelId>,
emptiness: Emptiness,
people_emptiness: Emptiness,
_subscriptions: Vec<Subscription>,
}
@@ -118,6 +142,7 @@ struct Snapshot {
card: Option<MemberCard>,
selected: Option<ChannelId>,
emptiness: Emptiness,
people_emptiness: Emptiness,
}
impl Snapshot {
@@ -129,6 +154,7 @@ impl Snapshot {
None => (Vec::new(), Vec::new(), 0),
};
Self {
people_emptiness: Emptiness::of_people(vm, people.len(), total),
rows,
people,
total,
@@ -162,6 +188,7 @@ impl TreeModel {
card: snapshot.card,
selected: snapshot.selected,
emptiness: snapshot.emptiness,
people_emptiness: snapshot.people_emptiness,
_subscriptions: subscriptions,
}
}
@@ -191,11 +218,17 @@ impl TreeModel {
self.selected
}
/// Why the lists are empty, were they.
/// Why the tree is empty, were it.
pub fn emptiness(&self) -> Emptiness {
self.emptiness
}
/// Why the members panel is empty, were it: the same as
/// [`TreeModel::emptiness`], or that the search matches nobody.
pub fn people_emptiness(&self) -> Emptiness {
self.people_emptiness
}
/// Build the rows again, and tell the panes what differs.
fn refresh(&mut self, cx: &mut Context<Self>) {
let new = Snapshot::of(self.app.read(cx));
@@ -207,8 +240,10 @@ impl TreeModel {
if !people.is_empty() {
self.people = Arc::new(new.people);
}
let lists = (self.emptiness, self.total) != (new.emptiness, new.total);
(self.emptiness, self.total) = (new.emptiness, new.total);
let lists = (self.emptiness, self.people_emptiness, self.total)
!= (new.emptiness, new.people_emptiness, new.total);
(self.emptiness, self.people_emptiness, self.total) =
(new.emptiness, new.people_emptiness, new.total);
let card = self.card != new.card;
self.card = new.card;
let selection = self.selected != new.selected;
+69
View File
@@ -1461,6 +1461,75 @@ mod tests {
assert_eq!(shell.app.read_with(cx, |app, _| app.vm.member_filter.clone()), "");
}
/// A search that matches nobody on a server that has people says so, where
/// "Connect to see who is here." would be false; the tree is not told (it
/// is not searched), and closing the search shows everyone again.
#[gpui::test]
fn a_search_with_no_match_says_nobody_matches(cx: &mut TestAppContext) {
let (shell, cx) = open(cx, Backend::in_memory().unwrap(), Switches::default());
sample_server(&shell, cx);
let emptiness = |shell: &Shell, cx: &mut VisualTestContext| {
shell.view.read_with(cx, |view, cx| {
(
view.members_pane().read(cx).emptiness(),
view.channel_tree().read(cx).emptiness(),
view.tree_model().read(cx).people_emptiness(),
)
})
};
assert_eq!(emptiness(&shell, cx).0, Emptiness::Connect, "full: only said when empty");
assert!(at(cx, "members-empty").is_none());
click(cx, "members-search");
// The first key typed draws the tree once whatever it is (the field's
// focus: not the search's doing); what follows must not.
cx.simulate_input("z");
frame(cx);
assert_eq!(members_shape(&shell, cx), ["Streaming — 1: Zeph", "Guest — 1: Blaze"]);
let tree_drawn = shell.counters.panes.tree.get();
cx.simulate_input("zz");
frame(cx);
assert!(members_shape(&shell, cx).is_empty(), "nobody is called zzz");
let (panel, tree, model) = emptiness(&shell, cx);
assert_eq!((panel, model), (Emptiness::NoMatch, Emptiness::NoMatch));
assert_eq!(tree, Emptiness::Connect, "the tree is not searched and says nothing new");
assert!(at(cx, "members-empty").is_some(), "the panel says so");
assert_eq!(shell.counters.panes.tree.get(), tree_drawn, "and the tree was not drawn");
// Closing the search shows everyone again, with no word for emptiness.
click(cx, "members-search");
assert_eq!(members_shape(&shell, cx).len(), 9);
assert!(at(cx, "members-empty").is_none());
assert_eq!(emptiness(&shell, cx).0, Emptiness::Connect);
}
/// A server whose voice is connecting has its people and channels on the
/// way: both panes say they are loading, not that one has to connect.
#[gpui::test]
fn a_server_being_connected_says_it_is_loading(cx: &mut TestAppContext) {
let (shell, cx) = open(cx, Backend::in_memory().unwrap(), Switches::default());
sample_server(&shell, cx);
let third = sample::DEMO + 2;
shell.app.update(cx, |app, cx| app.select_server(third, cx));
frame(cx);
let words = |shell: &Shell, cx: &mut VisualTestContext| {
shell.view.read_with(cx, |view, cx| {
(view.members_pane().read(cx).emptiness(), view.channel_tree().read(cx).emptiness())
})
};
assert_eq!(words(&shell, cx), (Emptiness::Connect, Emptiness::Connect), "not connected");
let voice = |voice| Event::State {
session: third as u64,
state: SessionState { voice, ..Default::default() },
};
shell.events.send(voice(VoiceState::Connecting)).unwrap();
frame(cx);
assert_eq!(words(&shell, cx), (Emptiness::Loading, Emptiness::Loading), "connecting");
shell.events.send(voice(VoiceState::Disconnected)).unwrap();
frame(cx);
assert_eq!(words(&shell, cx), (Emptiness::Connect, Emptiness::Connect), "gave up");
}
/// 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.
+1 -1
View File
@@ -1675,7 +1675,7 @@ seventh standing in for the chat. The callbacks are GPUI actions
| `member_card` (`members.slint`) | `TreeModel::card` (`voelin_ui_vm::tree::member_card`), shown by `MemberCardView` |
| `members` (the people in our channel: the voice page, not the two files) | built by `tree_view` and not shown: the voice page (slice 3) draws it |
| `current_server` (`channels.slint`) | `AppState::vm.current` (slice 1) |
| `observing` (`channels.slint`, `members.slint`) | `SidebarView::observing` (slice 1: the user's card says Observing); here also `Emptiness`, the words of a list with nothing in it ("No server yet.", "Loading the channels…", "Connect to see the channels.") |
| `observing` (`channels.slint`, `members.slint`) | `SidebarView::observing` (slice 1: the user's card says Observing); here also `Emptiness`, the words of a list with nothing in it: the tree's ("No server yet.", "Loading the channels…", "Connect to see the channels.") and the panel's ("Loading who is here…", "Connect to see who is here.", and "Nobody matches." for a search that leaves nobody of a server that has people); a server whose voice is connecting is loading |
| `server_title`, `server_icon`, `server_stats` (`channels.slint`, the server card) | slice 1: the sidebar's server card (`ServerItem`'s name and icon, `SidebarView::stats`, "9 online · 9 channels") |
| `voice_connected`, `voice_connecting` (`channels.slint`, the server card and its Connect) | slice 1: `SidebarView::voice_connected` and `voice_connecting`, the voice card ("Voice Connected", "Connecting…") |
| `server_banner` (`channels.slint`, the server card's picture) | not drawn: the sidebar's server card has no banner behind it. The same `BannerPicture` and veil (`widgets::banner_scrim`, which the tree's rows use) would do; it comes with the slice that lays the sidebar's cards again, the voice page and call bar (3) |