Skip to content

Jump from a PDF bibliography card to where the paper cites it - #767

Merged
NielsRogge merged 3 commits into
mainfrom
claude/pdf-bibliography-backlinks
Oct 27, 2026
Merged

NielsRogge merged 3 commits into
mainfrom
claude/pdf-bibliography-backlinks

Conversation

@NielsRogge

@NielsRogge NielsRogge commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Follow-up to #754 and #758. A bibliography entry's paper card can open the cited paper, but there's no way back to where the text cites it. In-text cards already have "Jump to reference" for the other direction.

What

  • createPdfCitationResolver builds a lazy index of every in-text citation of each bibliography entry. bibliographyLinks(page) returns it as citations: one list of boxes per citation, in reading order, on the 0–1000 page grid.
    • Hyperref PDFs: link annotations whose destination is the entry's cite.* name.
    • Numbered PDFs without destinations (Word exports, for example): [n], [2, 7] and [4-6] labels in the text before the first bibliography entry. Text items are joined into lines first, so a label split as [ + 12] still matches.
    • Author/year citations are linked as "Chen et al." and "2017" separately. When the two sit side by side on one line, or the citation wraps onto the start of the next line, they count as one citation and highlight together.
  • Bibliography cards get a footer with "Open paper ↗" and "Jump to citation". When a paper is cited more than once, the button reads "Jump to citation 1 of 3" and each click moves to the next citation, wrapping back to the first. Entries the text never cites get no button.
  • The jump uses the reader's existing chat-citation highlight: it scrolls to the citation and flashes it. Whichever highlight was requested last (chat citation or card jump) is shown, and opening another PDF clears the jump.

Verification

  • vitest run src/components/pdf src/views/PaperReaderView.test.tsx (78 passed). New tests cover: hyperref citations including split and wrapped author/year links; numbered citations (single labels, lists, ranges, split labels, [abc]/[2023a] ignored); Word-export citations excluding labels inside the bibliography; and the card button stepping through citations, plus no button for uncited entries.
  • tsc -p tsconfig.app.json passes. eslint shows only an existing warning.
  • Resolver run in Node on real arXiv PDFs against the production lookup API. Every resolved entry had at least one in-text citation:
    • Longformer 2004.05150: 37 entries, 80 citations.
    • Attention Is All You Need 1706.03762: 26 entries, 50 citations.
    • Word export 2206.02424: 36 entries, 60 citations.
  • Dev reader in headless Chrome on /pdf/2004.05150, with /api proxied to the public site:
    • Hovering the Clark et al. entry on page 11 shows the card with "Jump to citation".
    • Clicking it scrolls to page 6 and highlights the whole wrapped citation "(Clark / et al., 2019)".

🤖 Generated with Claude Code


Note

Medium Risk
Adds whole-document PDF annotation/text scanning and highlight/scroll wiring in the reader; behavior is user-facing but confined to citation UX with solid test coverage.

Overview
Bibliography paper preview cards in the PDF reader can now jump back to in-text citations, mirroring the existing “Jump to reference” flow from in-text links.

The citation resolver gains a lazy citationsOf index: hyperref PDFs use link annotations to cite.* destinations (with adjacent/wrapped author–year fragments merged into one highlight); Word-style numbered PDFs parse [n], lists, and ranges in body text before the bibliography via new numberedCitationBoxes. PdfBibliographyEntryLink shows Open paper plus a Jump to citation control that cycles 1 of N when there are multiple cites; uncited entries omit the button.

PdfViewer loads citation boxes per bibliography card, then reuses the chat citation highlight/scroll path via transient citationJump state (last-requested highlight wins; new PDF or chat citation clears the jump).

Reviewed by Cursor Bugbot for commit 4f2914d. Bugbot is set up for automated code reviews on this repo. Configure here.

Bibliography cards could open the cited paper but not lead back into the text.
The citation resolver now also indexes every in-text citation of each entry:
hyperref links to its cite.* destination, or for numbered PDFs without them,
"[n]", "[2, 7]" and "[4-6]" labels printed before the bibliography. Author/year
links split across "Chen et al." and "2017", or wrapped onto the next line,
count as one citation.

The card footer gains "Jump to citation" (with "n of m" when cited more than
once, stepping through each in turn), which scrolls to the citation and flashes
the existing chat-citation highlight over it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread frontend/src/components/pdf/pdfCitationLinks.ts Outdated
Bibliography links no longer wait for the whole-document citation index;
pages fill in each card's jump once citationsOf resolves, and the scan reads
pages in parallel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6d2990c. Configure here.

Comment thread frontend/src/components/pdf/pdfCitationLinks.ts Outdated
Range-loaded PDFs fetch pages on demand, so the citation index now reads six
pages ahead like the text search instead of the whole document at once, and a
page that fails to load contributes no citations rather than failing the scan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NielsRogge
NielsRogge merged commit 8feeec7 into main Oct 27, 2026
4 checks passed
@NielsRogge
NielsRogge deleted the claude/pdf-bibliography-backlinks branch October 27, 2026 15:47
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.

1 participant