Compare commits
7 Commits
worktree-c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ffa02ca83c | |||
| ca1f0e8c66 | |||
| 8c455d6ef6 | |||
| f9ef664ac9 | |||
| 532bef04a7 | |||
| 639779e6a9 | |||
| 676ae4532b |
@@ -115,6 +115,10 @@ async def main(args: argparse.Namespace) -> int:
|
||||
print(f"judges available — deepseek:{bool(DEEPSEEK_KEY)} gemini:{bool(GEMINI_KEY)} "
|
||||
f"claude:local\n", flush=True)
|
||||
pending = await db.list_halachot(review_status="pending_review", limit=5000)
|
||||
if args.case_number:
|
||||
want = args.case_number.strip()
|
||||
pending = [h for h in pending if (h.get("case_number") or "").strip() == want]
|
||||
print(f"scoped to case {want}: {len(pending)} pending halachot\n", flush=True)
|
||||
if args.limit:
|
||||
pending = pending[: args.limit]
|
||||
|
||||
@@ -306,6 +310,9 @@ if __name__ == "__main__":
|
||||
ap = argparse.ArgumentParser(description=__doc__,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
ap.add_argument("--limit", type=int, default=0)
|
||||
ap.add_argument("--case-number", default="",
|
||||
help="scope the panel to a single case's pending halachot "
|
||||
"(e.g. 8508-03-24); applied before --limit")
|
||||
ap.add_argument("--concurrency", type=int, default=6)
|
||||
ap.add_argument("--apply", action="store_true",
|
||||
help="write the agreed verdicts (reversible, CSV-backed); default dry-run")
|
||||
|
||||
@@ -614,6 +614,8 @@ function HalachaRestoreCard({
|
||||
))}
|
||||
</div>
|
||||
|
||||
{h.panel_round && <PanelDeliberation round={h.panel_round} />}
|
||||
|
||||
<div className="flex items-center gap-2 justify-end pt-1 border-t border-rule-soft">
|
||||
<Button size="sm" variant="ghost"
|
||||
onClick={secondaryAction}
|
||||
@@ -708,7 +710,14 @@ function RestorePanel({
|
||||
secondaryLabel: string;
|
||||
getSecondaryStatus: () => "approved" | "rejected" | "pending_review";
|
||||
}) {
|
||||
const { data, isPending, error } = useHalachotByStatus(status);
|
||||
const [searchInput, setSearchInput] = useState("");
|
||||
const [search, setSearch] = useState("");
|
||||
useEffect(() => {
|
||||
const t = setTimeout(() => setSearch(searchInput.trim()), 300);
|
||||
return () => clearTimeout(t);
|
||||
}, [searchInput]);
|
||||
|
||||
const { data, isPending, error } = useHalachotByStatus(status, { search });
|
||||
const update = useUpdateHalacha();
|
||||
const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set());
|
||||
|
||||
@@ -716,6 +725,8 @@ function RestorePanel({
|
||||
() => buildGroups(data?.items ?? []),
|
||||
[data],
|
||||
);
|
||||
const searching = search.length > 0;
|
||||
const matchCount = data?.count ?? 0;
|
||||
|
||||
const restore = async (h: Halacha, newStatus: "approved" | "rejected" | "pending_review") => {
|
||||
try {
|
||||
@@ -735,31 +746,19 @@ function RestorePanel({
|
||||
});
|
||||
};
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
const body = error ? (
|
||||
<div className="rounded bg-danger-bg border border-danger/40 px-6 py-5 text-danger text-center">
|
||||
{error.message}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isPending) {
|
||||
return (
|
||||
) : isPending ? (
|
||||
<div className="space-y-3">
|
||||
{[...Array(3)].map((_, i) => <Skeleton key={i} className="h-24 w-full" />)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!groups.length) {
|
||||
return (
|
||||
) : !groups.length ? (
|
||||
<div className="text-center text-ink-muted py-16">
|
||||
<p className="text-lg">אין הלכות בסטטוס זה.</p>
|
||||
<p className="text-lg">{searching ? "אין התאמות לחיפוש." : "אין הלכות בסטטוס זה."}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
{groups.map((g) => {
|
||||
const isOpen = expandedIds.has(g.caseLawId);
|
||||
@@ -813,6 +812,54 @@ function RestorePanel({
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
{/* Locate bar — reach any item in this status, not only the top window */}
|
||||
<div className="flex items-center gap-2.5 rounded-lg border border-rule bg-surface px-3.5 py-2.5 shadow-sm">
|
||||
<Search className="w-4 h-4 text-ink-muted shrink-0" />
|
||||
<input
|
||||
value={searchInput}
|
||||
onChange={(e) => setSearchInput(e.target.value)}
|
||||
placeholder="חיפוש — מספר פס״ד, שם-תיק או נוסח-הלכה"
|
||||
dir="rtl"
|
||||
className="flex-1 bg-transparent border-0 outline-none text-sm text-ink placeholder:text-ink-muted"
|
||||
/>
|
||||
{searchInput && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setSearchInput("")}
|
||||
className="shrink-0 w-5 h-5 rounded-full bg-rule-soft text-ink-muted hover:text-navy
|
||||
flex items-center justify-center text-[0.7rem]"
|
||||
title="נקה"
|
||||
>
|
||||
<X className="w-3 h-3" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{searching && !isPending && !error && (
|
||||
<div className="flex items-center gap-2 flex-wrap rounded-lg border border-gold/50 bg-gold-wash px-3.5 py-2.5 text-sm text-navy">
|
||||
<span>מציג עבור</span>
|
||||
<span className="rounded bg-navy text-parchment text-[0.78rem] font-semibold px-2 py-0.5">
|
||||
{search}
|
||||
</span>
|
||||
<span className="text-ink-muted">
|
||||
· {matchCount} {matchCount === 1 ? "התאמה" : "התאמות"}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setSearchInput("")}
|
||||
className="ms-auto text-gold-deep font-semibold text-[0.8rem] underline hover:no-underline"
|
||||
>
|
||||
נקה חיפוש
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{body}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Pending queue panel (main review flow) ───────────────────────────────────
|
||||
|
||||
@@ -646,21 +646,43 @@ export function useHalachotPending(opts: { limit?: number; search?: string } = {
|
||||
});
|
||||
}
|
||||
|
||||
/** Genuine extraction defects — the rule TEXT is malformed, so it needs re-extraction
|
||||
* (not a chair keep/drop judgment). Mirrors the backend's DEFECT set in
|
||||
* scripts/halacha_panel_approve.py; other flags (e.g. `application` = fact-specific
|
||||
* application) are judgment signals, NOT defects, and the panel deliberately skips them. */
|
||||
const EXTRACTION_DEFECT_FLAGS = new Set([
|
||||
"quote_unverified",
|
||||
"truncated_quote",
|
||||
"thin_restatement",
|
||||
"near_duplicate",
|
||||
]);
|
||||
|
||||
/** A pending item belongs in the "needs extraction fix" segment when it carries a
|
||||
* quality flag AND the panel never deliberated it (no round). Everything else —
|
||||
* deliberated items and clean items — is a chair-judgment item. (#133 unified queue) */
|
||||
* genuine extraction-DEFECT flag AND the panel never deliberated it (no round).
|
||||
* Everything else — deliberated items, clean items, and items flagged only for
|
||||
* chair judgment (e.g. `application`) — is a chair-judgment item. (#133 unified queue) */
|
||||
export function isExtractionFixItem(h: Halacha): boolean {
|
||||
return !h.panel_round && (h.quality_flags?.length ?? 0) > 0;
|
||||
return (
|
||||
!h.panel_round &&
|
||||
(h.quality_flags ?? []).some((f) => EXTRACTION_DEFECT_FLAGS.has(f))
|
||||
);
|
||||
}
|
||||
|
||||
export function useHalachotByStatus(status: string, limit = 300) {
|
||||
export function useHalachotByStatus(
|
||||
status: string,
|
||||
opts: { limit?: number; search?: string } = {},
|
||||
) {
|
||||
const { limit = 300, search = "" } = opts;
|
||||
const term = search.trim();
|
||||
// include_panel_round surfaces the 3-judge deliberation on these tabs too
|
||||
// (same card as the pending queue), so the chair sees WHY an item was
|
||||
// auto-rejected/approved; search locates an item server-side beyond the window.
|
||||
const qs = `review_status=${encodeURIComponent(status)}&include_panel_round=true&limit=${limit}`
|
||||
+ (term ? `&search=${encodeURIComponent(term)}` : "");
|
||||
return useQuery({
|
||||
queryKey: libraryKeys.halachot({ review_status: status, limit: String(limit) }),
|
||||
queryKey: libraryKeys.halachot({ review_status: status, limit: String(limit), search: term }),
|
||||
queryFn: ({ signal }) =>
|
||||
apiRequest<{ items: Halacha[]; count: number }>(
|
||||
`/api/halachot?review_status=${encodeURIComponent(status)}&limit=${limit}`,
|
||||
{ signal },
|
||||
),
|
||||
apiRequest<{ items: Halacha[]; count: number }>(`/api/halachot?${qs}`, { signal }),
|
||||
staleTime: 10_000,
|
||||
refetchOnMount: "always",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user