fix: final review pass — email collision, orphaned-run loop, null confidence guards

- changeEmail validates and refuses an address another account owns (users.email is UNIQUE; a collision was a 500 inside the settings form).
- /app/[id] no longer redirects a 'running' row to itself; it renders what exists and says the run was interrupted.
- ScoreBar / OptionRow / VerdictBlock survive null numbers from the model instead of throwing and losing the block (seen live: '[openui] runtime/render-error: Component ScoreBar render failed').
- drop the ad-hoc render-debug scripts now that Playwright covers the browser.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
ahmed mohammed
2026-09-22 09:10:29 +03:00
co-authored by Claude Opus 4.7
parent 07dd3d6bf8
commit 5160a00db5
12 changed files with 101 additions and 80 deletions
+6 -2
View File
@@ -1,4 +1,4 @@
import { notFound, redirect } from "next/navigation";
import { notFound } from "next/navigation";
import { requireUser } from "@/lib/auth";
import { getAnalysis } from "@/lib/db";
import { ReportView } from "@/components/report-view";
@@ -9,9 +9,13 @@ export default async function Stored({ params }: { params: Promise<{ id: string
const u = await requireUser();
const a = getAnalysis((await params).id, u.id);
if (!a) notFound();
if (a.status === "running") redirect(`/app/${a.id}`); // still streaming elsewhere; rare, bounce once
// Never redirect here: a row left "running" by a crashed process would bounce this page to itself forever.
const interrupted = a.status === "running";
return <main style={{ display: "grid", gap: "var(--qai-space-xl)" }}>
<h1 style={{ fontFamily: "var(--qai-font-display)", fontSize: "var(--qai-text-2xl)", margin: 0 }}>{a.title}</h1>
{interrupted && <p role="alert" style={{ color: "var(--qai-warn)" }}>
This run was interrupted before it finished — what is below is everything it managed to produce.
</p>}
{a.error && <p role="alert" style={{ color: "var(--qai-danger)" }}>{a.error}</p>}
{a.verdict && <VerdictSummary verdict={JSON.parse(a.verdict)} />}
{a.oul ? <><ExportButtons oul={a.oul} title={a.title} /><ReportView oul={a.oul} streaming={false} /></>