import { useState } from "react"; import { XIcon, WarningIcon, CheckCircleIcon, CaretRightIcon } from "@phosphor-icons/react"; import { copyTextToClipboard } from "../utils/clipboard"; export interface LintFinding { severity: "error" | "warning"; message: string; file?: string; fixHint?: string; } export function LintModal({ findings, projectId, onClose, }: { findings: LintFinding[]; projectId: string; onClose: () => void; }) { const errors = findings.filter((f) => f.severity === "error"); const warnings = findings.filter((f) => f.severity === "warning"); const hasIssues = findings.length > 0; const [copied, setCopied] = useState(false); const handleCopyToAgent = async () => { const lines = findings.map((f) => { let line = `[${f.severity}] ${f.message}`; if (f.file) line += `\n File: ${f.file}`; if (f.fixHint) line += `\n Fix: ${f.fixHint}`; return line; }); const text = `Fix these HyperFrames lint issues for project "${projectId}":\n\nProject path: ${window.location.href}\n\n${lines.join("\n\n")}`; const copiedText = await copyTextToClipboard(text); if (copiedText) { setCopied(true); setTimeout(() => setCopied(false), 2000); } }; return (
e.stopPropagation()} > {/* Header */}
{hasIssues ? (
) : (
)}

{hasIssues ? `${errors.length} error${errors.length !== 1 ? "s" : ""}, ${warnings.length} warning${warnings.length !== 1 ? "s" : ""}` : "All checks passed"}

HyperFrame Lint Results

{/* Copy to agent + findings */} {hasIssues && (
)}
{!hasIssues && (
No errors or warnings found. Your composition looks good!
)} {errors.map((f, i) => (

{f.message}

{f.file &&

{f.file}

} {f.fixHint && (

{f.fixHint}

)}
))} {warnings.map((f, i) => (

{f.message}

{f.file &&

{f.file}

} {f.fixHint && (

{f.fixHint}

)}
))}
); }