Add Server Protokoll dialog

Adds the first StreamItem::MessageEvent handler in the connector's
event loop (previously dropped by a catch-all) - needed because log
lines aren't part of the bookkeeping data model, unlike client/server
connection info, so they only ever arrive as a raw notifyserverlog
reply rather than a book-state update. This unblocks the same pattern
for Bannliste/Beschwerdeliste next.

Sends "logview" via tsclientlib's typed Server::log_view() builder,
requesting the last 200 lines. Verified end-to-end against the real
server (though a permission-gated account got no reply at all there -
the frontend dialog now falls back to a "no response" message after a
timeout instead of loading forever, matching the connection-info
dialogs' existing behavior).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
MoepchiandClaude Sonnet 5 committed 2026-08-05 12:45:59 +02:00
1 parent 181b0fc43b
commit 4318ce359f
7 files changed
+157 -5

No files matched your search

+29 -2
View File
@@ -16,8 +16,8 @@ use tsclientlib::messages::c2s::{OutClientPokeRequestPart, OutSendTextMessagePar
use tsclientlib::prelude::*;
use tsclientlib::{
data, ChannelId, ClientId, CodecEncryptionMode, Connection, DisconnectOptions, HostBannerMode,
HostMessageMode, Identity, MaxClients, MessageHandle, MessageTarget, Reason, StreamItem,
TextMessageTargetMode,
HostMessageMode, Identity, InMessage, MaxClients, MessageHandle, MessageTarget, Reason,
StreamItem, TextMessageTargetMode,
};
use tsproto_packets::packets::{AudioData, CodecType, Direction, Flags, OutAudio, OutCommand, PacketType};
@@ -233,6 +233,11 @@ enum Event {
bandwidth_sent_last_second: u64,
bandwidth_received_last_second: u64,
},
/// Reply to a "serverlog" request - raw lines from the virtual server's
/// protocol log (distinct from `ServerLog` above, which is the synthesized
/// client-join/channel-edit/etc. feed for the Server tab).
#[serde(rename = "serverProtocolLog")]
ServerProtocolLog { lines: Vec<String> },
}
fn emit(event: &Event) {
@@ -544,6 +549,10 @@ async fn run(args: Args) -> Result<()> {
// batch, not as a direct command result) - checked and emitted below.
let mut pending_client_conninfo: Option<ClientId> = None;
let mut pending_server_conninfo = false;
// Set by "serverlog" while waiting for the notifyserverlog reply, which
// arrives as a StreamItem::MessageEvent (not a BookEvents batch, since log
// lines aren't part of the channel/client/server data model).
let mut pending_server_log = false;
enum LoopOutcome {
StdinLine(std::io::Result<Option<String>>),
@@ -876,6 +885,15 @@ async fn run(args: Args) -> Result<()> {
}
Err(e) => emit(&Event::Error { message: e.to_string() }),
}
} else if l == "serverlog" {
let part = con.get_state()?.server.log_view().set_lines(200);
match part.send_with_result(&mut con) {
Ok(handle) => {
pending_server_log = true;
pending_messages.insert(handle, "Server log".into());
}
Err(e) => emit(&Event::Error { message: e.to_string() }),
}
} else if let Some(b64) = l.strip_prefix("audio ") {
match base64::engine::general_purpose::STANDARD.decode(b64.trim()) {
Ok(bytes) => {
@@ -1049,6 +1067,15 @@ async fn run(args: Args) -> Result<()> {
}
}
}
Some(Ok(StreamItem::MessageEvent(msg))) => {
if pending_server_log {
if let InMessage::ServerLog(log) = &msg {
let lines: Vec<String> = log.iter().map(|part| part.log.clone()).collect();
emit(&Event::ServerProtocolLog { lines });
pending_server_log = false;
}
}
}
Some(Ok(_)) => {}
Some(Err(e)) => {
emit(&Event::Disconnected { reason: e.to_string() });