feat(call): mute + deafen global hotkeys with chord support (group E)

- New voiceHotkeys.ts storage module. Stores per-action bindings with
  modifier flags (Ctrl/Shift/Alt) so Discord-style chords like
  Ctrl+Shift+M work. Defaults match Discord — Ctrl+Shift+M mute,
  Ctrl+Shift+D deafen — but ship disabled to avoid surprise collisions.
- globalShortcut.ts grows registerGlobalShortcutPress /
  unregisterGlobalShortcut helpers that accept pre-formatted Tauri
  accelerator strings, since voiceHotkey chords can't be expressed by
  the existing codeToShortcut path (PTT-only single-key).
- CallContext registers the chords OS-wide while a call is active
  (connected | reconnecting) so the hotkeys work from any focused
  window. A window-keydown fallback handles the non-Tauri / denied
  registration case. Both unregister on call end.
- SettingsPage adds VoiceHotkeyControls (mute + deafen variants)
  with a chord-capture button that waits past modifier-only presses
  and binds to the first real key. Labels render as "Ctrl+Shift+M"
  consistently with the in-call PTT hint.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
byGalax
2026-04-22 20:07:09 +02:00
parent bc8a7c5a32
commit eb8f702576
4 changed files with 388 additions and 0 deletions
+32
View File
@@ -48,6 +48,38 @@ export async function unregisterPttShortcut(code: string): Promise<void> {
}
}
// Press-only global shortcut (for toggles like Mute/Deafen). Accepts an
// already-formatted accelerator string (e.g. "CommandOrControl+Shift+M")
// since these bindings may include modifier chords — the KeyboardEvent.code
// variant used by PTT can't express that.
export async function registerGlobalShortcutPress(
shortcut: string,
onPress: () => void,
): Promise<boolean> {
try {
if (await isRegistered(shortcut)) {
await unregister(shortcut);
}
await register(shortcut, (event: ShortcutEvent) => {
if (event.state === 'Pressed') onPress();
});
return true;
} catch (err: unknown) {
console.warn('registerGlobalShortcutPress failed', { shortcut, err });
return false;
}
}
export async function unregisterGlobalShortcut(shortcut: string): Promise<void> {
try {
if (await isRegistered(shortcut)) {
await unregister(shortcut);
}
} catch (err: unknown) {
console.warn('unregisterGlobalShortcut failed', { shortcut, err });
}
}
// Detects whether we're running under Tauri. When running in a pure web
// preview (vite dev in a browser without Tauri), importing the plugin still
// works but calls fall through to window.__TAURI_INTERNALS__ which doesn't