Spaces:
Running
Running
Deploy 383f0a24
Browse files- api.py +3 -0
- frontend/src/main.jsx +33 -60
- frontend/src/styles.css +1 -1
- nodes/executor.py +27 -5
api.py
CHANGED
|
@@ -54,6 +54,9 @@ def _public_job(job: dict[str, Any]) -> dict[str, Any]:
|
|
| 54 |
|
| 55 |
|
| 56 |
def _run_job(job_id: str, request: ReviewRequest) -> None:
|
|
|
|
|
|
|
|
|
|
| 57 |
try:
|
| 58 |
state, config, cost, _ = _build_and_stream(request.repo, request.pr_number, _normalize_endpoint_name(request.endpoint), ragas_background=True)
|
| 59 |
verdict: Verdict | None = state.values.get("verdict")
|
|
|
|
| 54 |
|
| 55 |
|
| 56 |
def _run_job(job_id: str, request: ReviewRequest) -> None:
|
| 57 |
+
with _lock:
|
| 58 |
+
if job_id in _jobs:
|
| 59 |
+
_jobs[job_id]["status"] = "processing"
|
| 60 |
try:
|
| 61 |
state, config, cost, _ = _build_and_stream(request.repo, request.pr_number, _normalize_endpoint_name(request.endpoint), ragas_background=True)
|
| 62 |
verdict: Verdict | None = state.values.get("verdict")
|
frontend/src/main.jsx
CHANGED
|
@@ -1,69 +1,42 @@
|
|
| 1 |
-
import React, { useEffect, useState } from "react";
|
| 2 |
import { createRoot } from "react-dom/client";
|
| 3 |
import "./styles.css";
|
| 4 |
|
| 5 |
-
const API_BASE = import.meta.env.VITE_REVIEW_API_URL || "";
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
function
|
| 8 |
-
|
| 9 |
-
const
|
| 10 |
-
const
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
if (!job?.id || ["awaiting_approval","rejected","posted","partially_posted","post_failed","failed"].includes(job.status)) return;
|
| 17 |
-
const timer = setInterval(async () => { try { const response = await fetch(`${API_BASE}/api/reviews/${job.id}`); if (!response.ok) throw new Error(`Status check failed (${response.status})`); const next = await response.json(); setJob(next); setStatus(next.status); setMessage(next.status === "awaiting_approval" ? "Review complete. Inspect the findings before posting." : `Review status: ${next.status}`); } catch (error) { setStatus("error"); setMessage(error.message); } }, 3000);
|
| 18 |
-
return () => clearInterval(timer);
|
| 19 |
-
}, [job?.id, job?.status]);
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
setStatus("error");
|
| 25 |
-
setMessage("Enter a repository as owner/name and a valid PR number.");
|
| 26 |
-
return;
|
| 27 |
-
}
|
| 28 |
-
setStatus("loading");
|
| 29 |
-
setMessage("Review queued. The API worker will report progress here.");
|
| 30 |
-
try {
|
| 31 |
-
const response = await fetch(`${API_BASE}/api/reviews`, {
|
| 32 |
-
method: "POST", headers: { "Content-Type": "application/json" },
|
| 33 |
-
body: JSON.stringify({ repo: repo.trim(), pr_number: Number(pr), endpoint }),
|
| 34 |
-
});
|
| 35 |
-
if (!response.ok) throw new Error(`Request failed (${response.status})`);
|
| 36 |
-
const created = await response.json(); setJob(created); setStatus(created.status); setMessage("Review queued successfully. Approval will be required before posting.");
|
| 37 |
-
} catch (error) {
|
| 38 |
-
setStatus("error");
|
| 39 |
-
setMessage(API_BASE ? error.message : "Set VITE_REVIEW_API_URL to connect the review worker.");
|
| 40 |
-
}
|
| 41 |
-
}
|
| 42 |
-
async function decide(action) { if (!job?.id) return; setDecisionBusy(true); try { const response = await fetch(`${API_BASE}/api/reviews/${job.id}/decision`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ action }) }); const next = await response.json(); if (!response.ok) throw new Error(next.detail || `Decision failed (${response.status})`); setJob(next); setStatus(next.status); setMessage(action === "approve" ? "Posting completed. See the delivery receipt below." : "Review rejected. Nothing was posted to GitHub."); } catch (error) { setStatus("error"); setMessage(error.message); } finally { setDecisionBusy(false); } }
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
<section className="hero"><p className="eyebrow">Pull request intelligence</p><h1>Review changes with<br /><em>evidence before action.</em></h1><p className="lede">Parallel analysis for correctness, security, and test coverage. Nothing is posted to GitHub until you approve it.</p></section>
|
| 48 |
-
<section className="workspace">
|
| 49 |
-
<form className="panel form-panel" onSubmit={startReview}>
|
| 50 |
-
<div className="panel-kicker">New review</div><h2>Inspect a pull request</h2>
|
| 51 |
-
<label>Repository<input value={repo} onChange={e => setRepo(e.target.value)} placeholder="owner/repository" autoComplete="off" /></label>
|
| 52 |
-
<label>Pull request<input value={pr} onChange={e => setPr(e.target.value)} placeholder="42" inputMode="numeric" /></label>
|
| 53 |
-
<label>LLM endpoint<select value={endpoint} onChange={e => setEndpoint(e.target.value)}><option value="auto">Automatic fallback</option><option value="gemini">Gemini</option><option value="groq">Groq</option></select></label>
|
| 54 |
-
<button type="submit" disabled={status === "loading"}>{status === "loading" ? "Queueing reviewβ¦" : "Start review"}<span>β</span></button>
|
| 55 |
-
{message && <p className={`message ${status}`}>{message}</p>}
|
| 56 |
-
{job && <div className="job-card"><strong>Job {job.id.slice(0, 8)}</strong><span className={`pill ${job.status}`}>{job.status.replaceAll("_", " ")}</span></div>}
|
| 57 |
-
{job?.verdict && <div className="result-card"><div className="result-title"><strong>{job.verdict.recommendation.replaceAll("_", " ").toUpperCase()}</strong><b>{job.verdict.overall_score}/10</b></div><p>{job.verdict.summary}</p><small>{job.findings?.length || 0} findings Β· {job.cost || "Cost unavailable"}</small></div>}
|
| 58 |
-
{job?.findings?.length > 0 && <div className="findings">{job.findings.map((finding, index) => <article className="finding" key={`${finding.file_path}-${finding.line_start}-${index}`}><div><span className={`severity ${finding.severity}`}>{finding.severity}</span><span className="category">{finding.category}</span></div><strong>{finding.file_path}:{finding.line_start}β{finding.line_end}</strong><p>{finding.comment}</p><small>Confidence {Math.round((finding.confidence || 0) * 100)}%</small></article>)}</div>}
|
| 59 |
-
{job?.status === "awaiting_approval" && <div className="actions"><button type="button" onClick={() => decide("approve")} disabled={decisionBusy}>Approve & post</button><button type="button" className="secondary" onClick={() => decide("reject")} disabled={decisionBusy}>Reject</button></div>}
|
| 60 |
-
{job?.posting_result && <div className="result-card"><strong>Delivery receipt</strong><p>{job.posting_result.status.replaceAll("_", " ")}</p><small>Inline: {job.posting_result.inline_posted || 0} Β· Fallback: {job.posting_result.fallback_posted || 0} Β· Failed: {job.posting_result.failed || 0}</small></div>}
|
| 61 |
-
</form>
|
| 62 |
-
<aside className="panel signal-panel"><div className="panel-kicker">What you receive</div><div className="signal"><strong>01</strong><span><b>Evidence-grounded findings</b><small>Code locations, severity, and confidence</small></span></div><div className="signal"><strong>02</strong><span><b>Human checkpoint</b><small>Approve or reject before GitHub comments</small></span></div><div className="signal"><strong>03</strong><span><b>Evaluation trail</b><small>RAGAS and cost telemetry when configured</small></span></div></aside>
|
| 63 |
-
</section>
|
| 64 |
-
</main>
|
| 65 |
-
<footer>OpenCodeReview <span>Β·</span> React migration preview <span>Β·</span> API keys stay server-side</footer>
|
| 66 |
-
</div>;
|
| 67 |
}
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
createRoot(document.getElementById("root")).render(<App />);
|
|
|
|
| 1 |
+
import React, { useEffect, useMemo, useState } from "react";
|
| 2 |
import { createRoot } from "react-dom/client";
|
| 3 |
import "./styles.css";
|
| 4 |
|
| 5 |
+
const API_BASE = (import.meta.env.VITE_REVIEW_API_URL || "").replace(/\/$/, "");
|
| 6 |
+
const TERMINAL = new Set(["awaiting_approval", "rejected", "posted", "partially_posted", "post_failed", "failed"]);
|
| 7 |
+
const apiUrl = (path) => `${API_BASE}${path}`;
|
| 8 |
+
const pretty = (value) => String(value || "").replaceAll("_", " ");
|
| 9 |
|
| 10 |
+
function Verdict({ job }) {
|
| 11 |
+
if (!job?.verdict) return null;
|
| 12 |
+
const v = job.verdict;
|
| 13 |
+
const blocking = ["block", "request_changes"].includes(v.recommendation);
|
| 14 |
+
return <section className={`result-card verdict ${blocking ? "blocking" : "approved"}`} aria-labelledby="verdict-title">
|
| 15 |
+
<div className="result-title"><div><span className="panel-kicker">Final verdict</span><h3 id="verdict-title">{pretty(v.recommendation).toUpperCase()}</h3></div><strong className="score">{typeof v.overall_score === "number" ? `${v.overall_score.toFixed(1)}/10` : "β"}</strong></div>
|
| 16 |
+
<p>{v.summary || "No summary was returned."}</p><div className="metrics"><span>{job.findings?.length || 0} findings</span>{job.cost && <span>Cost {typeof job.cost === "string" ? job.cost : JSON.stringify(job.cost)}</span>}</div>
|
| 17 |
+
</section>;
|
| 18 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
function Findings({ findings = [] }) {
|
| 21 |
+
return <section aria-labelledby="findings-title"><div className="section-heading"><h3 id="findings-title">Findings</h3><span>{findings.length}</span></div>{findings.length ? <div className="findings">{findings.map((f, i) => <article className="finding" key={`${f.file_path || "finding"}-${f.line_start || 0}-${i}`}><div className="finding-meta"><span className={`severity ${String(f.severity || "info").toLowerCase()}`}>{f.severity || "info"}</span>{f.category && <span className="category">{f.category}</span>}<span className="finding-location">{f.file_path || "Unknown file"}{f.line_start ? `:${f.line_start}${f.line_end && f.line_end !== f.line_start ? `β${f.line_end}` : ""}` : ""}</span></div><p>{f.comment || f.description || "No explanation provided."}</p>{f.confidence != null && <small>Confidence {Math.round(Number(f.confidence) * 100)}%</small>}</article>)}</div> : <div className="empty-result"><strong>No findings</strong><span>The reviewers did not identify actionable issues.</span></div>}</section>;
|
| 22 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
function Receipt({ result }) {
|
| 25 |
+
if (!result) return null;
|
| 26 |
+
return <section className="result-card receipt" aria-labelledby="receipt-title"><span className="panel-kicker">Delivery receipt</span><h3 id="receipt-title">{pretty(result.status || "completed")}</h3><div className="metrics"><span>Inline: {result.inline_posted || 0}</span><span>Fallback: {result.fallback_posted || 0}</span><span>Failed: {result.failed || 0}</span></div></section>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
| 28 |
|
| 29 |
+
function App() {
|
| 30 |
+
const [repo, setRepo] = useState(""); const [pr, setPr] = useState(""); const [endpoint, setEndpoint] = useState("auto");
|
| 31 |
+
const [job, setJob] = useState(null); const [message, setMessage] = useState(""); const [error, setError] = useState(""); const [busy, setBusy] = useState(false);
|
| 32 |
+
const isTerminal = useMemo(() => TERMINAL.has(job?.status), [job?.status]);
|
| 33 |
+
useEffect(() => {
|
| 34 |
+
if (!job?.id || isTerminal) return undefined; let stopped = false;
|
| 35 |
+
const poll = async () => { try { const r = await fetch(apiUrl(`/api/reviews/${job.id}`)); if (!r.ok) throw new Error(`Status check failed (${r.status})`); const next = await r.json(); if (!stopped) { setJob(next); setMessage(next.status === "awaiting_approval" ? "Review complete. Inspect the findings before posting." : `Review ${pretty(next.status)}β¦`); } } catch (e) { if (!stopped) setError(e.message); } };
|
| 36 |
+
poll(); const timer = window.setInterval(poll, 3000); return () => { stopped = true; window.clearInterval(timer); };
|
| 37 |
+
}, [job?.id, isTerminal]);
|
| 38 |
+
async function startReview(e) { e.preventDefault(); setError(""); if (!/^[-\w.]+\/[-\w.]+$/.test(repo.trim()) || !Number.isInteger(Number(pr)) || Number(pr) < 1) { setError("Enter a repository as owner/name and a valid PR number."); return; } setBusy(true); setJob(null); setMessage("Queueing reviewβ¦"); try { const r = await fetch(apiUrl("/api/reviews"), { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ repo: repo.trim(), pr_number: Number(pr), endpoint }) }); const data = await r.json().catch(() => ({})); if (!r.ok) throw new Error(data.detail || `Request failed (${r.status})`); setJob(data); setMessage("Review queued. This page will update as analysis progresses."); } catch (e) { setError(API_BASE ? e.message : "Set VITE_REVIEW_API_URL to connect the review worker."); } finally { setBusy(false); } }
|
| 39 |
+
async function decide(action) { if (!job?.id) return; setBusy(true); setError(""); setMessage(action === "approve" ? "Posting approved reviewβ¦" : "Rejecting reviewβ¦"); try { const r = await fetch(apiUrl(`/api/reviews/${job.id}/decision`), { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ action }) }); const data = await r.json().catch(() => ({})); if (!r.ok) throw new Error(data.detail || `Decision failed (${r.status})`); setJob(data); setMessage(action === "approve" ? "Review delivery finished." : "Review rejected. Nothing was posted to GitHub."); } catch (e) { setError(e.message); } finally { setBusy(false); } }
|
| 40 |
+
return <div className="shell"><header className="topbar"><div className="brand"><span className="brand-mark">OC</span><span>OpenCodeReview</span></div><span className="status-dot">Human approval required</span></header><main className="content"><section className="hero"><p className="eyebrow">Pull request intelligence</p><h1>Review changes with<br /><em>evidence before action.</em></h1><p className="lede">Parallel analysis for correctness, security, and test coverage. Nothing is posted to GitHub until you approve it.</p></section><section className="workspace"><form className="panel form-panel" onSubmit={startReview} aria-busy={busy}><div className="panel-kicker">New review</div><h2>Inspect a pull request</h2><label htmlFor="repo">Repository<input id="repo" value={repo} onChange={e => setRepo(e.target.value)} placeholder="owner/repository" autoComplete="off" /></label><label htmlFor="pr">Pull request<input id="pr" value={pr} onChange={e => setPr(e.target.value)} placeholder="42" inputMode="numeric" /></label><label htmlFor="endpoint">LLM endpoint<select id="endpoint" value={endpoint} onChange={e => setEndpoint(e.target.value)}><option value="auto">Automatic fallback</option><option value="gemini">Gemini</option><option value="groq">Groq</option></select></label><button type="submit" disabled={busy}>{busy && !job ? "Queueing reviewβ¦" : "Start review"}<span aria-hidden="true">β</span></button>{(error || message) && <div className={`message ${error ? "error" : "success"}`} role="status" aria-live="polite">{error || message}</div>}{job && <div className="job-card"><div><strong>Review {job.id?.slice(0, 8)}</strong><small>{job.repo} Β· PR #{job.pr_number}</small></div><span className={`pill ${job.status}`}>{pretty(job.status)}</span></div>}{job && !isTerminal && <div className="progress" role="progressbar" aria-label={`Review ${pretty(job.status)}`}><span /><small>Analysis is running. This may take a few minutes.</small></div>}<div className="results"><Verdict job={job} />{job?.findings && <Findings findings={job.findings} />}{job?.status === "awaiting_approval" && <div className="actions"><button type="button" onClick={() => decide("approve")} disabled={busy}>Approve & post</button><button type="button" className="secondary" onClick={() => decide("reject")} disabled={busy}>Reject</button></div>}<Receipt result={job?.posting_result} />{job?.error && <div className="error detail">{job.error}</div>}</div></form><aside className="panel signal-panel"><div className="panel-kicker">What you receive</div><div className="signal"><strong>01</strong><span><b>Evidence-grounded findings</b><small>Code locations, severity, and confidence</small></span></div><div className="signal"><strong>02</strong><span><b>Human checkpoint</b><small>Approve or reject before GitHub comments</small></span></div><div className="signal"><strong>03</strong><span><b>Delivery receipt</b><small>See exactly what reached GitHub</small></span></div></aside></section></main><footer>OpenCodeReview <span>Β·</span> React review workspace <span>Β·</span> API keys stay server-side</footer></div>;
|
| 41 |
+
}
|
| 42 |
createRoot(document.getElementById("root")).render(<App />);
|
frontend/src/styles.css
CHANGED
|
@@ -3,4 +3,4 @@
|
|
| 3 |
*{box-sizing:border-box}body{margin:0;min-width:320px;background:radial-gradient(circle at 78% 4%,#273320 0,#111311 34rem);min-height:100vh}.shell{min-height:100vh;display:flex;flex-direction:column}.topbar{height:76px;padding:0 clamp(20px,5vw,76px);display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line)}.brand{display:flex;gap:12px;align-items:center;font-weight:700;letter-spacing:-.03em}.brand-mark{display:grid;place-items:center;width:31px;height:31px;border:1px solid var(--lime);color:var(--lime);font:500 11px 'DM Mono',monospace}.status-dot{font:500 11px 'DM Mono',monospace;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.status-dot:before{content:'';display:inline-block;width:7px;height:7px;margin-right:8px;border-radius:50%;background:var(--lime);box-shadow:0 0 14px var(--lime)}.content{width:min(1180px,calc(100% - 40px));margin:auto;padding:clamp(70px,10vw,140px) 0 80px}.eyebrow,.panel-kicker{font:500 11px 'DM Mono',monospace;letter-spacing:.12em;text-transform:uppercase;color:var(--lime)}h1{margin:18px 0 24px;font-size:clamp(48px,7vw,92px);line-height:.98;letter-spacing:-.075em;max-width:840px}h1 em{font-style:normal;color:var(--muted)}.lede{max-width:510px;color:var(--muted);line-height:1.7;font-size:16px}.workspace{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(280px,.9fr);gap:20px;margin-top:78px}.panel{border:1px solid var(--line);background:#161a15cc;backdrop-filter:blur(16px);padding:30px}.form-panel h2{margin:10px 0 28px;font-size:25px;letter-spacing:-.04em}label{display:grid;gap:9px;margin:18px 0;font:500 12px 'DM Mono',monospace;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}input,select{width:100%;border:1px solid #3b4438;background:#10130f;color:#eef2e7;padding:14px 15px;font:500 15px Manrope;outline:none}input:focus,select:focus{border-color:var(--lime);box-shadow:0 0 0 3px #c7f36b18}button{width:100%;margin-top:12px;border:0;background:var(--lime);color:#11170d;padding:15px 18px;font-weight:800;font-size:14px;cursor:pointer;display:flex;justify-content:space-between}button:hover{background:#d9ff8d}button:disabled{opacity:.6;cursor:wait}.message{font-size:13px;line-height:1.5;margin:17px 0 0}.message.error{color:#ff9f8d}.message.queued{color:var(--lime)}.signal-panel{display:flex;flex-direction:column;gap:25px}.signal{display:grid;grid-template-columns:35px 1fr;gap:14px;padding-top:21px;border-top:1px solid var(--line)}.signal strong{font:500 12px 'DM Mono',monospace;color:var(--lime)}.signal b{display:block;font-size:14px}.signal small{display:block;color:var(--muted);line-height:1.5;margin-top:5px}footer{padding:24px clamp(20px,5vw,76px);border-top:1px solid var(--line);color:var(--muted);font:11px 'DM Mono',monospace}footer span{color:var(--lime);padding:0 8px}@media(max-width:760px){.topbar{height:64px}.status-dot{display:none}.content{padding-top:70px}.workspace{grid-template-columns:1fr;margin-top:55px}h1{font-size:54px}}
|
| 4 |
.job-card,.result-card,.finding{margin-top:14px;border:1px solid rgba(255,255,255,.12);border-radius:14px;padding:14px;background:rgba(255,255,255,.04)}
|
| 5 |
.job-card{display:flex;justify-content:space-between;align-items:center;font-size:.85rem}.pill,.severity,.category{font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;border-radius:999px;padding:4px 8px;background:rgba(255,255,255,.1)}
|
| 6 |
-
.result-title{display:flex;justify-content:space-between;color:#d6ff70}.result-card p{margin:
|
|
|
|
| 3 |
*{box-sizing:border-box}body{margin:0;min-width:320px;background:radial-gradient(circle at 78% 4%,#273320 0,#111311 34rem);min-height:100vh}.shell{min-height:100vh;display:flex;flex-direction:column}.topbar{height:76px;padding:0 clamp(20px,5vw,76px);display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line)}.brand{display:flex;gap:12px;align-items:center;font-weight:700;letter-spacing:-.03em}.brand-mark{display:grid;place-items:center;width:31px;height:31px;border:1px solid var(--lime);color:var(--lime);font:500 11px 'DM Mono',monospace}.status-dot{font:500 11px 'DM Mono',monospace;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.status-dot:before{content:'';display:inline-block;width:7px;height:7px;margin-right:8px;border-radius:50%;background:var(--lime);box-shadow:0 0 14px var(--lime)}.content{width:min(1180px,calc(100% - 40px));margin:auto;padding:clamp(70px,10vw,140px) 0 80px}.eyebrow,.panel-kicker{font:500 11px 'DM Mono',monospace;letter-spacing:.12em;text-transform:uppercase;color:var(--lime)}h1{margin:18px 0 24px;font-size:clamp(48px,7vw,92px);line-height:.98;letter-spacing:-.075em;max-width:840px}h1 em{font-style:normal;color:var(--muted)}.lede{max-width:510px;color:var(--muted);line-height:1.7;font-size:16px}.workspace{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(280px,.9fr);gap:20px;margin-top:78px}.panel{border:1px solid var(--line);background:#161a15cc;backdrop-filter:blur(16px);padding:30px}.form-panel h2{margin:10px 0 28px;font-size:25px;letter-spacing:-.04em}label{display:grid;gap:9px;margin:18px 0;font:500 12px 'DM Mono',monospace;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}input,select{width:100%;border:1px solid #3b4438;background:#10130f;color:#eef2e7;padding:14px 15px;font:500 15px Manrope;outline:none}input:focus,select:focus{border-color:var(--lime);box-shadow:0 0 0 3px #c7f36b18}button{width:100%;margin-top:12px;border:0;background:var(--lime);color:#11170d;padding:15px 18px;font-weight:800;font-size:14px;cursor:pointer;display:flex;justify-content:space-between}button:hover{background:#d9ff8d}button:disabled{opacity:.6;cursor:wait}.message{font-size:13px;line-height:1.5;margin:17px 0 0}.message.error{color:#ff9f8d}.message.queued{color:var(--lime)}.signal-panel{display:flex;flex-direction:column;gap:25px}.signal{display:grid;grid-template-columns:35px 1fr;gap:14px;padding-top:21px;border-top:1px solid var(--line)}.signal strong{font:500 12px 'DM Mono',monospace;color:var(--lime)}.signal b{display:block;font-size:14px}.signal small{display:block;color:var(--muted);line-height:1.5;margin-top:5px}footer{padding:24px clamp(20px,5vw,76px);border-top:1px solid var(--line);color:var(--muted);font:11px 'DM Mono',monospace}footer span{color:var(--lime);padding:0 8px}@media(max-width:760px){.topbar{height:64px}.status-dot{display:none}.content{padding-top:70px}.workspace{grid-template-columns:1fr;margin-top:55px}h1{font-size:54px}}
|
| 4 |
.job-card,.result-card,.finding{margin-top:14px;border:1px solid rgba(255,255,255,.12);border-radius:14px;padding:14px;background:rgba(255,255,255,.04)}
|
| 5 |
.job-card{display:flex;justify-content:space-between;align-items:center;font-size:.85rem}.pill,.severity,.category{font-size:.72rem;text-transform:uppercase;letter-spacing:.08em;border-radius:999px;padding:4px 8px;background:rgba(255,255,255,.1)}
|
| 6 |
+
.result-title{display:flex;justify-content:space-between;align-items:flex-start;color:#d6ff70}.result-title h3{margin:5px 0 0;font-size:1.1rem}.score{font-size:1.35rem}.result-card p{margin:10px 0;color:#c1c8bc;line-height:1.55}.verdict{border-left:3px solid #c7f36b}.verdict.blocking{border-left-color:#ff9f8d}.metrics{display:flex;gap:14px;flex-wrap:wrap;color:#949a91;font:11px 'DM Mono',monospace;text-transform:uppercase}.section-heading{display:flex;justify-content:space-between;align-items:center;margin-top:22px}.section-heading h3{margin:0;font-size:1rem}.section-heading span{color:#c7f36b;font:12px 'DM Mono',monospace}.finding{background:rgba(255,255,255,.025)}.finding-meta{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:8px}.finding-location{margin-left:auto;color:#c7f36b;font:11px 'DM Mono',monospace}.severity{color:#ffb3a7}.severity.low,.severity.info{color:#c7f36b}.category{color:#c0c8ba}.finding p{margin:8px 0;color:#c1c8bc;line-height:1.45}.finding small,.result-card small,.job-card small{display:block;color:#949a91;margin-top:6px}.job-card small{font-size:.72rem}.actions{display:flex;gap:10px;margin-top:14px}.actions button{margin:0}.actions .secondary{background:transparent;border:1px solid rgba(255,255,255,.2);color:#e8e9e5}.message{border-radius:10px;padding:11px 13px;margin-top:14px;font-size:13px;line-height:1.45}.message.success{color:#c7f36b;background:#c7f36b12}.message.error,.error.detail{color:#ff9f8d;background:#ff9f8d12}.progress{margin-top:15px;padding:12px;border:1px solid #30352f;border-radius:10px;color:#949a91}.progress span{display:block;height:3px;background:linear-gradient(90deg,transparent,#c7f36b,transparent);background-size:200% 100%;animation:load 1.4s linear infinite}.progress small{display:block;margin-top:8px}.empty-result{margin-top:14px;border:1px dashed #3b4438;padding:16px;color:#949a91;display:grid;gap:5px}.empty-result strong{color:#c7f36b}@keyframes load{to{background-position:-200% 0}}
|
nodes/executor.py
CHANGED
|
@@ -208,12 +208,12 @@ def executor_node(state: OpenCodeReviewState) -> dict:
|
|
| 208 |
"""
|
| 209 |
if not state.human_approved:
|
| 210 |
logger.info("Not approved \u2014 skipping executor")
|
| 211 |
-
return {}
|
| 212 |
|
| 213 |
parts = state.repo.split("/")
|
| 214 |
if len(parts) != 2:
|
| 215 |
logger.warning("Cannot post results: invalid repo '%s'", state.repo)
|
| 216 |
-
return {}
|
| 217 |
owner, repo_name = parts
|
| 218 |
pr_number = state.pr_number
|
| 219 |
|
|
@@ -234,7 +234,7 @@ def executor_node(state: OpenCodeReviewState) -> dict:
|
|
| 234 |
f.file_path, f.line_start, f.line_end,
|
| 235 |
f.severity.value, f.comment[:60],
|
| 236 |
)
|
| 237 |
-
return {}
|
| 238 |
|
| 239 |
# ββ 1. Fetch latest head SHA βββββββββββββββββββββββββββββββββββββββββ
|
| 240 |
commit_id = _fetch_pr_head_sha(owner, repo_name, pr_number)
|
|
@@ -281,9 +281,10 @@ def executor_node(state: OpenCodeReviewState) -> dict:
|
|
| 281 |
fallback_ok += 1
|
| 282 |
|
| 283 |
# ββ 3. Post the verdict ββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 284 |
if state.verdict:
|
| 285 |
verdict_body = _verdict_body(state.verdict.model_dump())
|
| 286 |
-
_post_issue_comment(owner, repo_name, pr_number, verdict_body)
|
| 287 |
|
| 288 |
total = len(state.final_findings)
|
| 289 |
logger.info(
|
|
@@ -293,4 +294,25 @@ def executor_node(state: OpenCodeReviewState) -> dict:
|
|
| 293 |
"posted" if state.verdict else "skipped",
|
| 294 |
owner, repo_name, pr_number,
|
| 295 |
)
|
| 296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
"""
|
| 209 |
if not state.human_approved:
|
| 210 |
logger.info("Not approved \u2014 skipping executor")
|
| 211 |
+
return {"posting_result": {"status": "skipped", "reason": "not_approved"}}
|
| 212 |
|
| 213 |
parts = state.repo.split("/")
|
| 214 |
if len(parts) != 2:
|
| 215 |
logger.warning("Cannot post results: invalid repo '%s'", state.repo)
|
| 216 |
+
return {"posting_result": {"status": "failed", "reason": "invalid_repo"}}
|
| 217 |
owner, repo_name = parts
|
| 218 |
pr_number = state.pr_number
|
| 219 |
|
|
|
|
| 234 |
f.file_path, f.line_start, f.line_end,
|
| 235 |
f.severity.value, f.comment[:60],
|
| 236 |
)
|
| 237 |
+
return {"posting_result": {"status": "dry_run", "inline_posted": 0, "fallback_posted": 0, "failed": len(state.final_findings)}}
|
| 238 |
|
| 239 |
# ββ 1. Fetch latest head SHA βββββββββββββββββββββββββββββββββββββββββ
|
| 240 |
commit_id = _fetch_pr_head_sha(owner, repo_name, pr_number)
|
|
|
|
| 281 |
fallback_ok += 1
|
| 282 |
|
| 283 |
# ββ 3. Post the verdict ββββββββββββββββββββββββββββββββββββββββββββββ
|
| 284 |
+
verdict_posted = False
|
| 285 |
if state.verdict:
|
| 286 |
verdict_body = _verdict_body(state.verdict.model_dump())
|
| 287 |
+
verdict_posted = _post_issue_comment(owner, repo_name, pr_number, verdict_body)
|
| 288 |
|
| 289 |
total = len(state.final_findings)
|
| 290 |
logger.info(
|
|
|
|
| 294 |
"posted" if state.verdict else "skipped",
|
| 295 |
owner, repo_name, pr_number,
|
| 296 |
)
|
| 297 |
+
failed = total - inline_ok - fallback_ok
|
| 298 |
+
# A review is fully posted only when every finding and the verdict were
|
| 299 |
+
# accepted by GitHub. Keep the per-part counts so the API/UI can explain a
|
| 300 |
+
# partial result instead of reporting a misleading success.
|
| 301 |
+
successful_parts = inline_ok + fallback_ok + int(verdict_posted)
|
| 302 |
+
expected_parts = total + int(state.verdict is not None)
|
| 303 |
+
if expected_parts == 0:
|
| 304 |
+
status = "posted"
|
| 305 |
+
elif successful_parts == expected_parts:
|
| 306 |
+
status = "posted"
|
| 307 |
+
elif successful_parts:
|
| 308 |
+
status = "partially_posted"
|
| 309 |
+
else:
|
| 310 |
+
status = "post_failed"
|
| 311 |
+
return {"posting_result": {
|
| 312 |
+
"status": status,
|
| 313 |
+
"total_findings": total,
|
| 314 |
+
"inline_posted": inline_ok,
|
| 315 |
+
"fallback_posted": fallback_ok,
|
| 316 |
+
"failed": failed,
|
| 317 |
+
"verdict_posted": verdict_posted,
|
| 318 |
+
}}
|