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