import { App, Button, Input, Select } from "antd"; import { Activity, CheckCircle2, Clock3, Download, FileText, ShieldCheck } from "lucide-react"; import { useEffect, useState } from "react"; import { exportDiagnosticBundle, downloadDiagnosticBundle, previewDiagnosticBundle, type DiagnosticExportInput, type DiagnosticPreview } from "@/services/diagnostics/diagnostics-api"; import { getClientDiagnosticEvents, getDiagnosticRuntime } from "@/services/diagnostics/client-diagnostics"; type DiagnosticsPanelProps = { taskId?: string; projectId?: string; }; type DiagnosticRange = "15m" | "30m" | "1h" | "24h"; const rangeOptions = [ { value: "15m", label: "最近 15 分钟" }, { value: "30m", label: "最近 30 分钟" }, { value: "1h", label: "最近 1 小时" }, { value: "24h", label: "最近 24 小时" }, ]; export default function DiagnosticsPanel({ taskId, projectId }: DiagnosticsPanelProps) { const { message } = App.useApp(); const [range, setRange] = useState("30m"); const [description, setDescription] = useState(""); const [preview, setPreview] = useState(null); const [loadingPreview, setLoadingPreview] = useState(false); const [exporting, setExporting] = useState(false); const [bundleId, setBundleId] = useState(""); useEffect(() => { let cancelled = false; setLoadingPreview(true); void previewDiagnosticBundle(buildInput(range, undefined, taskId, projectId)) .then((result) => { if (!cancelled) setPreview(result); }) .catch(() => { if (!cancelled) setPreview(null); }) .finally(() => { if (!cancelled) setLoadingPreview(false); }); return () => { cancelled = true; }; }, [projectId, range, taskId]); const handleExport = async () => { setExporting(true); try { const download = await exportDiagnosticBundle(buildInput(range, description, taskId, projectId)); downloadDiagnosticBundle(download); setBundleId(download.bundleId); message.success("诊断包已下载,请连同诊断编号提交给支持人员"); } catch (error) { message.error(error instanceof Error ? error.message : "导出诊断包失败"); } finally { setExporting(false); } }; return (

问题诊断

遇到报错、任务失败或生成卡住时,导出一份给开发人员排查。

默认已脱敏

不包含 API Key、Cookie、完整提示词或原始媒体。

选择问题发生前后的日志时间窗口。

最长 24 小时