# TRUEREF-0016 — Web UI: Search Explorer **Priority:** P2 **Status:** Pending **Depends On:** TRUEREF-0010, TRUEREF-0015 **Blocks:** — --- ## Overview An interactive search interface within the web UI that lets users test the documentation retrieval system directly from the browser. Mirrors the two-step context7 flow: first resolve a library ID, then query documentation. Results are displayed with syntax highlighting. Useful for validating indexing quality and demonstrating the system to stakeholders. --- ## Acceptance Criteria - [ ] Search page at `/search` with two-step workflow - [ ] Step 1: Library name input → displays matching libraries with IDs and scores - [ ] Step 2: Click library → query input → displays ranked snippets - [ ] Syntax-highlighted code blocks (using a lightweight highlighter) - [ ] Snippet type badge (code vs info) - [ ] Breadcrumb display per snippet - [ ] Token count per snippet and total - [ ] "Copy as Markdown" button for the full response - [ ] Library switcher (return to step 1 without full page reload) - [ ] URL reflects current state (`/search?lib=/facebook/react&q=useState`) - [ ] No server-side rendering needed for this page (can be client-side) --- ## Page Layout ``` /search ├── Header: "Search Documentation" ├── Step 1: Library Search │ ├── Input: "Library name..." + Search button │ └── Results list: library cards with ID, description, snippet count, trust score │ └── [Click to select] ├── Step 2: Documentation Query (shown after library selected) │ ├── Selected library badge + "Change" button │ ├── Input: "What would you like to know?" + Search button │ └── Results: │ ├── Token count summary │ ├── "Copy as Markdown" button │ └── Snippet list: │ ├── Code snippets: syntax-highlighted code block │ └── Info snippets: formatted markdown └── (loading states + empty states throughout) ``` --- ## Component: LibrarySearchResult ```svelte ``` --- ## Component: SnippetCard ```svelte
{snippet.breadcrumb}
{/if}{snippet.content}
{:else}
` with a CSS-based theme. Optionally integrate `highlight.js` (lightweight) as an enhancement:
```typescript
// Optional: lazy-load highlight.js only when code snippets are present
async function highlightCode(code: string, language: string): Promise {
const hljs = await import('highlight.js/lib/core');
// Register only needed languages
return hljs.highlight(code, { language }).value;
}
```
---
## Files to Create
- `src/routes/search/+page.svelte`
- `src/lib/components/search/LibraryResult.svelte`
- `src/lib/components/search/SnippetCard.svelte`
- `src/lib/components/search/SearchInput.svelte`
- `src/lib/utils/copy-to-clipboard.ts`