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().
This commit is contained in:
Moepchi committed 2026-08-04 18:14:04 +02:00
1 parent a0ede4a12a
commit f5cb4dd160
6 files changed
+345 -13

No files matched your search

+5
View File
@@ -587,6 +587,11 @@ async fn run(args: Args) -> Result<()> {
if let Err(e) = part.send(&mut con) { if let Err(e) = part.send(&mut con) {
emit(&Event::Error { message: e.to_string() }); 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 ") { } else if let Some(rest) = l.strip_prefix("whisper ") {
// Format: "whisper <channelId,channelId,...>;<clientId,clientId,...>" // Format: "whisper <channelId,channelId,...>;<clientId,clientId,...>"
// (either side may be empty, e.g. "whisper 5;" or "whisper ;12,13"). // (either side may be empty, e.g. "whisper 5;" or "whisper ;12,13").
+4
View File
@@ -114,6 +114,10 @@ wss.on("connection", (socket: WebSocket) => {
await connection?.setOutputMuted(msg.muted); await connection?.setOutputMuted(msg.muted);
break; break;
} }
case "setNickname": {
await connection?.setNickname(msg.nickname);
break;
}
case "setWhisperTargets": { case "setWhisperTargets": {
await connection?.setWhisperTargets(msg.channelIds ?? [], msg.clientIds ?? []); await connection?.setWhisperTargets(msg.channelIds ?? [], msg.clientIds ?? []);
break; break;
+5
View File
@@ -268,6 +268,11 @@ export class Ts3Connection {
this.child?.stdin.write(`muteoutput ${muted ? "1" : "0"}\n`); this.child?.stdin.write(`muteoutput ${muted ? "1" : "0"}\n`);
} }
async setNickname(nickname: string): Promise<void> {
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 /** Empty channelIds/clientIds clears whisper mode, returning outgoing
* voice to the normal current-channel broadcast. */ * voice to the normal current-channel broadcast. */
async setWhisperTargets(channelIds: number[], clientIds: number[]): Promise<void> { async setWhisperTargets(channelIds: number[], clientIds: number[]): Promise<void> {
+25
View File
@@ -779,6 +779,31 @@
width: 760px; 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 { .ts-log-level-row {
flex-wrap: wrap; flex-wrap: wrap;
} }
+262 -13
View File
@@ -140,6 +140,12 @@ interface ClientLogEntry {
const LOG_LEVELS: LogLevel[] = ["critical", "error", "warning", "info", "debug"]; const LOG_LEVELS: LogLevel[] = ["critical", "error", "warning", "info", "debug"];
const MAX_LOG_ENTRIES = 500; const MAX_LOG_ENTRIES = 500;
interface WhisperLogEntry {
id: number;
timestamp: number;
description: string;
}
interface MessagePreset { interface MessagePreset {
name: string; name: string;
message: 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 (
<div className="ts-dialog-backdrop" {...backdrop}>
<div className="ts-dialog ts-whisper-history-dialog" onClick={(e) => e.stopPropagation()}>
<div className="ts-dialog-titlebar">
<span>{t("whisperHistory.title", { server: serverName })}</span>
<button onClick={onClose} title={t("dialog.close")}>
✕
</button>
</div>
<div className="ts-dialog-body">
<div className="ts-whisper-history-list">
{entries.length === 0 && (
<div className="ts-whisper-history-empty">{t("whisperHistory.empty")}</div>
)}
{entries.map((e) => (
<div key={e.id} className="ts-whisper-history-row">
<span className="ts-log-time">{new Date(e.timestamp).toLocaleString()}</span>
<span>{e.description}</span>
</div>
))}
</div>
</div>
<div className="ts-dialog-buttons">
<button onClick={onClear}>{t("whisperHistory.clear")}</button>
<div className="ts-dialog-buttons-right">
<button disabled title={t("clientContext.notSupported")}>
{t("whisperHistory.options")}
</button>
<button onClick={onClose}>{t("dialog.close")}</button>
</div>
</div>
</div>
</div>
);
}
function AwayDialog({ function AwayDialog({
message, message,
presets, presets,
@@ -1787,6 +1843,15 @@ function AppInner() {
const [logEntries, setLogEntries] = useState<ClientLogEntry[]>([]); const [logEntries, setLogEntries] = useState<ClientLogEntry[]>([]);
const [clientLogOpen, setClientLogOpen] = useState(false); const [clientLogOpen, setClientLogOpen] = useState(false);
const logIdRef = useRef(0); const logIdRef = useRef(0);
const [whisperLog, setWhisperLog] = useState<WhisperLogEntry[]>([]);
const [whisperHistoryOpen, setWhisperHistoryOpen] = useState(false);
const [selfMenuOpen, setSelfMenuOpen] = useState(false);
const selfMenuRef = useRef<HTMLDivElement | null>(null);
const [changeNicknameOpen, setChangeNicknameOpen] = useState(false);
const [nicknameDraft, setNicknameDraft] = useState("");
const nicknameBackdrop = useBackdropDismiss(() => setChangeNicknameOpen(false));
const whisperLogIdRef = useRef(0);
const prevWhisperTargetsRef = useRef<{ channels: Set<number>; clients: Set<number> } | null>(null);
const logClient = (level: LogLevel, category: string, message: string) => { const logClient = (level: LogLevel, category: string, message: string) => {
const entry: ClientLogEntry = { id: ++logIdRef.current, timestamp: Date.now(), category, level, message }; const entry: ClientLogEntry = { id: ++logIdRef.current, timestamp: Date.now(), category, level, message };
@@ -2170,6 +2235,8 @@ function AppInner() {
setPokes([]); setPokes([]);
setActiveTab("channel"); setActiveTab("channel");
setTalkers(new Set()); setTalkers(new Set());
setWhisperLog([]);
prevWhisperTargetsRef.current = null;
stopMic(); stopMic();
appendLog({ text: `Disconnected: ${data.reason}`, kind: "info" }); appendLog({ text: `Disconnected: ${data.reason}`, kind: "info" });
logClient("info", "Connection", `Disconnected: ${data.reason}`); logClient("info", "Connection", `Disconnected: ${data.reason}`);
@@ -2362,6 +2429,30 @@ function AppInner() {
clientIds: [...whisperClientIds], 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]); }, [whisperChannelIds, whisperClientIds, connected]);
useEffect(() => { useEffect(() => {
@@ -2396,6 +2487,22 @@ function AppInner() {
}; };
}, [extrasMenuOpen]); }, [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(() => { useEffect(() => {
const onKeyDown = (e: KeyboardEvent) => { const onKeyDown = (e: KeyboardEvent) => {
if (!e.ctrlKey) return; if (!e.ctrlKey) return;
@@ -2503,6 +2610,10 @@ function AppInner() {
socketRef.current?.send(JSON.stringify({ type: "setOutputMuted", muted: !outputMutedRef.current })); 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) => { const handleOutputDeviceChange = async (deviceId: string) => {
setOutputDeviceId(deviceId); setOutputDeviceId(deviceId);
await audioPlayerRef.current?.setOutputDevice(deviceId); await audioPlayerRef.current?.setOutputDevice(deviceId);
@@ -2720,11 +2831,104 @@ function AppInner() {
</div> </div>
)} )}
</div> </div>
{[t("menu.self"), t("menu.rights")].map((item) => ( <div className="ts-menubar-dropdown" ref={selfMenuRef}>
<span key={item} className="ts-menubar-item"> <span
{item} className="ts-menubar-item ts-menubar-item-active"
onClick={() => setSelfMenuOpen((v) => !v)}
>
{t("menu.self")}
</span> </span>
))} {selfMenuOpen && (
<div className="ts-menu">
<button className="ts-menu-item" disabled title={t("clientContext.notSupported")}>
<span className="ts-menu-item-icon">🎙️</span>
<span className="ts-menu-item-label">{t("menu.self.recordingProfile")}</span>
</button>
<button className="ts-menu-item" disabled title={t("clientContext.notSupported")}>
<span className="ts-menu-item-icon">🔊</span>
<span className="ts-menu-item-label">{t("menu.self.playbackProfile")}</span>
</button>
<button className="ts-menu-item" disabled title={t("clientContext.notSupported")}>
<span className="ts-menu-item-icon">⌨️</span>
<span className="ts-menu-item-label">{t("menu.self.hotkeyProfile")}</span>
</button>
<button className="ts-menu-item" disabled title={t("clientContext.notSupported")}>
<span className="ts-menu-item-icon">🔔</span>
<span className="ts-menu-item-label">{t("menu.self.soundPack")}</span>
</button>
<div className="ts-menu-separator" />
<button
className="ts-menu-item"
disabled={!connected}
onClick={() => {
setAwayDialogMessage("");
setAwayDialogOpen(true);
setSelfMenuOpen(false);
}}
>
<span className="ts-menu-item-icon">💤</span>
<span className="ts-menu-item-label">{t("menu.self.setAway")}</span>
</button>
<button
className="ts-menu-item"
disabled={!connected}
onClick={() => {
void handleToggleMic();
setSelfMenuOpen(false);
}}
>
<span className="ts-menu-item-icon">{micOn ? "🔇" : "🎤"}</span>
<span className="ts-menu-item-label">
{micOn ? t("menu.self.disableMic") : t("menu.self.enableMic")}
</span>
</button>
<button
className="ts-menu-item"
disabled={!connected}
onClick={() => {
handleToggleOutputMuted();
setSelfMenuOpen(false);
}}
>
<span className="ts-menu-item-icon">{outputMuted ? "🔊" : "🔇"}</span>
<span className="ts-menu-item-label">
{outputMuted ? t("menu.self.unmuteOutput") : t("menu.self.muteOutput")}
</span>
</button>
<div className="ts-menu-separator" />
<button
className="ts-menu-item"
disabled={!connected}
onClick={() => {
setNicknameDraft(nickname);
setChangeNicknameOpen(true);
setSelfMenuOpen(false);
}}
>
<span className="ts-menu-item-icon">✎</span>
<span className="ts-menu-item-label">{t("menu.self.changeNickname")}</span>
</button>
<button className="ts-menu-item" disabled title={t("clientContext.notSupported")}>
<span className="ts-menu-item-icon">🗣️</span>
<span className="ts-menu-item-label">{t("menu.self.requestTalkPower")}</span>
</button>
<button className="ts-menu-item" disabled title={t("clientContext.notSupported")}>
<span className="ts-menu-item-icon">🖼️</span>
<span className="ts-menu-item-label">{t("menu.self.setAvatar")}</span>
</button>
<button className="ts-menu-item" disabled title={t("clientContext.notSupported")}>
<span className="ts-menu-item-icon">🔤</span>
<span className="ts-menu-item-label">{t("menu.self.setPhoneticNickname")}</span>
</button>
<div className="ts-menu-separator" />
<button className="ts-menu-item" disabled title={t("clientContext.notSupported")}>
<span className="ts-menu-item-icon">ℹ️</span>
<span className="ts-menu-item-label">{t("menu.self.connectionInfo")}</span>
</button>
</div>
)}
</div>
<span className="ts-menubar-item">{t("menu.rights")}</span>
<div className="ts-menubar-dropdown" ref={extrasMenuRef}> <div className="ts-menubar-dropdown" ref={extrasMenuRef}>
<span <span
className="ts-menubar-item ts-menubar-item-active" className="ts-menubar-item ts-menubar-item-active"
@@ -2767,16 +2971,22 @@ function AppInner() {
<span className="ts-menu-item-label">{t("menu.extras.inviteFriend")}</span> <span className="ts-menu-item-label">{t("menu.extras.inviteFriend")}</span>
</button> </button>
<div className="ts-menu-separator" /> <div className="ts-menu-separator" />
{[ <button className="ts-menu-item" disabled>
{ icon: "🗒️", label: t("menu.extras.whisperLists"), shortcut: "Strg+Umschalt+W" }, <span className="ts-menu-item-icon">🗒️</span>
{ icon: "🕓", label: t("menu.extras.whisperHistory"), shortcut: "Strg+Umschalt+H" }, <span className="ts-menu-item-label">{t("menu.extras.whisperLists")}</span>
].map((item) => ( <span className="ts-menu-item-shortcut">Strg+Umschalt+W</span>
<button key={item.label} className="ts-menu-item" disabled> </button>
<span className="ts-menu-item-icon">{item.icon}</span> <button
<span className="ts-menu-item-label">{item.label}</span> className="ts-menu-item"
<span className="ts-menu-item-shortcut">{item.shortcut}</span> onClick={() => {
setWhisperHistoryOpen(true);
setExtrasMenuOpen(false);
}}
>
<span className="ts-menu-item-icon">🕓</span>
<span className="ts-menu-item-label">{t("menu.extras.whisperHistory")}</span>
<span className="ts-menu-item-shortcut">Strg+Umschalt+H</span>
</button> </button>
))}
<button <button
className="ts-menu-item" className="ts-menu-item"
onClick={() => { onClick={() => {
@@ -3058,6 +3268,15 @@ function AppInner() {
<ClientLogDialog entries={logEntries} onClose={() => setClientLogOpen(false)} /> <ClientLogDialog entries={logEntries} onClose={() => setClientLogOpen(false)} />
)} )}
{whisperHistoryOpen && (
<WhisperHistoryDialog
serverName={serverName}
entries={whisperLog}
onClear={() => setWhisperLog([])}
onClose={() => setWhisperHistoryOpen(false)}
/>
)}
{awayDialogOpen && ( {awayDialogOpen && (
<AwayDialog <AwayDialog
message={awayDialogMessage} message={awayDialogMessage}
@@ -3111,6 +3330,36 @@ function AppInner() {
</div> </div>
)} )}
{changeNicknameOpen && (
<div className="ts-poke-compose-backdrop" {...nicknameBackdrop}>
<div className="ts-poke-compose" onClick={(e) => e.stopPropagation()}>
<span>✎ {t("menu.self.changeNickname")}</span>
<input
autoFocus
value={nicknameDraft}
onChange={(e) => setNicknameDraft(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter" && nicknameDraft.trim()) {
handleSetNickname(nicknameDraft.trim());
setChangeNicknameOpen(false);
}
if (e.key === "Escape") setChangeNicknameOpen(false);
}}
/>
<button
disabled={!nicknameDraft.trim()}
onClick={() => {
handleSetNickname(nicknameDraft.trim());
setChangeNicknameOpen(false);
}}
>
{t("favorites.ok")}
</button>
<button onClick={() => setChangeNicknameOpen(false)}>{t("favorites.cancel")}</button>
</div>
</div>
)}
{pokeTarget && ( {pokeTarget && (
<div className="ts-poke-compose-backdrop" {...pokeBackdrop}> <div className="ts-poke-compose-backdrop" {...pokeBackdrop}>
<div className="ts-poke-compose" onClick={(e) => e.stopPropagation()}> <div className="ts-poke-compose" onClick={(e) => e.stopPropagation()}>
+44
View File
@@ -105,6 +105,28 @@ const translations: Record<Lang, Record<string, string>> = {
"clientLog.caseSensitive": "Groß-/Kleinschreibung", "clientLog.caseSensitive": "Groß-/Kleinschreibung",
"clientLog.mark": "Markieren", "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.title": "🔖 myTeamSpeak Favoriten",
"favorites.synced": "Synchronisierte Favoriten", "favorites.synced": "Synchronisierte Favoriten",
"favorites.notLoggedIn": "Nicht angemeldet", "favorites.notLoggedIn": "Nicht angemeldet",
@@ -374,6 +396,28 @@ const translations: Record<Lang, Record<string, string>> = {
"clientLog.caseSensitive": "Case sensitive", "clientLog.caseSensitive": "Case sensitive",
"clientLog.mark": "Mark", "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.title": "🔖 myTeamSpeak Bookmarks",
"favorites.synced": "Synced Bookmarks", "favorites.synced": "Synced Bookmarks",
"favorites.notLoggedIn": "Not logged in", "favorites.notLoggedIn": "Not logged in",