Retrieval Inspector

What the retriever found for a question, and which chunks reached the model.

PROGet Retrieval Inspector and 168 other Pro components with pro lifetime — Get Pro

Category
RAG & Evals
Access
Pro
Source
527 lines · one file
States
7 drawn
Added
12 Oct 2026

The decision inside it

A score is a similarity, not a probability

Scores are shown only when supplied, never as zero when missing, and sorting by score is offered only when every chunk has one. The tooltip says what the number is not.

When to use it

Use Retrieval Inspector to see what a RAG search returned for a query: every chunk ranked with its score, source and matched words, which chunks the answer actually used, and empty, loading and error states.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Retrieval Inspector for this.
Install it: npx shadcn@latest add @liro/retrieval-inspector
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/retrieval-inspector.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/retrieval-debug.tsx
import { RetrievalInspector, type RetrievalResult } from "@/components/ui/retrieval-inspector";

const result: RetrievalResult = {
  query: "refund window for annual plans",
  method: "hybrid",
  durationMs: 140,
  chunks: [
    { id: "c1", title: "Refund policy", sourceType: "pdf", text: "Annual plans can be refunded within 14 days.", rank: 1, score: 0.91 },
    { id: "c2", title: "Billing FAQ", sourceType: "web", text: "Monthly plans are not refunded.", rank: 2, score: 0.74 },
  ],
};

export function RetrievalDebug({ openSource }: { openSource: (chunkId: string) => void }) {
  return <RetrievalInspector result={result} usedIds={["c1"]} onOpenSource={(chunk) => openSource(chunk.id)} />;
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
resultRetrievalResult NoThe query and what came back. Leave it out while `loading`.
usedIdsstring[] NoChunks that were sent to the model. Marked "In context".
loadingboolean NoShows placeholder rows.
errorReact.ReactNode NoRetrieval failed. Shown in place of the list, with `onRetry`.
onRetry() => void No–
selectedIdstring | null NoControlled open chunk.
defaultSelectedIdstring | null No–
onChunkSelect(chunk: RetrievalChunk | null) => void No–
onOpenSource(chunk: RetrievalChunk) => void NoOpen the source yourself (a drawer, a route). Without it, `sourceUrl` opens in a new tab.
onCopyChunk(chunk: RetrievalChunk, what: "text" | "id") => void NoTold after a copy, with what was copied.
sortRetrievalSort No–
defaultSortRetrievalSort No–
onSortChange(sort: RetrievalSort) => void No–
emptyStateReact.ReactNode NoReplaces the default "nothing matched" state.

Dependencies

npm packages

clsxframer-motionlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-themebadgebuttonstatetabstooltip

States

All of them are drawn by the component. None is left for you to design.

  • Results
  • Chunk open
  • Sorted by score
  • Filtered by source
  • Loading
  • Nothing matched
  • Error

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances