import { useState, useCallback, useEffect } from "react"; import { View, Text, TouchableOpacity, ActivityIndicator } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; import { router } from "expo-router"; import { MaterialIcons } from "@expo/vector-icons"; import { pickAndReadCodexAuth } from "@/lib/fileReader"; import { saveCodexAuth, loadCodexAuth } from "@/lib/storage"; import type { CodexAuth } from "@/types/codex"; export default function OnboardingCodexScreen() { const [auth, setAuth] = useState(null); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); useEffect(() => { loadCodexAuth().then((stored) => { if (stored) setAuth(stored); }); }, []); const importFile = useCallback(async () => { setLoading(true); setError(null); try { const parsed = await pickAndReadCodexAuth(); await saveCodexAuth(parsed); setAuth(parsed); } catch (e: unknown) { const msg = e instanceof Error ? e.message : "UNKNOWN_ERROR"; if (msg !== "PICKER_CANCELLED") setError(msg); } finally { setLoading(false); } }, []); return ( {/* Top: back + step indicator */} router.back()} className="w-9 h-9 rounded-xl bg-neutral-900 items-center justify-center" > 1 2 {/* Content */} Connect Codex CLI Import your{" "} ~/.codex/auth.json {" "} file to track your rate limits and credits. {/* Status / action */} {auth ? ( Connected {auth.accountId && ( {auth.accountId.slice(0, 12)}… )} Re-import ) : ( {error && ( {error} )} {loading ? ( ) : ( Import auth.json )} Located at ~/.codex/auth.json on your Mac )} {/* Bottom actions */} router.push("/onboarding/claude")} className="rounded-2xl py-4 items-center" style={{ backgroundColor: auth ? "#10a37f" : "#1a1a1a" }} > Continue router.push("/onboarding/claude")} className="py-3 items-center" > Skip for now ); }