diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx
index 7a0042903a3c3..a4c85e50cb3ad 100644
--- a/apps/mobile/src/Stack.tsx
+++ b/apps/mobile/src/Stack.tsx
@@ -99,6 +99,7 @@ import { SettingsProviderAccountsRouteScreen } from "./features/settings/Setting
import { SettingsAuthRouteScreen } from "./features/settings/SettingsAuthRouteScreen";
import { SettingsEnvironmentDetailRouteScreen } from "./features/settings/SettingsEnvironmentDetailRouteScreen";
import { SettingsEnvironmentsRouteScreen } from "./features/settings/SettingsEnvironmentsRouteScreen";
+import { SettingsDictationLanguageRouteScreen } from "./features/settings/SettingsDictationLanguageRouteScreen";
import { SettingsFollowUpRouteScreen } from "./features/settings/SettingsFollowUpRouteScreen";
import {
SettingsEnvironmentMaintenanceRouteScreen,
@@ -373,6 +374,14 @@ const SETTINGS_SCREENS = {
title: "Microphone",
},
}),
+ SettingsDictationLanguage: createNativeStackScreen({
+ screen: SettingsDictationLanguageRouteScreen,
+ linking: "settings/dictation-language",
+ options: {
+ ...SETTINGS_PAGE_OPTIONS,
+ title: "Dictation language",
+ },
+ }),
SettingsFollowUp: createNativeStackScreen({
screen: SettingsFollowUpRouteScreen,
linking: "settings/follow-ups",
diff --git a/apps/mobile/src/features/settings/SettingsDictationLanguageRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsDictationLanguageRouteScreen.tsx
new file mode 100644
index 0000000000000..b350ba64a1176
--- /dev/null
+++ b/apps/mobile/src/features/settings/SettingsDictationLanguageRouteScreen.tsx
@@ -0,0 +1,56 @@
+import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
+import { useAtomSet, useAtomValue } from "@effect/atom-react";
+import { AsyncResult } from "effect/reactivity";
+import { View } from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+
+import {
+ DEVICE_DICTATION_LANGUAGE_LABEL,
+ useDictationLanguages,
+} from "../../lib/dictationLanguages";
+import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
+import { SettingsChoiceRow } from "./components/SettingsChoiceRow";
+import { SettingsSection } from "./components/SettingsSection";
+
+export function SettingsDictationLanguageRouteScreen() {
+ const insets = useSafeAreaInsets();
+ const preferencesResult = useAtomValue(mobilePreferencesAtom);
+ const savePreferences = useAtomSet(updateMobilePreferencesAtom);
+ const preferencesReady = AsyncResult.isSuccess(preferencesResult) && !preferencesResult.waiting;
+ const selectedId = AsyncResult.isSuccess(preferencesResult)
+ ? (preferencesResult.value.voiceInputLocale ?? null)
+ : undefined;
+ const languages = useDictationLanguages();
+ const options = [{ id: null, label: DEVICE_DICTATION_LANGUAGE_LABEL }, ...(languages ?? [])];
+
+ return (
+
+
+
+ {options.map((option, index) => (
+ 0}
+ disabled={!preferencesReady}
+ onPress={() => savePreferences({ voiceInputLocale: option.id })}
+ />
+ ))}
+
+
+
+ );
+}
diff --git a/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
index adcf71595b177..c31a901be9320 100644
--- a/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsMicrophoneRouteScreen.tsx
@@ -11,6 +11,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { type AppSymbolName, SymbolView } from "../../components/ui/AppSymbol";
import { AppText as Text } from "../../components/ui/AppText";
import { cn } from "../../lib/cn";
+import { dictationLanguageLabel, useDictationLanguages } from "../../lib/dictationLanguages";
import { makePermissionStatusAtom } from "../../lib/permissionStatusAtom";
import {
isMicrophoneDevice,
@@ -23,6 +24,7 @@ import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/
import { ListRowLayout } from "../../components/ui/ListRowLayout";
import { SettingsActionRow } from "./components/SettingsActionRow";
import { SettingsDragHandle } from "./components/SettingsDragHandle";
+import { SettingsRow } from "./components/SettingsRow";
import { SettingsSection } from "./components/SettingsSection";
const REMOVE_SIZE = 20;
@@ -94,6 +96,7 @@ export function SettingsMicrophoneRouteScreen() {
const insets = useSafeAreaInsets();
const preferencesResult = useAtomValue(mobilePreferencesAtom);
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
+ const dictationLanguages = useDictationLanguages();
const ready = AsyncResult.isSuccess(preferencesResult) && !preferencesResult.waiting;
const entries = microphoneOrder(
AsyncResult.isSuccess(preferencesResult) ? preferencesResult.value.microphones : undefined,
@@ -217,6 +220,19 @@ export function SettingsMicrophoneRouteScreen() {
devices are added by name after you use voice input with them connected; until then, the
Other row ranks them.
+
+
+
);
diff --git a/apps/mobile/src/features/settings/components/settings-page-targets.ts b/apps/mobile/src/features/settings/components/settings-page-targets.ts
index 6a98023f2ed7c..2b2cb822916f1 100644
--- a/apps/mobile/src/features/settings/components/settings-page-targets.ts
+++ b/apps/mobile/src/features/settings/components/settings-page-targets.ts
@@ -16,6 +16,7 @@ export const SETTINGS_PAGE_TARGETS = [
"SettingsProviderAccounts",
"SettingsKeyboard",
"SettingsMicrophone",
+ "SettingsDictationLanguage",
"SettingsFollowUp",
"SettingsScheduledTasks",
"SettingsProjectGrouping",
diff --git a/apps/mobile/src/features/voice-input/VoiceInputProvider.tsx b/apps/mobile/src/features/voice-input/VoiceInputProvider.tsx
index 809ee3a9d21b5..0135c06bd8f59 100644
--- a/apps/mobile/src/features/voice-input/VoiceInputProvider.tsx
+++ b/apps/mobile/src/features/voice-input/VoiceInputProvider.tsx
@@ -91,7 +91,14 @@ const voiceInputAtom = Atom.make((get) => {
});
const session: VoiceInputSession = new VoiceInputSession({
recorder,
- getTranscriber: getLocalVoiceTranscriber,
+ getTranscriber: () => {
+ const preferences = registry.get(mobilePreferencesAtom);
+ return getLocalVoiceTranscriber(
+ AsyncResult.isSuccess(preferences)
+ ? (preferences.value.voiceInputLocale ?? undefined)
+ : undefined,
+ );
+ },
requestPermission: async () => {
const permission = await requestRecordingPermissionsAsync();
return { granted: permission.granted, canAskAgain: permission.canAskAgain };
diff --git a/apps/mobile/src/lib/dictationLanguages.test.ts b/apps/mobile/src/lib/dictationLanguages.test.ts
new file mode 100644
index 0000000000000..8668eaf3587ca
--- /dev/null
+++ b/apps/mobile/src/lib/dictationLanguages.test.ts
@@ -0,0 +1,21 @@
+import { describe, expect, it } from "vite-plus/test";
+
+import { dictationLanguageLabel } from "./dictationLanguages";
+
+const languages = [{ id: "pt-BR", label: "Português (Brasil)" }];
+
+describe("dictationLanguageLabel", () => {
+ it("names the chosen language from the loaded list", () => {
+ expect(dictationLanguageLabel(languages, "pt-BR")).toBe("Português (Brasil)");
+ });
+
+ it("shows the raw tag until the list loads or when the list lacks it", () => {
+ expect(dictationLanguageLabel(undefined, "pt-BR")).toBe("pt-BR");
+ expect(dictationLanguageLabel(languages, "sv-SE")).toBe("sv-SE");
+ });
+
+ it("names the device language when nothing is chosen", () => {
+ expect(dictationLanguageLabel(languages, null)).toBe("Device language");
+ expect(dictationLanguageLabel(undefined, undefined)).toBe("Device language");
+ });
+});
diff --git a/apps/mobile/src/lib/dictationLanguages.ts b/apps/mobile/src/lib/dictationLanguages.ts
new file mode 100644
index 0000000000000..83834d0868293
--- /dev/null
+++ b/apps/mobile/src/lib/dictationLanguages.ts
@@ -0,0 +1,35 @@
+import { useEffect, useState } from "react";
+
+import { getDictationLanguages } from "../native/voiceTranscription";
+import type { DictationLanguage } from "../native/voiceTranscription.types";
+
+export const DEVICE_DICTATION_LANGUAGE_LABEL = "Device language";
+
+/** The languages this device can transcribe, or undefined while they load. */
+export function useDictationLanguages(): ReadonlyArray | undefined {
+ const [languages, setLanguages] = useState>();
+ // oxlint-disable-next-line t3code/react-effect-budget -- Load the native device capabilities when this screen mounts.
+ useEffect(() => {
+ let cancelled = false;
+ getDictationLanguages().then(
+ (loaded) => {
+ if (!cancelled) setLanguages(loaded);
+ },
+ () => {
+ if (!cancelled) setLanguages([]);
+ },
+ );
+ return () => {
+ cancelled = true;
+ };
+ }, []);
+ return languages;
+}
+
+export function dictationLanguageLabel(
+ languages: ReadonlyArray | undefined,
+ id: string | null | undefined,
+): string {
+ if (id == null) return DEVICE_DICTATION_LANGUAGE_LABEL;
+ return languages?.find((language) => language.id === id)?.label ?? id;
+}
diff --git a/apps/mobile/src/native/voiceTranscription.ios.test.ts b/apps/mobile/src/native/voiceTranscription.ios.test.ts
index d3ee19c262de6..c0a77f769e801 100644
--- a/apps/mobile/src/native/voiceTranscription.ios.test.ts
+++ b/apps/mobile/src/native/voiceTranscription.ios.test.ts
@@ -6,6 +6,8 @@ import { VoiceTranscriptionError } from "@t3tools/client-runtime/voice-input";
const mocks = vi.hoisted(() => ({
isAvailable: vi.fn<(locale: string) => boolean>(),
prepare: vi.fn<(locale: string) => Promise>(),
+ supportedLanguages:
+ vi.fn<() => Promise>>(),
transcribe: vi.fn<(audio: ArrayBufferLike, locale: string) => Promise>(),
readAudio: vi.fn<() => Promise>(),
}));
@@ -14,6 +16,7 @@ vi.mock("@react-native-ai/apple/src/NativeAppleTranscription", () => ({
default: {
isAvailable: mocks.isAvailable,
prepare: mocks.prepare,
+ supportedLanguages: mocks.supportedLanguages,
transcribe: mocks.transcribe,
},
}));
@@ -24,7 +27,7 @@ vi.mock("expo-file-system", () => ({
},
}));
-import { getLocalVoiceTranscriber } from "./voiceTranscription.ios";
+import { getDictationLanguages, getLocalVoiceTranscriber } from "./voiceTranscription.ios";
const audio = new ArrayBuffer(4);
const nativeTranscript: TranscriptionResult = {
@@ -56,6 +59,40 @@ afterEach(() => {
});
describe("getLocalVoiceTranscriber", () => {
+ it("keeps the selected language and Apple's resolved locale when the device language changes", async () => {
+ const resolvedOptions = Intl.DateTimeFormat().resolvedOptions();
+ const deviceLocale = vi
+ .spyOn(Intl.DateTimeFormat.prototype, "resolvedOptions")
+ .mockReturnValue({ ...resolvedOptions, locale: "sv-FI" });
+ const transcriber = getLocalVoiceTranscriber()!;
+ const options = { signal: new AbortController().signal };
+
+ deviceLocale.mockReturnValue({ ...resolvedOptions, locale: "de-DE" });
+ const prepared = await transcriber.prepare(options);
+ deviceLocale.mockReturnValue({ ...resolvedOptions, locale: "en-US" });
+
+ await expect(prepared.transcribe("file:///voice.m4a", options)).resolves.toBe("Hej världen.");
+ expect(mocks.prepare).toHaveBeenCalledWith("sv-FI");
+ expect(prepared.locale).toBe("sv-SE");
+ expect(mocks.transcribe).toHaveBeenCalledWith(audio, "sv-SE");
+ });
+
+ it("prepares the chosen dictation language instead of the device language", async () => {
+ const resolvedOptions = Intl.DateTimeFormat().resolvedOptions();
+ vi.spyOn(Intl.DateTimeFormat.prototype, "resolvedOptions").mockReturnValue({
+ ...resolvedOptions,
+ locale: "en-US",
+ });
+ mocks.prepare.mockResolvedValue("pt_BR");
+
+ const prepared = await getLocalVoiceTranscriber("pt-BR")!.prepare({
+ signal: new AbortController().signal,
+ });
+
+ expect(mocks.prepare).toHaveBeenCalledWith("pt-BR");
+ expect(prepared.locale).toBe("pt_BR");
+ });
+
it("does not start native transcription after cancellation during a file read", async () => {
const enteredRead = deferred();
const readResult = deferred();
@@ -80,3 +117,25 @@ describe("getLocalVoiceTranscriber", () => {
expect(mocks.transcribe).not.toHaveBeenCalled();
});
});
+
+describe("getDictationLanguages", () => {
+ it("lists what the device supports, sorted by name", async () => {
+ mocks.supportedLanguages.mockResolvedValue([
+ { id: "pt-BR", label: "Português (Brasil)" },
+ { id: "de-DE", label: "Deutsch (Deutschland)" },
+ { id: "en-US", label: "English (US)" },
+ ]);
+
+ expect(await getDictationLanguages()).toEqual([
+ { id: "de-DE", label: "Deutsch (Deutschland)" },
+ { id: "en-US", label: "English (US)" },
+ { id: "pt-BR", label: "Português (Brasil)" },
+ ]);
+ });
+
+ it("is empty where the device cannot transcribe", async () => {
+ mocks.supportedLanguages.mockResolvedValue([]);
+
+ expect(await getDictationLanguages()).toEqual([]);
+ });
+});
diff --git a/apps/mobile/src/native/voiceTranscription.ios.ts b/apps/mobile/src/native/voiceTranscription.ios.ts
index 216b9e958dd66..2b1b15ca53dea 100644
--- a/apps/mobile/src/native/voiceTranscription.ios.ts
+++ b/apps/mobile/src/native/voiceTranscription.ios.ts
@@ -9,6 +9,8 @@ import {
type VoiceTranscriptionOptions,
} from "@t3tools/client-runtime/voice-input";
+import type { DictationLanguage } from "./voiceTranscription.types";
+
function getDeviceLocale(): string {
return Intl.DateTimeFormat().resolvedOptions().locale;
}
@@ -33,12 +35,17 @@ function getNativeErrorCode(error: unknown): string | undefined {
return typeof error.code === "string" ? error.code : undefined;
}
-export function getLocalVoiceTranscriber(): VoiceTranscriber | null {
- const locale = getDeviceLocale();
+export function getLocalVoiceTranscriber(preferredLocale?: string): VoiceTranscriber | null {
+ const locale = preferredLocale ?? getDeviceLocale();
if (!AppleTranscription.isAvailable(locale)) return null;
return { prepare: (options) => prepareVoiceTranscription(locale, options) };
}
+export async function getDictationLanguages(): Promise> {
+ const languages = await AppleTranscription.supportedLanguages();
+ return [...languages].sort((a, b) => a.label.localeCompare(b.label));
+}
+
async function prepareVoiceTranscription(
locale: string,
{ signal }: VoiceTranscriptionOptions,
diff --git a/apps/mobile/src/native/voiceTranscription.ts b/apps/mobile/src/native/voiceTranscription.ts
index e003064ae3f84..ab030691a30f8 100644
--- a/apps/mobile/src/native/voiceTranscription.ts
+++ b/apps/mobile/src/native/voiceTranscription.ts
@@ -1,5 +1,11 @@
import type { VoiceTranscriber } from "@t3tools/client-runtime/voice-input";
-export function getLocalVoiceTranscriber(): VoiceTranscriber | null {
+import type { DictationLanguage } from "./voiceTranscription.types";
+
+export function getLocalVoiceTranscriber(_preferredLocale?: string): VoiceTranscriber | null {
return null;
}
+
+export function getDictationLanguages(): Promise> {
+ return Promise.resolve([]);
+}
diff --git a/apps/mobile/src/native/voiceTranscription.types.ts b/apps/mobile/src/native/voiceTranscription.types.ts
new file mode 100644
index 0000000000000..dee7210e766f7
--- /dev/null
+++ b/apps/mobile/src/native/voiceTranscription.types.ts
@@ -0,0 +1,4 @@
+export interface DictationLanguage {
+ readonly id: string;
+ readonly label: string;
+}
diff --git a/apps/mobile/src/persistence/mobile-preferences.ts b/apps/mobile/src/persistence/mobile-preferences.ts
index 3a79a73ee3c36..83e0e839e572d 100644
--- a/apps/mobile/src/persistence/mobile-preferences.ts
+++ b/apps/mobile/src/persistence/mobile-preferences.ts
@@ -110,6 +110,8 @@ export interface Preferences {
readonly composerEnterBehavior?: ComposerEnterBehavior;
readonly followUpBehavior?: FollowUpBehavior;
readonly microphones?: ReadonlyArray;
+ /** A BCP 47 tag the device can transcribe, or null for the device language. */
+ readonly voiceInputLocale?: string | null;
readonly projectGroupingEnabled?: boolean;
readonly projectGroupingMode?: SidebarProjectGroupingMode;
readonly planModeEnabled?: boolean;
@@ -165,6 +167,14 @@ export class MobilePreferencesStore extends Context.Service<
}
>()("@t3tools/mobile/persistence/MobilePreferencesStore") {}
+// Shape only; whether the device can transcribe the tag is checked when preparing voice input.
+const LANGUAGE_TAG =
+ /^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{2,8})*(?:-[0-9A-WY-Za-wy-z](?:-[A-Za-z0-9]{2,8})+)*(?:-[xX](?:-[A-Za-z0-9]{1,8})+)?$/;
+
+function isLanguageTag(value: unknown): value is string {
+ return typeof value === "string" && LANGUAGE_TAG.test(value);
+}
+
function sanitizePreferences(parsed: Preferences): Preferences {
const preferences: {
navigationTabOrder?: readonly string[];
@@ -189,6 +199,7 @@ function sanitizePreferences(parsed: Preferences): Preferences {
composerEnterBehavior?: ComposerEnterBehavior;
followUpBehavior?: FollowUpBehavior;
microphones?: ReadonlyArray;
+ voiceInputLocale?: string | null;
projectGroupingEnabled?: boolean;
projectGroupingMode?: SidebarProjectGroupingMode;
planModeEnabled?: boolean;
@@ -302,6 +313,9 @@ function sanitizePreferences(parsed: Preferences): Preferences {
: [];
});
}
+ if (parsed.voiceInputLocale === null || isLanguageTag(parsed.voiceInputLocale)) {
+ preferences.voiceInputLocale = parsed.voiceInputLocale;
+ }
if (typeof parsed.projectGroupingEnabled === "boolean") {
preferences.projectGroupingEnabled = parsed.projectGroupingEnabled;
}
diff --git a/apps/mobile/src/state/preferences.test.ts b/apps/mobile/src/state/preferences.test.ts
index cd9669c51d2d7..7b6d7a90964ef 100644
--- a/apps/mobile/src/state/preferences.test.ts
+++ b/apps/mobile/src/state/preferences.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from "@effect/vitest";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
+import * as Option from "effect/Option";
import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity";
import { vi } from "vite-plus/test";
import { ProviderInstanceId } from "@t3tools/contracts";
@@ -26,7 +27,9 @@ vi.mock("../lib/runtime", async () => {
});
import { createMobilePreferencesState } from "./preferences";
+import * as MobileDatabase from "../persistence/mobile-database";
import * as MobilePreferences from "../persistence/mobile-preferences";
+import * as MobileSecureStorage from "../persistence/mobile-secure-storage";
function deferred() {
let resolve!: (value: A) => void;
@@ -59,6 +62,65 @@ function makePreferencesState(
);
}
+function makePreferencesStore(initialPayload: MobilePreferences.Preferences) {
+ const row = { payload: JSON.stringify(initialPayload), updatedAt: 1 };
+ const unused = Effect.die("unused in preferences tests");
+ return MobilePreferences.make().pipe(
+ Effect.provideService(
+ MobileDatabase.MobileDatabase,
+ MobileDatabase.MobileDatabase.of({
+ loadCache: () => unused,
+ listCache: () => unused,
+ saveCache: () => unused,
+ removeCache: () => unused,
+ clearCacheKind: () => unused,
+ clearEnvironmentCache: () => unused,
+ clearAllCaches: unused,
+ inspectCaches: unused,
+ loadPreferencesJson: Effect.sync(() => Option.some({ ...row })),
+ savePreferencesJson: (payload, updatedAt) =>
+ Effect.sync(() => {
+ row.payload = payload;
+ row.updatedAt = updatedAt;
+ }),
+ }),
+ ),
+ Effect.provideService(
+ MobileSecureStorage.MobileSecureStorage,
+ MobileSecureStorage.MobileSecureStorage.of({
+ getItem: () => Effect.succeed(null),
+ setItem: () => Effect.void,
+ removeItem: () => Effect.void,
+ }),
+ ),
+ Effect.map((store) => ({ store, storedPayload: () => JSON.parse(row.payload) as unknown })),
+ );
+}
+
+describe("mobile preferences store", () => {
+ it.effect("keeps a null or well-formed dictation language and drops a malformed one", () =>
+ Effect.gen(function* () {
+ const cleared = yield* makePreferencesStore({ voiceInputLocale: null });
+ expect(yield* cleared.store.load).toEqual({ voiceInputLocale: null });
+
+ const chosen = yield* makePreferencesStore({ voiceInputLocale: "yue-Hant-HK" });
+ expect(yield* chosen.store.load).toEqual({ voiceInputLocale: "yue-Hant-HK" });
+
+ const extended = yield* makePreferencesStore({ voiceInputLocale: "en-US-u-ca-gregory" });
+ expect(yield* extended.store.load).toEqual({ voiceInputLocale: "en-US-u-ca-gregory" });
+
+ const privateUse = yield* makePreferencesStore({ voiceInputLocale: "en-US-x-a" });
+ expect(yield* privateUse.store.load).toEqual({ voiceInputLocale: "en-US-x-a" });
+
+ const incomplete = yield* makePreferencesStore({ voiceInputLocale: "en-US-u" });
+ expect(yield* incomplete.store.load).toEqual({});
+
+ const malformed = yield* makePreferencesStore({ voiceInputLocale: "Portuguese" });
+ expect(yield* malformed.store.load).toEqual({});
+ }),
+ );
+});
+
describe("mobile preferences state", () => {
it.effect("preserves an optimistic patch when the initial load finishes later", () =>
Effect.gen(function* () {
@@ -195,4 +257,34 @@ describe("mobile preferences state", () => {
registry.dispose();
}),
);
+ it.effect("keeps the device dictation language after another preference saves", () =>
+ Effect.gen(function* () {
+ const { store, storedPayload } = yield* makePreferencesStore({ voiceInputLocale: "pt-BR" });
+ const state = createMobilePreferencesState(
+ Atom.runtime(Layer.succeed(MobilePreferences.MobilePreferencesStore, store)),
+ );
+ const registry = AtomRegistry.make();
+ const unmountPreferences = registry.mount(state.preferencesAtom);
+ const unmountUpdate = registry.mount(state.updatePreferencesAtom);
+ const save = (patch: Partial) => {
+ registry.set(state.updatePreferencesAtom, patch);
+ return AtomRegistry.getResult(registry, state.updatePreferencesAtom, {
+ suspendOnWaiting: true,
+ });
+ };
+
+ yield* AtomRegistry.getResult(registry, state.preferencesAtom, { suspendOnWaiting: true });
+ yield* save({ voiceInputLocale: null });
+ yield* save({ baseFontSize: 18 });
+
+ expect(
+ yield* AtomRegistry.getResult(registry, state.preferencesAtom, { suspendOnWaiting: true }),
+ ).toEqual({ voiceInputLocale: null, baseFontSize: 18 });
+ expect(storedPayload()).toEqual({ voiceInputLocale: null, baseFontSize: 18 });
+
+ unmountUpdate();
+ unmountPreferences();
+ registry.dispose();
+ }),
+ );
});
diff --git a/docs/user/composer.md b/docs/user/composer.md
index 82cc005d061f1..bc3c4ea27636e 100644
--- a/docs/user/composer.md
+++ b/docs/user/composer.md
@@ -192,6 +192,9 @@ for example, put **Other Bluetooth** above your AirPods so a new headset is pref
while the AirPods microphone stays low. By default, CarPlay comes after the built-in
microphone.
+Voice input transcribes in your iPhone's language. If you speak a different language,
+pick it in **Settings → Microphone → Dictation language**.
+
Transcription runs on your device. T3 Code deletes the temporary audio after
transcription or cancellation; only the message text is sent when you submit.
diff --git a/patches/@react-native-ai__apple@0.12.0.patch b/patches/@react-native-ai__apple@0.12.0.patch
index b2a7aaf229914..6b5890d8095e1 100644
--- a/patches/@react-native-ai__apple@0.12.0.patch
+++ b/patches/@react-native-ai__apple@0.12.0.patch
@@ -1,5 +1,18 @@
+diff --git a/ios/transcription/AppleTranscription.mm b/ios/transcription/AppleTranscription.mm
+index c0f036ce7d9905cf7a54c80199e4d6039f64ef30..fac31400a57098527637161cde70fbbd92b5652e 100644
+--- a/ios/transcription/AppleTranscription.mm
++++ b/ios/transcription/AppleTranscription.mm
+@@ -116,4 +116,8 @@ - (void)prepare:(nonnull NSString *)language resolve:(nonnull RCTPromiseResolveB
+ [_transcription prepare:language resolve:resolve reject:reject];
+ }
+
++- (void)supportedLanguages:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
++ [_transcription supportedLanguages:resolve];
++}
++
+ @end
diff --git a/ios/transcription/AppleTranscriptionImpl.swift b/ios/transcription/AppleTranscriptionImpl.swift
-index 188371a5f55fadae19187108c4a688569d0223e3..3e1cdd77b0bb8ae6c97a40d29c1854200d931eee 100644
+index 188371a5f55fadae19187108c4a688569d0223e3..0baaed8196491d2791f97fd6b861163f1ff10491 100644
--- a/ios/transcription/AppleTranscriptionImpl.swift
+++ b/ios/transcription/AppleTranscriptionImpl.swift
@@ -12,6 +12,11 @@ import UniformTypeIdentifiers
@@ -44,7 +57,30 @@ index 188371a5f55fadae19187108c4a688569d0223e3..3e1cdd77b0bb8ae6c97a40d29c185420
@unknown default:
reject ("AppleTranscription", "Unknown asset inventory status", nil)
}
-@@ -83,57 +86,77 @@ public class AppleTranscriptionImpl: NSObject {
+@@ -73,6 +76,22 @@ public class AppleTranscriptionImpl: NSObject {
+ }
+ }
+
++ @objc
++ public func supportedLanguages(_ resolve: @escaping (Any?) -> Void) {
++ guard #available(iOS 26, *) else {
++ resolve([])
++ return
++ }
++ Task {
++ let languages = await SpeechTranscriber.supportedLocales.map { locale -> [String: String] in
++ let id = locale.identifier(.bcp47)
++ let name = locale.localizedString(forIdentifier: locale.identifier) ?? id
++ return ["id": id, "label": name.prefix(1).uppercased(with: locale) + name.dropFirst()]
++ }
++ resolve(languages)
++ }
++ }
++
+ @objc
+ public func transcribe(_ audioData: Data, language: String, resolve: @escaping ([String: Any]) -> Void, reject: @escaping (String, String, Error?) -> Void) {
+ if #available(iOS 26, *) {
+@@ -83,57 +102,77 @@ public class AppleTranscriptionImpl: NSObject {
do {
try audioData.write(to: fileURL)
@@ -153,21 +189,25 @@ index 188371a5f55fadae19187108c4a688569d0223e3..3e1cdd77b0bb8ae6c97a40d29c185420
reject("AppleTranscription", "Failed to write audio data: \(error.localizedDescription)", error)
}
} else {
-@@ -141,4 +164,3 @@ public class AppleTranscriptionImpl: NSObject {
+@@ -141,4 +180,3 @@ public class AppleTranscriptionImpl: NSObject {
}
}
}
-
diff --git a/lib/typescript/NativeAppleTranscription.d.ts b/lib/typescript/NativeAppleTranscription.d.ts
-index 985b6b3593a884c41d689346be9d73d86c55eae1..86e7936f23a8673d099f7fe18af9a31abae5a13a 100644
+index 985b6b3593a884c41d689346be9d73d86c55eae1..e030c91e6b1b6bb856c92aa9144434c775734852 100644
--- a/lib/typescript/NativeAppleTranscription.d.ts
+++ b/lib/typescript/NativeAppleTranscription.d.ts
-@@ -10,14 +10,14 @@ export interface TranscriptionResult {
+@@ -10,14 +10,22 @@ export interface TranscriptionResult {
}
export interface Spec extends TurboModule {
isAvailable(language: string): boolean;
- prepare(language: string): Promise;
+ prepare(language: string): Promise;
++ supportedLanguages(): Promise>;
}
declare global {
function __apple__llm__transcribe__(data: ArrayBufferLike, language: string): Promise;
@@ -176,19 +216,31 @@ index 985b6b3593a884c41d689346be9d73d86c55eae1..86e7936f23a8673d099f7fe18af9a31a
transcribe: (data: ArrayBufferLike, language: string) => Promise;
- prepare: (language: string) => Promise;
+ prepare: (language: string) => Promise;
++ supportedLanguages: () => Promise>;
isAvailable: (language: string) => boolean;
};
export default _default;
diff --git a/src/NativeAppleTranscription.ts b/src/NativeAppleTranscription.ts
-index 13332a0176000b60b6f6f043de681db55a7b4bef..5389fb4b3a53de48721c307d2145b6770624c852 100644
+index 13332a0176000b60b6f6f043de681db55a7b4bef..8bb7b281b3f03dedfa3758f4d4354a7d2af72b85 100644
--- a/src/NativeAppleTranscription.ts
+++ b/src/NativeAppleTranscription.ts
-@@ -14,7 +14,7 @@ export interface TranscriptionResult {
+@@ -14,7 +14,8 @@ export interface TranscriptionResult {
export interface Spec extends TurboModule {
isAvailable(language: string): boolean
- prepare(language: string): Promise
+ prepare(language: string): Promise
++ supportedLanguages(): Promise>
}
declare global {
+@@ -32,5 +33,6 @@ export default {
+ transcribe: (data: ArrayBufferLike, language: string) =>
+ globalThis.__apple__llm__transcribe__(data, language),
+ prepare: NativeAppleTranscription.prepare,
++ supportedLanguages: NativeAppleTranscription.supportedLanguages,
+ isAvailable: NativeAppleTranscription.isAvailable,
+ }
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c854ee336471c..f38d8c30919d2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -355,7 +355,7 @@ patchedDependencies:
'@legendapp/list@3.3.5': 6cbdacd8c380d9a5afb9f73d4198dc2cc44be6ef28a955b1183c781469307896
'@muse-code/sdk@1.4.6': 7b495b607fc5d76b444c7c4d58821e839726a30e6f3c53564f0d59f2d5b42101
'@pierre/diffs@1.6.1': 4645364ddf113e48e8827f3b4966b3b1ff745317011e5a3d904e2d8672dee7dc
- '@react-native-ai/apple@0.12.0': 2d09870c2848d185cb05b53ed823a46e12dba519324d8dd8e584e28731990f9d
+ '@react-native-ai/apple@0.12.0': 268fa178f07af686634ad9963eaee6ed1e5ca800ce7fd16300df87c007562838
'@react-native-menu/menu@2.0.0': 910ec1bf22aa85a96fcf12299cd823bc30f702dd9b2d77b564d10b9ed709f7f6
'@react-navigation/native-stack@7.21.0': 990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42
alchemy@2.0.0-beta.80: bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd
@@ -545,7 +545,7 @@ importers:
version: 0.2.0
'@react-native-ai/apple':
specifier: 0.12.0
- version: 0.12.0(patch_hash=2d09870c2848d185cb05b53ed823a46e12dba519324d8dd8e584e28731990f9d)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))
+ version: 0.12.0(patch_hash=268fa178f07af686634ad9963eaee6ed1e5ca800ce7fd16300df87c007562838)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))
'@react-native-async-storage/async-storage':
specifier: 3.1.1
version: 3.1.1(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
@@ -15711,7 +15711,7 @@ snapshots:
prompts: 2.4.2
tinyexec: 1.3.1
- '@react-native-ai/apple@0.12.0(patch_hash=2d09870c2848d185cb05b53ed823a46e12dba519324d8dd8e584e28731990f9d)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))':
+ '@react-native-ai/apple@0.12.0(patch_hash=268fa178f07af686634ad9963eaee6ed1e5ca800ce7fd16300df87c007562838)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))':
dependencies:
'@ai-sdk/provider': 3.0.18
'@ai-sdk/provider-utils': 4.0.57(zod@4.6.5)