From f5cb4dd16027a6942335f2989bc953e149aa42f9 Mon Sep 17 00:00:00 2001 From: Moepchi Date: Tue, 4 Aug 2026 18:14:04 +0200 Subject: [PATCH] Add Whisper Verlauf dialog and complete the Selbst menu Whisper Verlauf logs outgoing whisper-target changes with timestamps (incoming-whisper detection isn't observable yet, so it's outgoing-only for now). The Selbst menu now wires Abwesend/Mikrofon/Lautsprecher to the existing toolbar actions and adds a real nickname-change flow, backed by a new "nickname" connector command using tsclientlib's existing client_update().set_name(). --- connector/src/main.rs | 5 + gateway/src/index.ts | 4 + gateway/src/ts3/connection.ts | 5 + web/src/App.css | 25 +++ web/src/App.tsx | 277 ++++++++++++++++++++++++++++++++-- web/src/i18n.tsx | 44 ++++++ 6 files changed, 346 insertions(+), 14 deletions(-) diff --git a/connector/src/main.rs b/connector/src/main.rs index 2a3a6c1..c18ae4f 100644 --- a/connector/src/main.rs +++ b/connector/src/main.rs @@ -587,6 +587,11 @@ async fn run(args: Args) -> Result<()> { if let Err(e) = part.send(&mut con) { emit(&Event::Error { message: e.to_string() }); } + } else if let Some(rest) = l.strip_prefix("nickname ") { + let part = con.get_state()?.client_update().set_name(rest.trim()); + if let Err(e) = part.send(&mut con) { + emit(&Event::Error { message: e.to_string() }); + } } else if let Some(rest) = l.strip_prefix("whisper ") { // Format: "whisper ;" // (either side may be empty, e.g. "whisper 5;" or "whisper ;12,13"). diff --git a/gateway/src/index.ts b/gateway/src/index.ts index 4e97f72..e1f608d 100644 --- a/gateway/src/index.ts +++ b/gateway/src/index.ts @@ -114,6 +114,10 @@ wss.on("connection", (socket: WebSocket) => { await connection?.setOutputMuted(msg.muted); break; } + case "setNickname": { + await connection?.setNickname(msg.nickname); + break; + } case "setWhisperTargets": { await connection?.setWhisperTargets(msg.channelIds ?? [], msg.clientIds ?? []); break; diff --git a/gateway/src/ts3/connection.ts b/gateway/src/ts3/connection.ts index fbf2771..f330dd0 100644 --- a/gateway/src/ts3/connection.ts +++ b/gateway/src/ts3/connection.ts @@ -268,6 +268,11 @@ export class Ts3Connection { this.child?.stdin.write(`muteoutput ${muted ? "1" : "0"}\n`); } + async setNickname(nickname: string): Promise { + const sanitized = nickname.replace(/[\r\n]+/g, " ").trim(); + if (sanitized) this.child?.stdin.write(`nickname ${sanitized}\n`); + } + /** Empty channelIds/clientIds clears whisper mode, returning outgoing * voice to the normal current-channel broadcast. */ async setWhisperTargets(channelIds: number[], clientIds: number[]): Promise { diff --git a/web/src/App.css b/web/src/App.css index a1da3e2..f15ff4c 100644 --- a/web/src/App.css +++ b/web/src/App.css @@ -779,6 +779,31 @@ width: 760px; } +.ts-whisper-history-dialog { + width: 560px; +} + +.ts-whisper-history-list { + height: 260px; + overflow-y: auto; + border: 1px solid var(--border-soft); + border-radius: 3px; + font-size: 12px; +} + +.ts-whisper-history-empty { + padding: 1rem; + text-align: center; + color: var(--text-muted); +} + +.ts-whisper-history-row { + display: flex; + gap: 0.6rem; + padding: 0.3rem 0.5rem; + border-bottom: 1px solid var(--border-soft); +} + .ts-log-level-row { flex-wrap: wrap; } diff --git a/web/src/App.tsx b/web/src/App.tsx index 0bcf0ac..fd54d25 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -140,6 +140,12 @@ interface ClientLogEntry { const LOG_LEVELS: LogLevel[] = ["critical", "error", "warning", "info", "debug"]; const MAX_LOG_ENTRIES = 500; +interface WhisperLogEntry { + id: number; + timestamp: number; + description: string; +} + interface MessagePreset { name: string; message: string; @@ -1050,6 +1056,56 @@ function ClientLogDialog({ entries, onClose }: { entries: ClientLogEntry[]; onCl ); } +function WhisperHistoryDialog({ + serverName, + entries, + onClear, + onClose, +}: { + serverName: string; + entries: WhisperLogEntry[]; + onClear: () => void; + onClose: () => void; +}) { + const t = useT(); + const backdrop = useBackdropDismiss(onClose); + + return ( +
+
e.stopPropagation()}> +
+ {t("whisperHistory.title", { server: serverName })} + +
+
+
+ {entries.length === 0 && ( +
{t("whisperHistory.empty")}
+ )} + {entries.map((e) => ( +
+ {new Date(e.timestamp).toLocaleString()} + {e.description} +
+ ))} +
+
+
+ +
+ + +
+
+
+
+ ); +} + function AwayDialog({ message, presets, @@ -1787,6 +1843,15 @@ function AppInner() { const [logEntries, setLogEntries] = useState([]); const [clientLogOpen, setClientLogOpen] = useState(false); const logIdRef = useRef(0); + const [whisperLog, setWhisperLog] = useState([]); + const [whisperHistoryOpen, setWhisperHistoryOpen] = useState(false); + const [selfMenuOpen, setSelfMenuOpen] = useState(false); + const selfMenuRef = useRef(null); + const [changeNicknameOpen, setChangeNicknameOpen] = useState(false); + const [nicknameDraft, setNicknameDraft] = useState(""); + const nicknameBackdrop = useBackdropDismiss(() => setChangeNicknameOpen(false)); + const whisperLogIdRef = useRef(0); + const prevWhisperTargetsRef = useRef<{ channels: Set; clients: Set } | null>(null); const logClient = (level: LogLevel, category: string, message: string) => { const entry: ClientLogEntry = { id: ++logIdRef.current, timestamp: Date.now(), category, level, message }; @@ -2170,6 +2235,8 @@ function AppInner() { setPokes([]); setActiveTab("channel"); setTalkers(new Set()); + setWhisperLog([]); + prevWhisperTargetsRef.current = null; stopMic(); appendLog({ text: `Disconnected: ${data.reason}`, kind: "info" }); logClient("info", "Connection", `Disconnected: ${data.reason}`); @@ -2362,6 +2429,30 @@ function AppInner() { clientIds: [...whisperClientIds], }) ); + + const prev = prevWhisperTargetsRef.current; + prevWhisperTargetsRef.current = { channels: new Set(whisperChannelIds), clients: new Set(whisperClientIds) }; + const wasEmpty = !prev || (prev.channels.size === 0 && prev.clients.size === 0); + const isEmpty = whisperChannelIds.size === 0 && whisperClientIds.size === 0; + if (wasEmpty && isEmpty) return; + + const describe = () => { + const channelNames = [...whisperChannelIds] + .map((id) => channels.find((c) => c.id === id)?.name) + .filter((n): n is string => Boolean(n)); + const clientNames = [...whisperClientIds] + .map((id) => clients.find((c) => c.id === id)?.name) + .filter((n): n is string => Boolean(n)); + return [...channelNames, ...clientNames].join(", "); + }; + + const description = isEmpty + ? t("whisperHistory.stopped") + : t("whisperHistory.started", { targets: describe() }); + setWhisperLog((prevLog) => [ + ...prevLog, + { id: ++whisperLogIdRef.current, timestamp: Date.now(), description }, + ]); }, [whisperChannelIds, whisperClientIds, connected]); useEffect(() => { @@ -2396,6 +2487,22 @@ function AppInner() { }; }, [extrasMenuOpen]); + useEffect(() => { + if (!selfMenuOpen) return; + const onPointerDown = (e: MouseEvent) => { + if (!selfMenuRef.current?.contains(e.target as Node)) setSelfMenuOpen(false); + }; + const onKeyDown = (e: KeyboardEvent) => { + if (e.key === "Escape") setSelfMenuOpen(false); + }; + window.addEventListener("mousedown", onPointerDown); + window.addEventListener("keydown", onKeyDown); + return () => { + window.removeEventListener("mousedown", onPointerDown); + window.removeEventListener("keydown", onKeyDown); + }; + }, [selfMenuOpen]); + useEffect(() => { const onKeyDown = (e: KeyboardEvent) => { if (!e.ctrlKey) return; @@ -2503,6 +2610,10 @@ function AppInner() { socketRef.current?.send(JSON.stringify({ type: "setOutputMuted", muted: !outputMutedRef.current })); }; + const handleSetNickname = (newNickname: string) => { + socketRef.current?.send(JSON.stringify({ type: "setNickname", nickname: newNickname })); + }; + const handleOutputDeviceChange = async (deviceId: string) => { setOutputDeviceId(deviceId); await audioPlayerRef.current?.setOutputDevice(deviceId); @@ -2720,11 +2831,104 @@ function AppInner() { )} - {[t("menu.self"), t("menu.rights")].map((item) => ( - - {item} +
+ setSelfMenuOpen((v) => !v)} + > + {t("menu.self")} - ))} + {selfMenuOpen && ( +
+ + + + +
+ + + +
+ + + + +
+ +
+ )} +
+ {t("menu.rights")}
{t("menu.extras.inviteFriend")}
- {[ - { icon: "🗒️", label: t("menu.extras.whisperLists"), shortcut: "Strg+Umschalt+W" }, - { icon: "🕓", label: t("menu.extras.whisperHistory"), shortcut: "Strg+Umschalt+H" }, - ].map((item) => ( - - ))} + + + +
+
+ )} + {pokeTarget && (
e.stopPropagation()}> diff --git a/web/src/i18n.tsx b/web/src/i18n.tsx index 434b1db..7598b57 100644 --- a/web/src/i18n.tsx +++ b/web/src/i18n.tsx @@ -105,6 +105,28 @@ const translations: Record> = { "clientLog.caseSensitive": "Groß-/Kleinschreibung", "clientLog.mark": "Markieren", + "whisperHistory.title": "Whisper Verlauf - {server}", + "whisperHistory.empty": "Kein Whisper-Verlauf vorhanden.", + "whisperHistory.started": "Whispern an: {targets}", + "whisperHistory.stopped": "Whispern beendet", + "whisperHistory.clear": "Löschen", + "whisperHistory.options": "Optionen", + + "menu.self.recordingProfile": "Aufnahmeprofil", + "menu.self.playbackProfile": "Wiedergabeprofil", + "menu.self.hotkeyProfile": "Hotkeyprofil", + "menu.self.soundPack": "Sound Pack", + "menu.self.setAway": "Abwesend setzen", + "menu.self.enableMic": "Mikrofon aktivieren", + "menu.self.disableMic": "Mikrofon ausschalten", + "menu.self.muteOutput": "Lautsprecher/Kopfhörer ausschalten", + "menu.self.unmuteOutput": "Lautsprecher/Kopfhörer einschalten", + "menu.self.changeNickname": "Nickname ändern", + "menu.self.requestTalkPower": "Talk Power anfordern", + "menu.self.setAvatar": "Avatar setzen", + "menu.self.setPhoneticNickname": "Phonetischen Nicknamen setzen", + "menu.self.connectionInfo": "Verbindungsinformationen", + "favorites.title": "🔖 myTeamSpeak Favoriten", "favorites.synced": "Synchronisierte Favoriten", "favorites.notLoggedIn": "Nicht angemeldet", @@ -374,6 +396,28 @@ const translations: Record> = { "clientLog.caseSensitive": "Case sensitive", "clientLog.mark": "Mark", + "whisperHistory.title": "Whisper History - {server}", + "whisperHistory.empty": "No whisper history yet.", + "whisperHistory.started": "Whispering to: {targets}", + "whisperHistory.stopped": "Stopped whispering", + "whisperHistory.clear": "Clear", + "whisperHistory.options": "Options", + + "menu.self.recordingProfile": "Recording Profile", + "menu.self.playbackProfile": "Playback Profile", + "menu.self.hotkeyProfile": "Hotkey Profile", + "menu.self.soundPack": "Sound Pack", + "menu.self.setAway": "Set Away", + "menu.self.enableMic": "Enable Microphone", + "menu.self.disableMic": "Disable Microphone", + "menu.self.muteOutput": "Mute Speakers/Headphones", + "menu.self.unmuteOutput": "Unmute Speakers/Headphones", + "menu.self.changeNickname": "Change Nickname", + "menu.self.requestTalkPower": "Request Talk Power", + "menu.self.setAvatar": "Set Avatar", + "menu.self.setPhoneticNickname": "Set Phonetic Nickname", + "menu.self.connectionInfo": "Connection Info", + "favorites.title": "🔖 myTeamSpeak Bookmarks", "favorites.synced": "Synced Bookmarks", "favorites.notLoggedIn": "Not logged in",