Skip to content

feat(citations): add prompt filter with a searchable combobox - #55

Merged
gkhngyk merged 1 commit into
mainfrom
feat/citations-prompt-filter
May 19, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feat/citations-prompt-filter

Conversation

@gkhngyk

@gkhngyk gkhngyk commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a Prompt filter to the Citations page filter bar, between Topic and Platform, so users can scope citations to a single prompt's tracked results.
  • Implements it as a searchable combobox (not a plain select) so it stays usable on brands with 50+ prompts — live filter, keyboard navigation, truncated long-prompt labels.
  • Backend just gains `promptIds: string[]` on `CitationsFilters` and a matching `.in('prompt_id', ...)` clause; everything else is UI.

Closes #43, closes #17 (duplicate).

What's new for the codebase

  • `web/src/components/ui/combobox.tsx` — new shadcn-style wrapper around `@base-ui/react/combobox` (the project's existing primitive library already ships a Combobox component). Exports the usual parts: `Combobox`, `ComboboxTrigger`, `ComboboxInput`, `ComboboxContent`, `ComboboxList`, `ComboboxCollection`, `ComboboxItem`, `ComboboxEmpty`, `ComboboxValue`, `ComboboxPortal`. No new package deps — no `cmdk`, no radix-popover.
  • This wrapper is now available for any future filter that needs search-in-dropdown UX (no more "should we add a search box?" debates).

Two implementation notes worth flagging for review

  1. Items render through ``, not a manual `.map()`. base-ui's built-in filter only applies to children rendered through Collection — a manual map silently bypasses the search input and produces a non-filtering combobox.
  2. `` uses `empty:hidden` so it collapses to zero height when there are matches. base-ui keeps the element in the DOM as an aria-live region (for screen-reader announcements of the empty state), which means without `:empty` collapsing, its padding leaks visible whitespace above the list whenever the search hasn't narrowed anything down. Took a round to spot; left a comment in the wrapper.

Test plan

  • /dashboard/citations with a brand that has prompts → Prompt filter renders between Topic and Platform
  • Open the combobox → live items list, search input auto-focused
  • Type → list filters down; clearing the search restores full list
  • No-match query → "No prompts match." empty state, no phantom space above
  • Pick a prompt → citations table narrows to that prompt's rows; URL stays at /dashboard/citations
  • Pick another or clear → table updates; trigger label reflects the current selection (truncated if >80 chars)
  • Brand with zero prompts → Prompt filter is hidden entirely

The Citations page lets you slice by topic, platform, region, and a
few flags — but not by an individual prompt. For 200+ prompt brands,
"what URLs are AI engines citing when answering THIS prompt?" was
unanswerable without exporting and pivoting in a spreadsheet.

This change adds a Prompt filter between Topic and Platform in the
filter bar. Because prompt lists get long, it's a combobox with an
inline search input (live filter, keyboard nav) instead of a plain
select. The combobox is built as a thin shadcn-style wrapper around
the existing @base-ui/react/combobox primitive — no new package
deps (cmdk, radix-popover, etc.), and consistent with the way every
other UI primitive in the repo (Select, Sheet, Tabs, Dialog) is
wired up.

Two implementation notes worth flagging for review:

- Items are rendered through Combobox.Collection (render-prop)
  rather than a manual .map() over the items array. base-ui's
  built-in filter only applies to children fed through Collection;
  a manual map silently bypasses the search input.
- Combobox.Empty stays in the DOM as an aria-live region even
  when there are matches. Without `empty:hidden` its padding leaks
  vertical whitespace above the list when the search hasn't
  narrowed anything down.

Backend just adds promptIds: string[] to CitationsFilters and an
.in('prompt_id', filters.promptIds) clause next to the existing
platforms / regions filters.

Closes #43, closes #17.
@gkhngyk
gkhngyk merged commit 20f0a54 into main May 19, 2026
2 checks passed
@gkhngyk
gkhngyk deleted the feat/citations-prompt-filter branch May 19, 2026 19:57
@gkhngyk gkhngyk mentioned this pull request May 26, 2026

This branch was successfully deployed

1 active deployment
Preview — 836f1c03 Deployed May 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(citations): add a Prompt filter dropdown to the citations page Add prompt-based filtering to dashboard/citations view

1 participant