Add web dictation recorder and shortcuts

This commit is contained in:
Mohamed Boudra
2025-11-23 14:32:08 +01:00
parent 47a99f5668
commit 6aa9b1c72e
4 changed files with 326 additions and 0 deletions
@@ -261,6 +261,7 @@ export function AgentInputArea({ agentId }: AgentInputAreaProps) {
};
}, []);
function isTextAreaLike(value: unknown): value is TextAreaHandle {
if (!value || typeof value !== "object") {
return false;
@@ -457,6 +458,44 @@ export function AgentInputArea({ agentId }: AgentInputAreaProps) {
}
}, [isAgentRunning, ws.isConnected]);
useEffect(() => {
if (!IS_WEB) {
return;
}
const handleDictationShortcut = (event: KeyboardEvent) => {
const key = event.key.toLowerCase();
if (event.metaKey && !event.altKey && !event.ctrlKey && key === "d") {
event.preventDefault();
if (isRecording) {
void handleSendRecording();
} else if (!isRealtimeMode && shouldShowVoiceControls && ws.isConnected) {
void handleVoicePress();
}
return;
}
if (key === "escape" && isRecording) {
event.preventDefault();
void handleCancelRecording();
}
};
window.addEventListener("keydown", handleDictationShortcut);
return () => {
window.removeEventListener("keydown", handleDictationShortcut);
};
}, [
isRecording,
isRealtimeMode,
shouldShowVoiceControls,
ws,
handleVoicePress,
handleSendRecording,
handleCancelRecording,
]);
useEffect(() => {
focusWebTextInput();
}, [agentId]);