import { useState } from 'react'; import { cn } from '@renderer/lib/utils'; import { AlertTriangle, ChevronRight, Info, ShieldCheck, X } from 'lucide-react'; import { ConfidenceBadge } from './ConfidenceBadge'; import type { TaskScopeConfidence } from '@shared/types'; import type { FC } from 'react'; interface ScopeWarningBannerProps { warnings: string[]; confidence: TaskScopeConfidence; onDismiss?: () => void; } interface TierConfig { Icon: FC<{ className?: string }>; border: string; bg: string; accentColor: string; title: string; detail: string; } const TIER_CONFIGS: Record = { 1: { Icon: ShieldCheck, border: 'border-emerald-500/15', bg: 'bg-emerald-500/5', accentColor: 'text-emerald-400', title: 'Task scope determined precisely', detail: 'Both start and completion markers found in the session log. The diff includes only changes made during this specific task — other tasks that modified the same files are excluded.', }, 2: { Icon: Info, border: 'border-blue-500/15', bg: 'bg-blue-500/5', accentColor: 'text-blue-400', title: 'End boundary estimated', detail: 'Only the start marker was found — the task has no completion marker yet. Changes shown from task start to end of session. If other tasks ran after this one in the same session, their changes may also be included.', }, 3: { Icon: AlertTriangle, border: 'border-orange-500/20', bg: 'bg-orange-500/5', accentColor: 'text-orange-400', title: 'Start boundary estimated', detail: 'Only the completion marker was found — the start of work was not captured. If other tasks ran before this one in the same session, their changes to the same files may also be included.', }, 4: { Icon: AlertTriangle, border: 'border-red-500/20', bg: 'bg-red-500/5', accentColor: 'text-red-400', title: 'Showing all session changes', detail: 'No task markers found in the session log. Cannot isolate this task — all file changes from the entire session are shown, including changes from other tasks. This can happen with older CLI versions or non-standard workflows.', }, }; export const ScopeWarningBanner = ({ warnings, confidence, onDismiss, }: ScopeWarningBannerProps): JSX.Element => { const [expanded, setExpanded] = useState(false); const config = TIER_CONFIGS[confidence.tier] ?? TIER_CONFIGS[4]; const { Icon } = config; return (
{config.title}
{onDismiss && ( )}
{expanded && (

{config.detail}

{warnings.length > 0 && (
    {warnings.map((w, i) => (
  • {w}
  • ))}
)}
)}
); };