From 30c5ac35a7f2c66786566b676f7017a743cc87d7 Mon Sep 17 00:00:00 2001 From: RCXDd <92461990+RCXDd@users.noreply.github.com> Date: Sun, 18 Oct 2026 23:14:36 +0200 Subject: [PATCH 1/2] feat(mobile): set up speech to text from the app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Speech to text could only be configured in web or desktop Settings, so a phone-only user could not choose a service, enter a key, or turn cleanup on. Settings → Server settings → Speech to text now edits the same environment settings: service, API key (stored as a secret, replace or remove), model, server URL, language, vocabulary, and cleanup with its server, model, key, thread-context toggle, and instructions. Each selected environment gets its own sections, like Provider accounts. Co-Authored-By: Claude Opus 5.5 --- apps/mobile/src/Stack.tsx | 6 + .../features/settings/SettingsRouteScreen.tsx | 1 + .../SettingsSpeechToTextRouteScreen.tsx | 320 ++++++++++++++++++ .../components/settings-page-targets.ts | 1 + .../src/features/settings/settings-search.ts | 1 + docs/user/composer.md | 3 +- 6 files changed, 331 insertions(+), 1 deletion(-) create mode 100644 apps/mobile/src/features/settings/SettingsSpeechToTextRouteScreen.tsx diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx index 8a07f8b7a0867..2c17ca4295638 100644 --- a/apps/mobile/src/Stack.tsx +++ b/apps/mobile/src/Stack.tsx @@ -90,6 +90,7 @@ import { SettingsAppearanceRouteScreen } from "./features/settings/SettingsAppea import { SettingsClientStorageRouteScreen } from "./features/settings/SettingsClientStorageRouteScreen"; import { SettingsDiagnosticsRouteScreen } from "./features/diagnostics/SettingsDiagnosticsRouteScreen"; import { SettingsProviderAccountsRouteScreen } from "./features/settings/SettingsProviderAccountsRouteScreen"; +import { SettingsSpeechToTextRouteScreen } from "./features/settings/SettingsSpeechToTextRouteScreen"; import { SettingsAuthRouteScreen } from "./features/settings/SettingsAuthRouteScreen"; import { SettingsEnvironmentDetailRouteScreen } from "./features/settings/SettingsEnvironmentDetailRouteScreen"; import { SettingsEnvironmentsRouteScreen } from "./features/settings/SettingsEnvironmentsRouteScreen"; @@ -281,6 +282,11 @@ const SETTINGS_SCREENS = { linking: "settings/provider-accounts", options: { ...SETTINGS_PAGE_OPTIONS, title: "Provider accounts" }, }), + SettingsSpeechToText: createNativeStackScreen({ + screen: SettingsSpeechToTextRouteScreen, + linking: "settings/speech-to-text", + options: { ...SETTINGS_PAGE_OPTIONS, title: "Speech to text" }, + }), SettingsEnvironmentMaintenance: createNativeStackScreen({ screen: SettingsEnvironmentMaintenanceRouteScreen, linking: "settings/maintenance", diff --git a/apps/mobile/src/features/settings/SettingsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsRouteScreen.tsx index 2f7406d5b7820..4afce7a6bf99b 100644 --- a/apps/mobile/src/features/settings/SettingsRouteScreen.tsx +++ b/apps/mobile/src/features/settings/SettingsRouteScreen.tsx @@ -268,6 +268,7 @@ function useSettingsIndexSections(): SettingsListSection[] { serverPage("SettingsEnvironmentNewThreads", "text.bubble", "New threads"), serverPage("SettingsEnvironmentSourceControl", "arrow.triangle.branch", "Source control"), serverPage("SettingsEnvironmentAgentBehavior", "text.alignleft", "Agent behavior"), + serverPage("SettingsSpeechToText", "mic", "Speech to text"), serverPage("SettingsEnvironmentMaintenance", "arrow.clockwise", "Maintenance"), ], }, diff --git a/apps/mobile/src/features/settings/SettingsSpeechToTextRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsSpeechToTextRouteScreen.tsx new file mode 100644 index 0000000000000..d5c7c5c910031 --- /dev/null +++ b/apps/mobile/src/features/settings/SettingsSpeechToTextRouteScreen.tsx @@ -0,0 +1,320 @@ +import { + AuthSettingsWriteScope, + isSpeechToTextConfigured, + resolveSpeechToTextProviderSettings, + SPEECH_TO_TEXT_PROVIDERS, + type SpeechToTextCleanupMode, + type SpeechToTextProvider, + type SpeechToTextSettings, + type SpeechToTextSettingsPatch, +} from "@t3tools/contracts"; +import { useRef } from "react"; +import { View } from "react-native"; +import { useSafeAreaInsets } from "react-native-safe-area-context"; + +import { AppText as Text, AppTextInput } from "../../components/ui/AppText"; +import { ScreenScrollView } from "../../components/ui/ScreenScrollView"; +import { useEnvironmentScope } from "../../state/session"; +import { serverEnvironment } from "../../state/server"; +import { useAtomCommand } from "../../state/use-atom-command"; +import { SettingsActionRow } from "./components/SettingsActionRow"; +import { SettingsChoiceRow } from "./components/SettingsChoiceRow"; +import { + AndroidSettingsEnvironmentFilter, + SettingsEnvironmentFilterHeader, +} from "./components/SettingsEnvironmentFilterHeader"; +import { SettingsScreen } from "./components/SettingsScreen"; +import { SettingsSection } from "./components/SettingsSection"; +import { SettingsSwitchRow } from "./components/SettingsSwitchRow"; +import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter"; + +const PROVIDER_IDS = Object.keys(SPEECH_TO_TEXT_PROVIDERS) as SpeechToTextProvider[]; + +const CLEANUP_CHOICES: ReadonlyArray<{ + readonly mode: SpeechToTextCleanupMode | null; + readonly label: string; + readonly description: string; +}> = [ + { mode: null, label: "Off", description: "Insert the transcript as the service returned it." }, + { + mode: "text-generation", + label: "Text generation model", + description: "Rewrite with the model chosen for commit messages and titles.", + }, + { + mode: "openai-compatible", + label: "OpenAI-compatible", + description: "Rewrite with a chat completions server such as Ollama or LM Studio.", + }, +]; + +export function SettingsSpeechToTextRouteScreen() { + const { selectedTargets } = useSettingsEnvironmentFilter(); + const insets = useSafeAreaInsets(); + return ( + <> + + }> + + {selectedTargets.length === 0 ? ( + Select a connected environment. + ) : ( + selectedTargets.map((environment) => ( + + )) + )} + + + + ); +} + +/** Commits on end of editing, like the other text settings, so typing does not round-trip. */ +function SettingsTextField(props: { + readonly label: string; + readonly description?: string; + readonly value: string; + readonly placeholder: string; + readonly disabled: boolean; + readonly secure?: boolean; + readonly keyboardType?: "default" | "url"; + readonly onCommit: (value: string) => void; +}) { + const edited = useRef(false); + return ( + + {props.label} + {props.description ? ( + {props.description} + ) : null} + { + edited.current = true; + }} + onEndEditing={(event) => { + const value = event.nativeEvent.text.trim(); + // A stored key is replaced only by a new value; removing it is its own action. + if (!props.disabled && edited.current && (props.secure ? value.length > 0 : true)) { + if (props.secure || value !== props.value) props.onCommit(value); + } + edited.current = false; + }} + /> + + ); +} + +function EnvironmentSpeechToText({ environment }: { readonly environment: SettingsTarget }) { + const settings: SpeechToTextSettings = environment.serverConfig.settings.speechToText; + const supported = environment.serverConfig.environment.capabilities.speechToText === true; + const canEdit = useEnvironmentScope(environment.environmentId, AuthSettingsWriteScope); + const disabled = !supported || !canEdit; + const updateSettings = useAtomCommand(serverEnvironment.updateSettings, { reportFailure: true }); + const update = (speechToText: SpeechToTextSettingsPatch) => + void updateSettings({ + environmentId: environment.environmentId, + input: { patch: { speechToText } }, + }); + + const provider = settings.provider; + const info = provider ? SPEECH_TO_TEXT_PROVIDERS[provider] : null; + const configured = provider ? resolveSpeechToTextProviderSettings(settings, provider) : null; + const keyStored = (configured?.apiKey.length ?? 0) > 0; + const updateProvider = (fields: { model?: string; baseUrl?: string; apiKey?: string }) => { + if (provider) update({ providers: { [provider]: fields } }); + }; + const cleanup = settings.cleanup; + const cleanupKeyStored = cleanup.apiKey.length > 0; + + const status = !supported + ? `Update ${environment.label} to use speech to text.` + : !canEdit + ? "This connection cannot change this environment's settings." + : provider === null + ? "Off. Dictation uses on-device transcription where the device supports it." + : isSpeechToTextConfigured(settings) + ? "Ready. Use the microphone in the composer to dictate." + : info?.apiKeyRequired && !keyStored + ? `Add your ${info.label} API key to finish setup.` + : "Add the server URL and model to finish setup."; + + return ( + <> + + update({ provider: null })} + /> + {PROVIDER_IDS.map((id) => ( + update({ provider: id })} + /> + ))} + + + {provider && info && configured ? ( + + updateProvider({ apiKey })} + /> + {keyStored ? ( + updateProvider({ apiKey: "" })} + /> + ) : null} + {provider !== "xai" ? ( + 0 + ? `Leave empty for ${info.defaultModel}. Also: ${info.suggestedModels + .filter((model) => model !== info.defaultModel) + .join(", ")}.` + : "The model name your server expects." + } + value={configured.model} + placeholder={info.defaultModel || "parakeet-tdt-0.6b-v3"} + disabled={disabled} + onCommit={(model) => updateProvider({ model })} + /> + ) : null} + updateProvider({ baseUrl })} + /> + + ) : null} + + + update({ language: language.toLowerCase() })} + /> + update({ prompt })} + /> + + + + {CLEANUP_CHOICES.map((choice, index) => ( + 0} + disabled={disabled} + onPress={() => update({ cleanup: { mode: choice.mode } })} + /> + ))} + {cleanup.mode === "openai-compatible" ? ( + <> + update({ cleanup: { baseUrl } })} + /> + update({ cleanup: { model } })} + /> + update({ cleanup: { apiKey } })} + /> + {cleanupKeyStored ? ( + update({ cleanup: { apiKey: "" } })} + /> + ) : null} + update({ cleanup: { useThreadContext } })} + /> + + ) : null} + {cleanup.mode !== null ? ( + update({ cleanup: { instructions } })} + /> + ) : null} + + + ); +} 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 21267a0871435..91f59db2428f2 100644 --- a/apps/mobile/src/features/settings/components/settings-page-targets.ts +++ b/apps/mobile/src/features/settings/components/settings-page-targets.ts @@ -14,6 +14,7 @@ export const SETTINGS_PAGE_TARGETS = [ "SettingsEnvironmentAgentBehavior", "SettingsEnvironmentMaintenance", "SettingsProviderAccounts", + "SettingsSpeechToText", "SettingsKeyboard", "SettingsMicrophone", "SettingsFollowUp", diff --git a/apps/mobile/src/features/settings/settings-search.ts b/apps/mobile/src/features/settings/settings-search.ts index f82f90dfe8333..93264a8eb5f1d 100644 --- a/apps/mobile/src/features/settings/settings-search.ts +++ b/apps/mobile/src/features/settings/settings-search.ts @@ -45,6 +45,7 @@ const SETTINGS_SEARCH_TERMS = { SettingsFollowUp: ["queue", "steer", "while the agent is running"], SettingsArchive: ["archive", "archived", "restore", "unarchive"], SettingsProviderAccounts: ["codex", "claude", "cursor", "opencode", "sign in", "login", "auth"], + SettingsSpeechToText: ["dictation", "transcription", "voice", "whisper", "parakeet", "api key"], SettingsEnvironmentNewThreads: [ "default workspace", "worktree", diff --git a/docs/user/composer.md b/docs/user/composer.md index 7db8248f00e8c..e5d1266ab2695 100644 --- a/docs/user/composer.md +++ b/docs/user/composer.md @@ -182,7 +182,8 @@ recording and preserves your existing draft. ### Set up a transcription service -Choose a service in **Settings → Speech to text**. The setting belongs to the environment, so every +Choose a service in **Settings → Speech to text** on web and desktop, or **Settings → Server +settings → Speech to text** in the mobile app. The setting belongs to the environment, so every web, desktop, and mobile client connected to it can dictate. API keys stay in that environment's secret store. Recordings go from the environment to the service you choose and are deleted after transcription; only the message text is sent when you submit. From 87a849b0311863089baa44f72c5c19acce76abc2 Mon Sep 17 00:00:00 2001 From: RCXDd <92461990+RCXDd@users.noreply.github.com> Date: Sun, 18 Oct 2026 23:23:36 +0200 Subject: [PATCH 2/2] fix(mobile): keep speech-to-text drafts with their field Review of the mobile settings screen: - Key fields are keyed by service and clear after each save, so a draft typed for one service can no longer be saved as another service's key. - Fields own their draft while focused and only take a value saved by another device once idle, instead of remounting and dropping the edit. - Vocabulary only shows when the service or cleanup uses it, matching web. Co-Authored-By: Claude Opus 5.5 --- .../SettingsSpeechToTextRouteScreen.tsx | 62 ++++++++++++------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/apps/mobile/src/features/settings/SettingsSpeechToTextRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsSpeechToTextRouteScreen.tsx index d5c7c5c910031..f17a0bfd6beaf 100644 --- a/apps/mobile/src/features/settings/SettingsSpeechToTextRouteScreen.tsx +++ b/apps/mobile/src/features/settings/SettingsSpeechToTextRouteScreen.tsx @@ -8,7 +8,7 @@ import { type SpeechToTextSettings, type SpeechToTextSettingsPatch, } from "@t3tools/contracts"; -import { useRef } from "react"; +import { useState } from "react"; import { View } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; @@ -74,7 +74,11 @@ export function SettingsSpeechToTextRouteScreen() { ); } -/** Commits on end of editing, like the other text settings, so typing does not round-trip. */ +/** + * Commits on end of editing, like the other text settings, so typing does not round-trip. The + * field owns its draft while focused: a value another device saves only replaces it once the + * field is idle. A secret field never shows the stored key and clears after each commit. + */ function SettingsTextField(props: { readonly label: string; readonly description?: string; @@ -85,7 +89,14 @@ function SettingsTextField(props: { readonly keyboardType?: "default" | "url"; readonly onCommit: (value: string) => void; }) { - const edited = useRef(false); + const initial = props.secure ? "" : props.value; + const [draft, setDraft] = useState(initial); + const [focused, setFocused] = useState(false); + const [syncedValue, setSyncedValue] = useState(initial); + if (!focused && initial !== syncedValue) { + setSyncedValue(initial); + setDraft(initial); + } return ( {props.label} @@ -93,9 +104,8 @@ function SettingsTextField(props: { {props.description} ) : null} { - edited.current = true; - }} - onEndEditing={(event) => { - const value = event.nativeEvent.text.trim(); - // A stored key is replaced only by a new value; removing it is its own action. - if (!props.disabled && edited.current && (props.secure ? value.length > 0 : true)) { - if (props.secure || value !== props.value) props.onCommit(value); + onFocus={() => setFocused(true)} + onChangeText={setDraft} + onEndEditing={() => { + setFocused(false); + const value = draft.trim(); + if (props.secure) { + // A stored key is replaced only by a new value; removing it is its own action. + if (!props.disabled && value.length > 0) props.onCommit(value); + setDraft(""); + return; } - edited.current = false; + if (!props.disabled && value !== props.value) props.onCommit(value); + setDraft(value); }} /> @@ -177,6 +190,7 @@ function EnvironmentSpeechToText({ environment }: { readonly environment: Settin {provider && info && configured ? ( 0 @@ -215,6 +230,7 @@ function EnvironmentSpeechToText({ environment }: { readonly environment: Settin /> ) : null} update({ language: language.toLowerCase() })} /> - update({ prompt })} - /> + {!info || info.supportsPrompt || cleanup.mode !== null ? ( + update({ prompt })} + /> + ) : null}