gpt-engineer-app[bot] commited on
Commit
39a907f
Β·
1 Parent(s): 6b7d556
src/routes/dashboard.branch-debug.tsx CHANGED
@@ -103,6 +103,57 @@ function BranchDebugPage() {
103
  const step = STEPS[active];
104
  const zone = ZONES[step.zone];
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  return (
107
  <>
108
  <header className="h-16 border-b border-border flex items-center justify-between px-8 bg-surface/40 backdrop-blur">
@@ -112,7 +163,37 @@ function BranchDebugPage() {
112
  <GitBranch className="h-4 w-4 text-primary" /> Branch Debug
113
  </h1>
114
  </div>
115
- <div className="flex gap-2">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  <button
117
  onClick={handlePlay}
118
  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"
@@ -126,7 +207,6 @@ function BranchDebugPage() {
126
  <RotateCcw className="h-3 w-3" /> Reset
127
  </button>
128
  </div>
129
- </header>
130
 
131
  <div className="flex-1 grid grid-cols-1 lg:grid-cols-[360px_1fr] min-h-0 overflow-hidden">
132
  {/* Left: pipeline */}
 
103
  const step = STEPS[active];
104
  const zone = ZONES[step.zone];
105
 
106
+ // ─── Analyzer state ───
107
+ const [tab, setTab] = useState<"analyzer" | "howto">("analyzer");
108
+ const [diff, setDiff] = useState("");
109
+ const [failure, setFailure] = useState("");
110
+ const [result, setResult] = useState<DebugResult | null>(null);
111
+ const [analyzing, setAnalyzing] = useState(false);
112
+ const [editorBase, setEditorBase] = useState(() => localStorage.getItem("branchdebug.editorBase") ?? "vscode://file/");
113
+ const debugFn = useServerFn(debugBranch);
114
+
115
+ const runAnalysis = async () => {
116
+ if (!diff.trim() || !failure.trim()) {
117
+ toast.error("Provide both a diff and a failure description.");
118
+ return;
119
+ }
120
+ setAnalyzing(true);
121
+ setResult(null);
122
+ try {
123
+ const res = await debugFn({ data: { diff, failureDescription: failure } });
124
+ setResult(res);
125
+ toast.success(`Found ${res.suspects.length} suspect${res.suspects.length === 1 ? "" : "s"}`);
126
+ } catch (e: any) {
127
+ toast.error(e.message ?? "Analysis failed");
128
+ } finally {
129
+ setAnalyzing(false);
130
+ }
131
+ };
132
+
133
+ const loadSample = () => {
134
+ setDiff(`diff --git a/payments/AmexValidator.py b/payments/AmexValidator.py
135
+ index 1a2b3c4..5d6e7f8 100644
136
+ --- a/payments/AmexValidator.py
137
+ +++ b/payments/AmexValidator.py
138
+ @@ -10,7 +10,7 @@ class AmexValidator:
139
+ def validate_card(self, card_number):
140
+ # Amex cards are 15 digits
141
+ - if len(card_number) > 15:
142
+ + if len(card_number) > 16:
143
+ return False
144
+ return self._luhn_check(card_number)
145
+ diff --git a/checkout/handler.py b/checkout/handler.py
146
+ index aaa..bbb 100644
147
+ --- a/checkout/handler.py
148
+ +++ b/checkout/handler.py
149
+ @@ -42,6 +42,7 @@ def process_checkout(payload):
150
+ validator = AmexValidator()
151
+ + payload = sanitize_payload(payload)
152
+ if not validator.validate_card(payload["card"]):
153
+ raise ValueError("Invalid card")`);
154
+ setFailure("API throwing 500 on /checkout after deploy. Card validation seems broken for Amex cards.");
155
+ };
156
+
157
  return (
158
  <>
159
  <header className="h-16 border-b border-border flex items-center justify-between px-8 bg-surface/40 backdrop-blur">
 
163
  <GitBranch className="h-4 w-4 text-primary" /> Branch Debug
164
  </h1>
165
  </div>
166
+ <div className="flex gap-1 p-1 rounded-lg bg-surface border border-border">
167
+ <button
168
+ onClick={() => setTab("analyzer")}
169
+ className={cn("px-3 py-1.5 rounded-md text-xs font-mono uppercase tracking-widest transition-colors",
170
+ tab === "analyzer" ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:text-foreground")}
171
+ >
172
+ <Sparkles className="h-3 w-3 inline mr-1.5" /> Analyzer
173
+ </button>
174
+ <button
175
+ onClick={() => setTab("howto")}
176
+ className={cn("px-3 py-1.5 rounded-md text-xs font-mono uppercase tracking-widest transition-colors",
177
+ tab === "howto" ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:text-foreground")}
178
+ >
179
+ How it works
180
+ </button>
181
+ </div>
182
+ </header>
183
+
184
+ {tab === "analyzer" && (
185
+ <AnalyzerView
186
+ diff={diff} setDiff={setDiff}
187
+ failure={failure} setFailure={setFailure}
188
+ result={result} analyzing={analyzing}
189
+ onRun={runAnalysis} onSample={loadSample}
190
+ editorBase={editorBase} setEditorBase={(v) => { setEditorBase(v); localStorage.setItem("branchdebug.editorBase", v); }}
191
+ />
192
+ )}
193
+
194
+ {tab === "howto" && (
195
+ <>
196
+ <div className="px-8 py-3 border-b border-border flex justify-end gap-2 bg-surface/20">
197
  <button
198
  onClick={handlePlay}
199
  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"
 
207
  <RotateCcw className="h-3 w-3" /> Reset
208
  </button>
209
  </div>
 
210
 
211
  <div className="flex-1 grid grid-cols-1 lg:grid-cols-[360px_1fr] min-h-0 overflow-hidden">
212
  {/* Left: pipeline */}