diff --git a/web-ui/src/components/precedents/extracted-halachot.tsx b/web-ui/src/components/precedents/extracted-halachot.tsx index cdcafeb..28281f1 100644 --- a/web-ui/src/components/precedents/extracted-halachot.tsx +++ b/web-ui/src/components/precedents/extracted-halachot.tsx @@ -78,9 +78,21 @@ export function ExtractedHalachotSection({ halachot }: { halachot: Halacha[] }) if (filter === "pending") return h.review_status === "pending_review"; return h.review_status === "rejected"; }; + /* Surface citation-corroborated halachot first: any with a badge + * (positive count or a negative treatment) float to the top, ordered + * by corroboration strength; the rest keep document order by index. */ + const hasTag = (h: Halacha) => + (h.corroboration_count ?? 0) > 0 || (h.corroboration_negative ?? false); return halachot .filter(matches) - .sort((a, b) => a.halacha_index - b.halacha_index); + .sort((a, b) => { + const tagDelta = Number(hasTag(b)) - Number(hasTag(a)); + if (tagDelta !== 0) return tagDelta; + const countDelta = + (b.corroboration_count ?? 0) - (a.corroboration_count ?? 0); + if (countDelta !== 0) return countDelta; + return a.halacha_index - b.halacha_index; + }); }, [halachot, filter]); if (!halachot.length) {