gpt-engineer-app[bot] commited on
Commit ·
9915ab0
1
Parent(s): ed3d7ad
Changes
Browse files
src/routes/dashboard.branch-debug.tsx
CHANGED
|
@@ -895,3 +895,91 @@ function StatCell({ label, value, highlight }: { label: string; value: number; h
|
|
| 895 |
</div>
|
| 896 |
);
|
| 897 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 895 |
</div>
|
| 896 |
);
|
| 897 |
}
|
| 898 |
+
|
| 899 |
+
function ExportButtons({ result, mode }: { result: DebugResult; mode: "diff" | "snippet" | "unknown" }) {
|
| 900 |
+
const stamp = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
| 901 |
+
|
| 902 |
+
const download = (filename: string, content: string, mime: string) => {
|
| 903 |
+
const blob = new Blob([content], { type: mime });
|
| 904 |
+
const url = URL.createObjectURL(blob);
|
| 905 |
+
const a = document.createElement("a");
|
| 906 |
+
a.href = url;
|
| 907 |
+
a.download = filename;
|
| 908 |
+
a.click();
|
| 909 |
+
URL.revokeObjectURL(url);
|
| 910 |
+
toast.success(`Exported ${filename}`);
|
| 911 |
+
};
|
| 912 |
+
|
| 913 |
+
const exportJson = () => {
|
| 914 |
+
const payload = {
|
| 915 |
+
generatedAt: new Date().toISOString(),
|
| 916 |
+
mode,
|
| 917 |
+
summary: result.summary,
|
| 918 |
+
suspects: result.suspects,
|
| 919 |
+
sanitizationStats: result.sanitizationStats,
|
| 920 |
+
};
|
| 921 |
+
download(`branchdebug-report-${stamp}.json`, JSON.stringify(payload, null, 2), "application/json");
|
| 922 |
+
};
|
| 923 |
+
|
| 924 |
+
const exportMarkdown = () => {
|
| 925 |
+
const lines: string[] = [];
|
| 926 |
+
lines.push(`# BranchDebug Root-Cause Report`);
|
| 927 |
+
lines.push("");
|
| 928 |
+
lines.push(`**Generated:** ${new Date().toLocaleString()}`);
|
| 929 |
+
lines.push(`**Mode:** ${mode === "snippet" ? "Code snippet" : mode === "diff" ? "Git diff" : "Unknown"}`);
|
| 930 |
+
lines.push("");
|
| 931 |
+
lines.push(`## Verdict`);
|
| 932 |
+
lines.push("");
|
| 933 |
+
lines.push(result.summary || "_No summary available._");
|
| 934 |
+
lines.push("");
|
| 935 |
+
lines.push(`## IP Shield Sanitization`);
|
| 936 |
+
lines.push("");
|
| 937 |
+
lines.push(`- ${result.sanitizationStats.identifiersTokenized} identifiers tokenized`);
|
| 938 |
+
lines.push(`- ${result.sanitizationStats.commentsStripped} comment lines stripped`);
|
| 939 |
+
lines.push(`- ${result.sanitizationStats.secretsBlocked} secrets blocked`);
|
| 940 |
+
lines.push("");
|
| 941 |
+
lines.push(`## Ranked Suspects (${result.suspects.length})`);
|
| 942 |
+
lines.push("");
|
| 943 |
+
if (result.suspects.length === 0) {
|
| 944 |
+
lines.push("_No suspect changes identified._");
|
| 945 |
+
} else {
|
| 946 |
+
result.suspects.forEach((s, i) => {
|
| 947 |
+
lines.push(`### #${i + 1} · [${s.confidence.toUpperCase()}] ${s.changeSummary}`);
|
| 948 |
+
lines.push("");
|
| 949 |
+
lines.push(`- **File:** \`${s.filePath}\``);
|
| 950 |
+
lines.push(`- **Lines:** ${s.lineStart}${s.lineEnd !== s.lineStart ? `–${s.lineEnd}` : ""}`);
|
| 951 |
+
if (s.functionName) lines.push(`- **Function:** \`${s.functionName}()\``);
|
| 952 |
+
lines.push("");
|
| 953 |
+
lines.push(`**Mechanism:** ${s.mechanism}`);
|
| 954 |
+
lines.push("");
|
| 955 |
+
if (s.beforeSnippet || s.afterSnippet) {
|
| 956 |
+
lines.push("```diff");
|
| 957 |
+
if (s.beforeSnippet) s.beforeSnippet.split("\n").forEach((l) => lines.push(`- ${l}`));
|
| 958 |
+
if (s.afterSnippet) s.afterSnippet.split("\n").forEach((l) => lines.push(`+ ${l}`));
|
| 959 |
+
lines.push("```");
|
| 960 |
+
lines.push("");
|
| 961 |
+
}
|
| 962 |
+
});
|
| 963 |
+
}
|
| 964 |
+
download(`branchdebug-report-${stamp}.md`, lines.join("\n"), "text/markdown");
|
| 965 |
+
};
|
| 966 |
+
|
| 967 |
+
return (
|
| 968 |
+
<div className="flex items-center gap-1">
|
| 969 |
+
<button
|
| 970 |
+
onClick={exportMarkdown}
|
| 971 |
+
className="h-7 px-2 rounded-md border border-border bg-background hover:border-primary/40 hover:text-primary text-muted-foreground text-[10px] font-mono uppercase tracking-widest flex items-center gap-1"
|
| 972 |
+
title="Export Markdown report"
|
| 973 |
+
>
|
| 974 |
+
<FileText className="h-3 w-3" /> .md
|
| 975 |
+
</button>
|
| 976 |
+
<button
|
| 977 |
+
onClick={exportJson}
|
| 978 |
+
className="h-7 px-2 rounded-md border border-border bg-background hover:border-primary/40 hover:text-primary text-muted-foreground text-[10px] font-mono uppercase tracking-widest flex items-center gap-1"
|
| 979 |
+
title="Export JSON report"
|
| 980 |
+
>
|
| 981 |
+
<FileJson className="h-3 w-3" /> .json
|
| 982 |
+
</button>
|
| 983 |
+
</div>
|
| 984 |
+
);
|
| 985 |
+
}
|