The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): say HTTPS fixes the microphone on a plain-HTTP Webapp
unsupportedpastels1c67fed9753b
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-mic-recorder.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-mic-recorder.test.tsxindex 7e350a6d394..9a2d31e442f 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-mic-recorder.test.tsx+++ b/apps/desktop/src/app/chat/composer/hooks/use-mic-recorder.test.tsx@@ -12,6 +12,7 @@ const copy: MicRecorderErrorCopy = {microphoneAccessDenied: 'denied',microphoneConstraintsUnsupported: 'constraints',microphoneInUse: 'in use',+ microphoneNeedsHttps: 'needs https',microphonePermissionDenied: 'permission',microphoneStartFailed: 'start failed',microphoneUnsupported: 'unsupported',diff --git a/apps/desktop/src/app/chat/composer/hooks/use-mic-recorder.ts b/apps/desktop/src/app/chat/composer/hooks/use-mic-recorder.tsindex 566751e31dd..5f07e580cff 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-mic-recorder.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-mic-recorder.ts@@ -1,6 +1,7 @@import { useEffect, useRef, useState } from 'react'import { closeMeterContext, meterContextsClosed } from '@/lib/mic-meter-context'+import { isBrowserHostedDesktop } from '@/lib/platform'type BrowserAudioContext = typeof AudioContext@@ -33,6 +34,7 @@ export interface MicRecorderErrorCopy {microphoneAccessDenied: stringmicrophoneConstraintsUnsupported: stringmicrophoneInUse: string+ microphoneNeedsHttps: stringmicrophonePermissionDenied: stringmicrophoneStartFailed: stringmicrophoneUnsupported: string@@ -45,6 +47,15 @@ interface MicRecorderHandle {cancel: () => void}+/** "Microphone unsupported" copy. The Webapp opened over plain HTTP from another machine is an+ * insecure context with no mediaDevices: it says HTTPS or a tunnel fixes that. Native Desktop+ * keeps the plain copy. */+function unsupportedMicrophone(copy: MicRecorderErrorCopy): string {+ return isBrowserHostedDesktop() && window.isSecureContext === false+ ? copy.microphoneNeedsHttps+ : copy.microphoneUnsupported+}+/** Recorder + live-start mic failures → the same friendly copy: a DOMException* name is mapped, an unrecognized DOMException falls back to the generic start* copy, and anything else keeps its own message (non-mic failures must not be@@ -69,7 +80,7 @@ export function micError(error: unknown, copy: MicRecorderErrorCopy): Error {}if (name === 'NotSupportedError') {- return new Error(copy.microphoneUnsupported)+ return new Error(unsupportedMicrophone(copy))}if (error instanceof DOMException) {@@ -272,7 +283,7 @@ export function useMicRecorder(copy: MicRecorderErrorCopy): {}if (!navigator.mediaDevices?.getUserMedia || typeof MediaRecorder === 'undefined') {- throw new Error(copy.microphoneUnsupported)+ throw new Error(unsupportedMicrophone(copy))}const permitted = await window.hermesDesktop?.requestMicrophoneAccess?.()diff --git a/apps/desktop/src/i18n/ar_diagnostics.ts b/apps/desktop/src/i18n/ar_diagnostics.tsindex 4694eaf93bf..5c1f83dd830 100644--- a/apps/desktop/src/i18n/ar_diagnostics.ts+++ b/apps/desktop/src/i18n/ar_diagnostics.ts@@ -73,6 +73,7 @@ export const arDiagnostics = {microphoneConstraintsUnsupported: 'قيود الميكروفون غير مدعومة على هذا الجهاز.',microphoneFailed: 'فشل الميكروفون',microphoneInUse: 'الميكروفون مستخدم من تطبيق آخر.',+ microphoneNeedsHttps: 'يحتاج الميكروفون إلى اتصال آمن. افتح Webapp عبر HTTPS، أو عبر نفق SSH إلى 127.0.0.1، لاستخدامه.',microphonePermissionDenied: 'تم رفض إذن الميكروفون.',microphoneStartFailed: 'تعذر بدء تسجيل الميكروفون.',microphoneUnsupported: 'هذا المتصفح لا يدعم تسجيل الميكروفون.',diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.tsindex b6bc9ed0bb1..81ae8f25ad6 100644--- a/apps/desktop/src/i18n/de.ts+++ b/apps/desktop/src/i18n/de.ts@@ -464,6 +464,7 @@ export const deOverrides = {microphoneConstraintsUnsupported: 'Mikrofon-Einschränkungen werden von diesem Gerät nicht unterstützt.',microphoneFailed: 'Mikrofon fehlgeschlagen',microphoneInUse: 'Das Mikrofon wird bereits von einer anderen App verwendet.',+ microphoneNeedsHttps: 'Das Mikrofon braucht eine sichere Verbindung. Öffne die Webapp über HTTPS oder über einen SSH-Tunnel zu 127.0.0.1, um es zu nutzen.',microphonePermissionDenied: 'Die Mikrofonberechtigung wurde verweigert.',microphoneStartFailed: 'Mikrofonaufnahme konnte nicht gestartet werden.',microphoneUnsupported: 'Diese Laufzeitumgebung unterstützt keine Mikrofonaufnahme.',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 8a0e9714205..e8d90bbcff7 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -454,6 +454,7 @@ export const en: Translations = {microphoneConstraintsUnsupported: 'Microphone constraints are not supported by this device.',microphoneFailed: 'Microphone failed',microphoneInUse: 'Microphone is already in use by another app.',+ microphoneNeedsHttps: 'The microphone needs a secure connection. Open the Webapp over HTTPS, or through an SSH tunnel to 127.0.0.1, to use it.',microphonePermissionDenied: 'Microphone permission was denied.',microphoneStartFailed: 'Could not start microphone recording.',microphoneUnsupported: 'This runtime does not support microphone recording.',diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.tsindex 7f4de6d8c1b..57e1a495bdb 100644--- a/apps/desktop/src/i18n/es.ts+++ b/apps/desktop/src/i18n/es.ts@@ -467,6 +467,7 @@ export const esOverrides = {microphoneConstraintsUnsupported: 'Este dispositivo no admite las restricciones del micrófono.',microphoneFailed: 'Falló el micrófono',microphoneInUse: 'El micrófono ya está en uso por otra app.',+ microphoneNeedsHttps: 'El micrófono necesita una conexión segura. Abre la Webapp por HTTPS, o mediante un túnel SSH a 127.0.0.1, para usarlo.',microphonePermissionDenied: 'Se denegó el permiso del micrófono.',microphoneStartFailed: 'No se pudo iniciar la grabación del micrófono.',microphoneUnsupported: 'Este runtime no admite grabación de micrófono.',diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.tsindex 51246ae22e6..32515b80141 100644--- a/apps/desktop/src/i18n/fr.ts+++ b/apps/desktop/src/i18n/fr.ts@@ -464,6 +464,7 @@ export const frOverrides = {microphoneConstraintsUnsupported: 'Les contraintes du microphone ne sont pas prises en charge par cet appareil.',microphoneFailed: 'Échec du microphone',microphoneInUse: 'Le microphone est déjà utilisé par une autre application.',+ microphoneNeedsHttps: "Le micro nécessite une connexion sécurisée. Ouvrez la Webapp en HTTPS, ou via un tunnel SSH vers 127.0.0.1, pour l'utiliser.",microphonePermissionDenied: "L'autorisation du microphone a été refusée.",microphoneStartFailed: "Impossible de démarrer l'enregistrement du microphone.",microphoneUnsupported: "Ce runtime ne prend pas en charge l'enregistrement micro.",diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 6c02751744b..05db72758b0 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -159,6 +159,7 @@ export const jaOverrides = {microphoneConstraintsUnsupported: 'このデバイスはマイクの制約をサポートしていません。',microphoneFailed: 'マイクが失敗しました',microphoneInUse: 'マイクは他のアプリで使用中です。',+ microphoneNeedsHttps: 'マイクには安全な接続が必要です。使うには、Webapp を HTTPS か 127.0.0.1 への SSH トンネル経由で開いてください。',microphonePermissionDenied: 'マイクのアクセス許可が拒否されました。',microphoneStartFailed: 'マイクの録音を開始できませんでした。',microphoneUnsupported: 'このランタイムはマイク録音をサポートしていません。',diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex e67bd8960dd..8e91e823293 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -147,6 +147,7 @@ export const ruOverrides = {microphoneConstraintsUnsupported: 'Ограничения микрофона не поддерживаются этим устройством.',microphoneFailed: 'Ошибка микрофона',microphoneInUse: 'Микрофон уже используется другим приложением.',+ microphoneNeedsHttps: 'Микрофону нужно защищённое соединение. Откройте Webapp по HTTPS или через SSH-туннель к 127.0.0.1, чтобы им пользоваться.',microphonePermissionDenied: 'Доступ к микрофону запрещён.',microphoneStartFailed: 'Не удалось начать запись с микрофона.',microphoneUnsupported: 'Это окружение не поддерживает запись с микрофона.',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 59c05bc3cfd..4ce6eb6f189 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -481,6 +481,7 @@ catalog: CatalogTranslationsmicrophoneConstraintsUnsupported: stringmicrophoneFailed: stringmicrophoneInUse: string+ microphoneNeedsHttps: stringmicrophonePermissionDenied: stringmicrophoneStartFailed: stringmicrophoneUnsupported: stringdiff --git a/apps/desktop/src/i18n/zh-hant_diagnostics.ts b/apps/desktop/src/i18n/zh-hant_diagnostics.tsindex ac186d836e1..62da611e24e 100644--- a/apps/desktop/src/i18n/zh-hant_diagnostics.ts+++ b/apps/desktop/src/i18n/zh-hant_diagnostics.ts@@ -53,6 +53,7 @@ export const zhHantDiagnostics = {microphoneConstraintsUnsupported: '此裝置不支援目前的麥克風限制條件。',microphoneFailed: '麥克風發生錯誤',microphoneInUse: '麥克風正被其他應用程式使用中。',+ microphoneNeedsHttps: '麥克風需要安全連線。請透過 HTTPS 或到 127.0.0.1 的 SSH 通道開啟 Webapp 後使用。',microphonePermissionDenied: '麥克風權限被拒絕。',microphoneStartFailed: '無法開始麥克風錄音。',microphoneUnsupported: '目前執行環境不支援麥克風錄音。',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 3dd7876eb6e..d41e5010b7a 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -244,6 +244,7 @@ export const zhOverrides = {microphoneConstraintsUnsupported: '此设备不支持当前麦克风约束。',microphoneFailed: '麦克风出错',microphoneInUse: '麦克风正被其他应用占用。',+ microphoneNeedsHttps: '麦克风需要安全连接。请通过 HTTPS 或到 127.0.0.1 的 SSH 隧道打开 Webapp 后使用。',microphonePermissionDenied: '麦克风权限被拒绝。',microphoneStartFailed: '无法开始麦克风录音。',microphoneUnsupported: '当前运行环境不支持麦克风录音。',diff --git a/apps/desktop/src/lib/voice-microphone-unsupported.test.ts b/apps/desktop/src/lib/voice-microphone-unsupported.test.tsindex d24368a135d..264894eaace 100644--- a/apps/desktop/src/lib/voice-microphone-unsupported.test.ts+++ b/apps/desktop/src/lib/voice-microphone-unsupported.test.ts@@ -1,4 +1,4 @@-import { afterEach, expect, it, vi } from 'vitest'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { micError } from '@/app/chat/composer/hooks/use-mic-recorder'import { en } from '@/i18n/en'@@ -26,6 +26,26 @@ it('live voice fails with "microphone unsupported" without mediaDevices, beforeexpect(peers).not.toHaveBeenCalled()})+describe('on an insecure origin', () => {+ beforeEach(() => Object.defineProperty(window, 'isSecureContext', { configurable: true, value: false }))+ afterEach(() => {+ Reflect.deleteProperty(window, 'isSecureContext')+ delete document.documentElement.dataset.hermesDesktopHost+ })++ const unsupported = () => micError(new DOMException('no mic here', 'NotSupportedError'), en.notifications.voice)++ it('the Webapp says HTTPS or a tunnel brings the microphone back', () => {+ document.documentElement.dataset.hermesDesktopHost = 'browser'++ expect(unsupported().message).toBe(en.notifications.voice.microphoneNeedsHttps)+ })++ it('native Desktop keeps the plain "microphone unsupported" copy', () => {+ expect(unsupported().message).toBe(en.notifications.voice.microphoneUnsupported)+ })+})+it('barge-in never reaches for a microphone it cannot have', () => {const audioContext = vi.fn()vi.stubGlobal('AudioContext', audioContext)diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.jsonindex c594532ff9c..66fa0a0ef62 100644--- a/locales/_keys.desktop.json+++ b/locales/_keys.desktop.json@@ -2222,6 +2222,7 @@"notifications.voice.microphoneConstraintsUnsupported","notifications.voice.microphoneFailed","notifications.voice.microphoneInUse",+ "notifications.voice.microphoneNeedsHttps","notifications.voice.microphonePermissionDenied","notifications.voice.microphoneStartFailed","notifications.voice.microphoneUnsupported",