ui: servers observe on selection; no gateway or query fields

Selecting a server (or saving one) observes it invisibly through its
gateway, else a query login an older version stored; without a gateway it
is looked up from the address (SRV, then /.well-known/tsgw) and observing
starts once found. The Observe button and the menu entry are gone.

The add/edit server dialog no longer asks for a gateway URL or ServerQuery
login: Advanced keeps the name and nickname. A new address drops the
gateway and query login of the old server, so they are looked up again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VZBWxxMsxUzp4PSTKVzbZN
This commit is contained in:
Claude committed 2026-10-04 21:10:59 +00:00
1 parent 4d04c992a3
commit 60b8e95661
10 files changed
+103 -179

No files matched your search

+1 -1
View File
@@ -41,7 +41,7 @@ Done so far (milestones M0–M4 and the first part of M5 of [the plan](docs/arch
reactions, topics, events, stream directory and administration; the media pipeline for streams
(capture → VP8 + Opus → stream, stream → decoder)
- `crates/voelin-ui` (`voelin`): Slint desktop app: servers, channel tree with talking indicators,
chat tabs (own channel via voice, other channels via relay), connect / observe invisibly, mute, push-to-talk
chat tabs (own channel via voice, other channels via relay), connect, observe invisibly (on selecting a server, through its gateway), mute, push-to-talk
(in the window and as a global hotkey), audio settings with a level meter, per-client volume, and on
TeamSpeak 6 streams: watch in a viewer, share the screen with sound. Desktop and phone layouts
from one design system, dark and light themes, text size, emoji ([docs/ui.md](docs/ui.md))
-3
View File
@@ -23,9 +23,6 @@ pub(super) fn wire(ui: &MainWindow) {
bridge.on_disconnect_voice(|| {
with_app(|app| app.command(|session| Command::DisconnectVoice { session }));
});
bridge.on_toggle_observe(|| {
with_app(|app| app.toggle_observe());
});
bridge.on_join_channel(|cid| {
with_app(|app| {
app.command(|session| Command::MoveToChannel {
+5 -1
View File
@@ -160,7 +160,11 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running {
with_app(|app| app.connect_voice());
}
Some("observe") => {
with_app(|app| app.toggle_observe());
with_app(|app| {
if let Some(id) = app.current {
app.observe(id);
}
});
}
_ => {}
}
+59 -94
View File
@@ -5,7 +5,7 @@ use slint::{ComponentHandle, SharedString};
use tracing::warn;
use voelin_core::identity::LaunchImport;
use voelin_core::{Command, ObserveState, Source, VoiceOptions, VoiceState};
use voelin_store::{Bookmark, QueryConfig, QueryTransport};
use voelin_store::{Bookmark, QueryTransport};
use crate::app::{App, BookmarkForm, Bridge, SessionView, later};
use crate::vm;
@@ -35,7 +35,9 @@ pub(crate) fn imported_status(report: &LaunchImport) -> Option<String> {
/// like the identity, the default channel or the client version, stays; a
/// new server has none of it). Only the address is needed: the name is the
/// address until the server tells its own (`adopt_server_name`), the
/// nickname `default_nickname`, the gateway is looked up later.
/// nickname `default_nickname`, the gateway is looked up in DNS
/// (`discover_gateway`). A new address drops the gateway and the query
/// login found or set for the old one.
fn bookmark_from_form(
old: Option<&Bookmark>,
form: &BookmarkForm,
@@ -46,6 +48,8 @@ fn bookmark_from_form(
bookmark.address = form.address.trim().to_string();
if old.is_some_and(|old| old.address != bookmark.address) {
bookmark.cached_server_icon = None;
bookmark.gateway_url = None;
bookmark.query = None;
}
bookmark.name = match form.name.trim() {
"" => bookmark.address.clone(),
@@ -55,35 +59,6 @@ fn bookmark_from_form(
"" => default_nickname(),
nickname => nickname.to_string(),
};
bookmark.gateway_url = Some(form.gateway_url.trim().to_string()).filter(|u| !u.is_empty());
bookmark.query = match form.query_transport.as_str() {
"none" | "" => None,
t => {
let (host, port) = form
.query_addr
.rsplit_once(':')
.map_or((form.query_addr.to_string(), None), |(h, p)| {
(h.to_string(), p.parse().ok())
});
let transport = match t {
"raw" => QueryTransport::Raw,
"http" => QueryTransport::Http,
_ => QueryTransport::Ssh,
};
let default_port = match transport {
QueryTransport::Raw => 10011,
QueryTransport::Ssh => 10022,
QueryTransport::Http => 10080,
};
Some(QueryConfig {
transport,
host,
port: port.unwrap_or(default_port),
user: form.query_user.to_string(),
server_port: bookmark.query.as_ref().and_then(|q| q.server_port),
})
}
};
bookmark
}
@@ -174,7 +149,8 @@ impl App {
}
/// A gateway was found for the server at `address`; it is kept unless
/// the server changed meanwhile.
/// the server changed meanwhile, and the server is observed through it
/// if it is the one shown.
fn gateway_found(&mut self, id: i64, address: &str, url: String) {
let Some(b) = self
.bookmarks
@@ -191,6 +167,9 @@ impl App {
}
self.set_status(format!("Found the gateway of {name}: {url}"));
self.refresh_toolbar();
if self.current == Some(id) {
self.observe(id);
}
}
/// The server told its name: a server still named by its address takes
@@ -210,13 +189,19 @@ impl App {
self.refresh_toolbar();
}
pub(crate) fn toggle_observe(&mut self) {
let Some(b) = self.current.and_then(|id| self.bookmark(id)).cloned() else { return };
/// Observe the server invisibly, unless it is already: through its
/// gateway, else its own query login. Without either the gateway is
/// looked up first, and observing starts when it is found
/// (`gateway_found`).
pub(crate) fn observe(&mut self, id: i64) {
let Some(b) = self.bookmark(id).cloned() else { return };
if self.demo_ui {
return;
}
let session = b.id as u64;
let observing =
self.sessions.get(&b.id).is_some_and(|v| v.state.observe != ObserveState::Off);
if observing {
self.engine.send(Command::StopObserving { session });
return;
}
if let Some(url) = &b.gateway_url {
@@ -242,13 +227,18 @@ impl App {
line: Default::default(),
};
self.engine.send(Command::ObserveQuery { session, connect: Box::new(connect) });
} else {
self.discover_gateway(b.id);
return;
}
self.set_status("Observing invisibly…");
}
/// Show a server, and observe it.
pub(crate) fn select_server(&mut self, id: i64) {
self.current = Some(id);
self.refresh_all();
self.observe(id);
}
pub(crate) fn bookmark_form(&self, id: i64) -> BookmarkForm {
@@ -256,26 +246,12 @@ impl App {
return BookmarkForm {
id: -1,
nickname: self.default_nickname().into(),
query_transport: "none".into(),
query_user: "serveradmin".into(),
..Default::default()
};
};
let secret = |key: String| -> SharedString {
self.secrets.get(&key).ok().flatten().unwrap_or_default().into()
};
let (transport, addr, user) = match &b.query {
Some(q) => (
match q.transport {
QueryTransport::Raw => "raw",
QueryTransport::Ssh => "ssh",
QueryTransport::Http => "http",
},
format!("{}:{}", q.host, q.port),
q.user.clone(),
),
None => ("none", String::new(), "serveradmin".to_string()),
};
BookmarkForm {
id: b.id as i32,
// Named by its address: empty, so a new address names it again.
@@ -283,17 +259,12 @@ impl App {
address: b.address.clone().into(),
nickname: b.nickname.clone().into(),
server_password: secret(b.server_password_key()),
gateway_url: b.gateway_url.clone().unwrap_or_default().into(),
query_transport: transport.into(),
query_addr: addr.into(),
query_user: user.into(),
query_password: secret(b.query_password_key()),
}
}
pub(crate) fn save_bookmark(&mut self, form: BookmarkForm) {
let mut bookmark =
bookmark_from_form(self.bookmark(form.id as i64), &form, || self.default_nickname());
let old = self.bookmark(form.id as i64).cloned();
let mut bookmark = bookmark_from_form(old.as_ref(), &form, || self.default_nickname());
let result = if bookmark.id < 0 {
self.store.add_bookmark(&bookmark).map(|id| bookmark.id = id)
} else {
@@ -303,23 +274,27 @@ impl App {
self.set_status(format!("Could not save: {e}"));
return;
}
for (key, value) in [
(bookmark.server_password_key(), &form.server_password),
(bookmark.query_password_key(), &form.query_password),
] {
let result = if value.is_empty() {
self.secrets.delete(&key)
} else {
self.secrets.set(&key, value)
};
if let Err(e) = result {
warn!(%e, "could not store secret");
let key = bookmark.server_password_key();
let result = if form.server_password.is_empty() {
self.secrets.delete(&key)
} else {
self.secrets.set(&key, &form.server_password)
};
if let Err(e) = result {
warn!(%e, "could not store secret");
}
// Another server: what was observed is the old one's.
if let Some(old) = old.filter(|old| old.address != bookmark.address) {
if old.query.is_some() {
let _ = self.secrets.delete(&old.query_password_key());
}
self.engine.send(Command::StopObserving { session: bookmark.id as u64 });
if let Some(view) = self.sessions.get_mut(&bookmark.id) {
view.state.observe = ObserveState::Off;
}
}
self.current = Some(bookmark.id);
self.bookmarks = self.store.bookmarks().unwrap_or_default();
self.refresh_all();
self.discover_gateway(bookmark.id);
self.select_server(bookmark.id);
}
pub(crate) fn delete_bookmark(&mut self, id: i64) {
@@ -436,9 +411,6 @@ impl App {
bridge.set_voice_connected(state.voice == VoiceState::Connected);
bridge.set_voice_connecting(state.voice == VoiceState::Connecting);
bridge.set_observing(state.observe != ObserveState::Off);
bridge.set_can_observe(
bookmark.is_some_and(|b| b.gateway_url.is_some() || b.query.is_some()),
);
bridge.set_input_muted(state.input_muted);
bridge.set_output_muted(state.output_muted);
bridge.set_transmitting(state.transmitting);
@@ -558,6 +530,7 @@ mod tests {
use voelin_core::identity::Found;
use super::*;
use voelin_store::QueryConfig;
#[test]
fn edited_server_rejects_queued_icons_and_failed_reconnect_keeps_them_hidden() {
@@ -600,12 +573,8 @@ mod tests {
#[test]
fn the_address_alone_makes_a_server() {
let form = BookmarkForm {
id: -1,
address: " ts.example.test ".into(),
query_transport: "none".into(),
..Default::default()
};
let form =
BookmarkForm { id: -1, address: " ts.example.test ".into(), ..Default::default() };
let b = bookmark_from_form(None, &form, || "Nick".into());
assert_eq!((b.address.as_str(), b.name.as_str()), ("ts.example.test", "ts.example.test"));
assert_eq!(b.nickname, "Nick");
@@ -632,31 +601,27 @@ mod tests {
id: 1234,
}),
};
let form = BookmarkForm {
// Same address: the gateway found and the query login stay.
let same = BookmarkForm {
id: 7,
name: "Mine".into(),
address: "new.example.test:9988".into(),
address: "old.example.test".into(),
nickname: "Other".into(),
// Cleared: looked up again.
gateway_url: "".into(),
query_transport: "raw".into(),
query_addr: "q.example.test".into(),
query_user: "serveradmin".into(),
..Default::default()
};
let b = bookmark_from_form(Some(&old), &form, || unreachable!("a nickname was given"));
let b = bookmark_from_form(Some(&old), &same, || unreachable!("a nickname was given"));
assert_eq!((b.id, b.name.as_str(), b.nickname.as_str()), (7, "Mine", "Other"));
assert_eq!(b.gateway_url, old.gateway_url);
assert_eq!(b.query, old.query);
assert_eq!(b.cached_server_icon, old.cached_server_icon);
// Another address: looked up again, for the new server.
let form = BookmarkForm { address: "new.example.test:9988".into(), ..same };
let b = bookmark_from_form(Some(&old), &form, || unreachable!("a nickname was given"));
assert_eq!(b.address, "new.example.test:9988");
assert!(b.cached_server_icon.is_none());
assert_eq!((b.identity, b.default_channel), (Some(2), Some("Lobby/Sub".into())));
assert_eq!(b.client_version.as_deref(), Some("linux"));
assert_eq!(b.gateway_url, None);
let q = b.query.unwrap();
assert_eq!(
(q.transport, q.host.as_str(), q.port),
(QueryTransport::Raw, "q.example.test", 10011)
);
assert_eq!(q.server_port, Some(9988));
assert_eq!((b.gateway_url, b.query), (None, None));
}
#[test]
+2 -7
View File
@@ -240,11 +240,6 @@ export struct BookmarkForm {
address: string,
nickname: string,
server-password: string,
gateway-url: string,
query-transport: string,
query-addr: string,
query-user: string,
query-password: string,
}
// A stream on the server, ours first: a stream can be watched from any
@@ -853,8 +848,9 @@ export global Bridge {
in property <int> own-channel-banner-mode;
in property <bool> voice-connected;
in property <bool> voice-connecting;
// Presence without joining (gateway or query), started when the server
// is selected.
in property <bool> observing;
in property <bool> can-observe;
in property <bool> input-muted;
in property <bool> output-muted;
in property <bool> transmitting;
@@ -945,7 +941,6 @@ export global Bridge {
callback search(string);
callback connect-voice();
callback disconnect-voice();
callback toggle-observe();
callback join-channel(int);
callback open-channel-chat(int);
callback toggle-collapse(int);
+5 -14
View File
@@ -1,5 +1,6 @@
// The server's sidebar: the server card, connect and observe, and the
// channel tree with its clients.
// The server's sidebar: the server card, connect, and the channel tree
// with its clients. Selecting a server observes it invisibly (through its
// gateway) on its own, so there is no button for it.
import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
@@ -82,14 +83,11 @@ export component ServerHeader inherits Rectangle {
menu := PopupMenu {
entries: [
{ text: @tr("Edit server"), icon: Icons.pencil, enabled: Bridge.current-server >= 0 },
{ text: Bridge.observing ? @tr("Stop observing") : @tr("Observe invisibly"), icon: Icons.eye, enabled: Bridge.can-observe },
{ text: @tr("Add server"), icon: Icons.plus, enabled: true, separator: true },
];
activated(i) => {
if i == 0 {
Nav.edit-server(Bridge.current-server);
} else if i == 1 {
Bridge.toggle-observe();
} else {
Nav.add-server();
}
@@ -97,7 +95,7 @@ export component ServerHeader inherits Rectangle {
}
}
// Connect and observe while not connected.
// Connect while not connected.
export component ConnectActions inherits HorizontalLayout {
spacing: Theme.space-3;
Button {
@@ -108,13 +106,6 @@ export component ConnectActions inherits HorizontalLayout {
enabled: Bridge.current-server >= 0 && !Bridge.voice-connecting;
clicked => { Bridge.connect-voice(); }
}
Button {
icon: Bridge.observing ? Icons.eye-off : Icons.eye;
text: Bridge.observing ? @tr("Stop observing") : @tr("Observe");
enabled: Bridge.can-observe;
checked: Bridge.observing;
clicked => { Bridge.toggle-observe(); }
}
}
// A server-provided icon in its own colours.
@@ -352,7 +343,7 @@ export component ChannelTree inherits VerticalLayout {
small: true;
}
if Bridge.tree.length == 0: Text {
text: Bridge.current-server < 0 ? @tr("No server yet.") : @tr("Connect or observe to see the channels.");
text: Bridge.current-server < 0 ? @tr("No server yet.") : Bridge.observing ? @tr("Loading the channels…") : @tr("Connect to see the channels.");
color: Theme.text-muted;
font-size: Theme.font-sm;
wrap: word-wrap;
+5 -41
View File
@@ -26,11 +26,13 @@ export component BookmarkDialog inherits Modal {
// The fields beyond address and password: shown when editing.
property <bool> advanced: form.id >= 0;
title: join ? @tr("Join a server") : form.id < 0 ? @tr("Add server") : @tr("Edit server");
subtitle: @tr("Only the address is needed; Voelin finds the rest.");
// The gateway (presence and chat without joining) is found from the
// address: DNS SRV records, else the gateway's own well-known URL.
subtitle: @tr("Only the address is needed; Voelin finds the rest, including the server's gateway.");
icon: Icons.server;
card-width: 560px;
// Fits the address and password (two lines more on a phone).
card-height: advanced ? 720px : Nav.narrow ? 360px : 330px;
card-height: advanced ? 500px : Nav.narrow ? 360px : 330px;
dismissed => { done(); }
ScrollView {
vertical-stretch: 1;
@@ -57,7 +59,7 @@ export component BookmarkDialog inherits Modal {
clicked => { root.advanced = !root.advanced; }
}
Text {
text: @tr("Name, nickname, gateway, ServerQuery");
text: @tr("Name, nickname");
color: Theme.text-muted;
font-size: Theme.font-sm;
vertical-alignment: center;
@@ -77,44 +79,6 @@ export component BookmarkDialog inherits Modal {
hint: @tr("Empty: the nickname of your identity.");
TextField { text <=> form.nickname; label: @tr("Nickname"); icon: Icons.user; }
}
Text {
text: @tr("Invisible presence and chat without joining");
font-weight: Theme.weight-semibold;
color: Theme.text;
wrap: word-wrap;
}
Field {
label: @tr("Gateway URL");
hint: @tr("Empty: looked up in DNS, as published by the server's admin.");
TextField { text <=> form.gateway-url; placeholder: @tr("Found automatically"); label: @tr("Gateway URL"); }
}
HorizontalLayout {
spacing: Theme.space-4;
Field {
label: @tr("Query transport");
Select {
model: ["none", "ssh", "raw", "http"];
current-value <=> form.query-transport;
current-index: form.query-transport == "ssh" ? 1 : form.query-transport == "raw" ? 2 : form.query-transport == "http" ? 3 : 0;
label: @tr("Query transport");
}
}
Field {
label: @tr("Query address");
TextField { text <=> form.query-addr; placeholder: "ts.example.org:10022"; label: @tr("Query address"); }
}
}
HorizontalLayout {
spacing: Theme.space-4;
Field {
label: @tr("Query login");
TextField { text <=> form.query-user; label: @tr("Query login"); }
}
Field {
label: @tr("Query password");
TextField { text <=> form.query-password; input-type: InputType.password; label: @tr("Query password"); }
}
}
}
}
}
+1 -1
View File
@@ -407,7 +407,7 @@ export component MembersPanel inherits VerticalLayout {
padding-left: Theme.space-5;
padding-right: Theme.space-5;
Text {
text: @tr("Connect or observe to see who is here.");
text: Bridge.observing ? @tr("Loading who is here…") : @tr("Connect to see who is here.");
color: Theme.text-muted;
font-size: Theme.font-sm;
wrap: word-wrap;
+8 -7
View File
@@ -94,12 +94,13 @@ Every login, post and settings change is written to the audit table.
When a user adds a server by its address (`ts.example.org`), Voelin looks
for its gateway the way TeamSpeak looks for the voice server (SRV
`_ts3._udp`, then TSDNS), and uses what it finds as if the user had typed
the URL (the field stays editable under *Advanced*). It asks at the
server's host name and then at each parent domain down to the registered
domain, the most specific name first; for `ts.example.org` that is
`ts.example.org`, then `example.org`. It looks again when the server is
saved with an empty gateway URL and when it connects with voice.
`_ts3._udp`, then TSDNS), and observes the server through it as soon as the
user selects the server (users do not type gateway URLs or query logins).
It asks at the server's host name and then at each parent domain down to the
registered domain, the most specific name first; for `ts.example.org` that
is `ts.example.org`, then `example.org`. It looks again when the server is
selected or saved without a gateway (a new address drops the old one) and
when it connects with voice.
**DNS records** (preferred). An SRV record names the gateway's host and
port, the service name says whether it speaks TLS:
@@ -144,7 +145,7 @@ Discovery is as trustworthy as DNS and the network, like TSDNS: prefer a
use one from a public CA (Caddy's automatic Let's Encrypt certificates
work); the Android app cannot reach `wss://` gateways yet (it has no
system store to read). A user logs in with
their own identity, and only when they choose to observe the server.
their own identity, when they select the server in Voelin.
## Install
+17 -10
View File
@@ -276,16 +276,23 @@ with the sample studio's sources, live at once with sample viewers.
The add-server dialog (`BookmarkDialog` in `screens/dialogs.slint`, logic in
`servers.rs`) asks for the address (host, host:port, IP or server
nickname; the resolver finds the port through SRV records and TSDNS) and
an optional server password. *Advanced* (open when editing) has the rest,
and empty fields there are filled in: the name is the address until the
first connection, then the server's own name (`adopt_server_name`); the
nickname is the default identity's (one imported from TeamSpeak keeps its
nickname there), else the system user's, else "Voelin user"; the identity is the default one,
there is no default channel; the gateway is looked up in DNS when the
server is saved without one and when it connects
([gateway-admin.md](gateway-admin.md#letting-voelin-find-the-gateway)),
and one found is stored as if typed. `bookmark` and `bookmark:edit` open
it (below).
an optional server password. *Advanced* (open when editing) has the name
and the nickname, and empty fields there are filled in: the name is the
address until the first connection, then the server's own name
(`adopt_server_name`); the nickname is the default identity's (one imported
from TeamSpeak keeps its nickname there), else the system user's, else
"Voelin user"; the identity is the default one, there is no default channel.
There are no gateway or ServerQuery fields: the gateway is looked up from
the address (DNS SRV records, else the gateway's `/.well-known/tsgw`) when
the server is saved, selected or connected
([gateway-admin.md](gateway-admin.md#letting-voelin-find-the-gateway)), one
found is stored, and a new address looks again. `bookmark` and
`bookmark:edit` open it (below).
Selecting a server observes it invisibly through its gateway (or a query
login an older version stored), so its channels, members and chats show
without joining; there is no Observe button. Without a gateway, observing
starts once one is found.
Settings → Profiles (`ProfilesSection` in `screens/settings-pages.slint`;
`settings_pages.rs`, and `identities.rs` for the default and the import