@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 57 lines 1.88 KB
Raw
1 import type { EnvironmentId } from "@t3tools/contracts";
2 import { useGT } from "gt-react-native";
3 import { View } from "react-native";
4
5 import { EmptyState } from "../../components/ui/EmptyState";
6 import type { AssetUrlFailureReason } from "../../state/asset-url-state";
7 import { useEnvironmentPresentation } from "../../state/presentation";
8 import { EnvironmentConnectionNotice } from "../connection/EnvironmentConnectionNotice";
9 import { useRetryEnvironment } from "../connection/useRetryEnvironment";
10
11 export function WorkspaceFilePreviewError(props: {
12 readonly environmentId: EnvironmentId | null;
13 readonly reason: AssetUrlFailureReason;
14 readonly onRetry: () => void;
15 }) {
16 const { environmentId, onRetry } = props;
17 const gt = useGT();
18 const environment = useEnvironmentPresentation(environmentId);
19 const retryEnvironment = useRetryEnvironment();
20 const retryConnection = () => {
21 if (environmentId !== null) void retryEnvironment(environmentId);
22 onRetry();
23 };
24
25 if (props.reason === "disconnected") {
26 return (
27 <View className="flex-1 bg-sheet">
28 <EnvironmentConnectionNotice
29 environmentLabel={
30 environment.presentation?.entry.target.label ??
31 gt("Environment", { $context: "fallback environment name" })
32 }
33 connection={
34 environment.presentation?.connection ?? {
35 phase: "available",
36 error: null,
37 traceId: null,
38 }
39 }
40 resource="preview"
41 onRetry={retryConnection}
42 />
43 </View>
44 );
45 }
46
47 return (
48 <View className="flex-1 items-center justify-center bg-sheet px-6">
49 <EmptyState
50 title={gt("Preview unavailable")}
51 detail={gt("This file may be missing, unsupported, or unavailable on this environment.")}
52 actionLabel={gt("Try again")}
53 onAction={props.onRetry}
54 />
55 </View>
56 );
57 }