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
| 1 | import type { ReactNode } from "react"; |
| 2 | import { Pressable, View, type ColorValue } from "react-native"; |
| 3 | import { AppText as Text } from "../../components/ui/AppText"; |
| 4 | import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol"; |
| 5 | import { ShimmeringWorkContent } from "./thread-work-log"; |
| 6 | |
| 7 | export function ThreadContextDivider(props: { |
| 8 | label: string; |
| 9 | icon?: AppSymbolName; |
| 10 | iconColor: ColorValue; |
| 11 | active?: boolean; |
| 12 | failed?: boolean; |
| 13 | children?: ReactNode; |
| 14 | }) { |
| 15 | return ( |
| 16 | <View className="mb-3 flex-row items-center gap-3 px-1 py-1"> |
| 17 | <View className="h-px min-w-4 flex-1 bg-separator" /> |
| 18 | <View className="shrink flex-row flex-wrap items-center justify-center gap-1.5"> |
| 19 | {/* One row, so a long label wraps beside its icon instead of under it. */} |
| 20 | <View className="shrink flex-row items-center gap-1.5"> |
| 21 | {props.icon ? ( |
| 22 | <SymbolView name={props.icon} size={12} tintColor={props.iconColor} type="monochrome" /> |
| 23 | ) : null} |
| 24 | {props.active ? ( |
| 25 | <ShimmeringWorkContent |
| 26 | className="flex-none" |
| 27 | textClassName="font-t3-medium" |
| 28 | compact |
| 29 | icon="brain" |
| 30 | iconSubtleColor={props.iconColor} |
| 31 | label={props.label} |
| 32 | showIcon={false} |
| 33 | /> |
| 34 | ) : ( |
| 35 | <Text |
| 36 | className={ |
| 37 | props.failed |
| 38 | ? "shrink font-t3-medium text-xs text-danger-foreground" |
| 39 | : "shrink font-t3-medium text-xs text-foreground-muted" |
| 40 | } |
| 41 | > |
| 42 | {props.label} |
| 43 | </Text> |
| 44 | )} |
| 45 | </View> |
| 46 | {props.children} |
| 47 | </View> |
| 48 | <View className="h-px min-w-4 flex-1 bg-separator" /> |
| 49 | </View> |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | export interface ThreadStatusLineModel { |
| 54 | readonly key: string; |
| 55 | readonly icon: AppSymbolName; |
| 56 | readonly label: string; |
| 57 | readonly accessibilityLabel?: string; |
| 58 | /** Tapping the label opens the state's detail. */ |
| 59 | readonly onOpen?: () => void; |
| 60 | readonly action: { |
| 61 | readonly label: string; |
| 62 | readonly accessibilityLabel: string; |
| 63 | readonly disabled: boolean; |
| 64 | readonly onPress: () => void; |
| 65 | }; |
| 66 | } |
| 67 | |
| 68 | /** A thread state that closes the feed with its one action, left-aligned as on web. */ |
| 69 | export function ThreadStatusLine(props: { |
| 70 | readonly line: ThreadStatusLineModel; |
| 71 | readonly iconColor: ColorValue; |
| 72 | }) { |
| 73 | const { line } = props; |
| 74 | const { action } = line; |
| 75 | const body = ( |
| 76 | <> |
| 77 | <SymbolView name={line.icon} size={13} tintColor={props.iconColor} type="monochrome" /> |
| 78 | <Text className="shrink font-t3-medium text-xs text-foreground-muted" numberOfLines={1}> |
| 79 | {line.label} |
| 80 | </Text> |
| 81 | </> |
| 82 | ); |
| 83 | return ( |
| 84 | <View className="mb-3 flex-row items-center gap-1.5 px-1 py-1"> |
| 85 | {line.onOpen ? ( |
| 86 | <Pressable |
| 87 | accessibilityRole="button" |
| 88 | accessibilityLabel={line.accessibilityLabel ?? line.label} |
| 89 | onPress={line.onOpen} |
| 90 | hitSlop={8} |
| 91 | className="shrink flex-row items-center gap-1.5 active:opacity-70" |
| 92 | > |
| 93 | {body} |
| 94 | </Pressable> |
| 95 | ) : ( |
| 96 | <View |
| 97 | accessible |
| 98 | accessibilityLabel={line.accessibilityLabel ?? line.label} |
| 99 | className="shrink flex-row items-center gap-1.5" |
| 100 | > |
| 101 | {body} |
| 102 | </View> |
| 103 | )} |
| 104 | <Text className="text-xs text-foreground-muted">·</Text> |
| 105 | <Pressable |
| 106 | accessibilityRole="button" |
| 107 | accessibilityLabel={action.accessibilityLabel} |
| 108 | accessibilityState={{ disabled: action.disabled }} |
| 109 | disabled={action.disabled} |
| 110 | onPress={action.onPress} |
| 111 | hitSlop={8} |
| 112 | className={`active:opacity-70 ${action.disabled ? "opacity-50" : ""}`} |
| 113 | > |
| 114 | <Text className="font-t3-medium text-xs text-foreground">{action.label}</Text> |
| 115 | </Pressable> |
| 116 | </View> |
| 117 | ); |
| 118 | } |