import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { Markdown } from '@/components/ui/markdown'; import { CheckCircle2, XCircle, AlertCircle, FileCode, Lightbulb, AlertTriangle, Plus, GitPullRequest, Clock, Wrench, } from 'lucide-react'; import { cn } from '@/lib/utils'; import type { IssueValidationResult, IssueValidationVerdict, IssueValidationConfidence, IssueComplexity, GitHubIssue, } from '@/lib/electron'; interface ValidationDialogProps { open: boolean; onOpenChange: (open: boolean) => void; issue: GitHubIssue | null; validationResult: IssueValidationResult | null; onConvertToTask?: (issue: GitHubIssue, validation: IssueValidationResult) => void; } const verdictConfig: Record< IssueValidationVerdict, { label: string; color: string; bgColor: string; icon: typeof CheckCircle2 } > = { valid: { label: 'Valid', color: 'text-green-500', bgColor: 'bg-green-500/10', icon: CheckCircle2, }, invalid: { label: 'Invalid', color: 'text-red-500', bgColor: 'bg-red-500/10', icon: XCircle, }, needs_clarification: { label: 'Needs Clarification', color: 'text-yellow-500', bgColor: 'bg-yellow-500/10', icon: AlertCircle, }, }; const confidenceConfig: Record = { high: { label: 'High Confidence', color: 'text-green-500' }, medium: { label: 'Medium Confidence', color: 'text-yellow-500' }, low: { label: 'Low Confidence', color: 'text-orange-500' }, }; const complexityConfig: Record = { trivial: { label: 'Trivial', color: 'text-green-500' }, simple: { label: 'Simple', color: 'text-blue-500' }, moderate: { label: 'Moderate', color: 'text-yellow-500' }, complex: { label: 'Complex', color: 'text-orange-500' }, very_complex: { label: 'Very Complex', color: 'text-red-500' }, }; export function ValidationDialog({ open, onOpenChange, issue, validationResult, onConvertToTask, }: ValidationDialogProps) { if (!issue) return null; const handleConvertToTask = () => { if (validationResult && onConvertToTask) { onConvertToTask(issue, validationResult); onOpenChange(false); } }; return ( Issue Validation Result #{issue.number}: {issue.title} {validationResult ? (
{/* Verdict Badge */}
{(() => { const config = verdictConfig[validationResult.verdict]; const Icon = config.icon; return ( <>

{config.label}

{confidenceConfig[validationResult.confidence].label}

); })()}
{validationResult.estimatedComplexity && (

Estimated Complexity

{complexityConfig[validationResult.estimatedComplexity].label}

)}
{/* Bug Confirmed Badge */} {validationResult.bugConfirmed && (
Bug Confirmed in Codebase
)} {/* PR Analysis Section - Show AI's analysis of linked PRs */} {validationResult.prAnalysis && validationResult.prAnalysis.hasOpenPR && (
{validationResult.prAnalysis.recommendation === 'wait_for_merge' ? ( ) : validationResult.prAnalysis.recommendation === 'pr_needs_work' ? ( ) : ( )}
{validationResult.prAnalysis.recommendation === 'wait_for_merge' ? 'Fix Ready - Wait for Merge' : validationResult.prAnalysis.recommendation === 'pr_needs_work' ? 'PR Needs Work' : 'Work in Progress'} {validationResult.prAnalysis.prNumber && (

PR #{validationResult.prAnalysis.prNumber} {validationResult.prAnalysis.prFixesIssue && ' appears to fix this issue'}

)} {validationResult.prAnalysis.prSummary && (

{validationResult.prAnalysis.prSummary}

)}
)} {/* Fallback Work in Progress Badge - Show when there's an open PR but no AI analysis */} {!validationResult.prAnalysis?.hasOpenPR && issue.linkedPRs?.some((pr) => pr.state === 'open' || pr.state === 'OPEN') && (
Work in Progress

{issue.linkedPRs .filter((pr) => pr.state === 'open' || pr.state === 'OPEN') .map((pr) => `PR #${pr.number}`) .join(', ')}{' '} is open for this issue

)} {/* Reasoning */}

Analysis

{validationResult.reasoning}
{/* Related Files */} {validationResult.relatedFiles && validationResult.relatedFiles.length > 0 && (

Related Files

{validationResult.relatedFiles.map((file, index) => (
{file}
))}
)} {/* Suggested Fix */} {validationResult.suggestedFix && (

Suggested Approach

{validationResult.suggestedFix}
)} {/* Missing Info (for needs_clarification) */} {validationResult.missingInfo && validationResult.missingInfo.length > 0 && (

Missing Information

    {validationResult.missingInfo.map((info, index) => (
  • {info}
  • ))}
)}
) : (

No validation result available.

)} {validationResult?.verdict === 'valid' && onConvertToTask && validationResult?.prAnalysis?.recommendation !== 'wait_for_merge' && ( )}
); }