From 8b605b5b45588814c3328e823ce0c18fdb762841 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 16:15:03 +0000 Subject: [PATCH] ui: a password dialog for locked channels, and pokes with a message Joining a locked channel sent no password, so the server refused it and nothing said so; pokes always went out empty. Every join (a double-click in the tree, joining a friend) now goes through App::join_channel: a locked channel asks for its password first (join_password), which is kept for the session until voice disconnects, and it is used when connecting into the channel too. Event::JoinFailed asks again under "Wrong password", or says the channel is full or why the server refused. Without voice, a double-click connects into the channel, as joining a friend did. Connecting into a channel names it by id (`/`): by name the server finds only a top-level channel, so a subchannel's name connected into the default channel. A wrong password when connecting also puts us into the default channel without a word, so the channel is joined again once it shows in the presence (after_connect), and that move asks again. Both seen on the dev TS3 and TS6 servers. Poking opens a dialog with an optional message, its length counted up to 100 characters; the UI trims and cuts it (poke_message), and the engine cuts it on characters too. Both dev servers take 100 characters of any width (400 bytes of emoji) and refuse 101 (seen through ServerQuery). Dev switches channel-password[:wrong] and poke. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ --- CHANGELOG.md | 9 ++ crates/voelin-core/src/lib.rs | 7 +- crates/voelin-core/src/voice.rs | 32 ++++- crates/voelin-ui/src/app.rs | 25 +++- crates/voelin-ui/src/bind/chat.rs | 3 + crates/voelin-ui/src/bind/servers.rs | 11 +- crates/voelin-ui/src/dev.rs | 46 +++++++- crates/voelin-ui/src/members.rs | 35 ++++-- crates/voelin-ui/src/servers.rs | 135 ++++++++++++++++++++-- crates/voelin-ui/src/social.rs | 27 +---- crates/voelin-ui/src/vm/servers.rs | 67 ++++++++++- crates/voelin-ui/src/vm/social.rs | 23 +++- crates/voelin-ui/ui/app.slint | 10 +- crates/voelin-ui/ui/bridge.slint | 6 + crates/voelin-ui/ui/nav.slint | 7 ++ crates/voelin-ui/ui/screens/dialogs.slint | 122 ++++++++++++++++++- docs/architecture.md | 5 +- docs/ui.md | 5 +- 18 files changed, 512 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98306eb..d26f6fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,8 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows - zbus's warnings about desktop portal requests are left out of the logs. - Pop-ups, menus and tooltips have a clearer edge, and the member card, the emoji picker and the notifications panel dim the window behind them. +- Double-clicking a channel of a server without voice connects into it + (it said "not connected with voice"). ### Fixed @@ -66,6 +68,13 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows are drawn as TeamSpeak draws them, like `[cspacer]` was, and chats, search results, notifications and the other screens show a spacer's text instead of its raw name. +- Locked channels ask for their password (kept until voice disconnects, and + asked again when it is wrong), and joining a full channel or one the + server refuses says why; joining did nothing before. +- Pokes can carry a message (up to 100 characters); they were always sent + empty. +- Joining a friend in a subchannel of a server without voice connects into + that subchannel; it connected into the default channel. ## [0.0.1-alpha] - 2026-10-04 diff --git a/crates/voelin-core/src/lib.rs b/crates/voelin-core/src/lib.rs index f7a953b..28abf56 100644 --- a/crates/voelin-core/src/lib.rs +++ b/crates/voelin-core/src/lib.rs @@ -99,6 +99,10 @@ pub use voice::VoiceOptions; pub type SessionId = u64; +/// The longest poke message servers take, in characters; a longer one is +/// cut ([`Command::Poke`]). +pub const POKE_MESSAGE_MAX: usize = 100; + /// What the UI asks for. #[derive(Clone, Debug)] pub enum Command { @@ -274,7 +278,8 @@ pub enum Command { volume: f32, }, /// Poke a client (voice): the server shows it a notification with - /// `message`. Failures come as [`Event::Error`]. + /// `message`, cut to [`POKE_MESSAGE_MAX`] characters. Failures come as + /// [`Event::Error`]. Poke { session: SessionId, client: u16, diff --git a/crates/voelin-core/src/voice.rs b/crates/voelin-core/src/voice.rs index 3e06911..00534de 100644 --- a/crates/voelin-core/src/voice.rs +++ b/crates/voelin-core/src/voice.rs @@ -33,7 +33,7 @@ use crate::cache; use crate::files::{self, FileEntry, Report, RequestId, Sink, TransferId, TransferState}; use crate::offline::{OfflineMessage, OfflineMessageInfo}; use crate::settings::{FILES_PROGRESS_MS, SharedSettings}; -use crate::{Event, JoinFailure, SessionId}; +use crate::{Event, JoinFailure, POKE_MESSAGE_MAX, SessionId}; #[derive(Clone, Debug)] pub struct VoiceOptions { @@ -43,7 +43,7 @@ pub struct VoiceOptions { /// Signed compatibility version; `None` selects the native platform's tuple. pub client_version: Option, pub server_password: Option, - /// Channel path to join, e.g. `Lobby/Sub`. + /// Channel path to join, e.g. `Lobby/Sub`, or `/`. pub channel: Option, /// The password of `channel`. pub channel_password: Option, @@ -889,7 +889,7 @@ impl Voice { let cmd = c2s::OutClientPokeRequestMessage::new(&mut std::iter::once( c2s::OutClientPokeRequestPart { client_id: tsclientlib::ClientId(client), - message: message.as_str().into(), + message: poke_message(&message).into(), }, )); self.send(cmd, Pending::Report("poke"))?; @@ -1098,6 +1098,15 @@ fn join_failure(error: TsError) -> Option { Some(JoinFailure::Other(text)) } +/// A poke's message as servers take it: its first [`POKE_MESSAGE_MAX`] +/// characters (not bytes, so a letter is never cut in half). +fn poke_message(message: &str) -> &str { + match message.char_indices().nth(POKE_MESSAGE_MAX) { + Some((end, _)) => &message[..end], + None => message, + } +} + /// A TeamSpeak error's name in lowercase words: /// `ChannelIsPrivateChannel` is "channel is private channel". fn error_words(error: TsError) -> String { @@ -1145,6 +1154,23 @@ mod join_tests { } } +#[cfg(test)] +mod poke_tests { + use super::*; + + #[test] + fn long_pokes_are_cut_by_characters() { + assert_eq!(poke_message("hi"), "hi"); + assert_eq!(poke_message(""), ""); + let exact = "x".repeat(POKE_MESSAGE_MAX); + assert_eq!(poke_message(&exact), exact); + // Two bytes each: cut after 100 letters, not 100 bytes. + let long = "ä".repeat(150); + assert_eq!(poke_message(&long), "ä".repeat(POKE_MESSAGE_MAX)); + assert_eq!(poke_message(&"🙂".repeat(101)).chars().count(), POKE_MESSAGE_MAX); + } +} + #[cfg(test)] mod image_download_tests { use super::*; diff --git a/crates/voelin-ui/src/app.rs b/crates/voelin-ui/src/app.rs index ea654fa..a19373b 100644 --- a/crates/voelin-ui/src/app.rs +++ b/crates/voelin-ui/src/app.rs @@ -234,6 +234,11 @@ pub(crate) struct SessionView { pub gateway_caps: Vec, /// The client whose member card is open. pub member_card: Option, + /// Passwords given for locked channels, until voice disconnects. + pub channel_passwords: HashMap, + /// The channel a voice connection was asked into, until it is joined + /// or joined again (`App::join_after_connect`). + pub join_after_connect: Option, /// Viewers of the streams in the gateway's directory, by stream id. pub stream_viewers: HashMap, /// Downloads started from chat, by transfer id. @@ -266,6 +271,8 @@ impl Default for SessionView { channel_groups: Vec::new(), gateway_caps: Vec::new(), member_card: None, + channel_passwords: HashMap::new(), + join_after_connect: None, stream_viewers: HashMap::new(), downloads: HashMap::new(), next_transfer: 1, @@ -454,6 +461,10 @@ pub(crate) struct App { pub contacts: HashMap, /// The client in the volume dialog: session, client id, unique id. pub playback_dialog: Option<(i64, u16, Option)>, + /// The locked channel the password dialog is for: session, channel. + pub join_target: Option<(i64, ChannelId)>, + /// Who the poke dialog pokes: session, client, nickname. + pub poke_target: Option<(i64, u16, String)>, pub mic_test: bool, pub ptt: GlobalPtt, pub video: Video, @@ -695,6 +706,8 @@ pub fn run(options: RunOptions) -> Result<()> { playback, contacts: HashMap::new(), playback_dialog: None, + join_target: None, + poke_target: None, mic_test: false, ptt, video, @@ -902,6 +915,11 @@ impl App { if state.voice != VoiceState::Connected { view.focused_own_channel = false; } + if state.voice == VoiceState::Disconnected && was_voice != VoiceState::Disconnected + { + view.channel_passwords.clear(); + view.join_after_connect = None; + } if state.voice == VoiceState::Connected && was_voice != VoiceState::Connected { // A new connection: volumes are sent again. view.applied_playback.clear(); @@ -926,6 +944,7 @@ impl App { if self.open_client_pending && self.current == Some(id) { self.open_first_client(); } + self.join_after_connect(id); } Event::ServerInfo { session, name, flavor, capabilities } => { self.sessions.entry(session as i64).or_default().capabilities = capabilities; @@ -944,6 +963,7 @@ impl App { Event::Presence { session, presence } => { self.sessions.entry(session as i64).or_default().presence = presence; self.apply_client_playback(session as i64); + self.join_after_connect(session as i64); if self.current == Some(session as i64) { self.refresh_toolbar(); self.refresh_tree(); @@ -1056,8 +1076,9 @@ impl App { // The sample sessions of VOELIN_DEMO_UI are unknown to the engine. Event::Error { .. } if self.demo_ui => {} Event::Error { message, .. } => self.set_status(message), - // Not shown yet: the channel password dialog will handle it. - Event::JoinFailed { .. } => {} + Event::JoinFailed { session, channel, reason } => { + self.join_failed(session as i64, channel, reason); + } Event::SettingChanged { key } => self.setting_changed(&key), Event::SettingRejected { key, message } => { self.set_status(format!("Setting {key}: {message}")); diff --git a/crates/voelin-ui/src/bind/chat.rs b/crates/voelin-ui/src/bind/chat.rs index 54d1ecb..ed9a7dc 100644 --- a/crates/voelin-ui/src/bind/chat.rs +++ b/crates/voelin-ui/src/bind/chat.rs @@ -61,6 +61,9 @@ pub(super) fn wire(ui: &MainWindow) { bridge.on_member_action(|action| { with_app(|app| app.member_action(&action)); }); + bridge.on_send_poke(|text| { + with_app(|app| app.send_poke(&text)); + }); bridge.on_member_volume(|percent| { with_app(|app| app.member_volume(percent)); }); diff --git a/crates/voelin-ui/src/bind/servers.rs b/crates/voelin-ui/src/bind/servers.rs index 7d61501..1096031 100644 --- a/crates/voelin-ui/src/bind/servers.rs +++ b/crates/voelin-ui/src/bind/servers.rs @@ -25,13 +25,14 @@ pub(super) fn wire(ui: &MainWindow) { }); bridge.on_join_channel(|cid| { with_app(|app| { - app.command(|session| Command::MoveToChannel { - session, - channel: cid as ChannelId, - password: None, - }) + if let Some(session) = app.current { + app.join_channel(session, cid as ChannelId); + } }); }); + bridge.on_join_with_password(|password| { + with_app(|app| app.join_with_password(password.to_string())); + }); bridge.on_toggle_collapse(|cid| { with_app(|app| app.toggle_collapse(cid as ChannelId)); }); diff --git a/crates/voelin-ui/src/dev.rs b/crates/voelin-ui/src/dev.rs index f85fac5..4321ee5 100644 --- a/crates/voelin-ui/src/dev.rs +++ b/crates/voelin-ui/src/dev.rs @@ -21,7 +21,11 @@ //! notification), `shared:` (text shared to the app on Android), //! `pins`, `topics` (the drawers), //! `topic:` (a topic's messages), `member` (the member card of the -//! first other client), `watch` (the first stream; with sample data the +//! first other client), `poke` (the poke dialog: for the contact shown +//! after `friends`, else for the first other client, its card open), +//! `channel-password` (the password dialog of the first locked channel, +//! the sample's Officers; `channel-password:wrong` as after a refused +//! one), `watch` (the first stream; with sample data the //! local test pattern in its place), `popout` (the same, popped out), //! `tab:` (phone layout); `friends[:]`, //! `messages[:]` (a private chat), `inbox` (offline messages), @@ -49,8 +53,8 @@ use slint::{ComponentHandle, Rgba8Pixel, SharedPixelBuffer}; use voelin_core::gateway::Pin; use voelin_core::stream::{StreamInfo, StreamKind}; use voelin_core::{ - Contact, Event, GatewayUpdate, HistoryMessage, HistorySource, ObserveState, OfflineMessageInfo, - Relation, SessionState, Source, VoiceState, + Contact, Event, GatewayUpdate, HistoryMessage, HistorySource, JoinFailure, ObserveState, + OfflineMessageInfo, Relation, SessionState, Source, VoiceState, }; use voelin_gateway_proto::{ Action, Attendee, ConfigEntry, ConfigSource, EventInfo, EventKind, EventSpec, PermRule, @@ -255,6 +259,23 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running { "member" => { with_app(|app| app.open_first_member()); } + // After `friends` the contact path (Kairo without a contact + // chosen), else the member card's. + "poke" => { + let friends = nav.get_page() == Page::Friends; + with_app(|app| { + if friends { + let uid = app.social.selected.clone().unwrap_or_else(|| "demo-3".into()); + app.contact_action(&uid, "poke"); + } else { + app.open_first_member(); + app.member_action("poke"); + } + }); + } + "channel-password" => { + with_app(|app| open_channel_password(app, arg == "wrong")); + } "watch" | "popout" => { with_app(|app| { if switches.demo_ui { app.demo_watch() } else { app.watch_first_stream() } @@ -382,6 +403,25 @@ fn save_png(image: &SharedPixelBuffer, path: &std::path::Path) -> Re Ok(()) } +/// `VOELIN_OPEN=channel-password`: join the current server's first locked +/// channel, which asks for its password; `wrong` as if the server had +/// refused one. +fn open_channel_password(app: &mut App, wrong: bool) { + let Some(session) = app.current else { return }; + let locked = app + .view() + .and_then(|v| v.presence.channels.values().filter(|c| c.has_password).map(|c| c.id).min()); + let Some(channel) = locked else { return }; + if wrong { + if let Some(view) = app.view_mut() { + view.channel_passwords.insert(channel, "guess".into()); + } + app.join_failed(session, channel, JoinFailure::Password); + } else { + app.join_channel(session, channel); + } +} + const DEMO: i64 = 9001; fn channel(id: u64, parent: u64, order: u64, name: &str) -> ChannelInfo { diff --git a/crates/voelin-ui/src/members.rs b/crates/voelin-ui/src/members.rs index 4aa3b2a..2023eed 100644 --- a/crates/voelin-ui/src/members.rs +++ b/crates/voelin-ui/src/members.rs @@ -6,7 +6,7 @@ use slint::ComponentHandle; use voelin_core::{Command, Contact, Relation}; use voelin_model::ChatTarget; -use crate::app::{App, Bridge, MemberCard}; +use crate::app::{App, Bridge, MemberCard, Nav}; use crate::settings::ClientPlayback; use crate::vm; @@ -96,14 +96,7 @@ impl App { self.open_member(-1); self.watch_client(client_id); } - "poke" => { - self.command(|session| Command::Poke { - session, - client: client_id, - message: String::new(), - }); - self.set_status(format!("Poked {nickname}")); - } + "poke" => self.ask_poke(id, client_id), "friend" | "blocked" => { let Some(uid) = uid else { return }; let wanted = if action == "friend" { Relation::Friend } else { Relation::Blocked }; @@ -126,6 +119,30 @@ impl App { } } + /// Open the poke dialog for a client (the member card, a contact). + pub(crate) fn ask_poke(&mut self, session: i64, client: u16) { + let Some(view) = self.sessions.get(&session) else { return }; + let name = view.nickname(client); + self.poke_target = Some((session, client, name.clone())); + let Some(ui) = self.ui.upgrade() else { return }; + let nav = ui.global::