feat(digests): Phase 2 — API endpoints + /digests UI (X12)
משטחי-משתמש לקורפוס היומונים: endpoints ב-FastAPI + דף UI נפרד /digests (לדפדוף, חיפוש, העלאה, וקישור לפסק המקורי). היומון נשאר מקור-משני המצביע על הפסק — אינו מצוטט בהחלטה (INV-DIG1) ואינו מחלץ הלכות (INV-DIG2). Backend (container-safe + local split): - digest_library: פוצל ל-create_pending_digest (CONTAINER-SAFE: stage+ extract_text+create row 'pending', בלי LLM) ↔ enrich_digest/ process_pending_digests (local: LLM+embed+autolink). ingest_digest מאחד. - db.list_pending_digests; MCP digest_process_pending (tool+server) — חלופה ל-batch script לריקון התור. - web/app.py: 10 endpoints /api/digests/* (upload/list/search/queue-pending/ get/patch/delete/link/relink/unlink). upload=INSERT-only pending (ה-LLM רץ מקומית — claude_session local-only). כולם מחזירים dict בדפוס precedent. Frontend (Next 16, ללא api:types — hooks עם טיפוסים hand-written כמו precedent-library.ts): - lib/api/digests.ts — hooks (useDigests/useDigestSearch/useDigestPending/ useUploadDigest/useLink/Relink/Unlink/Delete/Update). - דף /digests נפרד (לא כרטיסייה ב-/precedents — לשמור גבול סמכותי/משני, INV-DIG1): טאבים יומונים/חיפוש + DigestCard (badge קישור-לפסק) + DigestUploadDialog + pending badge. nav + header-context. אומת: backend round-trip מלא (create_pending→list_pending→process_pending→ search→restore); web-ui מתקמפל (webpack/tsc נקי, route /digests נוצר). הערה: build דיפולטי (turbopack) נכשל ב-worktree עקב symlink ל-node_modules — ב-CI/Docker (node_modules אמיתי) עובד; אומת עם --webpack. Invariants: מקיים INV-DIG1/2 (upload לא מחלץ הלכות, UI מציג "מצביע לא מצוטט"), INV-DIG3 (link/relink/queue). G4 (אין בליעה — שגיאות→toast/HTTP), G2 (מסלול נפרד, לא מקביל). X6 (חוזה UI↔API — endpoints בדפוס precedent; hooks hand-written כמו שאר ה-domain modules). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
95
web-ui/src/components/digests/digest-search-panel.tsx
Normal file
95
web-ui/src/components/digests/digest-search-panel.tsx
Normal file
@@ -0,0 +1,95 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Search } from "lucide-react";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
Select, SelectContent, SelectItem, SelectTrigger, SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { useDigestSearch } from "@/lib/api/digests";
|
||||
import type { PracticeArea } from "@/lib/api/precedent-library";
|
||||
import { PRACTICE_AREAS } from "@/components/precedents/practice-area";
|
||||
import { DigestCard } from "./digest-card";
|
||||
|
||||
export function DigestSearchPanel() {
|
||||
const [draft, setDraft] = useState("");
|
||||
const [query, setQuery] = useState("");
|
||||
const [practiceArea, setPracticeArea] = useState<PracticeArea>("");
|
||||
|
||||
const { data, isFetching, error } = useDigestSearch(query, {
|
||||
practiceArea: practiceArea || undefined,
|
||||
limit: 20,
|
||||
});
|
||||
|
||||
const onSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setQuery(draft.trim());
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<form onSubmit={onSubmit} className="flex items-end gap-3 flex-wrap">
|
||||
<div className="flex-1 min-w-[300px]">
|
||||
<label className="text-[0.78rem] text-ink-muted">שאילתת חיפוש</label>
|
||||
<Input
|
||||
value={draft}
|
||||
onChange={(e) => setDraft(e.target.value)}
|
||||
placeholder="שיקול דעת הוועדה המחוזית בהקלה"
|
||||
dir="rtl"
|
||||
/>
|
||||
</div>
|
||||
<div className="min-w-[180px]">
|
||||
<label className="text-[0.78rem] text-ink-muted">תחום</label>
|
||||
<Select
|
||||
value={practiceArea || "_all"}
|
||||
onValueChange={(v) => setPracticeArea(v === "_all" ? "" : (v as PracticeArea))}
|
||||
>
|
||||
<SelectTrigger><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="_all">הכל</SelectItem>
|
||||
{PRACTICE_AREAS.map((a) => (
|
||||
<SelectItem key={a.value} value={a.value}>{a.label}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<Button type="submit" className="bg-navy text-parchment hover:bg-navy-soft">
|
||||
<Search className="w-4 h-4 me-1" />
|
||||
חפש
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<p className="text-[0.78rem] text-ink-muted">
|
||||
חיפוש סמנטי ב-radar היומונים. כל תוצאה מצביעה על פסק דין מקורי —
|
||||
הצטט מהפסק עצמו (ספריית הפסיקה), לא מהיומון.
|
||||
</p>
|
||||
|
||||
{!query.trim() ? (
|
||||
<div className="text-center text-ink-muted py-12">
|
||||
הקלד שאילתא כדי לחפש ביומונים. החיפוש סמנטי — לא טקסטואלי.
|
||||
</div>
|
||||
) : error ? (
|
||||
<div className="rounded bg-danger-bg border border-danger/40 px-6 py-5 text-danger text-center">
|
||||
{error.message}
|
||||
</div>
|
||||
) : isFetching ? (
|
||||
<div className="space-y-3">
|
||||
{[...Array(3)].map((_, i) => <Skeleton key={i} className="h-32 w-full" />)}
|
||||
</div>
|
||||
) : !data?.items.length ? (
|
||||
<div className="text-center text-ink-muted py-12">
|
||||
לא נמצאו יומונים תואמים. נסה ניסוח אחר.
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
<p className="text-[0.78rem] text-ink-muted">{data.count} תוצאות</p>
|
||||
{data.items.map((hit) => (
|
||||
<DigestCard key={hit.id} digest={hit} score={hit.score} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user