@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 77 lines 3.16 KB
Raw
1 import { Button } from "../../../components/ui/Button";
2 import { T, useGT, useMessages, Var } from "gt-react-native";
3 import { View } from "react-native";
4 import Animated, { FadeIn, ReduceMotion } from "react-native-reanimated";
5 import { AppText as Text } from "../../../components/ui/AppText";
6 import { SymbolView } from "../../../components/ui/AppSymbol";
7 import { PR_ROW_EXIT, PR_ROW_LAYOUT } from "../pullRequestAnimations";
8 import { guideNoticeState } from "./reviewGuideState";
9 import type { useReviewGuide } from "./useReviewGuide";
10
11 const NOTICE_ENTER = FadeIn.delay(180).duration(120).reduceMotion(ReduceMotion.System);
12
13 export function GuideNotice({ state }: { readonly state: ReturnType<typeof useReviewGuide> }) {
14 const gt = useGT();
15 const messages = useMessages();
16 const notice = guideNoticeState(state, messages);
17 if (notice.kind === "ready") return null;
18 const compact = state.data?.guide != null;
19 const failed = notice.kind === "failed" || notice.kind === "unavailable";
20 const busy = notice.kind === "loading" || notice.kind === "writing";
21 return (
22 <Animated.View
23 layout={PR_ROW_LAYOUT}
24 entering={compact ? NOTICE_ENTER : undefined}
25 exiting={PR_ROW_EXIT}
26 className={
27 compact ? "mb-5 rounded-2xl bg-grouped-card p-4" : "rounded-2xl bg-grouped-card p-5"
28 }
29 accessibilityLiveRegion="polite"
30 accessibilityState={{ busy }}
31 >
32 <View className="flex-row items-center gap-3">
33 <SymbolView
34 name={failed ? "exclamationmark.circle" : busy ? "clock" : "list.number"}
35 size={19}
36 tintColorClassName={failed ? "accent-danger-foreground" : "accent-icon-muted"}
37 />
38 <Text className="text-base font-t3-semibold">
39 {compact ? notice.title : gt("Review guide")}
40 </Text>
41 </View>
42 <View style={compact ? undefined : { minHeight: 100 }} className="pt-3 pb-4">
43 <Text className="text-sm leading-6 text-foreground-muted">{notice.description}</Text>
44 </View>
45 <View className="min-h-12 flex-row flex-wrap items-center justify-between gap-3">
46 {state.canWrite || busy || notice.kind === "unavailable" ? (
47 <Button
48 label={notice.action}
49 tone={compact ? "secondary" : "contrast"}
50 disabled={busy}
51 onPress={() => (notice.kind === "unavailable" ? state.refresh() : void state.write())}
52 loading={busy}
53 />
54 ) : (
55 <Text className="text-xs text-foreground-muted">
56 {notice.kind === "failed"
57 ? gt("Reconnect or ask someone with write access to retry.")
58 : gt("Writing a guide requires a connection and write access.")}
59 </Text>
60 )}
61 {notice.kind === "writing" && state.data?.run?._tag === "Running" ? (
62 <Text className="shrink text-xs text-foreground-muted">
63 <T>
64 Started{" "}
65 <Var>
66 {new Date(state.data.run.startedAt).toLocaleTimeString([], {
67 hour: "2-digit",
68 minute: "2-digit",
69 })}
70 </Var>
71 </T>
72 </Text>
73 ) : null}
74 </View>
75 </Animated.View>
76 );
77 }