From 76cb90360c0273fde2e4f467e64f22e3087d12d5 Mon Sep 17 00:00:00 2001 From: Moepchi Date: Tue, 28 Jul 2026 20:41:29 +0200 Subject: [PATCH] Add server/channel passwords, connection autofill, and client status icons Server/channel passwords are now optional connect fields (hidden behind a lock toggle so the normal flow stays uncluttered). The last successfully used server/nickname is remembered via localStorage and autofilled on load. The channel tree now shows per-client status badges (channel commander, away, mic muted, deafened) sourced directly from tsclientlib's existing client data. Also credits Claude Code in the README, since it wrote the vast majority of this project's code. Co-Authored-By: Claude Sonnet 5 --- README.md | 9 ++++- connector/src/main.rs | 30 ++++++++++++++- gateway/src/index.ts | 2 + gateway/src/ts3/connection.ts | 45 ++++++++++++++++++---- web/src/App.css | 7 ++++ web/src/App.tsx | 71 +++++++++++++++++++++++++++++++++-- 6 files changed, 151 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index b0cd907..18a8670 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,11 @@ reimagined. ## Features -- Connect to a real TeamSpeak (3/6) server +- Connect to a real TeamSpeak (3/6) server, with optional server and + default-channel passwords +- Remembers the last server/nickname you connected with - Channel/client tree with correct ordering, click to switch channels +- Per-client status icons (channel commander, away, mic muted, deafened) - Text chat: channel, server-wide, and private (1:1) — each in its own tab - Voice with voice activation ("Sprachaktivierung", not push-to-talk), adjustable sensitivity, and per-client speaking indicators @@ -44,3 +47,7 @@ Browser (web/) <--WebSocket--> Gateway (gateway/) <--stdin/stdout JSON--> Ru ## Installation See [INSTALL.md](INSTALL.md). + +## Credits + +The vast majority of this project's code was written by [Claude Code](https://claude.com/claude-code) (Anthropic's Claude), working iteratively with the repo owner one feature at a time. diff --git a/connector/src/main.rs b/connector/src/main.rs index 4dfe9ba..7d77ac7 100644 --- a/connector/src/main.rs +++ b/connector/src/main.rs @@ -33,6 +33,12 @@ struct Args { /// Nickname to use on the server #[arg(short, long, default_value = "Browser User")] nickname: String, + /// Server password, if the server requires one + #[arg(long)] + server_password: Option, + /// Password for the default channel to join, if it's password-protected + #[arg(long)] + channel_password: Option, } #[derive(Serialize)] @@ -48,6 +54,11 @@ struct ClientInfo { id: u16, channel: u64, name: String, + input_muted: bool, + output_muted: bool, + input_hardware_enabled: bool, + away: bool, + is_channel_commander: bool, } #[derive(Serialize)] @@ -134,7 +145,16 @@ fn snapshot(con: &data::Connection) -> Event { let clients = con .clients .values() - .map(|c| ClientInfo { id: c.id.0, channel: c.channel.0, name: c.name.clone() }) + .map(|c| ClientInfo { + id: c.id.0, + channel: c.channel.0, + name: c.name.clone(), + input_muted: c.input_muted, + output_muted: c.output_muted, + input_hardware_enabled: c.input_hardware_enabled, + away: c.away_message.is_some(), + is_channel_commander: c.is_channel_commander, + }) .collect(); Event::Channels { channels, clients } } @@ -172,7 +192,13 @@ async fn run(args: Args) -> Result<()> { tracing_subscriber::fmt().with_env_filter("warn").with_writer(std::io::stderr).init(); let address = args.address.clone(); - let con_config = Connection::build(args.address).name(args.nickname); + let mut con_config = Connection::build(args.address).name(args.nickname); + if let Some(pwd) = args.server_password { + con_config = con_config.password(pwd); + } + if let Some(pwd) = args.channel_password { + con_config = con_config.channel_password(pwd); + } let mut con = con_config.connect().map_err(|e| friendly_connect_error(&address, e))?; diff --git a/gateway/src/index.ts b/gateway/src/index.ts index b08ad0e..17ad33f 100644 --- a/gateway/src/index.ts +++ b/gateway/src/index.ts @@ -18,6 +18,8 @@ wss.on("connection", (socket: WebSocket) => { const options: Ts3ConnectOptions = { host: msg.host, nickname: msg.nickname, + serverPassword: msg.serverPassword, + channelPassword: msg.channelPassword, }; connection = new Ts3Connection(options); connection.onEvent((event) => socket.send(JSON.stringify(event))); diff --git a/gateway/src/ts3/connection.ts b/gateway/src/ts3/connection.ts index f02c131..1f1d46f 100644 --- a/gateway/src/ts3/connection.ts +++ b/gateway/src/ts3/connection.ts @@ -21,6 +21,11 @@ export interface ClientInfo { id: number; channel: number; name: string; + inputMuted: boolean; + outputMuted: boolean; + inputHardwareEnabled: boolean; + away: boolean; + isChannelCommander: boolean; } export type Ts3ConnectionEvent = @@ -37,6 +42,8 @@ export type Ts3ConnectionEvent = export interface Ts3ConnectOptions { host: string; nickname: string; + serverPassword?: string; + channelPassword?: string; } const __dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -61,18 +68,27 @@ export class Ts3Connection { } async connect(): Promise { - this.child = spawn(CONNECTOR_BIN, [ - "--address", - this.options.host, - "--nickname", - this.options.nickname, - ]); + const args = ["--address", this.options.host, "--nickname", this.options.nickname]; + if (this.options.serverPassword) args.push("--server-password", this.options.serverPassword); + if (this.options.channelPassword) args.push("--channel-password", this.options.channelPassword); + this.child = spawn(CONNECTOR_BIN, args); createInterface({ input: this.child.stdout }).on("line", (line) => { try { + interface RawClientInfo { + id: number; + channel: number; + name: string; + input_muted: boolean; + output_muted: boolean; + input_hardware_enabled: boolean; + away: boolean; + is_channel_commander: boolean; + } + const event = JSON.parse(line) as | { type: "connected"; welcome_message: string } - | { type: "channels"; channels: ChannelInfo[]; clients: ClientInfo[] } + | { type: "channels"; channels: ChannelInfo[]; clients: RawClientInfo[] } | { type: "chatMessage"; from: string; message: string } | { type: "serverMessage"; from: string; message: string } | { type: "privateMessage"; partner_id: number; partner_name: string; from_self: boolean; message: string } @@ -83,6 +99,21 @@ export class Ts3Connection { if (event.type === "connected") { this.emit({ type: "connected", welcomeMessage: event.welcome_message }); + } else if (event.type === "channels") { + this.emit({ + type: "channels", + channels: event.channels, + clients: event.clients.map((c) => ({ + id: c.id, + channel: c.channel, + name: c.name, + inputMuted: c.input_muted, + outputMuted: c.output_muted, + inputHardwareEnabled: c.input_hardware_enabled, + away: c.away, + isChannelCommander: c.is_channel_commander, + })), + }); } else if (event.type === "privateMessage") { this.emit({ type: "privateMessage", diff --git a/web/src/App.css b/web/src/App.css index 5b89ac2..9153f60 100644 --- a/web/src/App.css +++ b/web/src/App.css @@ -211,6 +211,13 @@ background: color-mix(in srgb, #4caf50 15%, transparent); } +.ts-status-icons { + display: inline-flex; + gap: 0.15rem; + font-size: 11px; + opacity: 0.85; +} + .ts-mic-on { background: color-mix(in srgb, #4caf50 30%, var(--button-bg-1)) !important; } diff --git a/web/src/App.tsx b/web/src/App.tsx index 19ded77..fa1e2ff 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -11,6 +11,9 @@ import { const GATEWAY_URL = "ws://localhost:8080"; +const LAST_HOST_KEY = "ts-web-client:last-host"; +const LAST_NICKNAME_KEY = "ts-web-client:last-nickname"; + type LogEntry = { text: string; kind: "info" | "error" }; interface ChannelInfo { @@ -24,6 +27,11 @@ interface ClientInfo { id: number; channel: number; name: string; + inputMuted: boolean; + outputMuted: boolean; + inputHardwareEnabled: boolean; + away: boolean; + isChannelCommander: boolean; } function ChannelIcon() { @@ -49,6 +57,17 @@ function ClientIcon() { ); } +function ClientStatusIcons({ client }: { client: ClientInfo }) { + return ( + + {client.isChannelCommander && ⭐} + {client.away && 💤} + {(client.inputMuted || !client.inputHardwareEnabled) && 🔇} + {client.outputMuted && 🔕} + + ); +} + function ServerIcon() { return ( {c.name} + ))} @@ -141,8 +161,11 @@ interface PmThread { type ActiveTab = "channel" | "server" | number; function App() { - const [host, setHost] = useState("localhost"); - const [nickname, setNickname] = useState("Claude Code"); + const [host, setHost] = useState(() => localStorage.getItem(LAST_HOST_KEY) ?? "localhost"); + const [nickname, setNickname] = useState(() => localStorage.getItem(LAST_NICKNAME_KEY) ?? "Claude Code"); + const [serverPassword, setServerPassword] = useState(""); + const [channelPassword, setChannelPassword] = useState(""); + const [showPasswordFields, setShowPasswordFields] = useState(false); const [log, setLog] = useState([]); const [connected, setConnected] = useState(false); const [connecting, setConnecting] = useState(false); @@ -231,7 +254,15 @@ function App() { socketRef.current = socket; socket.onopen = () => { - socket.send(JSON.stringify({ type: "connect", host, nickname })); + socket.send( + JSON.stringify({ + type: "connect", + host, + nickname, + serverPassword: serverPassword || undefined, + channelPassword: channelPassword || undefined, + }) + ); }; socket.onmessage = (event) => { @@ -242,6 +273,8 @@ function App() { setConnecting(false); setConnectError(null); setConnected(true); + localStorage.setItem(LAST_HOST_KEY, host); + localStorage.setItem(LAST_NICKNAME_KEY, nickname); setServerChat((prev) => [...prev, { from: "Server", message: data.welcomeMessage }]); break; case "channels": @@ -422,6 +455,38 @@ function App() { disabled={connected || connecting} /> + {!connected && ( + + )} + {!connected && showPasswordFields && ( + <> + + + + )} {!connected ? (