Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<View collapsable={false} className="gap-2">
<Text className="px-4 text-sm font-t3-medium text-foreground-muted">
Or run on this phone
<T>Or run on this phone</T>
</Text>
<View collapsable={false} className="overflow-hidden rounded-[24px] bg-grouped-card">
<RowPressable
accessibilityRole="button"
accessibilityLabel={`Run agents on this phone, ${description}`}
accessibilityLabel={gt("Run agents on this phone, {description}", { description })}
accessibilityState={{ disabled: !supported }}
disabled={!supported}
android_ripple={{ color: rippleStyle.backgroundColor }}
Expand All @@ -460,7 +461,7 @@ function PhoneSection() {
className="min-w-0 flex-shrink text-base font-t3-bold leading-snug text-foreground"
numberOfLines={1}
>
Run agents on this phone
<T>Run agents on this phone</T>
</Text>
</View>
<Text className="text-xs text-foreground-muted">{description}</Text>
Expand Down
63 changes: 39 additions & 24 deletions apps/mobile/src/features/device-runtime/AgentAccessRouteScreen.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -12,18 +13,18 @@ import { deviceRuntime, type AgentAccessCategory, type AgentAccessPolicy } from

const CATEGORIES: Readonly<Record<string, { readonly label: string; readonly commands: string }>> =
{
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<{
Expand All @@ -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. */
Expand All @@ -60,6 +69,8 @@ function requestAndroidAccess(category: AgentAccessCategory): Promise<unknown> {
/** 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
Expand All @@ -79,39 +90,43 @@ export function AgentAccessRouteScreen() {
};

return (
<SettingsScreen title="Agent access">
<SettingsScreen title={gt("Agent access")}>
<ScreenScrollView
contentInsetAdjustmentBehavior="automatic"
className="flex-1"
contentContainerClassName="gap-6 px-5 pt-4"
contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }}
>
<Text className="px-2 text-sm leading-normal text-foreground-muted">
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.
<T>
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.
</T>
</Text>
{categories.map((category) => {
const meta = CATEGORIES[category.id];
if (meta === undefined) return null;
return (
<SettingsSection
key={category.id}
title={meta.label}
title={m(meta.label)}
footer={
category.policy === "deny"
? meta.commands
: category.granted
? `${meta.commands}. Android allows it.`
: `${meta.commands}. Android hasn't allowed T3 Code yet.`
? gt("{commands}. Android allows it.", { commands: meta.commands })
: gt("{commands}. Android hasn't allowed T3 Code yet.", {
commands: meta.commands,
})
}
>
{POLICIES.map((choice, index) => (
<ListChoiceRow
key={choice.policy}
label={choice.label}
description={choice.description}
label={m(choice.label)}
description={m(choice.description)}
selected={category.policy === choice.policy}
separated={index > 0}
onPress={() => choose(category, choice.policy)}
Expand All @@ -120,7 +135,7 @@ export function AgentAccessRouteScreen() {
{category.policy !== "deny" && !category.granted ? (
<ListRow
icon="exclamationmark.circle"
label="Allow in Android"
label={gt("Allow in Android")}
onPress={() =>
void requestAndroidAccess(category).then(() => setCategories(read()))
}
Expand Down
Loading
Loading