import { AlertTriangle, CheckCircle2, Folder, Info, Route, ShieldCheck, TerminalSquare, XCircle, } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { QuickCommands } from '@/components/shared'; import { Badge } from '@/components/ui/badge'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Separator } from '@/components/ui/separator'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; import type { CodexDashboardDiagnostics } from '@/hooks/use-codex-types'; import { CLIPROXY_NATIVE_CODEX_RECIPE } from '@/lib/codex-config'; import { cn } from '@/lib/utils'; function formatTimestamp(value: number | null | undefined): string { if (!value || !Number.isFinite(value)) return 'N/A'; return new Date(value).toLocaleString(); } function formatBytes(value: number | null | undefined): string { if (!value || value <= 0) return '0 B'; if (value < 1024) return `${value} B`; if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)} KB`; return `${(value / (1024 * 1024)).toFixed(2)} MB`; } function DetailRow({ label, value, mono = false, }: { label: string; value: string; mono?: boolean; }) { return (
{label} {value}
); } interface CodexOverviewTabProps { diagnostics: CodexDashboardDiagnostics; } export function CodexOverviewTab({ diagnostics }: CodexOverviewTabProps) { const { t } = useTranslation(); const inspectProfileCommand = diagnostics.config.activeProfile ? `codex --profile ${diagnostics.config.activeProfile}` : 'codex'; const supportsManagedRouting = diagnostics.binary.supportsConfigOverrides; return (
{t('codex.howCodexWorks')}
  • {t('codex.nativeDesc')}
  • {t('codex.nativeConfigLabel')} {t('codex.nativeConfigDesc')}
  • {t('codex.transientOverridesLabel')}{' '} {t('codex.transientOverridesDesc')}
  • {t('codex.cliproxyDefaultLabel')} {t('codex.cliproxyDefaultDesc')}
  • {t('codex.apiProfilesDefault')}
{t('codex.runtimeInstall')}
{t('codex.status')} {diagnostics.binary.installed ? t('codex.detected') : t('codex.notFound')}
{t('codex.configOverrideSupport')} {diagnostics.binary.supportsConfigOverrides ? t('codex.available') : t('codex.missing')}
{t('codex.cliproxyNativeCodex')} {supportsManagedRouting ? ( <>

{t('codex.twoSupportedPaths')}

  • {t('codex.builtInLabel')} {t('codex.builtInCcsxpDesc')}
  • {t('codex.nativeRecipeLabel')} {t('codex.nativeRecipeDesc')}

{t('codex.codexNativeRecipe')}

                    {CLIPROXY_NATIVE_CODEX_RECIPE}
                  
  1. {t('codex.saveProviderNamedCliproxy')}
  2. {t('codex.inTopLevelSetDefault')}
  3. {t('codex.exportCliproxyApiKey')}
) : (

{t('codex.noConfigOverrides')}

)}
{t('codex.configFile')}
{t('codex.userConfig')} {diagnostics.file.exists ? ( ) : ( )}
{diagnostics.file.parseError && (

{t('codex.tomlWarning')}: {diagnostics.file.parseError}

)} {diagnostics.file.readError && (

{t('codex.readWarning')}: {diagnostics.file.readError}

)}
{t('codex.currentUserLayerSummary')}
{t('codex.providersCount', { count: diagnostics.config.modelProviderCount })} {t('codex.profilesCount', { count: diagnostics.config.profileCount })} {t('codex.enabledFeaturesCount', { count: diagnostics.config.enabledFeatures.length, })} {t('codex.mcpServersCount', { count: diagnostics.config.mcpServerCount })}
{diagnostics.config.topLevelKeys.length > 0 && (

{t('codex.userLayerKeysPresent')}

{diagnostics.config.topLevelKeys.map((key) => ( {key} ))}
)}
{t('codex.runtimeVsProvider')}

{t('codex.nativeCodexRuntime')}

  • ccs-codex
  • ccsx
  • --target codex
{t('codex.honorsSavedNativeConfig')}

{t('codex.ccsCodexProvider')}

{supportsManagedRouting ? ( <>
  • ccsxp
  • ccs codex --target codex
{t('codex.usesTransientOverrides')} ) : (

{t('codex.unavailableNoConfig')}

)}
{t('codex.supportedFlows')} {t('codex.flow')} {t('codex.status')} {t('codex.notes')} {diagnostics.supportMatrix.map((entry) => ( {entry.label} {entry.supported ? t('codex.yes') : t('codex.no')} {entry.notes} ))}
{diagnostics.warnings.length > 0 && ( {t('codex.warningsTitle')} {diagnostics.warnings.map((warning) => (

- {warning}

))}
)}
); }