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