The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { msg, T, useGT, useMessages, Var } from "gt-react-native"; |
| 2 | import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView"; |
| 3 | import { useAtomValue } from "@effect/atom-react"; |
| 4 | import { AsyncResult } from "effect/reactivity"; |
| 5 | import { Platform } from "react-native"; |
| 6 | import { useSafeAreaInsets } from "react-native-safe-area-context"; |
| 7 | |
| 8 | import { AppText as Text } from "../../components/ui/AppText"; |
| 9 | import { DEFAULT_FOLLOW_UP_BEHAVIOR, type FollowUpBehavior } from "../../lib/followUpBehavior"; |
| 10 | import { mobilePreferencesAtom, saveMobilePreferences } from "../../state/preferences"; |
| 11 | import { useAtomCommand } from "../../state/use-atom-command"; |
| 12 | import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow"; |
| 13 | import { SettingsSection } from "./components/SettingsSection"; |
| 14 | import { SettingsScreen } from "./components/SettingsScreen"; |
| 15 | |
| 16 | const FOLLOW_UP_OPTIONS: ReadonlyArray<{ |
| 17 | readonly behavior: FollowUpBehavior; |
| 18 | readonly label: string; |
| 19 | readonly description: string; |
| 20 | }> = [ |
| 21 | { |
| 22 | behavior: "queue", |
| 23 | label: msg("Queue", { $context: "verb, follow-up behavior" }), |
| 24 | description: msg("Your message waits and runs after the current turn finishes."), |
| 25 | }, |
| 26 | { |
| 27 | behavior: "steer", |
| 28 | label: msg("Steer", { $context: "verb, follow-up behavior" }), |
| 29 | description: msg("Your message reaches the agent right away, changing what it is working on."), |
| 30 | }, |
| 31 | ]; |
| 32 | |
| 33 | export function SettingsFollowUpRouteScreen() { |
| 34 | const gt = useGT(); |
| 35 | const m = useMessages(); |
| 36 | const insets = useSafeAreaInsets(); |
| 37 | const preferencesResult = useAtomValue(mobilePreferencesAtom); |
| 38 | const savePreferences = useAtomCommand(saveMobilePreferences); |
| 39 | const preferencesReady = AsyncResult.isSuccess(preferencesResult) && !preferencesResult.waiting; |
| 40 | const selectedBehavior = AsyncResult.isSuccess(preferencesResult) |
| 41 | ? (preferencesResult.value.followUpBehavior ?? DEFAULT_FOLLOW_UP_BEHAVIOR) |
| 42 | : null; |
| 43 | |
| 44 | const content = ( |
| 45 | <ScrollView |
| 46 | contentInsetAdjustmentBehavior="automatic" |
| 47 | showsVerticalScrollIndicator={false} |
| 48 | className="flex-1" |
| 49 | contentContainerClassName="gap-3 px-5 pt-4" |
| 50 | contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }} |
| 51 | > |
| 52 | <SettingsSection title={gt("While the agent is running")}> |
| 53 | {FOLLOW_UP_OPTIONS.map((option, index) => ( |
| 54 | <SettingsChoiceRow |
| 55 | key={option.behavior} |
| 56 | label={m(option.label)} |
| 57 | description={m(option.description)} |
| 58 | selected={selectedBehavior === option.behavior} |
| 59 | separated={index > 0} |
| 60 | disabled={!preferencesReady} |
| 61 | onPress={() => { |
| 62 | void savePreferences({ followUpBehavior: option.behavior }); |
| 63 | }} |
| 64 | /> |
| 65 | ))} |
| 66 | </SettingsSection> |
| 67 | <Text className="px-2 text-sm text-foreground-muted"> |
| 68 | <T> |
| 69 | Long-press the send button to use the other option for a single message. With a hardware |
| 70 | keyboard, hold <Var>{Platform.OS === "android" ? "Ctrl" : "Command"}</Var> while sending. |
| 71 | </T> |
| 72 | </Text> |
| 73 | </ScrollView> |
| 74 | ); |
| 75 | |
| 76 | return <SettingsScreen title={gt("Chat")}>{content}</SettingsScreen>; |
| 77 | } |