Exclude ServerQuery from online total so it matches the filtered client list.

The PR #4 review fix still preferred virtualserver_clientsonline which usually includes Query; subtract bookkeeping Query count before applying the stale-data max.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nico B.andCursor committed 2026-09-06 01:28:19 +02:00
1 parent a118c0f58e
commit 77165af5e4
1 file changed
+9 -2
+9 -2
View File
@@ -612,11 +612,18 @@ fn snapshot(con: &data::Connection) -> Event {
// Prefer server-reported counters (GTS/TS `virtualserver_*` via notifyserverupdated)
// but never under-report vs. the visible (non-Query) client set (stale
// optional_data after joins would otherwise freeze the InfoPanel left number).
// `virtualserver_clientsonline` usually includes ServerQuery; subtract the
// Query clients we filtered from the list so the headline matches the tree.
let opt = con.server.optional_data.as_ref();
let visible_channels = channels.len() as u64;
let visible_clients_count = clients.len() as u16;
let server_clients_online =
opt.map(|d| d.client_count.max(visible_clients_count)).unwrap_or(visible_clients_count);
let query_count = (con.clients.len() as u16).saturating_sub(visible_clients_count);
let server_clients_online = opt
.map(|d| {
let without_query = d.client_count.saturating_sub(query_count);
without_query.max(visible_clients_count)
})
.unwrap_or(visible_clients_count);
let server_channels_online =
opt.map(|d| d.channel_count.max(visible_channels)).unwrap_or(visible_channels);