From 1905feceea57ab54c40bc3ae52f4f48910e79e11 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Mon, 17 Aug 2026 08:23:57 -0400 Subject: [PATCH] =?UTF-8?q?fix(reader):=20PDF=20search=20returned=20nothin?= =?UTF-8?q?g=20=E2=80=94=20reactive=20proxy=20broke=20pdf.js;=20add=20back?= =?UTF-8?q?-to-location?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PDF search diagnosis: extraction and matching were proven correct against the real 609-page library PDF (pdfjs 5.5.207, incl. the exact range-transport setup makePDF uses — 841 hits for 'SELECT'), and the served bundle had every piece. The failure was Alpine's reactivity: this.book is a plain object, so reading .pdf through component state returns a reactive Proxy around the PDFDocumentProxy — and pdf.js v5 uses #private fields, so getPage() through the proxy throws 'cannot read private member', which the empty catch rendered as a silent empty result set. runPdfSearch now unwraps via Alpine.raw (falls back to the raw read), and search failures surface in the drawer ('Search failed — see console') plus console.warn instead of masquerading as 'No matches'. Back-to-location stack (research/footnote workflow): the current position is recorded before every programmatic jump — search-result clicks, TOC entries, bookmark and highlight jumps — and on every internal link click (footnotes, cross-references) via foliate's 'link' event. A ↩ button appears in the topbar once a return target exists; Alt+← works everywhere. Ordinary paging never pollutes the stack (max depth 50, consecutive duplicates collapse). --- templates/reader.templ | 16 +++++++- templates/reader_templ.go | 18 ++++----- web/src/reader/reader.ts | 78 ++++++++++++++++++++++++++++++++++----- 3 files changed, 92 insertions(+), 20 deletions(-) diff --git a/templates/reader.templ b/templates/reader.templ index 6154e32..1e22701 100644 --- a/templates/reader.templ +++ b/templates/reader.templ @@ -243,6 +243,17 @@ templ ReaderChrome(metadata ReaderMetadata, progress ReadingProgress) { ← Back +

{ metadata.Title }

@@ -531,10 +542,11 @@ templ ReaderSearchDrawer() { ✕
-
+
Searching… 0 matches - No matches + No matches + Search failed