Skip to content

fix(web): PDF find matches curly quotes when you type straight ones - #29802

Open
saphid wants to merge 2 commits into
pingdotgg:mainfrom
saphid:fix/pdf-find-curly-quotes
Open

saphid wants to merge 2 commits into
pingdotgg:mainfrom
saphid:fix/pdf-find-curly-quotes

Conversation

@saphid

@saphid saphid commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

In the PDF viewer, typing don't into find never matches the don’t in a typeset PDF. No page is listed and nothing is highlighted. Typeset documents almost always use curly apostrophes and quotes (’ ‘ “ ”), but the find box gets the straight ones you type on a desktop keyboard. pdf.js's own find folds these characters, and our find helpers say they follow "pdf.js's own find", but they only lowercase.

Change

pdfLayout.ts gets a small foldQuotes helper. It maps U+2018–U+201B to ' and U+201C–U+201F to ", the same ranges as pdf.js's CHARACTERS_TO_NORMALIZE. Both pdfFindIncludes (which picks pages) and pdfFindMatchRuns (which highlights spans) apply it to the page text and the query, so page results and highlights still agree. Each fold swaps one UTF-16 unit for one unit, so the per-character run map that drives highlights stays aligned. This is the same fold #29759 added to in-thread find.

Scope and approval

This is a very small, focused fix for an obvious bug, so there is no prior issue. The helpers already promise to behave like pdf.js find, and this brings their quote handling in line with that promise. It changes one file plus one test case. Diacritics, ligatures and other pdf.js normalizations are left out.

Overlap search: I searched the local PR index and GitHub for PDF find / apostrophe / curly quote. The closest are #25702 (PDF find across wrapped lines, which added these helpers but not quote folding), #29759 (in-thread find, different code) and #27267 (server message search, different code). None touch pdfLayout.ts quote handling.

Verification

  • Red on main: vp test run src/components/files/pdfLayout.test.ts → AssertionError: expected [ false, false ] to deeply equal [ true, false ] for the new "matches straight quotes typed for typeset curly ones" case.
  • Green: same command, 18/18 pass.
  • vp run check:changed: passes.
  • Takeover verification: real-client PDF.js fallback matches straight apostrophes and double quotes against typeset curly text. Missing and cleared searches remove highlights. Blacksmith checks and evidence are recorded below.

Reviewed with sol-loop: 1 round with GPT-6.1 Sol on high. Sol verdict: approved.

Created with Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

Takeover verification

Note

Written by gpt-6.1-sol on behalf of Maria

Merged main without rebasing at d926154. The diff against that base remains two files, 22 additions and 5 deletions. This brings main's existing file-save browser timeout fix into the branch; no PDF code changes were needed.

Blacksmith vp run check:changed github/main passed format, lint, knip, typecheck and 11 test files. The 18 PDF tests and the exact file-save browser test also passed. Two independent code reviews found no issues.

Verified in the real client's PDF.js fallback with a typeset PDF: straight apostrophes and double quotes find curly text and highlight it; missing and cleared searches remove highlights. Chrome's native viewer was also exercised, then native PDF support was disabled for the fallback check.

CI is blocked by an unrelated failure also present on main: check-changed.test.ts / lints an Astro component and runs knip when only it changed expects a lint command without --no-error-on-unmatched-pattern. Main run 41561598417 and this PR run 41562197999 fail identically. Left that unrelated code untouched.

before: straight apostrophe finds zero pages

after: straight apostrophe finds and highlights curly text

pdf quote search and clearing interaction

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 3, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 4ac8d08

Macroscope's review found this PR approvable — PDF search now treats straight and curly quotes equivalently for page results and highlights. The change is limited to local search matching and does not modify documents or stored data.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

PDF text search now treats curly single and double quotation marks as equivalent to straight quotation marks. Tests cover matching in both directions for highlighted runs and full-page inclusion searches.

Changes: PDF search quote normalization

Layer / File(s) Summary
Normalize quotes for search and verify matching
apps/web/src/components/files/pdfLayout.ts, apps/web/src/components/files/pdfLayout.test.ts
Search text and queries normalize curly quotation marks to straight marks. Tests verify that straight and curly quotes match interchangeably in highlighted runs and full-page searches.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#25702: Adds pdfFindIncludes and the existing whitespace, line-end hyphen, and lowercase normalization extended by this change.
  • pingdotgg/t3code#25699: Moves PDF find logic into pdfLayout.ts and adds pdfFindMatchRuns, which this change updates.

