Open History to see the last commit
1import type { EnvironmentId, OrchestrationThreadShell } from "@t3tools/contracts";
2import { CHATGPT_USAGE_URL, isChatGptUsageLimitError } from "@t3tools/shared/usageLimits";
3import * as Option from "effect/Option";
4import { Linking, Pressable, View } from "react-native";
5import { AppText as Text } from "../../components/AppText";
6import { ProviderIcon } from "../../components/ProviderIcon";
7import { useThreadDetail } from "../../state/use-thread-detail";
8
9export function ChatGptUsageLimitNotice({
10 environmentId,
11 thread,
12}: {
13 environmentId: EnvironmentId;
14 thread: OrchestrationThreadShell;
15}) {
16 const state = useThreadDetail({ environmentId, threadId: thread.id });
17 const detail = Option.getOrNull(state.data);
18 if (!isChatGptUsageLimitError(detail?.activities ?? [], thread.session?.lastError)) return null;
19 return (
20 <View
21 accessibilityRole="alert"
22 className="mx-3 mb-2 gap-2 rounded-xl border border-border-subtle bg-composer-panel p-3"
23 >
24 <View className="flex-row items-center gap-2">
25 <ProviderIcon provider="codex" size={16} />
26 <Text className="text-sm font-t3-medium text-foreground">ChatGPT usage limit reached</Text>
27 </View>
28 <Text className="text-xs text-foreground-muted">
29 Review your usage settings in ChatGPT to continue.
30 </Text>
31 <Pressable
32 accessibilityRole="link"
33 className="min-h-11 self-start justify-center rounded-lg bg-primary px-3"
34 onPress={() => void Linking.openURL(CHATGPT_USAGE_URL).catch(() => undefined)}
35 >
36 <Text className="text-sm font-t3-medium text-primary-foreground">Manage usage</Text>
37 </Pressable>
38 </View>
39 );
40}