[feat-022] Cell-detail citation + related-keyword chips

↗ view on GitHub · Nick Whitehouse · 2026-05-07 · 04c7218a

User request: clicking a citation in the cell side panel should jump
the doc viewer to the cited page; clicking a related keyword should
drive the doc-search input + jump to the first match. Both speed up
the verify/spot-check workflow that's the point of tabular review.

Backend:
- Cell-extraction JSON schema gains `keywords: string[]`. Both
  queryGemini (single-cell regenerate) and queryGeminiAllColumns
  (full review run) now require 3-5 short search terms a reviewer
  could use to verify the cell against the source. Prompts say
  "skip generic words, skip column-name restatements, prefer
  near-verbatim phrases".
- sanitiseKeywords() junk-filters the LLM output: trims, dedupes
  case-insensitively, drops <2-char strings, caps at 5, max 60 chars
  each. Bad keywords can't leak into the UI.
- CellResult type extended with `keywords?: string[]`.
- Storage piggybacks on existing tabular_cells.content jsonb
  (no migration).

Frontend:
- TabularCell.content type extended with keywords?: string[].
  Legacy cells (pre-feat-022) have no keywords; the chip row simply
  doesn't render.
- CellCitationChips component - pill row of clickable citations,
  one per parsed [[page:N||quote:...]] marker. Chip label is "Section
  X.Y" if the quote starts with one, else "Page N". Tooltip carries
  the full quote. Click → jumps the doc viewer to the cited page
  (via the existing setActiveCitationIdx flow).
- CellKeywordChips component - pill row of LLM-suggested doc-search
  terms. Click → setSearchTerm(kw), which drives the existing
  doc-viewer search input + scroll-to-first-match.
- Both rows render under the Explanation block in TRDocDetailView,
  hidden in edit mode and absent when there are no citations /
  keywords (graceful for legacy cells).
- Citation chip click clears any active doc-search so the new jump
  starts on a fresh viewport.

Both components are deliberately generic ({citations, onJump} and
{keywords, onSearch}) so feat-024's RAG retrieved-passage chips can
reuse them without copy-paste.

Verified: tsc clean both sides; 16 backend tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Repository nwhitehouse/mike
Author Nick Whitehouse <nick.whitehouse@mccarthyfinch.com>
Authored
Parents 515592d0
Stats 5 files changed , +194 , -3
Part of Tabular cell citation + keyword chips

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-04c7218a.md from inside the repo you want the change in.

⬇ Download capture-commit-04c7218a.md