gpt-engineer-app[bot] commited on
Commit ·
ec7e2e2
1
Parent(s): 7d2ce0a
Changes
Browse files
src/routes/dashboard.branch-debug.tsx
CHANGED
|
@@ -375,3 +375,177 @@ index aaa..bbb 100644
|
|
| 375 |
|
| 376 |
function AnalyzerStyles() { return null; }
|
| 377 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
|
| 376 |
function AnalyzerStyles() { return null; }
|
| 377 |
|
| 378 |
+
const CONFIDENCE_STYLES = {
|
| 379 |
+
high: { bg: "bg-severity-critical/10", border: "border-severity-critical/40", text: "text-severity-critical", dot: "bg-severity-critical" },
|
| 380 |
+
medium: { bg: "bg-severity-high/10", border: "border-severity-high/40", text: "text-severity-high", dot: "bg-severity-high" },
|
| 381 |
+
low: { bg: "bg-muted/30", border: "border-border", text: "text-muted-foreground", dot: "bg-muted-foreground" },
|
| 382 |
+
} as const;
|
| 383 |
+
|
| 384 |
+
function AnalyzerView({
|
| 385 |
+
diff, setDiff, failure, setFailure, result, analyzing, onRun, onSample, editorBase, setEditorBase,
|
| 386 |
+
}: {
|
| 387 |
+
diff: string; setDiff: (v: string) => void;
|
| 388 |
+
failure: string; setFailure: (v: string) => void;
|
| 389 |
+
result: DebugResult | null; analyzing: boolean;
|
| 390 |
+
onRun: () => void; onSample: () => void;
|
| 391 |
+
editorBase: string; setEditorBase: (v: string) => void;
|
| 392 |
+
}) {
|
| 393 |
+
return (
|
| 394 |
+
<div className="flex-1 grid grid-cols-1 lg:grid-cols-[480px_1fr] min-h-0 overflow-hidden">
|
| 395 |
+
{/* Input panel */}
|
| 396 |
+
<div className="border-r border-border overflow-y-auto p-6 space-y-4 bg-surface/20">
|
| 397 |
+
<div>
|
| 398 |
+
<div className="flex items-center justify-between mb-2">
|
| 399 |
+
<label className="text-[10px] font-mono uppercase tracking-widest text-muted-foreground">Unified git diff</label>
|
| 400 |
+
<button onClick={onSample} className="text-[10px] font-mono uppercase tracking-widest text-primary hover:underline">Load sample</button>
|
| 401 |
+
</div>
|
| 402 |
+
<Textarea
|
| 403 |
+
value={diff}
|
| 404 |
+
onChange={(e) => setDiff(e.target.value)}
|
| 405 |
+
placeholder="Paste output of `git diff main..feature/...`"
|
| 406 |
+
className="font-mono text-xs h-64 resize-none bg-background"
|
| 407 |
+
/>
|
| 408 |
+
</div>
|
| 409 |
+
<div>
|
| 410 |
+
<label className="text-[10px] font-mono uppercase tracking-widest text-muted-foreground mb-2 block">Failure description</label>
|
| 411 |
+
<Textarea
|
| 412 |
+
value={failure}
|
| 413 |
+
onChange={(e) => setFailure(e.target.value)}
|
| 414 |
+
placeholder="What broke? Stack trace, error message, observed behavior…"
|
| 415 |
+
className="text-sm h-28 resize-none bg-background"
|
| 416 |
+
/>
|
| 417 |
+
</div>
|
| 418 |
+
<div>
|
| 419 |
+
<label className="text-[10px] font-mono uppercase tracking-widest text-muted-foreground mb-2 block">Editor deep-link prefix</label>
|
| 420 |
+
<input
|
| 421 |
+
value={editorBase}
|
| 422 |
+
onChange={(e) => setEditorBase(e.target.value)}
|
| 423 |
+
className="w-full text-xs font-mono px-3 py-2 rounded-md bg-background border border-border focus:border-primary outline-none"
|
| 424 |
+
placeholder="vscode://file/ or cursor://file/"
|
| 425 |
+
/>
|
| 426 |
+
<p className="text-[10px] text-muted-foreground mt-1">Used to jump directly to suspect lines in your editor.</p>
|
| 427 |
+
</div>
|
| 428 |
+
<Button onClick={onRun} disabled={analyzing} className="w-full gap-2">
|
| 429 |
+
{analyzing ? <><Loader2 className="h-4 w-4 animate-spin" /> Analyzing…</> : <><Sparkles className="h-4 w-4" /> Analyze branch</>}
|
| 430 |
+
</Button>
|
| 431 |
+
<div className="rounded-lg border border-yellow-500/30 bg-yellow-500/5 p-3 flex gap-2 text-[11px] text-muted-foreground">
|
| 432 |
+
<Shield className="h-3.5 w-3.5 text-yellow-500 shrink-0 mt-0.5" />
|
| 433 |
+
<span>Identifiers, comments, and secrets are stripped server-side before any AI call. Real names are restored locally after analysis.</span>
|
| 434 |
+
</div>
|
| 435 |
+
</div>
|
| 436 |
+
|
| 437 |
+
{/* Results panel */}
|
| 438 |
+
<div className="overflow-y-auto p-8 space-y-5 max-w-4xl">
|
| 439 |
+
{!result && !analyzing && (
|
| 440 |
+
<div className="h-full flex flex-col items-center justify-center text-center text-muted-foreground py-24">
|
| 441 |
+
<Sparkles className="h-10 w-10 mb-4 text-primary/40" />
|
| 442 |
+
<p className="text-sm font-medium">Paste a diff and describe the failure</p>
|
| 443 |
+
<p className="text-xs mt-1">BranchDebug will rank suspect changes by likely root cause.</p>
|
| 444 |
+
</div>
|
| 445 |
+
)}
|
| 446 |
+
|
| 447 |
+
{analyzing && (
|
| 448 |
+
<div className="rounded-xl border border-primary/30 bg-primary/5 p-6 flex items-center gap-3">
|
| 449 |
+
<Loader2 className="h-5 w-5 animate-spin text-primary" />
|
| 450 |
+
<div>
|
| 451 |
+
<p className="font-medium text-sm">Sanitizing diff and analyzing…</p>
|
| 452 |
+
<p className="text-xs text-muted-foreground">Tokenize → AI ranks suspects → restore real names</p>
|
| 453 |
+
</div>
|
| 454 |
+
</div>
|
| 455 |
+
)}
|
| 456 |
+
|
| 457 |
+
{result && (
|
| 458 |
+
<>
|
| 459 |
+
<div className="rounded-xl border border-border bg-surface/60 p-5 space-y-3">
|
| 460 |
+
<div className="text-[10px] font-mono uppercase tracking-widest text-muted-foreground">Verdict</div>
|
| 461 |
+
<p className="text-sm leading-relaxed">{result.summary}</p>
|
| 462 |
+
<div className="flex flex-wrap gap-3 text-[10px] font-mono uppercase tracking-wider text-muted-foreground pt-2 border-t border-border">
|
| 463 |
+
<span><Shield className="h-3 w-3 inline mr-1 text-yellow-500" />{result.sanitizationStats.identifiersTokenized} identifiers tokenized</span>
|
| 464 |
+
<span>{result.sanitizationStats.commentsStripped} comment lines stripped</span>
|
| 465 |
+
<span>{result.sanitizationStats.secretsBlocked} secrets blocked</span>
|
| 466 |
+
</div>
|
| 467 |
+
</div>
|
| 468 |
+
|
| 469 |
+
<div className="space-y-3">
|
| 470 |
+
<div className="text-[10px] font-mono uppercase tracking-widest text-muted-foreground">Ranked suspects ({result.suspects.length})</div>
|
| 471 |
+
{result.suspects.length === 0 ? (
|
| 472 |
+
<p className="text-sm text-muted-foreground">No suspect changes identified.</p>
|
| 473 |
+
) : (
|
| 474 |
+
result.suspects.map((s, i) => <SuspectCard key={i} suspect={s} editorBase={editorBase} rank={i + 1} />)
|
| 475 |
+
)}
|
| 476 |
+
</div>
|
| 477 |
+
</>
|
| 478 |
+
)}
|
| 479 |
+
</div>
|
| 480 |
+
</div>
|
| 481 |
+
);
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
function SuspectCard({ suspect, editorBase, rank }: { suspect: Suspect; editorBase: string; rank: number }) {
|
| 485 |
+
const c = CONFIDENCE_STYLES[suspect.confidence];
|
| 486 |
+
const link = `${editorBase}${suspect.filePath}:${suspect.lineStart}`;
|
| 487 |
+
|
| 488 |
+
const copyLocation = () => {
|
| 489 |
+
navigator.clipboard.writeText(`${suspect.filePath}:${suspect.lineStart}`);
|
| 490 |
+
toast.success("Location copied");
|
| 491 |
+
};
|
| 492 |
+
|
| 493 |
+
return (
|
| 494 |
+
<div className={cn("rounded-xl border p-5 space-y-3", c.border, c.bg)}>
|
| 495 |
+
<div className="flex items-start justify-between gap-3">
|
| 496 |
+
<div className="flex items-start gap-3 min-w-0">
|
| 497 |
+
<div className={cn("h-7 w-7 rounded-full flex items-center justify-center text-[11px] font-bold font-mono shrink-0", c.text, "bg-background border", c.border)}>
|
| 498 |
+
#{rank}
|
| 499 |
+
</div>
|
| 500 |
+
<div className="min-w-0">
|
| 501 |
+
<div className="flex items-center gap-2 flex-wrap">
|
| 502 |
+
<span className={cn("text-[10px] font-mono uppercase tracking-widest font-bold px-2 py-0.5 rounded", c.bg, c.text, "border", c.border)}>
|
| 503 |
+
<span className={cn("inline-block h-1.5 w-1.5 rounded-full mr-1.5", c.dot)} />
|
| 504 |
+
{suspect.confidence}
|
| 505 |
+
</span>
|
| 506 |
+
<span className="text-sm font-semibold">{suspect.changeSummary}</span>
|
| 507 |
+
</div>
|
| 508 |
+
<div className="flex items-center gap-1.5 text-xs font-mono text-muted-foreground mt-1.5 min-w-0">
|
| 509 |
+
<FileCode className="h-3 w-3 shrink-0" />
|
| 510 |
+
<span className="truncate">{suspect.filePath}</span>
|
| 511 |
+
<span className="text-primary">:{suspect.lineStart}{suspect.lineEnd !== suspect.lineStart && `-${suspect.lineEnd}`}</span>
|
| 512 |
+
{suspect.functionName && <span className="text-muted-foreground/60">· {suspect.functionName}()</span>}
|
| 513 |
+
</div>
|
| 514 |
+
</div>
|
| 515 |
+
</div>
|
| 516 |
+
<div className="flex gap-1 shrink-0">
|
| 517 |
+
<button
|
| 518 |
+
onClick={copyLocation}
|
| 519 |
+
className="h-7 w-7 rounded-md border border-border bg-background hover:bg-surface flex items-center justify-center text-muted-foreground hover:text-foreground"
|
| 520 |
+
title="Copy location"
|
| 521 |
+
>
|
| 522 |
+
<Copy className="h-3 w-3" />
|
| 523 |
+
</button>
|
| 524 |
+
<a
|
| 525 |
+
href={link}
|
| 526 |
+
className="h-7 px-2 rounded-md border border-primary/40 bg-primary/10 hover:bg-primary/20 text-primary text-[10px] font-mono uppercase tracking-widest flex items-center gap-1"
|
| 527 |
+
title="Open in editor"
|
| 528 |
+
>
|
| 529 |
+
<ExternalLink className="h-3 w-3" /> Jump
|
| 530 |
+
</a>
|
| 531 |
+
</div>
|
| 532 |
+
</div>
|
| 533 |
+
|
| 534 |
+
<p className="text-sm leading-relaxed text-foreground/90">{suspect.mechanism}</p>
|
| 535 |
+
|
| 536 |
+
{(suspect.beforeSnippet || suspect.afterSnippet) && (
|
| 537 |
+
<div className="rounded-lg border border-border bg-background overflow-hidden">
|
| 538 |
+
<pre className="text-[11px] font-mono leading-relaxed">
|
| 539 |
+
{suspect.beforeSnippet?.split("\n").map((l, i) => (
|
| 540 |
+
<div key={`b${i}`} className="px-3 py-0.5 text-severity-critical bg-severity-critical/5">- {l}</div>
|
| 541 |
+
))}
|
| 542 |
+
{suspect.afterSnippet?.split("\n").map((l, i) => (
|
| 543 |
+
<div key={`a${i}`} className="px-3 py-0.5 text-severity-low bg-severity-low/5">+ {l}</div>
|
| 544 |
+
))}
|
| 545 |
+
</pre>
|
| 546 |
+
</div>
|
| 547 |
+
)}
|
| 548 |
+
</div>
|
| 549 |
+
);
|
| 550 |
+
}
|
| 551 |
+
|