import { Fragment } from 'react' import { Dialog, Transition } from '@headlessui/react' import { IconAlertTriangle, IconX } from '@tabler/icons-react' import { formatBytes } from '~/lib/util' import StyledButton from './StyledButton' import type { GuardrailVerdict } from '~/lib/kb_guardrail' /** * One-time confirmation modal for bulk indexing actions that trip the * disk-usage thresholds in `lib/kb_guardrail.ts`. The caller (e.g. * TierSelectionModal) decides whether to show the modal by evaluating the * guardrail BEFORE submit; this component just presents the verdict and * passes the user's choice back via `onConfirm` / `onCancel`. */ interface KbGuardrailModalProps { isOpen: boolean verdict: GuardrailVerdict onConfirm: () => void onCancel: () => void } export default function KbGuardrailModal({ isOpen, verdict, onConfirm, onCancel, }: KbGuardrailModalProps) { // The primary number to surface — every triggered reason carries the same // estimateBytes, so just grab the first one. `0` is a defensive fallback // for the (impossible-by-construction) "open with empty verdict" case. const estimateBytes = verdict.reasons[0]?.estimateBytes ?? 0 const freeReason = verdict.reasons.find((r) => r.kind === 'over_free_disk') return (
Confirm large AI indexing operation

Indexing this batch for the AI Assistant will use approximately{' '} {formatBytes(estimateBytes, 1)} of disk space for embeddings, on top of the raw downloads.

{freeReason && (

That's more than 10% of your remaining free disk space ({formatBytes(freeReason.freeBytes, 1)} free). Embedding can take several hours and is hard to interrupt cleanly once started.

)}

If you'd rather review per-item before indexing, cancel here and switch your Auto-index setting to Manual from the Knowledge Base panel.

Cancel Proceed anyway
) }