Retrieved Context Chunks
The RAG debugging surface: ranked passages with similarity as a meter, matched spans in real mark elements, and filter chips wired as a radiogroup so arrows move between them.
Retrieved sources ranked by how stale they are, because a confident answer from a two-year-old document is the failure people do not catch.
components/retrieval-freshness-list.tsxnpx hoverlab add retrieval-freshness-list
Or over MCP, from your editor's agent — no account needed.
Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.
Start a page with this section — add more, order them, and leave with the page source.
Relevance ranking says which document matched. It says nothing about whether the document is still true, and that is the question a reader has once the answer surprises them.
Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.
'use client'
/**
* <RetrievalFreshnessList> — Retrieved sources ranked by how stale they are, because a confident answer from a two-year-old document is the failure people do not catch.
*
* Relevance ranking answers which document matched. Nothing in a retrieval
* UI answers whether the document is still true, and that is the failure
* nobody catches — a confident, well-cited answer drawn from a two-year-old
* migration note. The layout problem is that freshness is a second axis on
* a list already sorted by relevance, and the obvious wrong answer is to
* sort by date instead, which promotes a fresh irrelevant source over a
* stale central one.
*
* So the order stays as retrieved and age is the badge. The reader sees
* relevance in the ordering and staleness in the pill, which is both axes at
* once without either overriding the other.
*
* The last row is deliberately one that was excluded. A freshness panel that
* only lists what was used cannot show its own judgement; the two-year-old
* note is there to say that something was considered and dropped, which is
* the part that makes the other four trustworthy.
*
* Ages are printed as durations — "3 weeks" — rather than dates. A date
* makes the reader do the subtraction, and the question is never "when was
* this written", it is "how old is it now".
*
* Rows are buttons with `aria-pressed` because opening a source is the
* obvious next action, and `status` carries the age separately from `tone`
* so the colour scale can stay on four values while the words stay precise.
*
* The demo selects the freshest row, which is the one a reader checks first.
*/
import * as React from 'react'
type Tone = 'neutral' | 'positive' | 'warning' | 'critical'
export interface RetrievalFreshnessListRow {
id: string
label: string
detail?: string
tone?: Tone
/** What the badge says. Falls back to the tone name when absent. */
status?: string
}
export interface RetrievalFreshnessListProps {
heading?: string
intro?: string
rows?: RetrievalFreshnessListRow[]
className?: string
}
/*
Tones as complete utility classes, never assembled from fragments.
Tailwind scans source text, so `text-${tone}-foreground` produces no
class at all — the same failure as an undefined token, and just as
invisible in review.
*/
const TONE_CLASS: Record<Tone, string> = {
neutral: 'bg-muted text-muted-foreground',
positive: 'bg-primary/10 text-primary',
warning: 'bg-accent text-accent-foreground',
critical: 'bg-destructive/10 text-destructive',
}
const ROWS: RetrievalFreshnessListRow[] = [
{ id: "row-1", label: "Pricing page — 2 days old", detail: "Re-indexed after the last deploy. Matches what is live.", tone: "positive", status: "2 days" },
{ id: "row-2", label: "API reference — 3 weeks old", detail: "Two endpoints have shipped since. Neither is quoted in this answer.", tone: "neutral", status: "3 weeks" },
{ id: "row-3", label: "Onboarding guide — 8 months old", detail: "Predates the current signup flow. Cited here for the account model only.", tone: "warning", status: "8 months" },
{ id: "row-4", label: "Migration notes — 2 years old", detail: "Superseded twice. Excluded from this answer and kept for the audit trail.", tone: "critical", status: "2 years" },
]
export function RetrievalFreshnessList({
heading = "How old the sources are",
intro = "Relevance ranking says which document matched. It says nothing about whether the document is still true, and that is the question a reader has once the answer surprises them.",
rows = ROWS,
className,
}: RetrievalFreshnessListProps) {
/*
Per-instance prefix for every id this block emits.
The literals these replaced were a latent duplicate the moment the
block appeared twice on one document, and `aria-labelledby` on a
duplicated id resolves to the first match -- so the second copy was
labelled by the first copy's heading. Client component, so `useId` is
the right tool.
*/
const uid = React.useId()
const [selected, setSelected] = React.useState<string | null>(rows[0]?.id ?? null)
return (
<section
aria-labelledby={`${uid}-retrieval-freshness-list-heading`}
className={`w-full bg-background px-6 py-16 ${className ?? ''}`}
>
<div className="mx-auto max-w-3xl">
<h2
id={`${uid}-retrieval-freshness-list-heading`}
className="text-2xl font-semibold tracking-tight text-foreground"
>
{heading}
</h2>
<p className="mt-2 text-sm text-muted-foreground">{intro}</p>
<ul className="mt-8 divide-y divide-border overflow-hidden rounded-xl border border-border bg-card">
{rows.map((row) => {
const isSelected = row.id === selected
return (
<li key={row.id}>
{/*
A button, not a div with onClick. The row is operable, so
it has to be reachable by keyboard and announce its
selected state — aria-pressed is what carries that.
*/}
<button
type="button"
aria-pressed={isSelected}
onClick={() => setSelected(row.id)}
className={`flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ${
isSelected ? 'bg-muted/40' : ''
}`}
>
<span className="min-w-0 flex-1">
<span className="block truncate text-sm font-medium text-foreground">
{row.label}
</span>
{row.detail ? (
<span className="mt-0.5 block text-sm text-muted-foreground">
{row.detail}
</span>
) : null}
</span>
<span
className={`shrink-0 rounded-full px-2.5 py-1 text-xs font-medium ${
TONE_CLASS[row.tone ?? 'neutral']
}`}
>
{row.status ?? row.tone ?? 'neutral'}
</span>
</button>
</li>
)
})}
</ul>
</div>
</section>
)
}
bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.Drop it at components/retrieval-freshness-list.tsx and import it where you need the section:
import { RetrievalFreshnessList } from '@/components/retrieval-freshness-list'1 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.
Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.
| Prop | Type | Default |
|---|---|---|
heading | string | "How old the sources are" |
intro | string | — |
rows | RetrievalFreshnessListRow[] | ROWS |
className | string | — |
The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.
This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.
<!--
Retrieval Freshness List — markup from the Hoverlab catalog.
This is the block rendered once to HTML and wrapped as a component
file. It is not a port of the React source: the Tailwind classes carry
the design, which is the part that took the work, and they are the same
in every framework.
This block is interactive in React and the handlers are NOT here.
Buttons, toggles and menus render in their initial state and do
nothing until you wire them up.
-->
<section aria-labelledby="_R_0_-retrieval-freshness-list-heading" class="w-full bg-background px-6 py-16 ">
<div class="mx-auto max-w-3xl">
<h2 id="_R_0_-retrieval-freshness-list-heading" class="text-2xl font-semibold tracking-tight text-foreground">How old the sources are</h2>
<p class="mt-2 text-sm text-muted-foreground">Relevance ranking says which document matched. It says nothing about whether the document is still true, and that is the question a reader has once the answer surprises them.</p>
<ul class="mt-8 divide-y divide-border overflow-hidden rounded-xl border border-border bg-card">
<li>
<button type="button" aria-pressed="true" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset bg-muted/40">
<span class="min-w-0 flex-1">
<span class="block truncate text-sm font-medium text-foreground">Pricing page — 2 days old</span>
<span class="mt-0.5 block text-sm text-muted-foreground">Re-indexed after the last deploy. Matches what is live.</span>
</span>
<span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-primary/10 text-primary">2 days</span>
</button>
</li>
<li>
<button type="button" aria-pressed="false" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ">
<span class="min-w-0 flex-1">
<span class="block truncate text-sm font-medium text-foreground">API reference — 3 weeks old</span>
<span class="mt-0.5 block text-sm text-muted-foreground">Two endpoints have shipped since. Neither is quoted in this answer.</span>
</span>
<span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-muted text-muted-foreground">3 weeks</span>
</button>
</li>
<li>
<button type="button" aria-pressed="false" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ">
<span class="min-w-0 flex-1">
<span class="block truncate text-sm font-medium text-foreground">Onboarding guide — 8 months old</span>
<span class="mt-0.5 block text-sm text-muted-foreground">Predates the current signup flow. Cited here for the account model only.</span>
</span>
<span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-accent text-accent-foreground">8 months</span>
</button>
</li>
<li>
<button type="button" aria-pressed="false" class="flex w-full items-center justify-between gap-4 px-5 py-4 text-start transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ">
<span class="min-w-0 flex-1">
<span class="block truncate text-sm font-medium text-foreground">Migration notes — 2 years old</span>
<span class="mt-0.5 block text-sm text-muted-foreground">Superseded twice. Excluded from this answer and kept for the audit trail.</span>
</span>
<span class="shrink-0 rounded-full px-2.5 py-1 text-xs font-medium bg-destructive/10 text-destructive">2 years</span>
</button>
</li>
</ul>
</div>
</section>
What each framework gets across the whole catalog — effects convert properly; this rung is markup.
The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.
Want the whole screen instead of this one section? Open a page and copy it entire.
All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.
Browse Retrieval & ContextCopying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.
The RAG debugging surface: ranked passages with similarity as a meter, matched spans in real mark elements, and filter chips wired as a radiogroup so arrows move between them.
The published footnotes under an answer — ordered list, real cite and time elements, the claim each source supports, and a staleness warning written in words rather than shown as an amber dot.
Choosing what the assistant may read, with indexing state told honestly — a half-indexed source says so rather than showing a green tick — and the footer stating the effect of the selection, not its cardinality.
The refusal screen: says plainly that nothing was found, shows where it looked and the near-misses below threshold, and offers the two real ways out instead of inventing an answer.
What is in the context and what fell out of it — a stacked budget with the reply reserve drawn as a segment, and the dropped chunks named with the reason, which is the part nobody ships.
A green tick means the connector works, not that the answers are current. Freshness as an age in words per source, the headline taken from the stalest one, and a failed sync that still says what age it is answering from.
Which sources this answer may draw on, shown as a scope the user can read before asking rather than a citation list after.
How an answer is tied to its sources, and what the system does when it cannot find any.