import React, { useMemo } from 'react'; import { CODEX_FAST_CREDIT_COST_MULTIPLIER, CODEX_FAST_SPEED_MULTIPLIER, resolveCodexFastMode, resolveCodexRuntimeSelection, } from '@features/codex-runtime-profile/renderer'; import { useAppTranslation } from '@features/localization/renderer'; import { Label } from '@renderer/components/ui/label'; import { useEffectiveCliProviderStatus } from '@renderer/hooks/useEffectiveCliProviderStatus'; import { cn } from '@renderer/lib/utils'; import { Zap } from 'lucide-react'; import type { TeamFastMode, TeamProviderBackendId } from '@shared/types'; export interface CodexFastModeSelectorProps { value: TeamFastMode; onValueChange: (value: TeamFastMode) => void; model?: string; providerBackendId?: TeamProviderBackendId | string | null; id?: string; } export const CodexFastModeSelector: React.FC = ({ value, onValueChange, model, providerBackendId, id, }) => { const { t } = useAppTranslation('team'); const { providerStatus } = useEffectiveCliProviderStatus('codex'); const selection = useMemo( () => resolveCodexRuntimeSelection({ source: { providerStatus, providerBackendId, }, selectedModel: model, }), [model, providerBackendId, providerStatus] ); const resolution = useMemo( () => resolveCodexFastMode({ selection, selectedFastMode: value, }), [selection, value] ); if (!resolution.showFastModeControl) { return null; } const helperText = value === 'inherit' ? resolution.selectable ? `Default is Off. Enable Fast for about ${CODEX_FAST_SPEED_MULTIPLIER}x speed at ${CODEX_FAST_CREDIT_COST_MULTIPLIER}x credits.` : (resolution.disabledReason ?? 'Available for Fast-capable Codex models with a ChatGPT account.') : (resolution.disabledReason ?? 'Available for Fast-capable Codex models with a ChatGPT account. API key mode uses standard API pricing.'); return (
{[ { value: 'inherit' as const, label: t('modelSelector.fastMode.defaultOff'), disabled: false, }, { value: 'on' as const, label: t('modelSelector.fastMode.fast'), disabled: !resolution.selectable, }, { value: 'off' as const, label: t('modelSelector.fastMode.off'), disabled: false }, ].map((option) => ( ))}

{helperText}

); };