Description
The DiagnosticCard component renders after the user clicks Analyze. Two sections: Baseline Metrics (retrieval relevance, answer faithfulness) and Forensics (retrieval distribution, hedging mismatch, chunk attribution, confidence calibration).
The chunk attribution section is the most visually distinctive element: the generated answer rendered as sentence-by-sentence annotated text, each sentence color-coded by source chunk or flagged red if unattributed.
Implementation details
components/DiagnosticCard.tsx
- Props: full
AnalyzeResponse
- Show
question and generated_answer at top before sections
- Two labeled sections with visual separation
- Each dimension: human-readable label, color-coded verdict badge (green/amber/red), explanation, evidence as styled blockquotes
- Chunk attribution: render
attribution_map as annotated answer — consistent color per chunk_id, red highlight for unattributed, hover tooltip showing chunk_id + similarity score
- Overall summary banner reflecting worst verdict
- Tailwind only, no external component library
Acceptance criteria
TDD
frontend/__tests__/DiagnosticCard.test.tsx:
- Renders question and generated answer text
- Both section headers present
- pass → green badge class, warn → amber, fail → red
- Attribution renders one element per sentence
- Unattributed sentences have red highlight class
- Summary says 'Issues detected' when any dimension is fail
- Renders without crash when evidence is empty
Description
The
DiagnosticCardcomponent renders after the user clicks Analyze. Two sections: Baseline Metrics (retrieval relevance, answer faithfulness) and Forensics (retrieval distribution, hedging mismatch, chunk attribution, confidence calibration).The chunk attribution section is the most visually distinctive element: the generated answer rendered as sentence-by-sentence annotated text, each sentence color-coded by source chunk or flagged red if unattributed.
Implementation details
components/DiagnosticCard.tsxAnalyzeResponsequestionandgenerated_answerat top before sectionsattribution_mapas annotated answer — consistent color per chunk_id, red highlight for unattributed, hover tooltip showing chunk_id + similarity scoreAcceptance criteria
TDD
frontend/__tests__/DiagnosticCard.test.tsx: