fix(pdf): split pagesRead from pagesConsulted — the honest badge count

Live-smoke follow-up the user approved (2026-09-19): the GEB read showed
"78 pages consulted" when the reader genuinely READ ~12 - pdf_search hit
snippets inflated the count. PdfResult now carries both:

- pagesRead: extract/render output entered the loop - the honest count
  the badge and brief footer show ("read N pages", "Pages read: ...").
- pagesConsulted: every page whose content entered the loop, search-hit
  context lines included - unchanged, still the citation audit set (the
  reader's instructions still say "Pages consulted: N, N, ..." and the
  footer still lists it when it exceeds the read set).

The unread-finish gate deliberately stays on CONSULTED: search hits are
genuine consultation (anti-fabrication duty), so a search-only brief is
honest and must deliver - pagesRead is a reporting refinement, not a
delivery gate. Pinned by the search-only faux test (read [], consulted
[1], delivered).

UI tolerates pre-split persisted records via ?? fallbacks (old steers
lack pagesRead).
This commit is contained in:
amosblomqvist
2026-09-19 16:52:09 +03:00
parent 7a3e19e95f
commit 1b9122c88b
8 changed files with 57 additions and 14 deletions
+5 -2
View File
@@ -79,15 +79,18 @@ function AbortedBadge({ kind }: { kind: string }) {
* the badge marks delivery, the collapsed details carries the full text
* + consulted pages. */
function PdfCompleteBadge({ result }: { result: PdfResult }) {
// The honest count is READ pages (extract/render — sources v1 split);
// the ?? is runtime tolerance for pre-split persisted steers.
const readPages = result.pagesRead ?? result.pagesConsulted;
return (
<details data-testid="pdf-complete-badge" className="group w-full text-xs text-muted-foreground">
<summary className="flex cursor-pointer select-none list-none items-center gap-2 [&::-webkit-details-marker]:hidden">
<CheckIcon className="size-3.5" />
<span className="font-medium uppercase tracking-wide">PDF</span>
<span>reading complete</span>
{result.pagesConsulted.length > 0 && (
{readPages.length > 0 && (
<span>
· {result.pagesConsulted.length} page{result.pagesConsulted.length === 1 ? "" : "s"} consulted
· read {readPages.length} page{readPages.length === 1 ? "" : "s"}
</span>
)}
<span className="ml-1 text-xs text-muted-foreground/70 group-open:hidden">view brief</span>