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

main
tsx 46 lines 1.77 KB
Raw
1 import { T, useGT, Var } from "gt-react-native";
2 import { Pressable } from "react-native";
3 import type { EnvironmentMachineKind } from "@t3tools/contracts";
4 import type { EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
5 import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
6 import { AppText as Text } from "../../components/ui/AppText";
7 import { SymbolView } from "../../components/ui/AppSymbol";
8
9 import { ConnectionStatusDot } from "../connection/ConnectionStatusDot";
10
11 export function DraftEnvironmentControl(props: {
12 readonly label: string;
13 readonly connectionState: EnvironmentConnectionPhase;
14 readonly machineKind: EnvironmentMachineKind;
15 readonly disabled: boolean;
16 readonly onChooseEnvironment: () => void;
17 }) {
18 const gt = useGT();
19 const disconnected = props.connectionState !== "connected";
20 return (
21 <Pressable
22 accessibilityRole="button"
23 accessibilityLabel={
24 disconnected
25 ? gt("Choose environment, {label}, Offline", { label: props.label })
26 : gt("Choose environment, {label}, Connected", { label: props.label })
27 }
28 disabled={props.disabled}
29 onPress={props.onChooseEnvironment}
30 className="flex-row items-center gap-1.5 rounded-xl px-3 py-2 active:opacity-65"
31 >
32 <EnvironmentMachineSymbol
33 kind={props.machineKind}
34 size={13}
35 tintColorClassName="accent-icon-muted"
36 />
37 <Text className="shrink text-sm text-foreground-muted" numberOfLines={1}>
38 <T>
39 on <Var>{props.label}</Var>
40 </T>
41 </Text>
42 <SymbolView name="chevron.right" size={11} tintColorClassName="accent-icon-muted" />
43 {disconnected ? <ConnectionStatusDot state="error" pulse={false} size={6} /> : null}
44 </Pressable>
45 );
46 }