Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
feat(mobile): pick the transcription mode by tapping its card (#2531)
Chad Pihaf29c14d5dc91
diff --git a/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx b/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsxindex b443dd840..b77815cc9 100644--- a/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx+++ b/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx@@ -1,5 +1,5 @@-import type { ReactElement, ReactNode } from 'react';-import { ScrollView, View } from 'react-native';+import { useState, type ReactElement, type ReactNode } from 'react';+import { Pressable, ScrollView, View } from 'react-native';import { Text } from '@/components/ui/Text';import { OnboardingShell } from '@/components/onboarding/OnboardingShell';import { SystemIcon } from '@/components/ui/SystemIcon';@@ -10,12 +10,22 @@ import { chooseOnboardingMode } from '@/lib/onboardingMode';import { useModelDownloadStore } from '@/store/useModelDownloadStore';import { useOnboardingStore } from '@/store/useOnboardingStore';+type ModeChoice = 'cloud' | 'private';+export function PrivacyModeStep(): ReactElement {const { goBack, progress } = useOnboardingStep('privacy-mode');const selectedMode = useOnboardingStore((state) => state.selectedMode);const cancelActiveDownloads = useModelDownloadStore((state) => state.cancelActiveDownloads);+ // Revisiting the step keeps the earlier Local choice; otherwise Cloud is the default.+ const [choice, setChoice] = useState<ModeChoice>(+ selectedMode === 'private' ? 'private' : 'cloud',+ );- const chooseCloud = async (): Promise<void> => {+ const handleContinue = async (): Promise<void> => {+ if (choice === 'private') {+ await chooseOnboardingMode('private', 'privacy-mode');+ return;+ }const choseLocalEarlier = selectedMode === 'private';await chooseOnboardingMode('cloud', 'privacy-mode');// Back from the download step leaves its model transferring; Cloud has no use for it. Without@@ -30,24 +40,29 @@ export function PrivacyModeStep(): ReactElement {title="How should we transcribe?"titleAccent="transcribe"subtitle="Your voice stays yours. Pick a mode — you can change it anytime."- ctaLabel="Use Cloud"- onCta={chooseCloud}- secondaryCtaLabel="Use Local"- secondaryCtaVariant="card"- onSecondaryCta={() => chooseOnboardingMode('private', 'privacy-mode')}+ ctaLabel="Continue"+ onCta={handleContinue}><ScrollViewshowsVerticalScrollIndicator={false}contentContainerStyle={{ gap: 12, paddingTop: 4, paddingBottom: 8 }}>- {selectedMode ? (- <Text className="text-[14px] font-medium text-primary">- {selectedMode === 'cloud' ? 'Cloud is selected' : 'Local is selected'}- </Text>- ) : null}+ <ModeCard+ title="OpenWhispr Cloud"+ icon={<OpenWhisprMark size={20} color={BRAND} />}+ selected={choice === 'cloud'}+ onSelect={() => setChoice('cloud')}+ >+ <Bullet text="Zero setup" />+ <Bullet text="Faster transcription" />+ <Bullet text="Higher quality" />+ <Bullet text="Automatic cleanup & formatting" />+ </ModeCard><ModeCardtitle="Local · Private mode"icon={<SystemIcon name="lock.fill" mdName="Lock" size={18} color="brand" />}+ selected={choice === 'private'}+ onSelect={() => setChoice('private')}><Text className="mt-1 text-[14px] leading-[19px] text-secondaryLabel">Everything runs on your device. Nothing is ever uploaded.@@ -65,11 +80,6 @@ export function PrivacyModeStep(): ReactElement {One-time ~140–461 MB download, depending on language</Text></ModeCard>- <ModeCard title="OpenWhispr Cloud" icon={<OpenWhisprMark size={20} color={BRAND} />}>- <Bullet text="Faster transcription" />- <Bullet text="Higher quality" />- <Bullet text="Automatic cleanup & formatting" />- </ModeCard></ScrollView></OnboardingShell>);@@ -87,19 +97,35 @@ function Bullet({ text }: { text: string }): ReactElement {function ModeCard({title,icon,+ selected,+ onSelect,children,}: {title: string;icon: ReactNode;+ selected: boolean;+ onSelect: () => void;children: ReactNode;}): ReactElement {return (- <View className="flex-row items-start gap-3 rounded-xl border border-separator bg-secondarySystemGroupedBackground px-4 py-4">+ <Pressable+ accessibilityRole="radio"+ accessibilityLabel={title}+ accessibilityState={{ selected }}+ onPress={onSelect}+ className={`flex-row items-start gap-3 rounded-xl border bg-secondarySystemGroupedBackground px-4 py-4 ${selected ? 'border-primary' : 'border-separator'}`}+ ><View className="mt-0.5 h-8 w-8 items-center justify-center">{icon}</View><View className="flex-1"><Text className="text-[16px] font-semibold text-label">{title}</Text>{children}</View>- </View>+ <SystemIcon+ name={selected ? 'checkmark.circle.fill' : 'circle'}+ mdName={selected ? 'CheckCircle2' : 'Circle'}+ size={22}+ color={selected ? 'brand' : 'tertiaryLabel'}+ />+ </Pressable>);}diff --git a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsxindex 0533a9cda..759728c7f 100644--- a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx+++ b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx@@ -28,9 +28,13 @@ beforeEach(() => {jest.mocked(chooseOnboardingMode).mockResolvedValue(undefined);mockCancelActiveDownloads.mockResolvedValue(undefined);});+const CLOUD = 'OpenWhispr Cloud';+const LOCAL = 'Local · Private mode';+it('describes each mode in a few short lines', () => {const screen = render(<PrivacyModeStep />);for (const text of [+ 'Zero setup','Everything runs on your device. Nothing is ever uploaded.','Works fully offline','Faster transcription',@@ -43,28 +47,40 @@ it('describes each mode in a few short lines', () => {expect(screen.queryByText(/voice agent/i)).toBeNull();expect(screen.queryByText(/Pro offer/i)).toBeNull();});-it('shows the confirmed mode when revisiting the choice', () => {+it('lists Cloud first and selects it by default', () => {+ const screen = render(<PrivacyModeStep />);+ const [first, second] = screen.getAllByRole('radio');+ expect(first.props.accessibilityLabel).toBe(CLOUD);+ expect(second.props.accessibilityLabel).toBe(LOCAL);+ expect(screen.getByLabelText(CLOUD).props.accessibilityState).toEqual({ selected: true });+ expect(screen.getByLabelText(LOCAL).props.accessibilityState).toEqual({ selected: false });+ expect(screen.queryByText('Use Cloud')).toBeNull();+ expect(screen.queryByText('Use Local')).toBeNull();+});+it('keeps the earlier Local choice when revisiting the step', () => {mockSelectedMode = 'private';const screen = render(<PrivacyModeStep />);- expect(screen.getByText('Local is selected')).toBeTruthy();+ expect(screen.getByLabelText(LOCAL).props.accessibilityState).toEqual({ selected: true });});it.each([- ['Use Cloud', 'cloud'],- ['Use Local', 'private'],-] as const)('commits %s without an extra Continue tap', async (label, mode) => {+ [CLOUD, 'cloud'],+ [LOCAL, 'private'],+] as const)('commits %s on Continue', async (label, mode) => {const screen = render(<PrivacyModeStep />);- fireEvent.press(screen.getByText(label));+ fireEvent.press(screen.getByLabelText(label));+ expect(chooseOnboardingMode).not.toHaveBeenCalled();+ fireEvent.press(screen.getByText('Continue'));await waitFor(() => expect(chooseOnboardingMode).toHaveBeenCalledWith(mode, 'privacy-mode'));- expect(screen.queryByText('Continue')).toBeNull();});it('keeps the choices available after a failed Cloud attempt', async () => {jest.mocked(chooseOnboardingMode).mockRejectedValueOnce(new OnboardingError('Cloud is unavailable'));const screen = render(<PrivacyModeStep />);- fireEvent.press(screen.getByText('Use Cloud'));+ fireEvent.press(screen.getByText('Continue'));expect(await screen.findByText('Cloud is unavailable')).toBeTruthy();- fireEvent.press(screen.getByText('Use Local'));+ fireEvent.press(screen.getByLabelText(LOCAL));+ fireEvent.press(screen.getByText('Continue'));await waitFor(() => expect(chooseOnboardingMode).toHaveBeenCalledWith('private', 'privacy-mode'));expect(mockCancelActiveDownloads).not.toHaveBeenCalled();});@@ -72,13 +88,14 @@ it('keeps the choices available after a failed Cloud attempt', async () => {it('stops a Local download left running once Cloud is chosen', async () => {mockSelectedMode = 'private';const screen = render(<PrivacyModeStep />);- fireEvent.press(screen.getByText('Use Cloud'));+ fireEvent.press(screen.getByLabelText(CLOUD));+ fireEvent.press(screen.getByText('Continue'));await waitFor(() => expect(mockCancelActiveDownloads).toHaveBeenCalledTimes(1));});// Reset onboarding shows setup straight away, so a model downloading from Settings is not ours.it('leaves other downloads alone when Local was not chosen in this setup', async () => {const screen = render(<PrivacyModeStep />);- fireEvent.press(screen.getByText('Use Cloud'));+ fireEvent.press(screen.getByText('Continue'));await waitFor(() => expect(chooseOnboardingMode).toHaveBeenCalledWith('cloud', 'privacy-mode'));expect(mockCancelActiveDownloads).not.toHaveBeenCalled();});