feat(dse): kuratierter DSEAgent + Snapshot-Tab (Art. 13/14, kein Firehose)
DSEAgent wrappt die existierende ART13_CHECKLIST (33 kuratierte Pflichtangaben
L1 + Detailchecks L2) → strukturierter AgentOutput, NICHT der 90k-Library-
Firehose (eCall/Gesundheit/Telekom-Lärm). GET /snapshots/{id}/dse-check spiegelt
impressum-check; doc_input_from_snapshot generalisiert. Frontend: generischer
AgentModuleTab (lazy → AgentResultTab) für Impressum + DSE; DSE-Tab in der
Snapshot-Seite. Plus HRB-Pattern \d→\d+ (volle Registernummer als Beleg).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
'use client'
|
||||
|
||||
/**
|
||||
* AgentModuleTab — generischer Snapshot-Modul-Tab für einen Doc-Type-Agenten
|
||||
* (Impressum, DSE, …). Lädt `/snapshots/{id}/{docType}-check` beim Mounten
|
||||
* (kein Re-Crawl) und rendert den AgentOutput im geteilten AgentResultTab.
|
||||
* Wird nur gemountet, wenn der Tab aktiv ist → Analyse läuft on-demand.
|
||||
*/
|
||||
|
||||
import React, { useEffect, useState } from 'react'
|
||||
|
||||
import { AgentResultTab } from './AgentResultTab'
|
||||
|
||||
export function AgentModuleTab(
|
||||
{ snapshotId, docType, label }:
|
||||
{ snapshotId: string; docType: string; label: string },
|
||||
) {
|
||||
const [data, setData] = useState<any>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
setLoading(true)
|
||||
fetch(`/api/sdk/v1/agent/snapshots/${snapshotId}/${docType}-check`)
|
||||
.then(r => r.json())
|
||||
.then(d => { if (!cancelled) setData(d) })
|
||||
.catch(() => {
|
||||
if (!cancelled) setData({ error: `${label}-Analyse fehlgeschlagen`, findings: [] })
|
||||
})
|
||||
.finally(() => { if (!cancelled) setLoading(false) })
|
||||
return () => { cancelled = true }
|
||||
}, [snapshotId, docType, label])
|
||||
|
||||
if (loading) return <div className="text-sm text-gray-500">{label}-Analyse läuft…</div>
|
||||
if (data?.error) return <div className="text-sm text-red-600">{data.error}</div>
|
||||
if (data && ((data.findings?.length ?? 0) > 0 || (data.mc_coverage?.length ?? 0) > 0)) {
|
||||
return <AgentResultTab topicLabel={label} output={data} />
|
||||
}
|
||||
return (
|
||||
<div className="text-sm text-gray-500">
|
||||
{data?.notes || `Keine ${label}-Auswertung verfügbar.`}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -3,8 +3,9 @@
|
||||
/**
|
||||
* Snapshot-Detail — öffnet einen gespeicherten Check aus der Historie und
|
||||
* zeigt die Ergebnis-Views aus den Rohdaten (kein Re-Crawl), als Modul-Tabs:
|
||||
* Cookies & Tracking + Impressum (DSE/AGB folgen). Impressum wird beim Öffnen
|
||||
* des Tabs nachgeladen (ImpressumAgent auf dem gespeicherten Text).
|
||||
* Cookies & Tracking + Impressum + Datenschutzerklärung (AGB folgen).
|
||||
* Doc-Agenten (Impressum/DSE) laufen beim Öffnen des Tabs auf dem gespeicherten
|
||||
* Text — generisch via AgentModuleTab.
|
||||
*/
|
||||
|
||||
import React, { use as useUnwrap, useEffect, useMemo, useState } from 'react'
|
||||
@@ -12,7 +13,7 @@ import Link from 'next/link'
|
||||
|
||||
import { CookieLibraryPanel } from '../../_components/CookieLibraryPanel'
|
||||
import { CookieResultView } from '../../_components/CookieResultView'
|
||||
import { AgentResultTab } from '../../_components/AgentResultTab'
|
||||
import { AgentModuleTab } from '../../_components/AgentModuleTab'
|
||||
|
||||
export default function SnapshotDetail(
|
||||
{ params }: { params: Promise<{ snapshotId: string }> },
|
||||
@@ -20,8 +21,6 @@ export default function SnapshotDetail(
|
||||
const { snapshotId } = useUnwrap(params)
|
||||
const [snap, setSnap] = useState<any>(null)
|
||||
const [check, setCheck] = useState<any>(null) // cookie-check
|
||||
const [impressum, setImpressum] = useState<any>(null) // impressum-check (lazy)
|
||||
const [impLoading, setImpLoading] = useState(false)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [tab, setTab] = useState<string>('')
|
||||
@@ -51,29 +50,20 @@ export default function SnapshotDetail(
|
||||
|
||||
const docs = snap?.doc_entries || []
|
||||
const hasCookies = (snap?.cmp_vendors?.length ?? 0) > 0
|
||||
const hasImpressum = docs.some(
|
||||
(e: any) => e.doc_type === 'impressum' && (e.text || e.content || '').length > 100)
|
||||
const hasDoc = (dt: string) => docs.some(
|
||||
(e: any) => e.doc_type === dt && (e.text || e.content || '').length > 100)
|
||||
|
||||
const modules = useMemo(() => [
|
||||
...(hasCookies ? [{ key: 'cookie', label: 'Cookies & Tracking' }] : []),
|
||||
...(hasImpressum ? [{ key: 'impressum', label: 'Impressum' }] : []),
|
||||
], [hasCookies, hasImpressum])
|
||||
...(hasDoc('impressum') ? [{ key: 'impressum', label: 'Impressum' }] : []),
|
||||
...(hasDoc('dse') ? [{ key: 'dse', label: 'Datenschutzerklärung' }] : []),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
], [snap])
|
||||
|
||||
useEffect(() => {
|
||||
if (!tab && modules.length) setTab(modules[0].key)
|
||||
}, [modules, tab])
|
||||
|
||||
// Impressum erst beim Öffnen des Tabs analysieren (ImpressumAgent, ggf. LLM).
|
||||
useEffect(() => {
|
||||
if (tab !== 'impressum' || impressum || impLoading) return
|
||||
setImpLoading(true)
|
||||
fetch(`/api/sdk/v1/agent/snapshots/${snapshotId}/impressum-check`)
|
||||
.then(r => r.json())
|
||||
.then(setImpressum)
|
||||
.catch(() => setImpressum({ error: 'Impressum-Analyse fehlgeschlagen', findings: [] }))
|
||||
.finally(() => setImpLoading(false))
|
||||
}, [tab, snapshotId, impressum, impLoading])
|
||||
|
||||
const tabBtn = (key: string, label: string) => (
|
||||
<button key={key} onClick={() => setTab(key)}
|
||||
className={`px-3 py-1.5 text-sm border-b-2 -mb-px ${tab === key ? 'border-blue-600 text-blue-700 font-medium' : 'border-transparent text-gray-500 hover:text-gray-700'}`}>
|
||||
@@ -108,17 +98,11 @@ export default function SnapshotDetail(
|
||||
)}
|
||||
|
||||
{tab === 'impressum' && (
|
||||
impLoading ? (
|
||||
<div className="text-sm text-gray-500">Impressum-Analyse läuft…</div>
|
||||
) : impressum?.error ? (
|
||||
<div className="text-sm text-red-600">{impressum.error}</div>
|
||||
) : impressum && (impressum.findings?.length || impressum.mc_coverage?.length) ? (
|
||||
<AgentResultTab topicLabel="Impressum" output={impressum} />
|
||||
) : impressum ? (
|
||||
<div className="text-sm text-gray-500">
|
||||
{impressum.notes || 'Keine Impressum-Auswertung verfügbar.'}
|
||||
</div>
|
||||
) : null
|
||||
<AgentModuleTab snapshotId={snapshotId} docType="impressum" label="Impressum" />
|
||||
)}
|
||||
|
||||
{tab === 'dse' && (
|
||||
<AgentModuleTab snapshotId={snapshotId} docType="dse" label="Datenschutzerklärung" />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user