Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

SettingsFollowUpRouteScreen.tsx

68 lines2.7 KB

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