From 266b9dfad39ffc9fc02cd1298db270a390111ea8 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Sat, 28 Feb 2026 21:13:26 +0100 Subject: [PATCH] Fix PDF 404: default to bp_compliance_ce collection, add PDF existence check Default collection changed from bp_compliance_gesetze (DE/AT/CH laws where PDFs need manual download) to bp_compliance_ce (EU regulations where PDFs are auto-downloaded). Added HEAD request check so missing PDFs show a clear "PDF nicht vorhanden" message instead of a 404 in the iframe. Co-Authored-By: Claude Opus 4.6 --- .../ai/rag/components/ChunkBrowserQA.tsx | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/admin-lehrer/app/(admin)/ai/rag/components/ChunkBrowserQA.tsx b/admin-lehrer/app/(admin)/ai/rag/components/ChunkBrowserQA.tsx index 854a8f3..2a48a3a 100644 --- a/admin-lehrer/app/(admin)/ai/rag/components/ChunkBrowserQA.tsx +++ b/admin-lehrer/app/(admin)/ai/rag/components/ChunkBrowserQA.tsx @@ -53,8 +53,11 @@ export function ChunkBrowserQA({ apiProxy }: ChunkBrowserQAProps) { const [splitViewActive, setSplitViewActive] = useState(true) const [chunksPerPage, setChunksPerPage] = useState(6) - // Collection - const [collection, setCollection] = useState('bp_compliance_gesetze') + // Collection — default to bp_compliance_ce where we have PDFs downloaded + const [collection, setCollection] = useState('bp_compliance_ce') + + // PDF existence check + const [pdfExists, setPdfExists] = useState(null) // Sidebar collapsed groups const [collapsedGroups, setCollapsedGroups] = useState>(new Set()) @@ -204,6 +207,17 @@ export function ChunkBrowserQA({ apiProxy }: ChunkBrowserQAProps) { const pdfMapping = selectedRegulation ? RAG_PDF_MAPPING[selectedRegulation] : null const pdfUrl = pdfMapping ? `/rag-originals/${pdfMapping.filename}#page=${pdfPage}` : null + // Check PDF existence when regulation changes + useEffect(() => { + if (!selectedRegulation) { setPdfExists(null); return } + const mapping = RAG_PDF_MAPPING[selectedRegulation] + if (!mapping) { setPdfExists(false); return } + const url = `/rag-originals/${mapping.filename}` + fetch(url, { method: 'HEAD' }) + .then(res => setPdfExists(res.ok)) + .catch(() => setPdfExists(false)) + }, [selectedRegulation]) + // Handlers const handleSelectRegulation = (code: string) => { setSelectedRegulation(code) @@ -602,7 +616,7 @@ export function ChunkBrowserQA({ apiProxy }: ChunkBrowserQAProps) {
- {pdfUrl ? ( + {pdfUrl && pdfExists ? (