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 onboarding, asking for each key under the provider it belongs to

Luis Ortizf47f2c7e8d8c
diff --git a/packages/ui/src/ai/components/AiSettings.tsx b/packages/ui/src/ai/components/AiSettings.tsx
index d723737..6268235 100644
--- a/packages/ui/src/ai/components/AiSettings.tsx
+++ b/packages/ui/src/ai/components/AiSettings.tsx
@@ -1,5 +1,5 @@
-import { type AiChoice, KEY_PROVIDER_LABELS, SERVER } from '@mimik/core/capture/ai/keys';
-import { AI_PROVIDERS, CUSTOM_MODEL_VALUE } from '@mimik/core/capture/ai/models';
+import { SERVER } from '@mimik/core/capture/ai/keys';
+import { CUSTOM_MODEL_VALUE } from '@mimik/core/capture/ai/models';
import { AI_LANGUAGES, type AILanguageCode } from '@mimik/core/capture/ai/prompts';
import { i18n } from '@mimik/core/env';
import { Globe, Sparkles } from 'lucide-react';
@@ -8,6 +8,7 @@ import { Input } from '../../components/ui/input';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../components/ui/select';
import { useAiSettings } from '../hooks/use-ai-settings';
import type { ApiKeysState } from '../hooks/use-api-keys';
+import { aiProviderOptions } from '../lib/ai-provider-options';
import { MissingKeyNote } from './MissingKeyNote';
import { ProviderSelect } from './ProviderSelect';
@@ -34,20 +35,9 @@ export function AiSettings({ keys, onOpenKeys, onChange }: AiSettingsProps) {
value={provider}
onChange={setProvider}
onOpenKeys={onOpenKeys}
- options={[
- ...(Object.keys(AI_PROVIDERS) as (keyof typeof AI_PROVIDERS)[]).map((key) => ({
- value: key as AiChoice,
- label: KEY_PROVIDER_LABELS[key],
- logo: key,
- available: Boolean(keys.keys[key]),
- })),
- {
- value: SERVER as AiChoice,
- label: i18n.t('settings.ownServer'),
- logo: 'server' as const,
- available: Boolean(keys.server.url.trim()),
- },
- ]}
+ options={aiProviderOptions((choice) =>
+ choice === SERVER ? Boolean(keys.server.url.trim()) : Boolean(keys.keys[choice]),
+ )}
/>
{missing && <MissingKeyNote text={missing} onOpenKeys={onOpenKeys} />}
</div>
diff --git a/packages/ui/src/ai/components/ProviderKeyRow.tsx b/packages/ui/src/ai/components/ProviderKeyRow.tsx
index 1dd9cdb..f3f6dce 100644
--- a/packages/ui/src/ai/components/ProviderKeyRow.tsx
+++ b/packages/ui/src/ai/components/ProviderKeyRow.tsx
@@ -1,4 +1,5 @@
import { KEY_PLACEHOLDERS, KEY_PROVIDER_LABELS, type KeyProvider } from '@mimik/core/capture/ai/keys';
+import { i18n } from '@mimik/core/env';
import { useEffect } from 'react';
import { useKeyCheck } from '../hooks/use-key-check';
import type { ValidateKey } from '../types';
@@ -13,9 +14,10 @@ interface ProviderKeyRowProps {
value: string;
onChange: (value: string) => void;
validate: ValidateKey;
+ bare?: boolean;
}
-export function ProviderKeyRow({ provider, value, onChange, validate }: ProviderKeyRowProps) {
+export function ProviderKeyRow({ provider, value, onChange, validate, bare = false }: ProviderKeyRowProps) {
const keyCheck = useKeyCheck(validate);
const { check, reset } = keyCheck;
@@ -24,12 +26,18 @@ export function ProviderKeyRow({ provider, value, onChange, validate }: Provider
}, []);
return (
- <div className="py-2.5">
+ <div className={bare ? '' : 'py-2.5'}>
<div className="flex items-center gap-3">
- <span className="w-7 h-7 rounded-lg bg-secondary text-foreground flex items-center justify-center shrink-0">
- <ProviderLogo provider={provider} />
- </span>
- <span className="w-24 shrink-0 text-[13px] font-semibold text-foreground">{KEY_PROVIDER_LABELS[provider]}</span>
+ {!bare && (
+ <>
+ <span className="w-7 h-7 rounded-lg bg-secondary text-foreground flex items-center justify-center shrink-0">
+ <ProviderLogo provider={provider} />
+ </span>
+ <span className="w-24 shrink-0 text-[13px] font-semibold text-foreground">
+ {KEY_PROVIDER_LABELS[provider]}
+ </span>
+ </>
+ )}
<SecretInput
value={value}
onChange={(next) => {
@@ -40,18 +48,21 @@ export function ProviderKeyRow({ provider, value, onChange, validate }: Provider
if (value.trim()) void check(provider, value.trim());
}}
placeholder={KEY_PLACEHOLDERS[provider]}
- className="h-8 text-[13px] rounded-lg border-border"
+ aria-label={bare ? i18n.t('settings.apiKey') : undefined}
+ className={bare ? 'h-11 rounded-xl pl-4 text-sm border-border' : 'h-8 text-[13px] rounded-lg border-border'}
/>
- <span className="w-4 shrink-0 flex justify-center">
- <KeyStatusIcon status={keyCheck.status} />
- </span>
+ {!bare && (
+ <span className="w-4 shrink-0 flex justify-center">
+ <KeyStatusIcon status={keyCheck.status} />
+ </span>
+ )}
</div>
- {keyCheck.status !== 'valid' && keyCheck.status !== 'checking' && (
- <div className="pl-10">
+ {(bare || (keyCheck.status !== 'valid' && keyCheck.status !== 'checking')) && (
+ <div className={bare ? '' : 'pl-10'}>
<KeyStatusNote status={keyCheck.status} />
</div>
)}
- <div className="pl-10">
+ <div className={bare ? '' : 'pl-10'}>
<KeyWarningNote warning={keyCheck.warning} />
</div>
</div>
diff --git a/packages/ui/src/ai/components/ProviderSelect.tsx b/packages/ui/src/ai/components/ProviderSelect.tsx
index d53191f..045fb50 100644
--- a/packages/ui/src/ai/components/ProviderSelect.tsx
+++ b/packages/ui/src/ai/components/ProviderSelect.tsx
@@ -18,14 +18,21 @@ interface ProviderSelectProps<T extends string> {
options: ProviderOption<T>[];
onChange: (value: T) => void;
onOpenKeys?: () => void;
+ triggerClassName?: string;
}
-export function ProviderSelect<T extends string>({ value, options, onChange, onOpenKeys }: ProviderSelectProps<T>) {
+export function ProviderSelect<T extends string>({
+ value,
+ options,
+ onChange,
+ onOpenKeys,
+ triggerClassName,
+}: ProviderSelectProps<T>) {
const [open, setOpen] = useState(false);
return (
<Select open={open} onOpenChange={setOpen} value={value} onValueChange={(next) => onChange(next as T)}>
- <SelectTrigger className="h-8">
+ <SelectTrigger className={triggerClassName ?? 'h-8'}>
<SelectValue />
</SelectTrigger>
<SelectContent>
diff --git a/packages/ui/src/ai/lib/ai-provider-options.ts b/packages/ui/src/ai/lib/ai-provider-options.ts
new file mode 100644
index 0000000..47f32f6
--- /dev/null
+++ b/packages/ui/src/ai/lib/ai-provider-options.ts
@@ -0,0 +1,21 @@
+import { type AiChoice, KEY_PROVIDER_LABELS, SERVER } from '@mimik/core/capture/ai/keys';
+import { AI_PROVIDERS } from '@mimik/core/capture/ai/models';
+import { i18n } from '@mimik/core/env';
+import type { ProviderOption } from '../components/ProviderSelect';
+
+export function aiProviderOptions(available: (choice: AiChoice) => boolean): ProviderOption<AiChoice>[] {
+ return [
+ ...(Object.keys(AI_PROVIDERS) as (keyof typeof AI_PROVIDERS)[]).map((key) => ({
+ value: key as AiChoice,
+ label: KEY_PROVIDER_LABELS[key],
+ logo: key,
+ available: available(key),
+ })),
+ {
+ value: SERVER as AiChoice,
+ label: i18n.t('settings.ownServer'),
+ logo: 'server' as const,
+ available: available(SERVER),
+ },
+ ];
+}
diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts
index b0dd176..2ec9941 100644
--- a/packages/ui/src/index.ts
+++ b/packages/ui/src/index.ts
@@ -48,5 +48,12 @@ export { LibraryContent } from './library/components/LibraryContent';
export { AppFrame } from './navigation/components/AppFrame';
export { useRoute } from './navigation/hooks/use-route';
export { navigate } from './navigation/lib/navigate';
+export { AISetupStep } from './onboarding/components/AISetupStep';
+export { GitHubStarStep } from './onboarding/components/GitHubStarStep';
+export { OnboardingFlow } from './onboarding/components/OnboardingFlow';
+export { ProgressDots } from './onboarding/components/ProgressDots';
+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 { MicrophonePicker } from './voice/components/MicrophonePicker';
diff --git a/src/ui/onboarding/steps/AISetupStep.tsx b/packages/ui/src/onboarding/components/AISetupStep.tsx
similarity index 62%
rename from src/ui/onboarding/steps/AISetupStep.tsx
rename to packages/ui/src/onboarding/components/AISetupStep.tsx
index c4b2f08..b61a17a 100644
--- a/src/ui/onboarding/steps/AISetupStep.tsx
+++ b/packages/ui/src/onboarding/components/AISetupStep.tsx
@@ -1,31 +1,24 @@
-import {
- Input,
- KeyStatusNote,
- KeyWarningNote,
- ModelList,
- SecretInput,
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
- useAiSettings,
- useApiKeys,
-} from '@mimik/ui';
-import { i18n } from '#imports';
-import { KEY_PLACEHOLDERS, SERVER } from '@/core/capture/ai/keys';
-import { AI_PROVIDERS, type AIProviderKey, CUSTOM_MODEL_VALUE, DEFAULT_AI_PROVIDER } from '@/core/capture/ai/models';
-import { AI_LANGUAGES, type AILanguageCode } from '@/core/capture/ai/prompts';
-import { useKeyCheck } from '@/ui/shared/hooks/use-key-check';
-import { ProgressDots } from '../ProgressDots';
+import { SERVER } from '@mimik/core/capture/ai/keys';
+import { CUSTOM_MODEL_VALUE } from '@mimik/core/capture/ai/models';
+import { AI_LANGUAGES, type AILanguageCode } from '@mimik/core/capture/ai/prompts';
+import { i18n } from '@mimik/core/env';
+import { ProviderKeyRow } from '../../ai/components/ProviderKeyRow';
+import { ProviderSelect } from '../../ai/components/ProviderSelect';
+import { ServerSettings } from '../../ai/components/ServerSettings';
+import { useAiSettings } from '../../ai/hooks/use-ai-settings';
+import { useApiKeys } from '../../ai/hooks/use-api-keys';
+import { aiProviderOptions } from '../../ai/lib/ai-provider-options';
+import { Input } from '../../components/ui/input';
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../components/ui/select';
import type { StepProps } from '../types';
+import { ProgressDots } from './ProgressDots';
-export function AISetupStep({ onNext, onSkip, onBack, index, total }: StepProps) {
- const aiKeyCheck = useKeyCheck();
+const FIELD = 'w-full h-11 rounded-xl px-4 text-sm focus:border-accent focus:ring-accent/10';
+
+export function AISetupStep({ onNext, onSkip, onBack, index, total, validate }: StepProps) {
const keys = useApiKeys({ reloadOnFocus: true });
- const ai = useAiSettings({ onDirty: aiKeyCheck.reset, reloadOnFocus: true });
- const provider = ai.provider === SERVER ? DEFAULT_AI_PROVIDER : ai.provider;
- const apiKey = keys.keys[provider] ?? '';
+ const ai = useAiSettings({ reloadOnFocus: true });
+ const provider = ai.provider;
return (
<div className="flex h-screen">
@@ -42,82 +35,67 @@ export function AISetupStep({ onNext, onSkip, onBack, index, total }: StepProps)
<label className="block text-xs font-semibold text-foreground mb-1.5">
{i18n.t('settings.provider')}
</label>
- <Select value={provider} onValueChange={(v) => ai.setProvider(v as AIProviderKey)}>
- <SelectTrigger className="w-full h-11 rounded-xl px-4 text-sm focus:border-accent focus:ring-accent/10">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- {Object.entries(AI_PROVIDERS).map(([key, cfg]) => (
- <SelectItem key={key} value={key}>
- {cfg.label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
+ <ProviderSelect
+ value={provider}
+ onChange={ai.setProvider}
+ options={aiProviderOptions(() => true)}
+ triggerClassName={FIELD}
+ />
</div>
+ {provider === SERVER ? (
+ <ServerSettings server={keys.server} onChange={keys.setServer} validate={validate} />
+ ) : (
+ <div>
+ <label className="block text-xs font-semibold text-foreground mb-1.5">
+ {i18n.t('settings.apiKey')}
+ </label>
+ <ProviderKeyRow
+ key={provider}
+ bare
+ provider={provider}
+ value={keys.keys[provider] ?? ''}
+ onChange={(next) => keys.setKey(provider, next)}
+ validate={validate}
+ />
+ <p className="mt-1.5 text-[11px] text-muted-foreground">{i18n.t('onboarding.keySaved')}</p>
+ </div>
+ )}
+
<div>
<label className="block text-xs font-semibold text-foreground mb-1.5">{i18n.t('settings.model')}</label>
- <Select value={ai.usingCustomModel ? CUSTOM_MODEL_VALUE : ai.model} onValueChange={ai.setModel}>
- <SelectTrigger className="w-full h-11 rounded-xl px-4 text-sm focus:border-accent focus:ring-accent/10">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- {ai.models.map((m) => (
- <SelectItem key={m.id} value={m.id}>
- {m.label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
+ {ai.models.length > 0 && (
+ <Select value={ai.usingCustomModel ? CUSTOM_MODEL_VALUE : ai.model} onValueChange={ai.setModel}>
+ <SelectTrigger className={FIELD}>
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {ai.models.map((m) => (
+ <SelectItem key={m.id} value={m.id}>
+ {m.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ )}
{ai.usingCustomModel && (
<Input
type="text"
value={ai.model}
onChange={(e) => ai.setModel(e.target.value)}
- placeholder={ai.defaultModel}
- className="w-full mt-1.5 h-11 rounded-xl px-4 text-sm focus:border-accent focus:ring-accent/10"
+ placeholder={ai.defaultModel || 'llama3.2'}
+ aria-label={i18n.t('settings.modelCustom')}
+ className={`${ai.models.length > 0 ? 'mt-1.5 ' : ''}${FIELD}`}
/>
)}
</div>
- <div>
- <label className="block text-xs font-semibold text-foreground mb-1.5">{i18n.t('settings.apiKey')}</label>
- <SecretInput
- value={apiKey}
- onChange={(next) => {
- aiKeyCheck.reset();
- keys.setKey(provider, next);
- }}
- placeholder={KEY_PLACEHOLDERS[provider]}
- className="w-full h-11 rounded-xl px-4 text-sm focus:border-accent focus:ring-accent/10"
- buttonClassName="right-3"
- />
- <div className="flex items-center gap-3 mt-2">
- <button
- type="button"
- disabled={!apiKey || aiKeyCheck.status === 'checking'}
- onClick={() => {
- if (aiKeyCheck.status !== 'checking') void aiKeyCheck.check(provider, apiKey, undefined, ai.model);
- }}
- className="px-4 py-2 bg-card text-foreground border border-border rounded-lg font-semibold text-xs hover:border-accent hover:text-accent transition-colors disabled:opacity-50 disabled:pointer-events-none"
- >
- {i18n.t('settings.checkKey')}
- </button>
- <div className="min-w-0">
- <KeyStatusNote status={aiKeyCheck.status} />
- <KeyWarningNote warning={aiKeyCheck.warning} />
- </div>
- </div>
- {aiKeyCheck.models && <ModelList models={aiKeyCheck.models} />}
- </div>
-
<div>
<label className="block text-xs font-semibold text-foreground mb-1.5">
{i18n.t('settings.aiLanguage')}
</label>
<Select value={ai.language} onValueChange={(v) => ai.setLanguage(v as AILanguageCode)}>
- <SelectTrigger className="w-full h-11 rounded-xl px-4 text-sm focus:border-accent focus:ring-accent/10">
+ <SelectTrigger className={FIELD}>
<SelectValue />
</SelectTrigger>
<SelectContent>
diff --git a/src/ui/onboarding/steps/DoneStep.tsx b/packages/ui/src/onboarding/components/DoneStep.tsx
similarity index 67%
rename from src/ui/onboarding/steps/DoneStep.tsx
rename to packages/ui/src/onboarding/components/DoneStep.tsx
index 7a90a41..4e2b4fe 100644
--- a/src/ui/onboarding/steps/DoneStep.tsx
+++ b/packages/ui/src/onboarding/components/DoneStep.tsx
@@ -1,22 +1,14 @@
+import { client, i18n, localStorage } from '@mimik/core/env';
import { useEffect } from 'react';
-import { browser, i18n } from '#imports';
-import { localStorage } from '@/lib/browser-api/local-storage';
-import { openSidebar } from '@/lib/browser-api/open-sidebar';
-import { requestHostPermissions } from '@/lib/browser-api/request-host-permissions';
-import { MascotLarge } from '../MascotLarge';
+import { MascotLarge } from './MascotLarge';
+
+export function DoneStep({ onOpen }: { onOpen: () => void }) {
+ const desktop = client() === 'desktop';
-export function DoneStep() {
useEffect(() => {
- localStorage.set({ onboardingCompleted: true });
+ void localStorage.set({ onboardingCompleted: true });
}, []);
- const handleOpen = async () => {
- openSidebar();
- const permissionsPromise = requestHostPermissions();
- await permissionsPromise;
- browser.tabs.create({ url: browser.runtime.getURL('/fullview.html') });
- };
-
return (
<div className="flex h-screen items-center justify-center">
<div className="text-center max-w-lg">
@@ -27,10 +19,10 @@ export function DoneStep() {
{i18n.t('onboarding.doneTitle')}
</h1>
<p className="text-base text-muted-foreground mb-8 max-w-md mx-auto leading-relaxed">
- {i18n.t('onboarding.doneMessage')}
+ {i18n.t(desktop ? 'onboarding.doneMessageDesktop' : 'onboarding.doneMessage')}
</p>
- <div className="grid grid-cols-3 gap-3 mb-8">
+ <div className="flex flex-wrap justify-center gap-3 mb-8">
{[
{
label: i18n.t('onboarding.featureAutoCapture'),
@@ -63,7 +55,7 @@ export function DoneStep() {
</>
),
},
- {
+ !desktop && {
label: i18n.t('onboarding.featureSmartBlur'),
icon: (
<>
@@ -81,28 +73,30 @@ export function DoneStep() {
</>
),
},
- ].map((f) => (
- <div key={f.label} className="bg-secondary rounded-xl px-3 py-4 text-center">
- <div className="text-accent flex justify-center mb-2">
- <svg
- width="24"
- height="24"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- strokeWidth="2"
- strokeLinecap="round"
- >
- {f.icon}
- </svg>
+ ]
+ .filter((f) => f !== false)
+ .map((f) => (
+ <div key={f.label} className="w-[calc((100%-1.5rem)/3)] bg-secondary rounded-xl px-3 py-4 text-center">
+ <div className="text-accent flex justify-center mb-2">
+ <svg
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ >
+ {f.icon}
+ </svg>
+ </div>
+ <p className="text-xs font-semibold text-foreground">{f.label}</p>
</div>
- <p className="text-xs font-semibold text-foreground">{f.label}</p>
- </div>
- ))}
+ ))}
</div>
<button
- onClick={handleOpen}
+ onClick={onOpen}
className="inline-flex items-center gap-2 px-7 py-3 bg-primary text-primary-foreground rounded-xl font-semibold text-sm hover:bg-primary/90 transition-colors"
>
{i18n.t('onboarding.openMimik')}
diff --git a/src/ui/onboarding/steps/GitHubStarStep.tsx b/packages/ui/src/onboarding/components/GitHubStarStep.tsx
similarity index 92%
rename from src/ui/onboarding/steps/GitHubStarStep.tsx
rename to packages/ui/src/onboarding/components/GitHubStarStep.tsx
index 4b3038f..1aec0fb 100644
--- a/src/ui/onboarding/steps/GitHubStarStep.tsx
+++ b/packages/ui/src/onboarding/components/GitHubStarStep.tsx
@@ -1,13 +1,14 @@
-import { browser, i18n } from '#imports';
-import { MascotWithStar } from '../MascotWithStar';
-import { ProgressDots } from '../ProgressDots';
+import { i18n } from '@mimik/core/env';
+import { tabs } from '../../env';
import type { StepProps } from '../types';
+import { MascotWithStar } from './MascotWithStar';
+import { ProgressDots } from './ProgressDots';
const REPO_URL = 'https://github.com/westpoint-io/mimik';
export function GitHubStarStep({ onSkip, onBack, index, total }: StepProps) {
const handleStar = () => {
- browser.tabs.create({ url: REPO_URL, active: true });
+ void tabs.create(REPO_URL);
};
return (
diff --git a/src/ui/onboarding/MascotLarge.tsx b/packages/ui/src/onboarding/components/MascotLarge.tsx
similarity index 100%
rename from src/ui/onboarding/MascotLarge.tsx
rename to packages/ui/src/onboarding/components/MascotLarge.tsx
diff --git a/src/ui/onboarding/MascotWithStar.tsx b/packages/ui/src/onboarding/components/MascotWithStar.tsx
similarity index 100%
rename from src/ui/onboarding/MascotWithStar.tsx
rename to packages/ui/src/onboarding/components/MascotWithStar.tsx
diff --git a/packages/ui/src/onboarding/components/OnboardingFlow.tsx b/packages/ui/src/onboarding/components/OnboardingFlow.tsx
new file mode 100644
index 0000000..9501517
--- /dev/null
+++ b/packages/ui/src/onboarding/components/OnboardingFlow.tsx
@@ -0,0 +1,43 @@
+import { type ComponentType, useState } from 'react';
+import type { ValidateKey } from '../../ai/types';
+import type { StepProps } from '../types';
+import { DoneStep } from './DoneStep';
+import { WelcomeStep } from './WelcomeStep';
+
+interface OnboardingFlowProps {
+ steps: ComponentType<StepProps>[];
+ validate: ValidateKey;
+ requestMicrophoneAccess: () => Promise<void>;
+ onFinish: () => void;
+}
+
+const KEYFRAMES =
+ '@keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)}}@keyframes sparkle{0%,100%{opacity:.3;transform:scale(.8)}50%{opacity:1;transform:scale(1.1)}}';
+
+export function OnboardingFlow({ steps, validate, requestMicrophoneAccess, onFinish }: OnboardingFlowProps) {
+ const [step, setStep] = useState(0);
+
+ const lastStep = steps.length + 1;
+ const next = () => setStep((s) => Math.min(s + 1, lastStep));
+ const back = () => setStep((s) => Math.max(s - 1, 0));
+ const CurrentStep = steps[step - 1];
+
+ return (
+ <div className="min-h-screen bg-card text-foreground">
+ <style>{KEYFRAMES}</style>
+ {step === 0 && <WelcomeStep onNext={next} />}
+ {CurrentStep && (
+ <CurrentStep
+ onNext={next}
+ onSkip={next}
+ onBack={back}
+ index={step}
+ total={steps.length}
+ validate={validate}
+ requestMicrophoneAccess={requestMicrophoneAccess}
+ />
+ )}
+ {step === lastStep && <DoneStep onOpen={onFinish} />}
+ </div>
+ );
+}
diff --git a/src/ui/onboarding/ProgressDots.tsx b/packages/ui/src/onboarding/components/ProgressDots.tsx
similarity index 100%
rename from src/ui/onboarding/ProgressDots.tsx
rename to packages/ui/src/onboarding/components/ProgressDots.tsx
diff --git a/src/ui/onboarding/steps/VoiceStep.tsx b/packages/ui/src/onboarding/components/VoiceStep.tsx
similarity index 76%
rename from src/ui/onboarding/steps/VoiceStep.tsx
rename to packages/ui/src/onboarding/components/VoiceStep.tsx
index 77daa68..549764d 100644
--- a/src/ui/onboarding/steps/VoiceStep.tsx
+++ b/packages/ui/src/onboarding/components/VoiceStep.tsx
@@ -1,14 +1,20 @@
-import { SecretInput, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, useApiKeys } from '@mimik/ui';
+import type { VoiceProvider } from '@mimik/core/capture/voice/transcribe';
+import { client, i18n, localStorage } from '@mimik/core/env';
import { Mic, MousePointerClick, Shield } from 'lucide-react';
import { useEffect, useState } from 'react';
-import { i18n } from '#imports';
-import type { VoiceProvider } from '@/core/capture/voice/transcribe';
-import { localStorage } from '@/lib/browser-api/local-storage';
-import { MicrophonePicker } from '@/ui/shared/MicrophonePicker';
-import { ProgressDots } from '../ProgressDots';
+import { ProviderKeyRow } from '../../ai/components/ProviderKeyRow';
+import { type ProviderOption, ProviderSelect } from '../../ai/components/ProviderSelect';
+import { useApiKeys } from '../../ai/hooks/use-api-keys';
+import { MicrophonePicker } from '../../voice/components/MicrophonePicker';
import type { StepProps } from '../types';
+import { ProgressDots } from './ProgressDots';
-export function VoiceStep({ onNext, onSkip, onBack, index, total }: StepProps) {
+const VOICE_PROVIDERS: ProviderOption<VoiceProvider>[] = [
+ { value: 'openai', label: 'OpenAI', logo: 'openai', available: true },
+ { value: 'groq', label: 'Groq', logo: 'groq', available: true },
+];
+
+export function VoiceStep({ onNext, onSkip, onBack, index, total, validate, requestMicrophoneAccess }: StepProps) {
const [provider, setProvider] = useState<VoiceProvider>('openai');
const [microphoneId, setMicrophoneId] = useState('');
const keys = useApiKeys({ reloadOnFocus: true });
@@ -53,44 +59,44 @@ export function VoiceStep({ onNext, onSkip, onBack, index, total }: StepProps) {
</h1>
<p className="text-sm text-muted-foreground leading-relaxed mb-6">{i18n.t('onboarding.voiceMessage')}</p>
- <div className="border border-border rounded-2xl p-4 space-y-3 mb-6">
- <div className="flex gap-3">
- <div className="flex-1">
- <label className="block text-xs font-semibold text-foreground mb-1.5">
- {i18n.t('settings.provider')}
- </label>
- <Select value={provider} onValueChange={(v) => handleProviderChange(v as VoiceProvider)}>
- <SelectTrigger className="h-11 rounded-xl px-4 text-sm focus:border-accent focus:ring-accent/10">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="openai">OpenAI</SelectItem>
- <SelectItem value="groq">Groq</SelectItem>
- </SelectContent>
- </Select>
- </div>
- <div className="flex-1">
- <label className="block text-xs font-semibold text-foreground mb-1.5">
- {i18n.t('settings.apiKey')}
- </label>
- <SecretInput
- value={apiKey}
- onChange={handleApiKeyChange}
- placeholder={provider === 'groq' ? 'gsk_...' : 'sk-...'}
- className="w-full h-11 rounded-xl px-4 text-sm focus:border-accent focus:ring-accent/10"
- />
- </div>
+ <div className="space-y-4 mb-6">
+ <div>
+ <label className="block text-xs font-semibold text-foreground mb-1.5">
+ {i18n.t('settings.provider')}
+ </label>
+ <ProviderSelect
+ value={provider}
+ onChange={handleProviderChange}
+ options={VOICE_PROVIDERS}
+ triggerClassName="w-full h-11 rounded-xl px-4 text-sm focus:border-accent focus:ring-accent/10"
+ />
+ </div>
+
+ <div>
+ <label className="block text-xs font-semibold text-foreground mb-1.5">{i18n.t('settings.apiKey')}</label>
+ <ProviderKeyRow
+ key={provider}
+ bare
+ provider={provider}
+ value={apiKey}
+ onChange={handleApiKeyChange}
+ validate={validate}
+ />
+ <p className="mt-1.5 text-[11px] text-muted-foreground">{i18n.t('onboarding.keySaved')}</p>
</div>
<MicrophonePicker
value={microphoneId}
onChange={handleMicrophoneChange}
+ onRequestAccess={requestMicrophoneAccess}
triggerClassName="h-11 px-4 text-sm"
/>
<div className="flex items-start gap-2 px-3 py-2.5 rounded-xl bg-secondary text-[11px] text-muted-foreground leading-relaxed">
<Mic size={12} className="shrink-0 mt-0.5 text-accent" />
- <span>{i18n.t('onboarding.voiceRecordHint')}</span>
+ <span>
+ {i18n.t(client() === 'desktop' ? 'onboarding.voiceRecordHintDesktop' : 'onboarding.voiceRecordHint')}
+ </span>
</div>
<div className="flex items-start gap-2 px-3 py-2.5 rounded-xl bg-secondary text-[11px] text-muted-foreground leading-relaxed">
diff --git a/src/ui/onboarding/steps/WelcomeStep.tsx b/packages/ui/src/onboarding/components/WelcomeStep.tsx
similarity index 90%
rename from src/ui/onboarding/steps/WelcomeStep.tsx
rename to packages/ui/src/onboarding/components/WelcomeStep.tsx
index f508242..58e9e04 100644
--- a/src/ui/onboarding/steps/WelcomeStep.tsx
+++ b/packages/ui/src/onboarding/components/WelcomeStep.tsx
@@ -1,5 +1,5 @@
-import { i18n } from '#imports';
-import { MascotLarge } from '../MascotLarge';
+import { client, i18n } from '@mimik/core/env';
+import { MascotLarge } from './MascotLarge';
export function WelcomeStep({ onNext }: { onNext: () => void }) {
return (
@@ -13,7 +13,7 @@ export function WelcomeStep({ onNext }: { onNext: () => void }) {
{i18n.t('onboarding.welcomeTitle')}
</h1>
<p className="text-base text-muted-foreground leading-relaxed mb-10 max-w-md">
- {i18n.t('onboarding.welcomeMessage')}
+ {i18n.t(client() === 'desktop' ? 'onboarding.welcomeMessageDesktop' : 'onboarding.welcomeMessage')}
</p>
<button
onClick={onNext}
diff --git a/src/ui/onboarding/types.ts b/packages/ui/src/onboarding/types.ts
similarity index 51%
rename from src/ui/onboarding/types.ts
rename to packages/ui/src/onboarding/types.ts
index 6ea9aa1..d499f3c 100644
--- a/src/ui/onboarding/types.ts
+++ b/packages/ui/src/onboarding/types.ts
@@ -1,7 +1,11 @@
+import type { ValidateKey } from '../ai/types';
+
export interface StepProps {
onNext: () => void;
onSkip: () => void;
onBack: () => void;
index: number;
total: number;
+ validate: ValidateKey;
+ requestMicrophoneAccess: () => Promise<void>;
}
diff --git a/src/ui/shared/MicrophonePicker.tsx b/packages/ui/src/voice/components/MicrophonePicker.tsx
similarity index 88%
rename from src/ui/shared/MicrophonePicker.tsx
rename to packages/ui/src/voice/components/MicrophonePicker.tsx
index a67c6fc..9c91654 100644
--- a/src/ui/shared/MicrophonePicker.tsx
+++ b/packages/ui/src/voice/components/MicrophonePicker.tsx
@@ -1,23 +1,23 @@
import { i18n } from '@mimik/core/env';
-import { Button, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@mimik/ui';
import { ChevronRight, Mic, Square, TriangleAlert } from 'lucide-react';
import { useCallback, useEffect, useId, useRef, useState } from 'react';
-import { getActiveTab } from '@/lib/browser-api/get-active-tab';
-import { openMicPermissionPage } from '@/lib/offscreen/open-mic-permission-page';
-import { isMicrophoneMissing } from './lib/is-microphone-missing';
-import { microphoneListState } from './lib/microphone-list-state';
-import { type MicrophonePermission, microphoneStatus } from './lib/microphone-status';
-import { nextMicLevel, SPEAKING_LEVEL } from './lib/next-mic-level';
-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 { Button } from '../../components/ui/button';
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../components/ui/select';
+import { isMicrophoneMissing } from '../lib/is-microphone-missing';
+import { microphoneListState } from '../lib/microphone-list-state';
+import { type MicrophonePermission, microphoneStatus } from '../lib/microphone-status';
+import { nextMicLevel, SPEAKING_LEVEL } from '../lib/next-mic-level';
+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 { StatusBadge } from './StatusBadge';
-import type { MicrophoneDevice } from './types';
interface MicrophonePickerProps {
triggerClassName?: string;
value: string;
onChange: (deviceId: string) => void;
+ onRequestAccess: () => Promise<void>;
}
interface MicTest {
@@ -30,7 +30,7 @@ const MICROPHONE: PermissionDescriptor = { name: 'microphone' as PermissionName
const ANALYSER_FFT_SIZE = 2048;
const METER_INTERVAL_MS = 80;
-export function MicrophonePicker({ value, onChange, triggerClassName }: MicrophonePickerProps) {
+export function MicrophonePicker({ value, onChange, onRequestAccess, triggerClassName }: MicrophonePickerProps) {
const [devices, setDevices] = useState<MicrophoneDevice[]>([]);
const [testing, setTesting] = useState(false);
const [level, setLevel] = useState(0);
@@ -89,10 +89,9 @@ export function MicrophonePicker({ value, onChange, triggerClassName }: Micropho
useEffect(() => stopTest, [stopTest]);
const requestAccess = useCallback(async () => {
- const tab = await getActiveTab().catch(() => undefined);
- await openMicPermissionPage(tab?.id).catch(() => undefined);
+ await onRequestAccess().catch(() => undefined);
await refresh();
- }, [refresh]);
+ }, [onRequestAccess, refresh]);
const startTest = useCallback(async () => {
stopTest();
diff --git a/src/ui/shared/StatusBadge.tsx b/packages/ui/src/voice/components/StatusBadge.tsx
similarity index 93%
rename from src/ui/shared/StatusBadge.tsx
rename to packages/ui/src/voice/components/StatusBadge.tsx
index f9ec5c6..78a2366 100644
--- a/src/ui/shared/StatusBadge.tsx
+++ b/packages/ui/src/voice/components/StatusBadge.tsx
@@ -1,6 +1,6 @@
import { i18n } from '@mimik/core/env';
import { Check, Mic, MicOff } from 'lucide-react';
-import type { MicrophoneStatus } from './lib/microphone-status';
+import type { MicrophoneStatus } from '../lib/microphone-status';
const STATUS_STYLES: Record<MicrophoneStatus, string> = {
allowed: 'bg-success/10 text-success',
diff --git a/src/ui/shared/__tests__/microphones.test.ts b/packages/ui/src/voice/lib/__tests__/microphones.test.ts
similarity index 92%
rename from src/ui/shared/__tests__/microphones.test.ts
rename to packages/ui/src/voice/lib/__tests__/microphones.test.ts
index 7a50a8c..e1cea42 100644
--- a/src/ui/shared/__tests__/microphones.test.ts
+++ b/packages/ui/src/voice/lib/__tests__/microphones.test.ts
@@ -1,14 +1,14 @@
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { describe, expect, it } from 'vitest';
-import { isMicrophoneMissing } from '../lib/is-microphone-missing';
-import { microphoneListState } from '../lib/microphone-list-state';
-import { microphoneStatus } from '../lib/microphone-status';
-import { nextMicLevel, SPEAKING_LEVEL } from '../lib/next-mic-level';
-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 { MicrophoneOption } from '../types';
+import type { MicrophoneOption } from '../../types';
+import { isMicrophoneMissing } from '../is-microphone-missing';
+import { microphoneListState } from '../microphone-list-state';
+import { microphoneStatus } from '../microphone-status';
+import { nextMicLevel, SPEAKING_LEVEL } from '../next-mic-level';
+import { toMicrophoneOptions } from '../to-microphone-options';
+import { SYSTEM_DEFAULT_VALUE, toSelectValue } from '../to-select-value';
+import { toStoredMicrophoneId } from '../to-stored-microphone-id';
const LOCALES = ['en', 'de', 'es', 'fr', 'pt-BR', 'zh-CN'];
diff --git a/src/ui/shared/lib/audio-inputs.ts b/packages/ui/src/voice/lib/audio-inputs.ts
similarity index 100%
rename from src/ui/shared/lib/audio-inputs.ts
rename to packages/ui/src/voice/lib/audio-inputs.ts
diff --git a/src/ui/shared/lib/is-microphone-missing.ts b/packages/ui/src/voice/lib/is-microphone-missing.ts
similarity index 100%
rename from src/ui/shared/lib/is-microphone-missing.ts
rename to packages/ui/src/voice/lib/is-microphone-missing.ts
diff --git a/src/ui/shared/lib/microphone-list-state.ts b/packages/ui/src/voice/lib/microphone-list-state.ts
similarity index 100%
rename from src/ui/shared/lib/microphone-list-state.ts
rename to packages/ui/src/voice/lib/microphone-list-state.ts
diff --git a/src/ui/shared/lib/microphone-status.ts b/packages/ui/src/voice/lib/microphone-status.ts
similarity index 100%
rename from src/ui/shared/lib/microphone-status.ts
rename to packages/ui/src/voice/lib/microphone-status.ts
diff --git a/src/ui/shared/lib/next-mic-level.ts b/packages/ui/src/voice/lib/next-mic-level.ts
similarity index 100%
rename from src/ui/shared/lib/next-mic-level.ts
rename to packages/ui/src/voice/lib/next-mic-level.ts
diff --git a/src/ui/shared/lib/to-microphone-options.ts b/packages/ui/src/voice/lib/to-microphone-options.ts
similarity index 100%
rename from src/ui/shared/lib/to-microphone-options.ts
rename to packages/ui/src/voice/lib/to-microphone-options.ts
diff --git a/src/ui/shared/lib/to-select-value.ts b/packages/ui/src/voice/lib/to-select-value.ts
similarity index 100%
rename from src/ui/shared/lib/to-select-value.ts
rename to packages/ui/src/voice/lib/to-select-value.ts
diff --git a/src/ui/shared/lib/to-stored-microphone-id.ts b/packages/ui/src/voice/lib/to-stored-microphone-id.ts
similarity index 100%
rename from src/ui/shared/lib/to-stored-microphone-id.ts
rename to packages/ui/src/voice/lib/to-stored-microphone-id.ts
diff --git a/src/ui/shared/types.ts b/packages/ui/src/voice/types.ts
similarity index 100%
rename from src/ui/shared/types.ts
rename to packages/ui/src/voice/types.ts
diff --git a/src/locales/de.yml b/src/locales/de.yml
index 4f8f576..ec29a88 100644
--- a/src/locales/de.yml
+++ b/src/locales/de.yml
@@ -471,15 +471,18 @@ onboarding:
welcomeBadge: Willkommen
welcomeTitle: "Du hast Mimik erfolgreich installiert!"
welcomeMessage: "Mit nur wenigen Schritten bist du bereit, Browser-Workflows automatisch aufzunehmen und Schritt-für-Schritt-Anleitungen zu erstellen. Kein Konto nötig — alles bleibt in deinem Browser."
+ welcomeMessageDesktop: "Mit nur wenigen Schritten bist du bereit, Workflows auf deinem Computer automatisch aufzunehmen und Schritt-für-Schritt-Anleitungen zu erstellen. Kein Konto nötig — alles bleibt auf deinem Computer."
getStarted: Loslegen
stepOf: "Schritt $1 von $2"
aiTitle: KI-Beschreibungen
aiMessage: Verbinde deinen eigenen API-Schlüssel, um KI-generierte Schrittbeschreibungen zu erhalten. Das ist optional und kann später in den Einstellungen geändert werden.
+ keySaved: "Wird mit deinen anderen Schlüsseln unter Einstellungen › API-Schlüssel gespeichert."
aiGenerated: KI-generiert
aiGeneratedDescription: KI-generierte Beschreibung
voiceTitle: Sprich, dann handle
voiceMessage: "Sag, was du als Nächstes tust, und tu es dann. Mimik ordnet deine Worte der nächsten Aktion zu."
voiceRecordHint: "Sprachkommentar ist standardmäßig aus. Aktiviere ihn pro Anleitung per Mikrofon in der Seitenleiste."
+ voiceRecordHintDesktop: "Sprachkommentar ist standardmäßig aus. Aktiviere ihn pro Anleitung per Mikrofon auf der Aufnahmekarte."
voiceDataNotice: "Audio geht mit deinem API-Schlüssel an den gewählten Anbieter."
voiceDemoLabel: "So wird dein Sprachkommentar zugeordnet"
voiceDemoSay: Du sagst
@@ -507,6 +510,7 @@ onboarding:
starLater: "Vielleicht später"
doneTitle: "Alles bereit"
doneMessage: "Klicke in der Seitenleiste auf „Aufnahme starten“, um deine erste Anleitung aufzunehmen."
+ doneMessageDesktop: "Klicke auf „Aufnahme starten“, um deine erste Anleitung aufzunehmen."
featureAutoCapture: Auto-Aufnahme
featureAIAssist: KI-Assistent
featureVoice: "Sprachkommentar"
diff --git a/src/locales/en.yml b/src/locales/en.yml
index e0c89db..a9cf420 100644
--- a/src/locales/en.yml
+++ b/src/locales/en.yml
@@ -540,15 +540,18 @@ onboarding:
welcomeBadge: Welcome
welcomeTitle: "You've successfully installed Mimik!"
welcomeMessage: "With just a few steps, you'll be ready to auto-capture browser workflows and generate step-by-step guides. No account needed \u2014 everything stays in your browser."
+ welcomeMessageDesktop: "With just a few steps, you'll be ready to auto-capture workflows on your computer and generate step-by-step guides. No account needed — everything stays on your computer."
getStarted: Get started
stepOf: "Step $1 of $2"
aiTitle: "AI descriptions"
aiMessage: Connect your own API key to get AI-generated step descriptions. This is optional and can be changed later in settings.
+ keySaved: "Saved with your other keys in Settings › API keys."
aiGenerated: AI-generated
aiGeneratedDescription: AI-generated description
voiceTitle: Talk, then act
voiceMessage: "Say what you're about to do, then do it. Mimik attaches your words to the next action."
voiceRecordHint: "Narration is off by default. Turn it on per guide with the microphone button in the side panel."
+ voiceRecordHintDesktop: "Narration is off by default. Turn it on per guide with the microphone button on the recording card."
voiceDataNotice: "Audio goes to the provider you choose, using your API key."
voiceDemoLabel: How narration is matched
voiceDemoSay: You say
@@ -576,6 +579,7 @@ onboarding:
starLater: Maybe later
doneTitle: "You're all set"
doneMessage: "Click \"Start capture\" in the side panel to record your first guide."
+ doneMessageDesktop: "Click \"Start capture\" to record your first guide."
featureAutoCapture: Auto-capture
featureAIAssist: AI assist
featureVoice: Voice narration
diff --git a/src/locales/es.yml b/src/locales/es.yml
index d8739be..d811c04 100644
--- a/src/locales/es.yml
+++ b/src/locales/es.yml
@@ -540,15 +540,18 @@ onboarding:
welcomeBadge: "Te damos la bienvenida"
welcomeTitle: "¡Ya tienes Mimik instalado!"
welcomeMessage: "En unos pasos vas a poder capturar flujos de trabajo y generar guías automáticas. Sin cuenta, sin registros \u2014 todo se queda en tu navegador."
+ welcomeMessageDesktop: "En unos pasos vas a poder capturar flujos de trabajo en tu ordenador y generar guías automáticas. Sin cuenta, sin registros — todo se queda en tu ordenador."
getStarted: Empezar
stepOf: "Paso $1 de $2"
aiTitle: Descripciones con IA
aiMessage: Conecta tu clave API para que la IA escriba las descripciones de cada paso. Es opcional y lo puedes cambiar después en Ajustes.
+ keySaved: "Se guarda con tus otras claves en Ajustes › Claves de API."
aiGenerated: Generado por IA
aiGeneratedDescription: "Descripción generada por IA"
voiceTitle: Habla y luego actúa
voiceMessage: "Di lo que vas a hacer y después hazlo. Mimik une tus palabras a la siguiente acción."
voiceRecordHint: "La narración viene desactivada. Actívala por guía con el botón de micrófono del panel lateral."
+ voiceRecordHintDesktop: "La narración viene desactivada. Actívala por guía con el botón de micrófono de la tarjeta de grabación."
voiceDataNotice: "El audio va al proveedor que elijas, con tu clave de API."
voiceDemoLabel: "Cómo se asigna la narración"
voiceDemoSay: Dices
@@ -576,6 +579,7 @@ onboarding:
starLater: "Quizá más tarde"
doneTitle: "Todo listo"
doneMessage: "Haz clic en \"Empezar a capturar\" en el panel lateral para grabar tu primera guía."
+ doneMessageDesktop: "Haz clic en \"Empezar a capturar\" para grabar tu primera guía."
featureAutoCapture: Captura automática
featureAIAssist: Asistente de IA
featureVoice: "Narración por voz"
diff --git a/src/locales/fr.yml b/src/locales/fr.yml
index 498735a..0704c6f 100644
--- a/src/locales/fr.yml
+++ b/src/locales/fr.yml
@@ -540,15 +540,18 @@ onboarding:
welcomeBadge: Bienvenue
welcomeTitle: "Mimik est installé !"
welcomeMessage: "En quelques étapes, vous pourrez capturer vos parcours navigateur et générer des guides automatiquement. Pas de compte nécessaire — tout reste dans votre navigateur."
+ welcomeMessageDesktop: "En quelques étapes, vous pourrez capturer vos parcours sur votre ordinateur et générer des guides automatiquement. Pas de compte nécessaire — tout reste sur votre ordinateur."
getStarted: "C'est parti"
stepOf: "Étape $1 sur $2"
aiTitle: Descriptions IA
aiMessage: "Connectez votre clé API pour obtenir des descriptions générées par IA. C'est facultatif et modifiable dans les paramètres."
+ keySaved: "Enregistrée avec vos autres clés dans Paramètres › Clés API."
aiGenerated: "Généré par IA"
aiGeneratedDescription: "Description générée par IA"
voiceTitle: "Parlez, puis agissez"
voiceMessage: "Dites ce que vous allez faire, puis faites-le. Mimik rattache vos paroles à l'action suivante."
voiceRecordHint: "Narration désactivée par défaut. Activez-la par guide avec le bouton micro du panneau latéral."
+ voiceRecordHintDesktop: "Narration désactivée par défaut. Activez-la par guide avec le bouton micro de la carte d'enregistrement."
voiceDataNotice: "L'audio est envoyé au fournisseur choisi, avec votre clé API."
voiceDemoLabel: "Comment la narration est rattachée"
voiceDemoSay: Vous dites
@@ -576,6 +579,7 @@ onboarding:
starLater: Plus tard
doneTitle: "Tout est prêt"
doneMessage: "Cliquez sur « Lancer la capture » dans le panneau latéral pour enregistrer votre premier guide."
+ doneMessageDesktop: "Cliquez sur « Lancer la capture » pour enregistrer votre premier guide."
featureAutoCapture: Capture automatique
featureAIAssist: Assistant IA
featureVoice: Narration vocale
diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.yml
index ee61d9c..8cbef12 100644
--- a/src/locales/pt-BR.yml
+++ b/src/locales/pt-BR.yml
@@ -540,15 +540,18 @@ onboarding:
welcomeBadge: "Boas-vindas"
welcomeTitle: "Mimik instalado!"
welcomeMessage: "Em poucos passos você vai poder capturar fluxos de trabalho e gerar guias automáticos. Sem conta, sem cadastro \u2014 tudo fica no seu navegador."
+ welcomeMessageDesktop: "Em poucos passos você vai poder capturar fluxos de trabalho no seu computador e gerar guias automáticos. Sem conta, sem cadastro — tudo fica no seu computador."
getStarted: "Começar"
stepOf: "Passo $1 de $2"
aiTitle: Descrições com IA
aiMessage: Conecta sua chave API pra ter descrições dos passos geradas por IA. É opcional e dá pra mudar depois nos ajustes.
+ keySaved: "Fica salva com suas outras chaves em Ajustes › Chaves de API."
aiGenerated: Gerado por IA
aiGeneratedDescription: Descrição gerada por IA
voiceTitle: "Fale e depois faça"
voiceMessage: "Diga o que vai fazer e depois faça. O Mimik associa suas palavras à próxima ação."
voiceRecordHint: "A narração fica desligada por padrão. Ative por guia no botão de microfone do painel lateral."
+ voiceRecordHintDesktop: "A narração fica desligada por padrão. Ative por guia no botão de microfone do cartão de gravação."
voiceDataNotice: "O áudio vai para o provedor que você escolher, com sua chave de API."
voiceDemoLabel: "Como a narração é atribuída"
voiceDemoSay: "Você fala"
@@ -576,6 +579,7 @@ onboarding:
starLater: Talvez depois
doneTitle: "Tudo pronto"
doneMessage: "Clique em \"Começar a capturar\" no painel lateral para gravar seu primeiro guia."
+ doneMessageDesktop: "Clique em \"Começar a capturar\" para gravar seu primeiro guia."
featureAutoCapture: Captura automática
featureAIAssist: Assistente de IA
featureVoice: "Narração por voz"
diff --git a/src/locales/zh-CN.yml b/src/locales/zh-CN.yml
index 9b86928..20c653c 100644
--- a/src/locales/zh-CN.yml
+++ b/src/locales/zh-CN.yml
@@ -540,15 +540,18 @@ onboarding:
welcomeBadge: 欢迎
welcomeTitle: "你已成功安装 Mimik!"
welcomeMessage: "只需几步即可开始自动捕获浏览器工作流并生成分步指南。无需账号,一切都保留在你的浏览器中。"
+ welcomeMessageDesktop: "只需几步即可开始自动捕获电脑上的工作流并生成分步指南。无需账号,一切都保留在你的电脑上。"
getStarted: 开始使用
stepOf: "第 $1 步,共 $2 步"
aiTitle: AI 描述
aiMessage: 连接你自己的 API 密钥,即可获得 AI 生成的步骤描述。此功能可选,也可以稍后在设置中更改。
+ keySaved: "与其他密钥一起保存在“设置 › API 密钥”中。"
aiGenerated: AI 生成
aiGeneratedDescription: AI 生成的描述
voiceTitle: 先说,再操作
voiceMessage: "先说出你要做什么,再去做。Mimik 会把你的话关联到下一个动作。"
voiceRecordHint: "语音讲解默认关闭。录制时可通过侧边栏的麦克风按钮为每份指南单独开启。"
+ voiceRecordHintDesktop: "语音讲解默认关闭。录制时可通过录制卡片上的麦克风按钮为每份指南单独开启。"
voiceDataNotice: "音频会使用你的 API 密钥发送到你选择的提供商。"
voiceDemoLabel: "语音讲解如何对应到步骤"
voiceDemoSay: 你说
@@ -576,6 +579,7 @@ onboarding:
starLater: 稍后再说
doneTitle: "设置完成"
doneMessage: "点击侧边栏中的“开始捕获”,录制第一份指南。"
+ doneMessageDesktop: "点击“开始捕获”,录制第一份指南。"
featureAutoCapture: 自动捕获
featureAIAssist: AI 辅助
featureVoice: 语音讲解
diff --git a/src/ui/onboarding/App.tsx b/src/ui/onboarding/App.tsx
index e064a4f..d33c079 100644
--- a/src/ui/onboarding/App.tsx
+++ b/src/ui/onboarding/App.tsx
@@ -1,11 +1,9 @@
-import { useState } from 'react';
-import { AISetupStep } from './steps/AISetupStep';
-import { DoneStep } from './steps/DoneStep';
-import { GitHubStarStep } from './steps/GitHubStarStep';
+import { AISetupStep, GitHubStarStep, OnboardingFlow, VoiceStep } from '@mimik/ui';
+import { requestMicrophoneAccess } from '@/ui/shared/lib/request-microphone-access';
+import { validateApiKey } from '@/ui/shared/lib/validate-api-key';
+import { openMimik } from './lib/open-mimik';
import { PinExtensionStep } from './steps/PinExtensionStep';
import { SmartBlurStep } from './steps/SmartBlurStep';
-import { VoiceStep } from './steps/VoiceStep';
-import { WelcomeStep } from './steps/WelcomeStep';
const CONFIG_STEPS =
import.meta.env.BROWSER === 'firefox'
@@ -13,21 +11,12 @@ const CONFIG_STEPS =
: [AISetupStep, VoiceStep, SmartBlurStep, PinExtensionStep, GitHubStarStep];
export function OnboardingApp() {
- const [step, setStep] = useState(0);
-
- const lastStep = CONFIG_STEPS.length + 1;
- const next = () => setStep((s) => Math.min(s + 1, lastStep));
- const back = () => setStep((s) => Math.max(s - 1, 0));
- const CurrentStep = CONFIG_STEPS[step - 1];
-
return (
- <div className="min-h-screen bg-card text-foreground">
- <style>{`@keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)}}@keyframes sparkle{0%,100%{opacity:.3;transform:scale(.8)}50%{opacity:1;transform:scale(1.1)}}`}</style>
- {step === 0 && <WelcomeStep onNext={next} />}
- {CurrentStep && (
- <CurrentStep onNext={next} onSkip={next} onBack={back} index={step} total={CONFIG_STEPS.length} />
- )}
- {step === lastStep && <DoneStep />}
- </div>
+ <OnboardingFlow
+ steps={CONFIG_STEPS}
+ validate={validateApiKey}
+ requestMicrophoneAccess={requestMicrophoneAccess}
+ onFinish={() => void openMimik()}
+ />
);
}
diff --git a/src/ui/onboarding/lib/open-mimik.ts b/src/ui/onboarding/lib/open-mimik.ts
new file mode 100644
index 0000000..839dd68
--- /dev/null
+++ b/src/ui/onboarding/lib/open-mimik.ts
@@ -0,0 +1,9 @@
+import { browser } from '#imports';
+import { openSidebar } from '@/lib/browser-api/open-sidebar';
+import { requestHostPermissions } from '@/lib/browser-api/request-host-permissions';
+
+export async function openMimik() {
+ openSidebar();
+ await requestHostPermissions();
+ await browser.tabs.create({ url: browser.runtime.getURL('/fullview.html') });
+}
diff --git a/src/ui/onboarding/steps/PinExtensionStep.tsx b/src/ui/onboarding/steps/PinExtensionStep.tsx
index 597b913..16ef598 100644
--- a/src/ui/onboarding/steps/PinExtensionStep.tsx
+++ b/src/ui/onboarding/steps/PinExtensionStep.tsx
@@ -1,6 +1,5 @@
+import { ProgressDots, type StepProps } from '@mimik/ui';
import { i18n } from '#imports';
-import { ProgressDots } from '../ProgressDots';
-import type { StepProps } from '../types';
export function PinExtensionStep({ onNext, onBack, index, total }: StepProps) {
return (
diff --git a/src/ui/onboarding/steps/SmartBlurStep.tsx b/src/ui/onboarding/steps/SmartBlurStep.tsx
index ad376e0..d6f39d8 100644
--- a/src/ui/onboarding/steps/SmartBlurStep.tsx
+++ b/src/ui/onboarding/steps/SmartBlurStep.tsx
@@ -1,9 +1,8 @@
+import { ProgressDots, type StepProps } from '@mimik/ui';
import { useEffect, useState } from 'react';
import { i18n } from '#imports';
import { PRESET_LABELS, type PresetKey } from '@/core/blur/regexes';
import { localStorage } from '@/lib/browser-api/local-storage';
-import { ProgressDots } from '../ProgressDots';
-import type { StepProps } from '../types';
const BLUR_PRESET_I18N: Record<PresetKey, string> = {
email: 'email',
diff --git a/src/ui/shared/SettingsView.tsx b/src/ui/shared/SettingsView.tsx
index 014081c..e818a87 100644
--- a/src/ui/shared/SettingsView.tsx
+++ b/src/ui/shared/SettingsView.tsx
@@ -7,6 +7,7 @@ import {
AiSettings,
ApiKeysSettings,
BrandingSettings,
+ MicrophonePicker,
MissingKeyNote,
ProviderSelect,
SettingsCard,
@@ -20,7 +21,8 @@ import { localStorage } from '@/lib/browser-api/local-storage';
import { sendMessage } from '@/lib/messaging';
import { useSettingsAutosave } from '@/ui/shared/hooks/use-settings-autosave';
import { API_KEYS_ID, openApiKeys } from '@/ui/shared/lib/open-api-keys';
-import { MicrophonePicker } from '@/ui/shared/MicrophonePicker';
+import { requestMicrophoneAccess } from '@/ui/shared/lib/request-microphone-access';
+import { validateApiKey } from '@/ui/shared/lib/validate-api-key';
interface SettingsViewProps {
onBack?: () => void;
@@ -51,11 +53,6 @@ export function SettingsView({ onBack }: SettingsViewProps) {
const { saved, queue } = useSettingsAutosave({ blurPresets, voiceProvider, voiceMicrophoneId }, loaded);
const keys = useApiKeys({ onChange: queue });
- const validate = useCallback(
- (provider: string, apiKey: string, baseUrl?: string, model?: string) =>
- sendMessage('validateApiKey', { provider, apiKey, baseUrl, model }),
- [],
- );
const listVoices = useCallback(
(provider: VoiceoverProviderKey, apiKey: string) =>
sendMessage('listVoices', { provider, apiKey }).then((result) => result.voices),
@@ -97,7 +94,7 @@ export function SettingsView({ onBack }: SettingsViewProps) {
<div className="flex-1 px-3 py-4 space-y-3">
<div id={API_KEYS_ID} className="scroll-mt-3 space-y-3">
- <ApiKeysSettings state={keys} validate={validate} title={i18n.t('settings.apiKeys')} />
+ <ApiKeysSettings state={keys} validate={validateApiKey} title={i18n.t('settings.apiKeys')} />
</div>
<AiSettings keys={keys} onOpenKeys={openApiKeys} onChange={queue} />
@@ -138,7 +135,12 @@ export function SettingsView({ onBack }: SettingsViewProps) {
</div>
{import.meta.env.BROWSER !== 'firefox' && (
- <MicrophonePicker value={voiceMicrophoneId} onChange={setVoiceMicrophoneId} triggerClassName="h-8" />
+ <MicrophonePicker
+ value={voiceMicrophoneId}
+ onChange={setVoiceMicrophoneId}
+ onRequestAccess={requestMicrophoneAccess}
+ triggerClassName="h-8"
+ />
)}
</SettingsCard>
diff --git a/src/ui/shared/__tests__/key-check.test.tsx b/src/ui/shared/__tests__/key-check.test.tsx
index 7af5324..593263d 100644
--- a/src/ui/shared/__tests__/key-check.test.tsx
+++ b/src/ui/shared/__tests__/key-check.test.tsx
@@ -7,8 +7,8 @@ const { sendMessageMock } = vi.hoisted(() => ({ sendMessageMock: vi.fn() }));
vi.mock('@/lib/messaging', () => ({ sendMessage: sendMessageMock }));
-import { KeyStatusNote, SecretInput } from '@mimik/ui';
-import { useKeyCheck } from '@/ui/shared/hooks/use-key-check';
+import { KeyStatusNote, SecretInput, useKeyCheck } from '@mimik/ui';
+import { validateApiKey } from '@/ui/shared/lib/validate-api-key';
describe('useKeyCheck', () => {
beforeEach(() => {
@@ -17,7 +17,7 @@ describe('useKeyCheck', () => {
it('retains models returned with an unsuccessful validation', async () => {
sendMessageMock.mockResolvedValue({ valid: false, reason: 'rejected', models: ['public-model'] });
- const { result } = renderHook(() => useKeyCheck());
+ const { result } = renderHook(() => useKeyCheck(validateApiKey));
await act(async () => {
await result.current.check('openai', 'sk-key', 'https://api.example.com/v1', 'selected-model');
@@ -29,7 +29,7 @@ describe('useKeyCheck', () => {
it('maps an invalid model response to a distinct status', async () => {
sendMessageMock.mockResolvedValue({ valid: false, reason: 'model-invalid', models: ['public-model'] });
- const { result } = renderHook(() => useKeyCheck());
+ const { result } = renderHook(() => useKeyCheck(validateApiKey));
await act(async () => {
await result.current.check('openai', 'sk-key', 'https://api.example.com/v1', 'missing-model');
@@ -41,7 +41,7 @@ describe('useKeyCheck', () => {
it('clears status and models when reset', async () => {
sendMessageMock.mockResolvedValue({ valid: false, reason: 'model-required', models: ['public-model'] });
- const { result } = renderHook(() => useKeyCheck());
+ const { result } = renderHook(() => useKeyCheck(validateApiKey));
await act(async () => {
await result.current.check('openai', 'sk-key', 'https://api.example.com/v1');
diff --git a/src/ui/shared/hooks/use-key-check.tsx b/src/ui/shared/hooks/use-key-check.tsx
deleted file mode 100644
index f1930f5..0000000
--- a/src/ui/shared/hooks/use-key-check.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { useKeyCheck as useSharedKeyCheck } from '@mimik/ui';
-import { useCallback } from 'react';
-import { sendMessage } from '@/lib/messaging';
-
-export function useKeyCheck() {
- return useSharedKeyCheck(
- useCallback(
- (provider: string, apiKey: string, baseUrl?: string, model?: string) =>
- sendMessage('validateApiKey', { provider, apiKey, baseUrl, model }),
- [],
- ),
- );
-}
diff --git a/src/ui/shared/lib/request-microphone-access.ts b/src/ui/shared/lib/request-microphone-access.ts
new file mode 100644
index 0000000..8408311
--- /dev/null
+++ b/src/ui/shared/lib/request-microphone-access.ts
@@ -0,0 +1,7 @@
+import { getActiveTab } from '@/lib/browser-api/get-active-tab';
+import { openMicPermissionPage } from '@/lib/offscreen/open-mic-permission-page';
+
+export async function requestMicrophoneAccess() {
+ const tab = await getActiveTab().catch(() => undefined);
+ await openMicPermissionPage(tab?.id);
+}
diff --git a/src/ui/shared/lib/validate-api-key.ts b/src/ui/shared/lib/validate-api-key.ts
new file mode 100644
index 0000000..d569a93
--- /dev/null
+++ b/src/ui/shared/lib/validate-api-key.ts
@@ -0,0 +1,5 @@
+import { sendMessage } from '@/lib/messaging';
+
+export function validateApiKey(provider: string, apiKey: string, baseUrl?: string, model?: string) {
+ return sendMessage('validateApiKey', { provider, apiKey, baseUrl, model });
+}