Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots 📖

feat(ui): share the voice narration card with an access row and a live meter

Luis Ortizbbe14900d0b3
diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts
index 2ec9941..33a1bda 100644
--- a/packages/ui/src/index.ts
+++ b/packages/ui/src/index.ts
@@ -56,4 +56,6 @@ export { VoiceStep } from './onboarding/components/VoiceStep';
export type { StepProps } from './onboarding/types';
export { SearchModal } from './search/components/SearchModal';
export { useFullview } from './stores/use-fullview';
+export { MicrophoneAccessRow } from './voice/components/MicrophoneAccessRow';
export { MicrophonePicker } from './voice/components/MicrophonePicker';
+export { NarrationSettings } from './voice/components/NarrationSettings';
diff --git a/packages/ui/src/voice/components/MicrophoneAccessRow.tsx b/packages/ui/src/voice/components/MicrophoneAccessRow.tsx
new file mode 100644
index 0000000..97a694f
--- /dev/null
+++ b/packages/ui/src/voice/components/MicrophoneAccessRow.tsx
@@ -0,0 +1,35 @@
+import { i18n } from '@mimik/core/env';
+import { ExternalLink, Mic, MicOff } from 'lucide-react';
+import { Button } from '../../components/ui/button';
+
+interface MicrophoneAccessRowProps {
+ refused: boolean;
+ hint: string;
+ action: string;
+ external?: boolean;
+ onRequest: () => void;
+}
+
+export function MicrophoneAccessRow({ refused, hint, action, external = false, onRequest }: MicrophoneAccessRowProps) {
+ const Icon = refused ? MicOff : Mic;
+ return (
+ <div className="flex items-center gap-2.5 rounded-[10px] border border-border p-2.5">
+ <span className="grid size-7 shrink-0 place-items-center rounded-lg bg-secondary">
+ <Icon size={15} className={refused ? 'text-destructive' : 'text-accent'} />
+ </span>
+ <div className="min-w-0 flex-1">
+ <p className="text-[12px] font-semibold text-foreground">{i18n.t('settings.microphoneAccess')}</p>
+ <p className="text-[11px] leading-snug text-muted-foreground">{hint}</p>
+ </div>
+ <Button
+ size="sm"
+ variant={refused ? 'outline' : 'default'}
+ onClick={onRequest}
+ className="h-7 shrink-0 rounded-lg text-[11px]"
+ >
+ {external && <ExternalLink size={12} />}
+ {action}
+ </Button>
+ </div>
+ );
+}
diff --git a/packages/ui/src/voice/components/MicrophonePicker.tsx b/packages/ui/src/voice/components/MicrophonePicker.tsx
index 9c91654..4716186 100644
--- a/packages/ui/src/voice/components/MicrophonePicker.tsx
+++ b/packages/ui/src/voice/components/MicrophonePicker.tsx
@@ -11,6 +11,7 @@ import { toMicrophoneOptions } from '../lib/to-microphone-options';
import { SYSTEM_DEFAULT_VALUE, toSelectValue } from '../lib/to-select-value';
import { toStoredMicrophoneId } from '../lib/to-stored-microphone-id';
import type { MicrophoneDevice } from '../types';
+import { MicrophoneAccessRow } from './MicrophoneAccessRow';
import { StatusBadge } from './StatusBadge';
interface MicrophonePickerProps {
@@ -18,6 +19,8 @@ interface MicrophonePickerProps {
value: string;
onChange: (deviceId: string) => void;
onRequestAccess: () => Promise<void>;
+ live?: boolean;
+ disabled?: boolean;
}
interface MicTest {
@@ -30,7 +33,14 @@ const MICROPHONE: PermissionDescriptor = { name: 'microphone' as PermissionName
const ANALYSER_FFT_SIZE = 2048;
const METER_INTERVAL_MS = 80;
-export function MicrophonePicker({ value, onChange, onRequestAccess, triggerClassName }: MicrophonePickerProps) {
+export function MicrophonePicker({
+ value,
+ onChange,
+ onRequestAccess,
+ triggerClassName,
+ live = false,
+ disabled = false,
+}: MicrophonePickerProps) {
const [devices, setDevices] = useState<MicrophoneDevice[]>([]);
const [testing, setTesting] = useState(false);
const [level, setLevel] = useState(0);
@@ -133,6 +143,14 @@ export function MicrophonePicker({ value, onChange, onRequestAccess, triggerClas
const missing = isMicrophoneMissing(value, options);
const status = microphoneStatus(permission, state);
const blocked = status === 'blocked';
+ const needsAccess = state === 'unlabelled' || blocked;
+ const metering = live && !disabled && state === 'ready' && !blocked;
+
+ useEffect(() => {
+ if (!metering) return;
+ void startTest();
+ return stopTest;
+ }, [metering, startTest, stopTest]);
return (
<div>
@@ -143,14 +161,25 @@ export function MicrophonePicker({ value, onChange, onRequestAccess, triggerClas
>
{i18n.t('settings.microphone')}
</label>
- <StatusBadge status={status} />
+ {!live && !disabled && <StatusBadge status={status} />}
</div>
{state === 'no-devices' && !blocked && (
<p className="text-[10px] text-muted-foreground leading-relaxed">{i18n.t('settings.microphoneNone')}</p>
)}
- {(state === 'unlabelled' || blocked) && (
+ {live && needsAccess && (
+ <div className="mb-2">
+ <MicrophoneAccessRow
+ refused={blocked}
+ hint={i18n.t(blocked ? 'settings.microphoneBlocked' : 'settings.microphoneAccessAsk')}
+ action={i18n.t(blocked ? 'micPermission.retry' : 'settings.microphoneAccessAllow')}
+ onRequest={() => void requestAccess()}
+ />
+ </div>
+ )}
+
+ {!live && needsAccess && (
<div className="space-y-2">
{!blocked && (
<p className="text-[10px] text-muted-foreground leading-relaxed">
@@ -180,9 +209,10 @@ export function MicrophonePicker({ value, onChange, onRequestAccess, triggerClas
</div>
)}
- {state === 'ready' && !blocked && (
+ {((state === 'ready' && !blocked) || (live && needsAccess)) && (
<div className="space-y-2">
<Select
+ disabled={disabled || needsAccess}
value={toSelectValue(value)}
onValueChange={(next) => {
stopTest();
@@ -212,15 +242,17 @@ export function MicrophonePicker({ value, onChange, onRequestAccess, triggerClas
</p>
)}
- <Button
- variant="outline"
- size="sm"
- onClick={() => (testing ? stopTest() : void startTest())}
- className="w-full rounded-lg bg-card text-[11px] font-semibold"
- >
- {testing ? <Square size={11} /> : <Mic size={11} />}
- {i18n.t(testing ? 'settings.microphoneTestStop' : 'settings.microphoneTest')}
- </Button>
+ {!live && !disabled && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => (testing ? stopTest() : void startTest())}
+ className="w-full rounded-lg bg-card text-[11px] font-semibold"
+ >
+ {testing ? <Square size={11} /> : <Mic size={11} />}
+ {i18n.t(testing ? 'settings.microphoneTestStop' : 'settings.microphoneTest')}
+ </Button>
+ )}
{testing && (
<div className="space-y-1">
diff --git a/packages/ui/src/voice/components/NarrationSettings.tsx b/packages/ui/src/voice/components/NarrationSettings.tsx
new file mode 100644
index 0000000..12ccadb
--- /dev/null
+++ b/packages/ui/src/voice/components/NarrationSettings.tsx
@@ -0,0 +1,87 @@
+import { KEY_PROVIDER_LABELS } from '@mimik/core/capture/ai/keys';
+import { normalizeVoiceProvider } from '@mimik/core/capture/voice/api-key';
+import type { VoiceProvider } from '@mimik/core/capture/voice/transcribe';
+import { i18n, localStorage } from '@mimik/core/env';
+import { Mic } from 'lucide-react';
+import { type ReactNode, useEffect, useState } from 'react';
+import { MissingKeyNote } from '../../ai/components/MissingKeyNote';
+import { ProviderSelect } from '../../ai/components/ProviderSelect';
+import type { ApiKeysState } from '../../ai/hooks/use-api-keys';
+import { SettingsCard } from '../../common/components/SettingsCard';
+import { MicrophonePicker } from './MicrophonePicker';
+
+interface NarrationSettingsProps {
+ keys: ApiKeysState;
+ onOpenKeys?: () => void;
+ onChange?: (patch: Record<string, unknown>) => void;
+ onRequestAccess?: () => Promise<void>;
+ access?: ReactNode;
+ microphoneDisabled?: boolean;
+ liveMeter?: boolean;
+}
+
+export function NarrationSettings({
+ keys,
+ onOpenKeys,
+ onChange,
+ onRequestAccess,
+ access,
+ microphoneDisabled = false,
+ liveMeter = false,
+}: NarrationSettingsProps) {
+ const [provider, setProvider] = useState<VoiceProvider>('openai');
+ const [microphoneId, setMicrophoneId] = useState('');
+
+ useEffect(() => {
+ localStorage.get(['voiceProvider', 'voiceMicrophoneId']).then((stored) => {
+ setProvider(normalizeVoiceProvider(stored.voiceProvider));
+ setMicrophoneId(stored.voiceMicrophoneId ?? '');
+ });
+ }, []);
+
+ const save = (patch: { voiceProvider?: VoiceProvider; voiceMicrophoneId?: string }) => {
+ void localStorage.set(patch);
+ onChange?.(patch);
+ };
+
+ return (
+ <SettingsCard icon={Mic} title={i18n.t('settings.voiceNarration')} hint={i18n.t('settings.voiceNarrationHint')}>
+ <div>
+ <label className="block text-[11px] font-semibold text-foreground mb-1">{i18n.t('settings.provider')}</label>
+ <ProviderSelect
+ value={provider}
+ onChange={(next) => {
+ setProvider(next);
+ save({ voiceProvider: next });
+ }}
+ onOpenKeys={onOpenKeys}
+ options={(['openai', 'groq'] as const).map((key) => ({
+ value: key,
+ label: KEY_PROVIDER_LABELS[key],
+ logo: key,
+ available: Boolean(keys.keys[key]),
+ }))}
+ />
+ {!keys.keys[provider] && (
+ <MissingKeyNote text={i18n.t('settings.noKeyFor', [KEY_PROVIDER_LABELS[provider]])} onOpenKeys={onOpenKeys} />
+ )}
+ </div>
+
+ {access}
+
+ {onRequestAccess && (
+ <MicrophonePicker
+ live={liveMeter}
+ disabled={microphoneDisabled}
+ value={microphoneId}
+ onChange={(next) => {
+ setMicrophoneId(next);
+ save({ voiceMicrophoneId: next });
+ }}
+ onRequestAccess={onRequestAccess}
+ triggerClassName="h-8"
+ />
+ )}
+ </SettingsCard>
+ );
+}
diff --git a/src/locales/de.yml b/src/locales/de.yml
index 27d6158..4edb461 100644
--- a/src/locales/de.yml
+++ b/src/locales/de.yml
@@ -90,6 +90,9 @@ recording:
minutesAgo: "vor $1 Min."
settings:
+ microphoneAccess: "Mikrofonzugriff"
+ microphoneAccessAsk: "Dein Browser fragt einmal, bevor Mimik dich hören kann."
+ microphoneAccessAllow: "Erlauben"
targetColorHint: "Färbt die Klickmarkierung und die Akzente in Exporten."
branding: "Export-Branding"
logoAndFooter: "Logo und Fußzeile"
@@ -183,6 +186,9 @@ blurPresets:
macAddress: MAC-Adresse
desktop:
+ micAccessAsk: "macOS fragt einmal, bevor Mimik dich hören kann."
+ micAccessRefused: "Abgelehnt. Aktiviere Mimik unter Datenschutz & Sicherheit."
+ micAccessOpen: "Einstellungen öffnen"
ready: "Bereit"
pause: "Pausieren"
resume: "Fortsetzen"
diff --git a/src/locales/en.yml b/src/locales/en.yml
index aa450cb..d82dff4 100644
--- a/src/locales/en.yml
+++ b/src/locales/en.yml
@@ -90,6 +90,9 @@ recording:
minutesAgo: "$1m ago"
settings:
+ microphoneAccess: "Microphone access"
+ microphoneAccessAsk: "Your browser asks once before Mimik can hear you."
+ microphoneAccessAllow: "Allow"
title: Settings
aiDescriptions: "Step descriptions"
aiDescriptionsHint: "Mimik writes each step's text and names your guide with your AI provider."
@@ -183,6 +186,9 @@ blurPresets:
macAddress: "MAC address"
desktop:
+ micAccessAsk: "macOS asks once before Mimik can hear you."
+ micAccessRefused: "Refused. Turn on Mimik in Privacy & Security."
+ micAccessOpen: "Open settings"
ready: Ready
pause: Pause
resume: Resume
diff --git a/src/locales/es.yml b/src/locales/es.yml
index 457c3e1..b4076b7 100644
--- a/src/locales/es.yml
+++ b/src/locales/es.yml
@@ -90,6 +90,9 @@ recording:
minutesAgo: "hace $1m"
settings:
+ microphoneAccess: "Acceso al micrófono"
+ microphoneAccessAsk: "Tu navegador pregunta una vez antes de que Mimik pueda oírte."
+ microphoneAccessAllow: "Permitir"
title: Ajustes
aiDescriptions: "Descripciones de los pasos"
aiDescriptionsHint: "Mimik escribe el texto de cada paso y nombra tu guía con tu proveedor de IA."
@@ -183,6 +186,9 @@ blurPresets:
macAddress: "Dirección MAC"
desktop:
+ micAccessAsk: "macOS pregunta una vez antes de que Mimik pueda oírte."
+ micAccessRefused: "Denegado. Activa Mimik en Privacidad y seguridad."
+ micAccessOpen: "Abrir ajustes"
ready: "Listo"
pause: "Pausar"
resume: "Reanudar"
diff --git a/src/locales/fr.yml b/src/locales/fr.yml
index 2f6355f..63c6f0f 100644
--- a/src/locales/fr.yml
+++ b/src/locales/fr.yml
@@ -90,6 +90,9 @@ recording:
minutesAgo: "Il y a $1 min"
settings:
+ microphoneAccess: "Accès au micro"
+ microphoneAccessAsk: "Votre navigateur demande une fois avant que Mimik puisse vous entendre."
+ microphoneAccessAllow: "Autoriser"
title: "Paramètres"
aiDescriptions: "Descriptions des étapes"
aiDescriptionsHint: "Mimik rédige le texte de chaque étape et nomme votre guide avec votre fournisseur d’IA."
@@ -183,6 +186,9 @@ blurPresets:
macAddress: Adresse MAC
desktop:
+ micAccessAsk: "macOS demande une fois avant que Mimik puisse vous entendre."
+ micAccessRefused: "Refusé. Activez Mimik dans Confidentialité et sécurité."
+ micAccessOpen: "Ouvrir les réglages"
ready: "Prêt"
pause: "Pause"
resume: "Reprendre"
diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.yml
index f6c500a..3649b31 100644
--- a/src/locales/pt-BR.yml
+++ b/src/locales/pt-BR.yml
@@ -90,6 +90,9 @@ recording:
minutesAgo: "$1min atrás"
settings:
+ microphoneAccess: "Acesso ao microfone"
+ microphoneAccessAsk: "Seu navegador pergunta uma vez antes que o Mimik possa ouvir você."
+ microphoneAccessAllow: "Permitir"
title: Ajustes
aiDescriptions: "Descrições das etapas"
aiDescriptionsHint: "O Mimik escreve o texto de cada etapa e dá nome ao seu guia com o seu provedor de IA."
@@ -183,6 +186,9 @@ blurPresets:
macAddress: Endereço MAC
desktop:
+ micAccessAsk: "O macOS pergunta uma vez antes que o Mimik possa ouvir você."
+ micAccessRefused: "Recusado. Ative o Mimik em Privacidade e Segurança."
+ micAccessOpen: "Abrir ajustes"
ready: "Pronto"
pause: "Pausar"
resume: "Retomar"
diff --git a/src/locales/zh-CN.yml b/src/locales/zh-CN.yml
index c307e70..b46e136 100644
--- a/src/locales/zh-CN.yml
+++ b/src/locales/zh-CN.yml
@@ -90,6 +90,9 @@ recording:
minutesAgo: "$1 分钟前"
settings:
+ microphoneAccess: "麦克风权限"
+ microphoneAccessAsk: "浏览器会先询问一次,Mimik 才能听到你的声音。"
+ microphoneAccessAllow: "允许"
title: 设置
aiDescriptions: "步骤描述"
aiDescriptionsHint: "Mimik 使用你的 AI 服务商撰写每个步骤的文字并为指南命名。"
@@ -183,6 +186,9 @@ blurPresets:
macAddress: MAC 地址
desktop:
+ micAccessAsk: "macOS 会先询问一次,Mimik 才能听到你的声音。"
+ micAccessRefused: "已拒绝。请在“隐私与安全性”中打开 Mimik。"
+ micAccessOpen: "打开设置"
ready: "就绪"
pause: "暂停"
resume: "继续"
diff --git a/src/ui/shared/SettingsView.tsx b/src/ui/shared/SettingsView.tsx
index 17225a8..48cbea4 100644
--- a/src/ui/shared/SettingsView.tsx
+++ b/src/ui/shared/SettingsView.tsx
@@ -1,21 +1,17 @@
import { PRESET_LABELS, type PresetKey } from '@mimik/core/blur/regexes';
-import { KEY_PROVIDER_LABELS } from '@mimik/core/capture/ai/keys';
-import type { VoiceProvider } from '@mimik/core/capture/voice/transcribe';
import { i18n } from '@mimik/core/env';
import type { VoiceoverProviderKey } from '@mimik/core/export/voiceover/providers';
import {
AiSettings,
ApiKeysSettings,
BrandingSettings,
- MicrophonePicker,
- MissingKeyNote,
- ProviderSelect,
+ NarrationSettings,
SettingsCard,
Switch,
useApiKeys,
VoiceoverSettings,
} from '@mimik/ui';
-import { ArrowLeft, Bug, Check, ChevronRight, EyeOff, Mic, Shield, Star } from 'lucide-react';
+import { ArrowLeft, Bug, Check, ChevronRight, EyeOff, Shield, Star } from 'lucide-react';
import { type ReactNode, useCallback, useEffect, useState } from 'react';
import { localStorage } from '@/lib/browser-api/local-storage';
import { sendMessage } from '@/lib/messaging';
@@ -33,8 +29,6 @@ interface SettingsViewProps {
export function SettingsView({ onBack, layout = 'column' }: SettingsViewProps) {
const [section, setSection] = useState<SettingsSection>(() => settingsSection(window.location.hash));
const [loaded, setLoaded] = useState(false);
- const [voiceProvider, setVoiceProvider] = useState<VoiceProvider>('openai');
- const [voiceMicrophoneId, setVoiceMicrophoneId] = useState('');
const [blurPresets, setBlurPresets] = useState<Record<PresetKey, boolean>>({
email: true,
phone: true,
@@ -45,15 +39,13 @@ export function SettingsView({ onBack, layout = 'column' }: SettingsViewProps) {
});
useEffect(() => {
- localStorage.get(['blurPresets', 'voiceProvider', 'voiceMicrophoneId']).then((result) => {
+ localStorage.get(['blurPresets']).then((result) => {
if (result.blurPresets) setBlurPresets(result.blurPresets as Record<PresetKey, boolean>);
- setVoiceProvider(result.voiceProvider === 'groq' ? 'groq' : 'openai');
- if (result.voiceMicrophoneId) setVoiceMicrophoneId(result.voiceMicrophoneId as string);
setLoaded(true);
});
}, []);
- const { saved, queue } = useSettingsAutosave({ blurPresets, voiceProvider, voiceMicrophoneId }, loaded);
+ const { saved, queue } = useSettingsAutosave({ blurPresets }, loaded);
const keys = useApiKeys({ onChange: queue });
const showSection = (next: SettingsSection) => {
@@ -93,37 +85,13 @@ export function SettingsView({ onBack, layout = 'column' }: SettingsViewProps) {
const sections: Record<SettingsSection, ReactNode> = {
ai: <AiSettings keys={keys} onOpenKeys={openKeys} onChange={queue} />,
narration: (
- <SettingsCard icon={Mic} title={i18n.t('settings.voiceNarration')} hint={i18n.t('settings.voiceNarrationHint')}>
- <div>
- <label className="block text-[11px] font-semibold text-foreground mb-1">{i18n.t('settings.provider')}</label>
- <ProviderSelect
- value={voiceProvider}
- onChange={setVoiceProvider}
- onOpenKeys={openKeys}
- options={(['openai', 'groq'] as const).map((key) => ({
- value: key,
- label: KEY_PROVIDER_LABELS[key],
- logo: key,
- available: Boolean(keys.keys[key]),
- }))}
- />
- {!keys.keys[voiceProvider] && (
- <MissingKeyNote
- text={i18n.t('settings.noKeyFor', [KEY_PROVIDER_LABELS[voiceProvider]])}
- onOpenKeys={openKeys}
- />
- )}
- </div>
-
- {import.meta.env.BROWSER !== 'firefox' && (
- <MicrophonePicker
- value={voiceMicrophoneId}
- onChange={setVoiceMicrophoneId}
- onRequestAccess={requestMicrophoneAccess}
- triggerClassName="h-8"
- />
- )}
- </SettingsCard>
+ <NarrationSettings
+ keys={keys}
+ onOpenKeys={openKeys}
+ onChange={queue}
+ onRequestAccess={import.meta.env.BROWSER !== 'firefox' ? requestMicrophoneAccess : undefined}
+ liveMeter
+ />
),
'voice-over': <VoiceoverSettings keys={keys.keys} listVoices={listVoices} onOpenKeys={openKeys} onChange={queue} />,
branding: <BrandingSettings onChange={queue} />,