Skip to content

Let the reader search inside a PDF — Ctrl+F sees only the page on screen, while the assistant has a search tool #68

Open

Description

@bencode

Problem

Gamma Reader's PDF surface has no find for the human reading it. The viewer is single-page — components/pdf-reader/index.tsx holds one pageNumber and renders one page's text layer at a time (textReadyPage === pageNumber) — so the browser's Ctrl/F can only see the text of the page currently on screen; every other page does not exist in the DOM. There is no product-level find either: zero matches for "search" in components/pdf-reader/ (the only find is an array lookup in pdf-outline.tsx:155).

Meanwhile the capability already exists in this codebase — wired to the assistant alone. core/document-text.ts exports findTextMatches, and features/agent/document-tools.ts exposes it to the model as a search operation over document text (PDFs included: create-reader-agent.ts marks them textReadable). Today a reader who wants to know where their PDF says something must ask the AI to run the search their own product ships against their own document.

The product made the opposite call on its newest surface: code files are searchable (code-reader.tsx:49 — "foldable and searchable"), because CodeMirror's basicSetup includes search. Code the reader skims can be searched; the PDF the reader reads cannot.

Proposal

  • Add find-in-document to the PDF reader: Ctrl/Cmd+F opens a query field, matches count "n of m", Enter / Shift+Enter steps through them, each jump lands on the page and scrolls to the match, highlighted in the rendered text layer.
  • Reuse what is already there: findTextMatches from core/document-text.ts as the matcher, and the per-page text the viewer already extracts for its text layers — no new infrastructure, no index to persist.
  • Plain case-insensitive text is the reading need; regex and replace stay out of scope.
  • The outline stays as structural navigation; this is content navigation.

Goal

After this, a reader looking for where a PDF says something presses Ctrl+F, sees every match counted, and steps through them page by page — the same search the assistant already runs on that text, available to the person holding the document.

Verification

grep -rq "findTextMatches" ui-packages/web/src/components/pdf-reader
pnpm --filter @gamma-reader/web test --silent
pnpm check

Refs

  • ui-packages/web/src/components/pdf-reader/index.tsx — single-page model: one text layer in the DOM at a time, so browser find sees one page of the document
  • ui-packages/web/src/core/document-text.ts:72 — findTextMatches, the matcher a reader-facing find would reuse
  • ui-packages/web/src/features/agent/document-tools.ts — the search operation wired to the assistant today
  • ui-packages/web/src/features/reader/code-reader.tsx:49 — the product's own reader-facing searchable-text precedent
  • Remember where the reader stopped — reopen documents at their page or scroll position #40 — position memory (shipped): remembering where you stopped; this is finding where to go

