The Atlas doc.haus documentation, bound to its code
108 documents

How a question becomes a cited answer

Follow one question — "What is the cap on the firm's liability?" — from the qa agent through local embeddings to a verified [Document § 9] citation in the browser.

apps/web/src/components/CitationView.tsx28 lines · CitationView L3–27
Outline 1 symbols
1import type { Citation } from "../api/opencode"
2
3export default function CitationView({ citations }: { citations: Citation[] }) {
4 if (citations.length === 0) return null
5 // A turn's searches return the same section many times over; the reader needs
6 // each distinct source once, not the raw retrieval dump. Keep the best-scoring
7 // hit per document+section and tuck them behind a collapsed "Sources" line so
8 // the answer stays the focus — the compact source list Harvey and Legora show.
9 const best = new Map<string, Citation>()
10 for (const c of [...citations].sort((a, b) => a.score - b.score)) best.set(`${c.documentName}§${c.section}`, c)
11 const unique = [...best.values()].sort((a, b) => b.score - a.score)
12 return (
13 <details className="sources">
14 <summary>
15 Sources ({unique.length})
16 </summary>
17 {unique.map((c, i) => (
18 <div className="citation" key={`${c.docPath}-${c.charStart}-${i}`}>
19 <div className="ref">
20 [{c.documentName} § {c.section}]
21 </div>
22 <div className="excerpt">{c.excerpt}</div>
23 </div>
24 ))}
25 </details>
26 )
27}
28