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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { createFileRoute } from "@tanstack/react-router";
|
| 2 |
+
import { useState, useEffect, useRef } from "react";
|
| 3 |
+
import { GitBranch, Play, RotateCcw, Shield, ChevronLeft, ChevronRight, Check } from "lucide-react";
|
| 4 |
+
import { cn } from "@/lib/utils";
|
| 5 |
+
|
| 6 |
+
export const Route = createFileRoute("/dashboard/branch-debug")({
|
| 7 |
+
component: BranchDebugPage,
|
| 8 |
+
});
|
| 9 |
+
|
| 10 |
+
type Zone = "user" | "server" | "ai";
|
| 11 |
+
|
| 12 |
+
const STEPS: {
|
| 13 |
+
id: number; label: string; sublabel: string; color: string; icon: string;
|
| 14 |
+
zone: Zone; code: string; detail: string; codeLabel: string;
|
| 15 |
+
}[] = [
|
| 16 |
+
{ id: 1, label: "Engineer runs git diff", sublabel: "After a failed deploy or test", color: "#4af0c4", icon: "⌥", zone: "user",
|
| 17 |
+
code: `git diff main..feature/checkout-fix > diff.txt`,
|
| 18 |
+
detail: "The engineer notices something broke after merging a branch. They grab the diff between their branch and main — this captures every line that changed.",
|
| 19 |
+
codeLabel: "TERMINAL" },
|
| 20 |
+
{ id: 2, label: "Paste diff + describe failure", sublabel: "Plain English note", color: "#4af0c4", icon: "✎", zone: "user",
|
| 21 |
+
code: `"API throwing 500 on /checkout after deploy.\nCard validation seems broken for Amex cards."`,
|
| 22 |
+
detail: "The engineer pastes the diff into BranchDebug and writes a plain-English description of what broke. No special format — just what they observed.",
|
| 23 |
+
codeLabel: "INPUT" },
|
| 24 |
+
{ id: 3, label: "IP Shield — Sanitizer runs", sublabel: "Server-side, before any external call", color: "#ffcc44", icon: "🛡", zone: "server",
|
| 25 |
+
code: `validate_card() → fn_0042\nAmexValidator → fn_0019\ncard_number → fn_0003\n\n# Comments stripped\n# Secrets blocked`,
|
| 26 |
+
detail: "BEFORE the diff reaches any AI, the server strips all identifiers and replaces them with anonymous tokens. Comments are removed. The token map is encrypted and stored locally — it never leaves your server.",
|
| 27 |
+
codeLabel: "SANITIZER OUTPUT" },
|
| 28 |
+
{ id: 4, label: "Sanitized diff sent to AI", sublabel: "Zero data retention API tier", color: "#aa88ff", icon: "→", zone: "ai",
|
| 29 |
+
code: `diff --git a/fn_0019.py b/fn_0019.py\n- if fn_0003 > 15:\n+ if fn_0003 > 16:`,
|
| 30 |
+
detail: "Only the anonymized diff — with no real function names, file paths, or comments — is sent to the AI API. Even if this were intercepted, it reveals nothing about your codebase.",
|
| 31 |
+
codeLabel: "PAYLOAD SENT TO AI" },
|
| 32 |
+
{ id: 5, label: "AI analyzes failure pattern", sublabel: "Root cause mapping", color: "#aa88ff", icon: "◎", zone: "ai",
|
| 33 |
+
code: `{\n "suspect": "fn_0019 :: fn_0042",\n "confidence": "High",\n "mechanism": "Threshold change\n from 15→16 excludes valid\n fn_0003 lengths"\n}`,
|
| 34 |
+
detail: "The AI cross-references the anonymized diff against the failure description. It identifies which changed lines are most likely responsible and explains the mechanism.",
|
| 35 |
+
codeLabel: "AI RESPONSE (anonymized)" },
|
| 36 |
+
{ id: 6, label: "Token map restores real names", sublabel: "Encrypted map decrypted server-side", color: "#ffcc44", icon: "↺", zone: "server",
|
| 37 |
+
code: `fn_0019 → AmexValidator\nfn_0042 → validate_card\nfn_0003 → card_number`,
|
| 38 |
+
detail: "The server decrypts the token map and replaces all anonymous tokens in the AI response with your real function and file names. The real-name mapping never left your server.",
|
| 39 |
+
codeLabel: "TOKEN RESTORATION" },
|
| 40 |
+
{ id: 7, label: "Results shown to engineer", sublabel: "Ranked suspects + auto Jira ticket", color: "#4af0c4", icon: "✓", zone: "user",
|
| 41 |
+
code: `HIGH payments/AmexValidator.py\n :: validate_card()\n\nThreshold change 15→16 excludes\nvalid 15-digit Amex card_numbers`,
|
| 42 |
+
detail: "The engineer sees real file paths, real function names, confidence scores, and a plain-English explanation of why each change causes the observed failure. One click creates a Jira ticket.",
|
| 43 |
+
codeLabel: "RESULT" },
|
| 44 |
+
];
|
| 45 |
+
|
| 46 |
+
const ZONES: Record<Zone, { label: string; color: string }> = {
|
| 47 |
+
user: { label: "YOUR MACHINE", color: "#4af0c4" },
|
| 48 |
+
server: { label: "YOUR SERVER (IP SHIELD)", color: "#ffcc44" },
|
| 49 |
+
ai: { label: "AI API (anonymized only)", color: "#aa88ff" },
|
| 50 |
+
};
|
| 51 |
+
|
| 52 |
+
function BranchDebugPage() {
|
| 53 |
+
const [active, setActive] = useState(0);
|
| 54 |
+
const [playing, setPlaying] = useState(false);
|
| 55 |
+
const [revealed, setRevealed] = useState<number[]>([0]);
|
| 56 |
+
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
| 57 |
+
|
| 58 |
+
useEffect(() => {
|
| 59 |
+
if (playing) {
|
| 60 |
+
timerRef.current = setInterval(() => {
|
| 61 |
+
setActive((prev) => {
|
| 62 |
+
const next = prev + 1;
|
| 63 |
+
if (next >= STEPS.length) {
|
| 64 |
+
setPlaying(false);
|
| 65 |
+
if (timerRef.current) clearInterval(timerRef.current);
|
| 66 |
+
return prev;
|
| 67 |
+
}
|
| 68 |
+
setRevealed((r) => (r.includes(next) ? r : [...r, next]));
|
| 69 |
+
return next;
|
| 70 |
+
});
|
| 71 |
+
}, 1800);
|
| 72 |
+
}
|
| 73 |
+
return () => { if (timerRef.current) clearInterval(timerRef.current); };
|
| 74 |
+
}, [playing]);
|
| 75 |
+
|
| 76 |
+
const handleStep = (i: number) => {
|
| 77 |
+
setActive(i);
|
| 78 |
+
setRevealed((r) => (r.includes(i) ? r : [...r, i]));
|
| 79 |
+
setPlaying(false);
|
| 80 |
+
if (timerRef.current) clearInterval(timerRef.current);
|
| 81 |
+
};
|
| 82 |
+
|
| 83 |
+
const handlePlay = () => {
|
| 84 |
+
if (active >= STEPS.length - 1) {
|
| 85 |
+
setActive(0);
|
| 86 |
+
setRevealed([0]);
|
| 87 |
+
}
|
| 88 |
+
setPlaying(true);
|
| 89 |
+
};
|
| 90 |
+
|
| 91 |
+
const handleReset = () => {
|
| 92 |
+
setActive(0);
|
| 93 |
+
setRevealed([0]);
|
| 94 |
+
setPlaying(false);
|
| 95 |
+
if (timerRef.current) clearInterval(timerRef.current);
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
const step = STEPS[active];
|
| 99 |
+
const zone = ZONES[step.zone];
|
| 100 |
+
|
| 101 |
+
return (
|
| 102 |
+
<>
|
| 103 |
+
<header className="h-16 border-b border-border flex items-center justify-between px-8 bg-surface/40 backdrop-blur">
|
| 104 |
+
<div>
|
| 105 |
+
<div className="text-[10px] uppercase tracking-widest text-muted-foreground font-mono">Engineering</div>
|
| 106 |
+
<h1 className="text-lg font-semibold flex items-center gap-2">
|
| 107 |
+
<GitBranch className="h-4 w-4 text-primary" /> Branch Debug
|
| 108 |
+
</h1>
|
| 109 |
+
</div>
|
| 110 |
+
<div className="flex gap-2">
|
| 111 |
+
<button
|
| 112 |
+
onClick={handlePlay}
|
| 113 |
+
className="flex items-center gap-2 px-3 py-2 rounded-md text-xs font-mono uppercase tracking-widest border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors"
|
| 114 |
+
>
|
| 115 |
+
<Play className="h-3 w-3" /> {playing ? "Playing…" : "Auto-Play"}
|
| 116 |
+
</button>
|
| 117 |
+
<button
|
| 118 |
+
onClick={handleReset}
|
| 119 |
+
className="flex items-center gap-2 px-3 py-2 rounded-md text-xs font-mono uppercase tracking-widest border border-border text-muted-foreground hover:text-foreground"
|
| 120 |
+
>
|
| 121 |
+
<RotateCcw className="h-3 w-3" /> Reset
|
| 122 |
+
</button>
|
| 123 |
+
</div>
|
| 124 |
+
</header>
|
| 125 |
+
|
| 126 |
+
<div className="flex-1 grid grid-cols-1 lg:grid-cols-[360px_1fr] min-h-0 overflow-hidden">
|
| 127 |
+
{/* Left: pipeline */}
|
| 128 |
+
<div className="border-r border-border overflow-y-auto p-4 space-y-2 bg-surface/20">
|
| 129 |
+
<div className="px-2 pb-3 space-y-1.5">
|
| 130 |
+
{(Object.entries(ZONES) as [Zone, typeof ZONES[Zone]][]).map(([k, z]) => (
|
| 131 |
+
<div key={k} className="flex items-center gap-2 text-[10px] font-mono uppercase tracking-wider text-muted-foreground">
|
| 132 |
+
<span className="h-1.5 w-1.5 rounded-full" style={{ background: z.color }} />
|
| 133 |
+
{z.label}
|
| 134 |
+
</div>
|
| 135 |
+
))}
|
| 136 |
+
</div>
|
| 137 |
+
|
| 138 |
+
{STEPS.map((s, i) => {
|
| 139 |
+
const isActive = active === i;
|
| 140 |
+
const isRevealed = revealed.includes(i);
|
| 141 |
+
const z = ZONES[s.zone];
|
| 142 |
+
const showZoneHeader = i === 0 || STEPS[i - 1].zone !== s.zone;
|
| 143 |
+
return (
|
| 144 |
+
<div key={s.id}>
|
| 145 |
+
{showZoneHeader && (
|
| 146 |
+
<div className="px-2 pt-3 pb-1 text-[9px] font-mono uppercase tracking-widest" style={{ color: z.color }}>
|
| 147 |
+
── {z.label} ──
|
| 148 |
+
</div>
|
| 149 |
+
)}
|
| 150 |
+
<button
|
| 151 |
+
onClick={() => handleStep(i)}
|
| 152 |
+
className={cn(
|
| 153 |
+
"w-full text-left p-3 rounded-lg border flex items-start gap-3 transition-all",
|
| 154 |
+
isActive ? "border-primary/60 bg-primary/5 shadow-[var(--shadow-glow)]" :
|
| 155 |
+
isRevealed ? "border-border bg-surface hover:border-primary/30" :
|
| 156 |
+
"border-border/40 bg-surface/30 opacity-50"
|
| 157 |
+
)}
|
| 158 |
+
style={isActive ? { borderColor: s.color + "80", background: s.color + "12" } : undefined}
|
| 159 |
+
>
|
| 160 |
+
<div
|
| 161 |
+
className="h-7 w-7 rounded-full flex items-center justify-center text-[11px] font-bold font-mono shrink-0"
|
| 162 |
+
style={{
|
| 163 |
+
background: isActive ? s.color : isRevealed ? s.color + "30" : "hsl(var(--muted))",
|
| 164 |
+
color: isActive ? "#001a0d" : s.color,
|
| 165 |
+
}}
|
| 166 |
+
>
|
| 167 |
+
{s.id}
|
| 168 |
+
</div>
|
| 169 |
+
<div className="min-w-0 flex-1">
|
| 170 |
+
<div className="text-sm font-medium truncate">{s.label}</div>
|
| 171 |
+
<div className="text-[10px] text-muted-foreground mt-0.5">{s.sublabel}</div>
|
| 172 |
+
</div>
|
| 173 |
+
</button>
|
| 174 |
+
{i < STEPS.length - 1 && (
|
| 175 |
+
<div className="ml-[26px] h-3 w-px bg-border" />
|
| 176 |
+
)}
|
| 177 |
+
</div>
|
| 178 |
+
);
|
| 179 |
+
})}
|
| 180 |
+
</div>
|
| 181 |
+
|
| 182 |
+
{/* Right: detail */}
|
| 183 |
+
<div className="overflow-y-auto p-8 space-y-6 max-w-4xl">
|
| 184 |
+
<div className="flex items-start gap-4">
|
| 185 |
+
<div
|
| 186 |
+
className="h-12 w-12 rounded-xl flex items-center justify-center text-xl shrink-0"
|
| 187 |
+
style={{ background: step.color + "20", color: step.color, border: `1px solid ${step.color}40` }}
|
| 188 |
+
>
|
| 189 |
+
{step.icon}
|
| 190 |
+
</div>
|
| 191 |
+
<div className="space-y-1">
|
| 192 |
+
<div className="text-[10px] font-mono uppercase tracking-widest text-muted-foreground">
|
| 193 |
+
Step {step.id} of {STEPS.length} — {zone.label}
|
| 194 |
+
</div>
|
| 195 |
+
<h2 className="text-2xl font-bold tracking-tight">{step.label}</h2>
|
| 196 |
+
<p className="text-sm text-muted-foreground leading-relaxed pt-2 max-w-2xl">{step.detail}</p>
|
| 197 |
+
</div>
|
| 198 |
+
</div>
|
| 199 |
+
|
| 200 |
+
{/* Code block */}
|
| 201 |
+
<div className="rounded-xl border border-border bg-surface overflow-hidden">
|
| 202 |
+
<div className="px-4 py-2 border-b border-border bg-background/40 text-[10px] font-mono uppercase tracking-widest text-muted-foreground flex items-center justify-between">
|
| 203 |
+
<span>{step.codeLabel}</span>
|
| 204 |
+
<span style={{ color: step.color }}>● {step.zone.toUpperCase()}</span>
|
| 205 |
+
</div>
|
| 206 |
+
<pre className="p-4 text-xs font-mono whitespace-pre-wrap leading-relaxed text-foreground/90 overflow-x-auto">
|
| 207 |
+
{step.code}
|
| 208 |
+
</pre>
|
| 209 |
+
</div>
|
| 210 |
+
|
| 211 |
+
{/* IP Shield callout */}
|
| 212 |
+
{(step.id === 3 || step.id === 6) && (
|
| 213 |
+
<div className="rounded-xl border border-yellow-500/40 bg-yellow-500/5 p-4">
|
| 214 |
+
<div className="flex items-center gap-2 text-xs font-mono uppercase tracking-widest text-yellow-500 font-bold mb-2">
|
| 215 |
+
<Shield className="h-3.5 w-3.5" /> IP Shield Active
|
| 216 |
+
</div>
|
| 217 |
+
<p className="text-xs text-muted-foreground leading-relaxed">
|
| 218 |
+
{step.id === 3
|
| 219 |
+
? "Real names are replaced with opaque tokens BEFORE any data leaves your server. The token map is encrypted with AES-256-GCM using a key derived from your org ID. It is never transmitted anywhere."
|
| 220 |
+
: "The token map is decrypted on your server using your org's encryption key. Real identifiers are restored locally. The AI never saw — and still doesn't know — your actual function or file names."}
|
| 221 |
+
</p>
|
| 222 |
+
</div>
|
| 223 |
+
)}
|
| 224 |
+
|
| 225 |
+
{/* Pipeline progress */}
|
| 226 |
+
<div className="rounded-xl border border-border bg-surface/60 p-4">
|
| 227 |
+
<div className="text-[10px] font-mono uppercase tracking-widest text-muted-foreground mb-3">Pipeline Progress</div>
|
| 228 |
+
<div className="flex items-center gap-1">
|
| 229 |
+
{STEPS.map((s, i) => {
|
| 230 |
+
const isDone = i < active;
|
| 231 |
+
const isCurrent = i === active;
|
| 232 |
+
return (
|
| 233 |
+
<div key={s.id} className="flex items-center flex-1 last:flex-initial">
|
| 234 |
+
<div
|
| 235 |
+
className={cn(
|
| 236 |
+
"h-7 w-7 rounded-full flex items-center justify-center text-[10px] font-mono font-bold shrink-0",
|
| 237 |
+
isCurrent && "ring-2 ring-offset-2 ring-offset-background"
|
| 238 |
+
)}
|
| 239 |
+
style={{
|
| 240 |
+
background: isDone || isCurrent ? s.color : "hsl(var(--muted))",
|
| 241 |
+
color: isDone || isCurrent ? "#001a0d" : "hsl(var(--muted-foreground))",
|
| 242 |
+
...(isCurrent ? ({ "--tw-ring-color": s.color } as React.CSSProperties) : {}),
|
| 243 |
+
}}
|
| 244 |
+
>
|
| 245 |
+
{isDone ? <Check className="h-3 w-3" /> : s.id}
|
| 246 |
+
</div>
|
| 247 |
+
{i < STEPS.length - 1 && (
|
| 248 |
+
<div
|
| 249 |
+
className="flex-1 h-px mx-1"
|
| 250 |
+
style={{ background: i < active ? s.color : "hsl(var(--border))" }}
|
| 251 |
+
/>
|
| 252 |
+
)}
|
| 253 |
+
</div>
|
| 254 |
+
);
|
| 255 |
+
})}
|
| 256 |
+
</div>
|
| 257 |
+
</div>
|
| 258 |
+
|
| 259 |
+
{/* Navigation */}
|
| 260 |
+
<div className="flex justify-between gap-2 pt-2">
|
| 261 |
+
<button
|
| 262 |
+
onClick={() => handleStep(Math.max(0, active - 1))}
|
| 263 |
+
disabled={active === 0}
|
| 264 |
+
className="flex items-center gap-1.5 px-4 py-2 rounded-md text-xs font-mono uppercase tracking-widest border border-border text-muted-foreground hover:text-foreground disabled:opacity-30 disabled:cursor-not-allowed"
|
| 265 |
+
>
|
| 266 |
+
<ChevronLeft className="h-3 w-3" /> Prev
|
| 267 |
+
</button>
|
| 268 |
+
<button
|
| 269 |
+
onClick={() => handleStep(Math.min(STEPS.length - 1, active + 1))}
|
| 270 |
+
disabled={active === STEPS.length - 1}
|
| 271 |
+
className="flex items-center gap-1.5 px-4 py-2 rounded-md text-xs font-mono uppercase tracking-widest font-bold disabled:opacity-30 disabled:cursor-not-allowed"
|
| 272 |
+
style={{
|
| 273 |
+
background: active === STEPS.length - 1 ? "hsl(var(--muted))" : step.color,
|
| 274 |
+
color: active === STEPS.length - 1 ? "hsl(var(--muted-foreground))" : "#001a0d",
|
| 275 |
+
}}
|
| 276 |
+
>
|
| 277 |
+
Next <ChevronRight className="h-3 w-3" />
|
| 278 |
+
</button>
|
| 279 |
+
</div>
|
| 280 |
+
</div>
|
| 281 |
+
</div>
|
| 282 |
+
</>
|
| 283 |
+
);
|
| 284 |
+
}
|