Activity

  1. added
    enhancement
    source:scheduled
    on Oct 2, 2026
  2. bencode commented on Oct 2, 2026

    @bencode
    OwnerAuthor

    Independent review — posted by the scheduled issue-reviewer loop (a session separate from the one that files these issues), under the maintainer's standing instruction to evaluate, sharpen, or retire source:scheduled proposals.

    Evidence audit (against main@d94348b): every citation confirmed, most to the exact line.

    • ✅ Single-page model confirmed: the viewer renders one page's text layer at a time, gated by textReadyPage === pageNumber (components/pdf-reader/index.tsx:56,75,80) — so browser Ctrl+F sees exactly one page, as claimed.
    • ✅ Zero "search" in components/pdf-reader/; the only find is the outline's array lookup (pdf-outline.tsx:155).
    • ✅ The reuse path is fully real: findTextMatches (core/document-text.ts:72, exact line), the agent's search operation consuming it (document-tools.ts:1,44,116), and PDFs explicitly textReadable (create-reader-agent.ts:36).
    • ✅ The precedent contrast holds — code files are searchable in the reader (code-reader.tsx:49 "foldable and searchable"); PDFs are not.
    • ✅ Sensor: lint passed; verify fails today → stays open.

    Verdict: valid, keep open — the strongest reuse story in the queue. The matcher, the per-page text, and even the interaction pattern (n of m, enter-to-step) all exist; nothing new needs inventing.

    One anchor fix to make before implementation (this queue now has two closed-correctly-but-anchor-refused cases: #41, #55): grep -rqi "search" guesses the vocabulary — a Cmd+F implementation named "Find" meets the Goal without the word "search". The one artifact any implementation must touch is the matcher the proposal itself mandates reusing:

    grep -rq "findTextMatches" ui-packages/web/src/components/pdf-reader
  3. bencode commented on Oct 21, 2026

    @bencode
    OwnerAuthor

    Re-audit — posted by the scheduled issue-reviewer loop (independent of the authoring session), against main@ebb0ee0 (25+ commits since the last review at d94348b).

    Evidence audit: every behavioral premise still holds; three citations drifted by refactor, not by removal.

    • ✅ Single-page model intact — components/pdf-reader/index.tsx:83 still gates the text layer on textReadyPage === pageNumber; still zero "search" in components/pdf-reader/ (verify grep fails).
    • 🔁 Path drift: findTextMatches moved from core/document-text.ts to utils/text.ts (with normalizeSearchText) — the reuse story survives, the import is just shorter. The old file's test lives on as features/assistant/document-text.test.tsx.
    • 🔁 Path drift: features/agent/ is now features/assistant/ — document-tools.ts:44,66,116 still exposes the search operation consuming the matcher; create-reader-agent.ts still marks PDFs textReadable.
    • ✅ Precedent quote confirmed to the line — features/reader/code-reader.tsx:49-50 "foldable and searchable"; pdf-outline.tsx:155 remains the only find (array lookup).

    Verification block edited (logged here per policy, replacing the vocabulary-guessing grep this loop recommended last beat, after the #41/#55 anchor refusals):

    - grep -rqi "search" ui-packages/web/src/components/pdf-reader
    + grep -rq "findTextMatches" ui-packages/web/src/components/pdf-reader

    The new anchor passes only when an implementation actually imports the mandated matcher into the PDF reader — any implementation naming. Re-linted ✓; verify fails on main today ✓ (not implemented).

    Verdict: valid, keep open. Sensor: lint ✓, verify ✗. No new commits implement or invalidate the proposal.

  4. bencode commented on Oct 23, 2026

    @bencode
    OwnerAuthor

    Re-audit — posted by the scheduled issue-reviewer loop (independent of the authoring session), against main@90b046f (21 commits since the last review at ebb0ee0).

    Evidence audit: nothing moved — none of the 21 commits (conversation numbers, composer refactor, background conversations, drag-tabs, resource-row actions) touches components/pdf-reader/ or utils/text.ts. Every anchor from the last re-audit holds as-is: the single-page gate index.tsx:83 (textReadyPage === pageNumber), the matcher at utils/text.ts:24, the assistant search op at features/assistant/document-tools.ts:44,66,116, the precedent quote at code-reader.tsx:49, and still zero "search" anywhere in components/pdf-reader/.

    Sensor: lint ✓, verify ✗ (not implemented).

    Verdict: valid, keep open. No new commits implement or invalidate the proposal.

  5. bencode commented on Oct 27, 2026

    @bencode
    OwnerAuthor

    Re-audit — posted by the scheduled issue-reviewer loop, independent of the authoring session, against main@e8c930f (36 commits since the last review at 90b046f).

    Evidence audit: of the 36 commits only c706f8c (link/drop navigation staying in the reader) touches the PDF reader, and it is orthogonal to search. Every anchor from the last re-audit still holds to the line: the single-page gate components/pdf-reader/index.tsx:83 (textReadyPage === pageNumber), the matcher findTextMatches at utils/text.ts:24, the assistant search operation at features/assistant/document-tools.ts:44,66, the textReadable contract at document-tools.ts:38,94, the precedent quote at code-reader.tsx:49 ("foldable and searchable") — and still zero search / findTextMatches anywhere in components/pdf-reader/.

    Sensor: lint ✓, verify ✗ (not implemented on main).

    Verdict: valid, keep open. No new commit implements or invalidates the proposal; the open+closed title scan still shows no duplicate.

  6. bencode commented on Nov 2, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Re-audit at d05b6b6 — the stalest review in the queue (15 commits since the last review @ e8c930f, none touching a cited file: git diff --stat e8c930f..HEAD over components/pdf-reader/, utils/text.ts, features/assistant/document-tools.ts, code-reader.tsx is empty). Valid, stays open; no edits.

  7. bencode commented on Nov 13, 2026

    @bencode
    OwnerAuthor

    Posted by the scheduled issue-reviewer loop, independent of the authoring session.

    Re-audit (sixth pass) @ d05b6b6 — HEAD still unchanged since 2026-10-28; valid, stays open; no edits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsource:scheduled

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions