Add whisper (targeted voice to channels/clients)

Connector: a new "whisper <channelIds>;<clientIds>" stdin command sets
persistent whisper targets; outgoing audio then goes out as
AudioData::C2SWhisper instead of the normal C2S broadcast until
"unwhisper" clears it. Gateway relays a setWhisperTargets message the
same way.

Frontend: a toolbar toggle lists channels as checkboxes, and the
client context menu gets an "add/remove as whisper target" entry;
selecting any target switches all subsequent outgoing voice to
whisper mode.

Verified against the real test server: setting a channel target and
sending a frame produced no connector error, and clearing targets
resumed normal voice cleanly.
This commit is contained in:
Moepchi committed 2026-08-02 14:41:54 +02:00
1 parent 7217bc146a
commit 5858631e6d
5 files changed
+184 -7

No files matched your search

+125
View File
@@ -1477,6 +1477,10 @@ function AppInner() {
isSelf: boolean;
} | null>(null);
const clientContextMenuRef = useRef<HTMLDivElement>(null);
const [whisperChannelIds, setWhisperChannelIds] = useState<Set<number>>(new Set());
const [whisperClientIds, setWhisperClientIds] = useState<Set<number>>(new Set());
const [whisperMenuOpen, setWhisperMenuOpen] = useState(false);
const whisperMenuRef = useRef<HTMLDivElement | null>(null);
const [activeTab, setActiveTab] = useState<ActiveTab>("channel");
const [theme, setTheme] = useState<"light" | "dark">(() =>
window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light"
@@ -2033,6 +2037,40 @@ function AppInner() {
};
}, [clientContextMenu]);
useEffect(() => {
if (!connected) {
setWhisperChannelIds(new Set());
setWhisperClientIds(new Set());
}
}, [connected]);
useEffect(() => {
if (!connected) return;
socketRef.current?.send(
JSON.stringify({
type: "setWhisperTargets",
channelIds: [...whisperChannelIds],
clientIds: [...whisperClientIds],
})
);
}, [whisperChannelIds, whisperClientIds, connected]);
useEffect(() => {
if (!whisperMenuOpen) return;
const onPointerDown = (e: MouseEvent) => {
if (!whisperMenuRef.current?.contains(e.target as Node)) setWhisperMenuOpen(false);
};
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === "Escape") setWhisperMenuOpen(false);
};
window.addEventListener("mousedown", onPointerDown);
window.addEventListener("keydown", onKeyDown);
return () => {
window.removeEventListener("mousedown", onPointerDown);
window.removeEventListener("keydown", onKeyDown);
};
}, [whisperMenuOpen]);
useEffect(() => {
if (!extrasMenuOpen) return;
const onPointerDown = (e: MouseEvent) => {
@@ -2215,6 +2253,29 @@ function AppInner() {
setPokeMessage("");
};
const toggleWhisperChannel = (channelId: number) => {
setWhisperChannelIds((prev) => {
const next = new Set(prev);
if (next.has(channelId)) next.delete(channelId);
else next.add(channelId);
return next;
});
};
const toggleWhisperClient = (clientId: number) => {
setWhisperClientIds((prev) => {
const next = new Set(prev);
if (next.has(clientId)) next.delete(clientId);
else next.add(clientId);
return next;
});
};
const clearWhisperTargets = () => {
setWhisperChannelIds(new Set());
setWhisperClientIds(new Set());
};
const handleClientContextMenu = (
e: React.MouseEvent,
clientId: number,
@@ -2500,6 +2561,54 @@ function AppInner() {
)}
</div>
<span className="ts-toolbar-sep" />
<div className="ts-toolbar-away" ref={whisperMenuRef}>
<button
className={`ts-icon-button${whisperChannelIds.size > 0 || whisperClientIds.size > 0 ? " ts-away-on" : ""}`}
onClick={() => setWhisperMenuOpen((v) => !v)}
disabled={!connected}
title={t("toolbar.whisper")}
>
🤫
</button>
{whisperMenuOpen && (
<div className="ts-menu ts-menu-away">
<div className="ts-context-menu-title">{t("whisper.channels")}</div>
{channels.map((ch) => (
<label key={ch.id} className="ts-menu-item">
<input
type="checkbox"
checked={whisperChannelIds.has(ch.id)}
onChange={() => toggleWhisperChannel(ch.id)}
/>
<span className="ts-menu-item-label">{ch.name}</span>
</label>
))}
{whisperClientIds.size > 0 && (
<>
<div className="ts-menu-separator" />
<div className="ts-context-menu-title">{t("whisper.clients")}</div>
{[...whisperClientIds].map((id) => (
<button key={id} className="ts-menu-item" onClick={() => toggleWhisperClient(id)}>
<span className="ts-menu-item-icon">✕</span>
<span className="ts-menu-item-label">
{clients.find((c) => c.id === id)?.name ?? id}
</span>
</button>
))}
</>
)}
{(whisperChannelIds.size > 0 || whisperClientIds.size > 0) && (
<>
<div className="ts-menu-separator" />
<button className="ts-menu-item" onClick={clearWhisperTargets}>
<span className="ts-menu-item-label">{t("whisper.clearAll")}</span>
</button>
</>
)}
</div>
)}
</div>
<span className="ts-toolbar-sep" />
<button
className={`ts-icon-button${micOn && !inputMuted ? " ts-mic-on" : ""}${micOn && inputMuted ? " ts-muted-on" : ""}`}
onClick={handleToggleMic}
@@ -2722,6 +2831,22 @@ function AppInner() {
<span className="ts-menu-item-icon">📋</span>
<span className="ts-menu-item-label">{t("clientContext.copyName")}</span>
</button>
{!clientContextMenu.isSelf && (
<button
className="ts-menu-item"
onClick={() => {
toggleWhisperClient(clientContextMenu.clientId);
setClientContextMenu(null);
}}
>
<span className="ts-menu-item-icon">🤫</span>
<span className="ts-menu-item-label">
{whisperClientIds.has(clientContextMenu.clientId)
? t("clientContext.removeWhisperTarget")
: t("clientContext.addWhisperTarget")}
</span>
</button>
)}
<div className="ts-menu-separator" />
<button className="ts-menu-item" disabled title={t("clientContext.notSupported")}>
<span className="ts-menu-item-icon">🏷️</span>
+12 -2
View File
@@ -38,12 +38,15 @@ const translations: Record<Lang, Record<string, string>> = {
"menu.extras.startRecording": "Aufnahme starten",
"menu.extras.startMultitrackRecording": "Start Multitrack Recording",
"menu.extras.stopRecording": "Aufnahme beenden",
"menu.extras.installOverwolf": "Overwolf installieren",
"menu.extras.options": "Optionen",
"toolbar.setAway": "Als abwesend markieren",
"toolbar.backOnline": "Wieder online",
"toolbar.awayOptions": "Abwesenheitsoptionen",
"toolbar.whisper": "Whisper-Ziele",
"whisper.channels": "Channels",
"whisper.clients": "Clients",
"whisper.clearAll": "Alle Whisper-Ziele entfernen",
"toolbar.micEnable": "Mikrofon aktivieren",
"toolbar.micMute": "Mikrofon stummschalten",
"toolbar.micUnmute": "Mikrofon aktivieren (unmute)",
@@ -209,6 +212,8 @@ const translations: Record<Lang, Record<string, string>> = {
"clientContext.privateChat": "Privater Chat",
"clientContext.poke": "Anstupsen",
"clientContext.copyName": "Namen kopieren",
"clientContext.addWhisperTarget": "Als Whisper-Ziel hinzufügen",
"clientContext.removeWhisperTarget": "Als Whisper-Ziel entfernen",
"clientContext.assignChannelGroup": "Channel-Gruppe zuweisen",
"clientContext.assignServerGroup": "Server-Gruppe zuweisen",
"clientContext.kick": "Vom Server kicken",
@@ -277,12 +282,15 @@ const translations: Record<Lang, Record<string, string>> = {
"menu.extras.startRecording": "Start Recording",
"menu.extras.startMultitrackRecording": "Start Multitrack Recording",
"menu.extras.stopRecording": "Stop Recording",
"menu.extras.installOverwolf": "Install Overwolf",
"menu.extras.options": "Options",
"toolbar.setAway": "Set away",
"toolbar.backOnline": "Back online",
"toolbar.awayOptions": "Away options",
"toolbar.whisper": "Whisper targets",
"whisper.channels": "Channels",
"whisper.clients": "Clients",
"whisper.clearAll": "Clear all whisper targets",
"toolbar.micEnable": "Enable microphone",
"toolbar.micMute": "Mute microphone",
"toolbar.micUnmute": "Unmute microphone",
@@ -448,6 +456,8 @@ const translations: Record<Lang, Record<string, string>> = {
"clientContext.privateChat": "Private chat",
"clientContext.poke": "Poke",
"clientContext.copyName": "Copy name",
"clientContext.addWhisperTarget": "Add as whisper target",
"clientContext.removeWhisperTarget": "Remove as whisper target",
"clientContext.assignChannelGroup": "Assign channel group",
"clientContext.assignServerGroup": "Assign server group",
"clientContext.kick": "Kick from server",