diff --git a/apps/mobile/modules/t3-device-runtime/android/src/main/java/expo/modules/t3deviceruntime/T3DeviceRuntimeModule.kt b/apps/mobile/modules/t3-device-runtime/android/src/main/java/expo/modules/t3deviceruntime/T3DeviceRuntimeModule.kt index b7d65c89b096c..3936f45ed56e4 100644 --- a/apps/mobile/modules/t3-device-runtime/android/src/main/java/expo/modules/t3deviceruntime/T3DeviceRuntimeModule.kt +++ b/apps/mobile/modules/t3-device-runtime/android/src/main/java/expo/modules/t3deviceruntime/T3DeviceRuntimeModule.kt @@ -17,6 +17,7 @@ import java.util.concurrent.Executors private const val LOG_LIMIT = 2000 +// DeviceRuntimeSetupScreen translates titles by id, so a new or renamed id needs a title there. private data class JobStep(val id: String, val title: String) private val INSTALL_STEPS = listOf( diff --git a/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx b/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx index 55b1c26bc4656..39b139652c070 100644 --- a/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx +++ b/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx @@ -422,20 +422,21 @@ function PhoneSection() { ); const [supported] = useState(supportsDeviceRuntime); const rippleStyle = useResolveClassNames("bg-subtle-strong"); + const gt = useGT(); const description = !supported - ? "Needs a 64-bit phone" + ? gt("Needs a 64-bit phone") : phone - ? `Set up as ${phone.environmentLabel}` - : "Claude Code on this phone, no other computer needed"; + ? gt("Set up as {name}", { name: phone.environmentLabel }) + : gt("Claude Code on this phone, no other computer needed"); return ( - Or run on this phone + Or run on this phone - Run agents on this phone + Run agents on this phone {description} diff --git a/apps/mobile/src/features/device-runtime/AgentAccessRouteScreen.tsx b/apps/mobile/src/features/device-runtime/AgentAccessRouteScreen.tsx index 6628d2ee00e6e..5a9609ab0f58f 100644 --- a/apps/mobile/src/features/device-runtime/AgentAccessRouteScreen.tsx +++ b/apps/mobile/src/features/device-runtime/AgentAccessRouteScreen.tsx @@ -1,3 +1,4 @@ +import { msg, T, useGT, useMessages } from "gt-react-native"; import { useCallback, useEffect, useState } from "react"; import { AppState, Linking, PermissionsAndroid } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; @@ -12,18 +13,18 @@ import { deviceRuntime, type AgentAccessCategory, type AgentAccessPolicy } from const CATEGORIES: Readonly> = { - location: { label: "Location", commands: "termux-location, termux-telephony-cellinfo" }, - camera: { label: "Camera", commands: "termux-camera-photo" }, - microphone: { label: "Microphone", commands: "termux-microphone-record" }, - contacts: { label: "Contacts", commands: "termux-contact-list" }, - sms: { label: "Text messages", commands: "termux-sms-list, termux-sms-send" }, - "call-log": { label: "Call log", commands: "termux-call-log" }, + location: { label: msg("Location"), commands: "termux-location, termux-telephony-cellinfo" }, + camera: { label: msg("Camera"), commands: "termux-camera-photo" }, + microphone: { label: msg("Microphone"), commands: "termux-microphone-record" }, + contacts: { label: msg("Contacts"), commands: "termux-contact-list" }, + sms: { label: msg("Text messages"), commands: "termux-sms-list, termux-sms-send" }, + "call-log": { label: msg("Call log"), commands: "termux-call-log" }, phone: { - label: "Phone calls and device info", + label: msg("Phone calls and device info"), commands: "termux-telephony-call, termux-telephony-deviceinfo", }, - notifications: { label: "Notifications", commands: "termux-notification-list" }, - apps: { label: "Other apps", commands: "am (also termux-am), pm" }, + notifications: { label: msg("Notifications"), commands: "termux-notification-list" }, + apps: { label: msg("Other apps"), commands: "am (also termux-am), pm" }, }; const POLICIES: ReadonlyArray<{ @@ -33,11 +34,19 @@ const POLICIES: ReadonlyArray<{ }> = [ { policy: "ask", - label: "Ask each time", - description: "This phone asks you before each command runs.", + label: msg("Ask each time"), + description: msg("This phone asks you before each command runs."), + }, + { + policy: "allow", + label: msg("Always allow"), + description: msg("Agents use it without asking."), + }, + { + policy: "deny", + label: msg("Never", { $context: "agent access policy" }), + description: msg("These commands are refused."), }, - { policy: "allow", label: "Always allow", description: "Agents use it without asking." }, - { policy: "deny", label: "Never", description: "These commands are refused." }, ]; /** Asks Android for what a category needs; notification access is a system settings page. */ @@ -60,6 +69,8 @@ function requestAndroidAccess(category: AgentAccessCategory): Promise { /** Settings → Agent access: what agents on this phone may reach through Android. */ export function AgentAccessRouteScreen() { const insets = useSafeAreaInsets(); + const gt = useGT(); + const m = useMessages(); const read = useCallback(() => deviceRuntime?.getAgentAccess() ?? [], []); const [categories, setCategories] = useState(read); // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- re-reads grants made in Android's settings @@ -79,7 +90,7 @@ export function AgentAccessRouteScreen() { }; return ( - + - Agents on this phone reach Android through termux-* commands. These need your say: with - Ask each time, this phone asks you before each one runs, even when another device started - it. Nobody answering within a minute counts as no. This covers those commands. It isn't a - hard barrier against someone using a terminal on this phone's server. + + Agents on this phone reach Android through termux-* commands. These need your say: with + Ask each time, this phone asks you before each one runs, even when another device + started it. Nobody answering within a minute counts as no. This covers those commands. + It isn't a hard barrier against someone using a terminal on this phone's server. + {categories.map((category) => { const meta = CATEGORIES[category.id]; @@ -98,20 +111,22 @@ export function AgentAccessRouteScreen() { return ( {POLICIES.map((choice, index) => ( 0} onPress={() => choose(category, choice.policy)} @@ -120,7 +135,7 @@ export function AgentAccessRouteScreen() { {category.policy !== "deny" && !category.granted ? ( void requestAndroidAccess(category).then(() => setCategories(read())) } diff --git a/apps/mobile/src/features/device-runtime/DeviceRuntimeSetupScreen.tsx b/apps/mobile/src/features/device-runtime/DeviceRuntimeSetupScreen.tsx index 6474e766ba18b..afaa2601981bc 100644 --- a/apps/mobile/src/features/device-runtime/DeviceRuntimeSetupScreen.tsx +++ b/apps/mobile/src/features/device-runtime/DeviceRuntimeSetupScreen.tsx @@ -1,4 +1,5 @@ import { useFocusEffect, useNavigation } from "@react-navigation/native"; +import { msg, T, useGT, useLocale, useMessages } from "gt-react-native"; import { useCallback, useEffect, useState, type ReactNode } from "react"; import { Linking, PermissionsAndroid, Platform, View } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; @@ -8,6 +9,7 @@ import { Button } from "../../components/ui/Button"; import * as Dialog from "../../components/ui/Dialog"; import { ListRow } from "../../components/ui/ListRow"; import { ScreenScrollView } from "../../components/ui/ScreenScrollView"; +import { m as mNow, type MessageResolver } from "../../i18n/messages"; import { setPhoneServerSettings, usePhoneServerSettings } from "../../state/phone-server-settings"; import { useWorkspaceEnvironments } from "../../state/workspace"; import { confirmPhoneServerReplacement } from "../phone/confirmPhoneServerReplacement"; @@ -27,6 +29,7 @@ import { requireDeviceRuntime, useDeviceRuntimeStatus, type DeviceRuntimeInspection, + type DeviceRuntimeJob, type DeviceRuntimeStatus, } from "./device-runtime"; @@ -35,11 +38,30 @@ type StepId = "install" | "signIn" | "connect"; const STEPS: ReadonlyArray = ["install", "signIn", "connect"]; const STEP_TITLES: Record = { - install: "Install Ubuntu, Claude Code and T3 Code", - signIn: "Sign in to Claude", - connect: "Connect this phone", + install: msg("Install Ubuntu, Claude Code and T3 Code"), + signIn: msg("Sign in to Claude"), + connect: msg("Connect this phone"), }; +/** By the native job's step id; an id missing here shows the native English title. */ +const JOB_STEP_TITLES: Partial> = { + ubuntu: msg("Downloading Ubuntu"), + packages: msg("Installing Ubuntu packages"), + node: msg("Installing Node.js"), + "claude-code": msg("Installing Claude Code"), + t3: msg("Installing T3 Code"), + "upgrade-claude-code": msg("Updating Claude Code"), + cleanup: msg("Cleaning up"), +}; + +function jobStepTitle(job: DeviceRuntimeJob, resolve: MessageResolver): string { + const title = + job.kind === "update" && job.step === "t3" + ? msg("Updating T3 Code") + : JOB_STEP_TITLES[job.step ?? ""]; + return title === undefined ? (job.stepTitle ?? "") : resolve(title); +} + /** Progress shows in a notification while T3 Code is in the background; Android 13+ asks first. */ function requestNotifications(): Promise { if (Platform.OS !== "android" || Platform.Version < 33) return Promise.resolve(); @@ -71,6 +93,9 @@ function errorText(error: unknown, fallback: string): string { export function DeviceRuntimeSetupScreen() { const native = requireDeviceRuntime(); const navigation = useNavigation(); + const gt = useGT(); + const m = useMessages(); + const locale = useLocale(); const insets = useSafeAreaInsets(); const { status, refresh } = useDeviceRuntimeStatus(); const [inspection, setInspection] = useState(null); @@ -91,7 +116,9 @@ export function DeviceRuntimeSetupScreen() { } inspectDeviceRuntime() .then(setInspection) - .catch((cause: unknown) => setError(errorText(cause, "Couldn't check the installation."))); + .catch((cause: unknown) => + setError(errorText(cause, mNow(msg("Couldn't check the installation.")))), + ); }, [native]); useFocusEffect( @@ -134,7 +161,7 @@ export function DeviceRuntimeSetupScreen() { setBusy(label); setError(null); return action() - .catch((cause: unknown) => setError(errorText(cause, "That didn't finish."))) + .catch((cause: unknown) => setError(errorText(cause, gt("That didn't finish.")))) .then(() => { setBusy(null); refresh(); @@ -153,12 +180,14 @@ export function DeviceRuntimeSetupScreen() { }; const reinstall = () => Dialog.alert( - "Reinstall?", - "Deletes Ubuntu with everything in it, including the threads and Claude sign-in on this phone, then installs it again.", + gt("Reinstall?"), + gt( + "Deletes Ubuntu with everything in it, including the threads and Claude sign-in on this phone, then installs it again.", + ), [ - { text: "Cancel", style: "cancel" }, + { text: gt("Cancel"), style: "cancel" }, { - text: "Reinstall", + text: gt("Reinstall"), style: "destructive", onPress: () => void run("install", async () => { @@ -175,12 +204,14 @@ export function DeviceRuntimeSetupScreen() { ); const remove = () => Dialog.alert( - "Remove from this phone?", - "Stops the server and deletes Ubuntu with everything in it, including the threads and Claude sign-in on this phone.", + gt("Remove from this phone?"), + gt( + "Stops the server and deletes Ubuntu with everything in it, including the threads and Claude sign-in on this phone.", + ), [ - { text: "Cancel", style: "cancel" }, + { text: gt("Cancel"), style: "cancel" }, { - text: "Remove", + text: gt("Remove"), style: "destructive", onPress: () => void run("remove", async () => { @@ -189,7 +220,7 @@ export function DeviceRuntimeSetupScreen() { await stopPhoneServerWhenSettled(); await native.remove(); await forgetDeviceServer(); - if (stillListed) Dialog.alert("Removed from this phone", stillListed); + if (stillListed) Dialog.alert(gt("Removed from this phone"), stillListed); navigation.goBack(); }), }, @@ -203,10 +234,12 @@ export function DeviceRuntimeSetupScreen() { : undefined, signIn: inspection?.claudeSignedIn ? inspection.claudePlan - ? `Signed in · ${inspection.claudePlan}` - : "Signed in" + ? gt("Signed in · {plan}", { plan: inspection.claudePlan }) + : gt("Signed in") + : undefined, + connect: environment + ? gt("Connected as {environment}", { environment: environment.environmentLabel }) : undefined, - connect: environment ? `Connected as ${environment.environmentLabel}` : undefined, }; const body: Record = { install: ( @@ -225,13 +258,15 @@ export function DeviceRuntimeSetupScreen() { ), connect: ( <> - Starts T3 Code's server on this phone and adds it to your environments. + + Starts T3 Code's server on this phone and adds it to your environments. +