Suggested labels: bugfix, size:XS

Suggested reviewers: juliusmarminge, macroscopeapp

Merge Risk: Moderate · up to 4ac8d

Run the required real-client validation before merging to confirm search selection and highlighting work together in an actual PDF client.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title names the main change: PDF find now matches curly quotes when the user types straight quotes. It follows a conventional commit format and fits the apps/web PDF find change. The title is shor…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template closely. It has Problem, Change, Scope and approval, and Verification sections. The Problem section explains the bug, which is that typing straight quot…
Full details: Title check

Explanation

The title names the main change: PDF find now matches curly quotes when the user types straight quotes. It follows a conventional commit format and fits the apps/web PDF find change. The title is short and specific.

Full details: Description check

Explanation

The description follows the repository template closely. It has Problem, Change, Scope and approval, and Verification sections. The Problem section explains the bug, which is that typing straight quotes or apostrophes in PDF find does not match typeset curly ones. The Change section explains the foldQuotes helper and its application to pdfFindIncludes and pdfFindMatchRuns, and it notes that UTF-16 unit counts stay aligned. The Scope section gives a justification for skipping a prior issue, because the change is a very small, focused fix of an obvious bug. It also cites overlap searches. The Verification section gives a red-then-green test result, a check:changed result, and manual verification in a real client, with before and after screenshots and a recording. It also reports an unrelated CI failure that also occurs on main. Minor gaps: the template asks for the triaged bug issue or maintainer approval comment, but the author relies on the small-fix exemption, and the author says the fix is in line with pdf.js behavior, which a reviewer may want to confirm. The template also asks for the model and harness, and the author includes that. Overall the description is mostly complete.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between f6503f0 and 4ac8d08.

Files selected for processing: 2
  • apps/web/src/components/files/pdfLayout.test.ts
  • apps/web/src/components/files/pdfLayout.ts

Limit details: You’ve used all 10 included reviews currently available.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

@maria-rcks

Copy link
Copy Markdown
Collaborator

Note

Written by gpt-6.1-sol on behalf of Maria

Merged main without rebasing at d926154. The diff against that base remains two files, 22 additions and 5 deletions. This brings main's existing file-save browser timeout fix into the branch; no PDF code changes were needed.

Blacksmith vp run check:changed github/main passed format, lint, knip, typecheck and 11 test files. The 18 PDF tests and the exact file-save browser test also passed. Two independent code reviews found no issues.

Verified in the real client's PDF.js fallback with a typeset PDF: straight apostrophes and double quotes find curly text and highlight it; missing and cleared searches remove highlights. Chrome's native viewer was also exercised, then native PDF support was disabled for the fallback check.

CI is blocked by an unrelated failure also present on main: check-changed.test.ts / lints an Astro component and runs knip when only it changed expects a lint command without --no-error-on-unmatched-pattern. Main run 41561598417 and this PR run 41562197999 fail identically. Left that unrelated code untouched.

before: straight apostrophe finds zero pages

after: straight apostrophe finds and highlights curly text

pdf quote search and clearing interaction

@saphid

saphid commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of saphid

Verified in a real client

A GPT-6 Astra verifier ran upstream/main (61c3794c32) and this head (d926154c82) one after the other in the real dev web app, with isolated .t3 state, --no-seed and the same ports. It used T3's Browser panel and no provider turns.

The fixture is a typeset PDF whose text layer holds curly punctuation (pdftotext shows don’t, ‘single’, “double”). The click path was Add project → Local folder → the fixture folder → Files → typeset.pdf → Find in PDF. On both versions, navigator.pdfViewerEnabled was set to false so the page used T3's PDF.js viewer instead of Chrome's built-in one.

Query typed main this PR
don't 0/0, no highlight 1/1, highlights don’t
"double" 0/0, no highlight 1/1, highlights “double”
main: don't this PR: don't
main finds nothing for a straight apostrophe this PR highlights don’t
main: "double" this PR: "double"
main finds nothing for straight double quotes this PR highlights “double”
Nearby behavior on this PR

A word that isn't in the PDF (platypus) shows 0/0. Clearing a matching search removes every highlight.

Absent word Cleared search
absent word has no match cleared search removes highlights

Not verified: Chrome's built-in PDF viewer search (this PR doesn't touch it), the desktop and mobile clients, and remote or relay connections.

This branch has not been deployed

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

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants