Commit graph

18 commits

Author SHA1 Message Date
You Gao
0535ac710a
feat(reader): vim-style find to start and extend a selection from the keyboard (#7282)
* feat(reader): search select

* refactor(reader): moved select into view

* feat: added tests for select logic

* fix: does not select from search, only options

* fix: test

* fix: CFI validation

* fix: code cleaning

* Revert "fix: code cleaning"

This reverts commit 00c9ec3b78e7f91828e28d9239f366cafddc4743.

* Revert "Revert "fix: code cleaning""

This reverts commit 2f85d454de39d3f551594a2fe0eb3c146314cbfe.

* Revert "fix: CFI validation"

This reverts commit 9ed92a3d9e6be0707513ba873687d54ad7b59d70.

* fix: cfi validation

* fix: test pt2

* feat(reader): vim-style find to start and extend a selection from the keyboard

A keyboard-only reader could act on a selection (Ctrl+H/U/N/D/T/R/C)
and adjust it with Shift+Arrows (#4728), but couldn't start one without
a mouse (#7281). Vim-style find fills that gap:

- `/` opens a command line at the bottom of the book. Enter searches the
  whole book and selects the first match at or after the current page,
  wrapping to the first. The line shows the term and `[i/N]` until Esc.
- `n` / `Shift+N` jump the selection to the next / previous match.
- While a match is selected, h l w b e j k 0 $ ( ) { } extend its moving
  end and `o` swaps the ends, as in visual mode. The page turns when the
  moving end leaves it. `y` copies (also added to Copy Selection).
- Esc clears the selection and ends it. The search stays live across
  Ctrl+H, so `/term`, Ctrl+H, `n`, Ctrl+H highlights match after match.

None of these keys change meaning unless a find is live: the handlers sit
ahead of page navigation and the Notebook in one shortcut listener and
fall through otherwise. The sidebar search and Previous/Next Result are
unchanged and keep using goTo(); vim find runs its own search so their
highlights are left alone.

A selection made by view.select(), and the keyboard extending it, opens
the toolbar and never runs the instant quick action, until the next
pointer press. Jumping to a match clears the last one's selection in
another section under the guard the cross-page path uses, so the
throttled popup dismiss can't close the new toolbar.

Chromium quirks handled: `paragraph` steps keep the caret's x, and a
forward selection won't extend back to a line or paragraph boundary, so
`}` steps to paragraphboundary and `0`/`{` move a collapsed caret and
re-extend. `w`/`e` skip spaces so they land the same with macOS and
Windows word steps.

This replaces the PR's first approach: the select() wrapper in
types/view.ts and its test are removed (foliate's view.select() already
selects), and the sidebar result click is back to goTo().

Text objects (iw/is/ip) were left out: a two-key sequence doesn't fit
the shortcut config without bare s/p bindings.

Verified:
- e2e/tests/vim-find.spec.ts (7 tests): 28/28 with --repeat-each 4.
  Before the feature 5 of 6 failed (no find line); the sidebar test
  passed. Resetting the navigated mark after the first selection fails
  "a match never runs the instant quick action, nor does extending it"
  (Dictionary opens on `e`). Dropping the stale-selection clear fails
  "n and N step through matches" (the old match stays selected).
- dev-web, Chromium: light, dark, e-ink, chrome shown (line sits above
  the footer); scrolled mode; `}` across a page turns the page; Ctrl+H,
  n, Ctrl+H made two highlights.
- annotation.spec.ts + reading.spec.ts: passed except #6540's "keeps the
  note bubble on restyle", which also fails 3/3 on main under dev-web.
- pnpm test: 1250 files, 15210 tests passed (shortcut tests updated for
  the new `n` / Shift+N defaults). pnpm lint, format:check: clean.
- i18n: 5 new strings added and translated in all 34 locales; nothing
  else in the locale files changed.
- Not run: Windows WebView2 and WebKit (macOS/iOS) word and boundary
  steps, Firefox web (no sentence/paragraph steps), Tauri builds.

Reported by you-gao on GitHub

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

---------

Co-authored-by: Huang Xin <chrox.huang@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 18:45:25 +01:00
Huang Xin
f004fa39fe
feat(library): add searchable history dropdown (#7261)
* feat(library): add searchable history dropdown

Show recent book and full-text searches below the library search field,
with per-item removal and Clear All. Reuse BoxedList styling, preserve
legacy full-text history, and translate the new labels in all locales.
Apply selections immediately, including reselecting a query while its
clear action is still waiting for the debounced URL update.

Verification:
- pnpm test --run: 1224 files passed, 4 skipped; 14863 tests passed,
  16 skipped. Final related run: 4 files and 13 tests passed.
- Library header Chromium tests: 18 passed across phone, tablet,
  desktop, RTL and e-ink layouts.
- Playwright search-history test passed with an imported Alice EPUB,
  covering book/full-text reuse and persisted deletion.
- pnpm lint passed; git diff --check passed.
- Running web app and isolated Linux CEF app exercised; screenshots
  inspected in light, dark, e-ink and RTL layouts.
- Before implementation, dropdown tests failed to find the Dune entry.
  Before the immediate-apply fix, the e2e test expected Alice but got
  an empty input after clear and reselect; it passes with the fix.
- Not tested on physical Android or iOS devices. Production builds
  were not run; no dependencies or Rust code changed.

Reported by d3m3vilurr on GitHub (#7126).

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

* fix(library): preserve search history deletion during pending writes

Apply pending book input before deleting history and invalidate running
full-text history writes when their query is removed or all history is
cleared. A later scan can save the same query again. Also record the query
when switching from text search to book search.

Verification:
- New full-text tests failed before the fix: deleted queries returned on
  completion (expected false, received true).
- New book deletion tests failed before the fix: pending search was not
  applied before removal. Mode-switch e2e failed with missing book history.
- All 15 focused unit tests, 18 header browser tests, and four app e2e
  tests pass. Typecheck, Biome lint and patch whitespace checks pass.
- Full unit suite runs again in the pre-push hook.
- Original CI's paginator browser timeout is tracked separately in #7266.
- Physical mobile devices and production builds were not run.

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

* fix(library): save explicitly applied book searches

Record Enter and history selections even when the query already matches
the URL. Keep pre-delete application separate so deletion stays effective.

Verification:
- New unit regression failed before the change: expected ['Dune'], got [].
- New app regression failed before the change: book history was null
  after Enter on the current query.
- 16 focused unit tests and five app e2e tests pass, including deletion
  regressions. Full format, lint and unit checks run in the pre-push hook.
- Physical mobile devices and production builds were not run locally.

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

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
2026-11-02 16:57:09 +01:00
Kel
9c952c1587
fix(reader): remove note bubbles when deleting highlights (#6545)
Co-authored-by: Kel <1563599+kelvinalfaro@users.noreply.github.com>
2026-10-02 07:19:11 +02:00
Huang Xin
22c23b3650
feat(annotator): make keeping the selection after an instant lookup optional (#6460) 2026-09-29 20:42:53 +08:00
Huang Xin
54e80d28db
fix(annotator): hand the selection back when the instant dictionary closes, closes #6213 (#6272)
#5730 made the instant dictionary quick action consume its selection: the word
was tapped to be looked up, not selected, so it deselected as the popup opened.
That fixed two things at once — iOS paints its selection grabbers and blue
highlight above web content, i.e. on top of the popup, and dismissing no longer
raised the selection toolbar (#5585).

It also took away the only route to the word afterwards. With a quick action
armed, re-selecting the word just opens the dictionary again, so highlighting or
copying it meant turning the quick action off entirely and starting over.

The deselect now lasts only as long as the lookup. `restoreSelectionRange` puts
the range back when it closes, programmatically — the engine only draws native
grabbers for a user-initiated selection, so they stay away and the app's own
handles take over — and the dismiss lands on the toolbar like every other lookup.

The handed-back selection carries `quickActionHandled`, which rides along through
every republish of it. Without that, `handleHighlight` stamping `annotated` on
the selection read as a fresh selection and re-opened the dictionary: highlighting
the word you had just looked up bounced you straight back into the lookup. The
once-per-gesture latch does not cover it, because Android bridges every touch on
the window — including the tap on the toolbar itself — and re-arms it.

Verified on a Xiaomi 13: the lookup opens with no grabbers over it, dismissing
gives back the selection, its handles and the toolbar, highlighting applies and
stays put, and a fresh long-press still fires the quick action.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-18 14:36:04 +02:00
Huang Xin
65287bd3eb
fix(annotator): anchor the selection toolbar to the book cell (#6068)
* fix(annotator): anchor the selection toolbar to the book cell

#6036 gave the annotation toolbar its own stacking band by wrapping it in
`fixed inset-0 z-[43]`. That wrapper also moved the popup. `fixed` makes the
viewport the containing block, but Annotator hands every popup coordinates in
the book cell's space (getPosition and getPopupPosition subtract
`#gridcell-<bookKey>`'s rect), and that cell, `position: relative`, was the
containing block before. So the toolbar painted exactly `gridcell.left` px to
the left of the selection the moment the cell left the viewport origin: 240px
with the sidebar open, and again for any book past the first in a split view.
Measured in Chrome with the sidebar open: gridcell.left 240, popup style.left
551.79, painted at viewport x 551.79 instead of 791.79.

Only the toolbar was wrong. The dictionary, translator and proofread popups
render as a bare `<Popup>` with no wrapper, so they kept the cell as their
containing block. The range editors' handle layers are right to use `fixed`,
because getHandlePositionsFromRange returns window coordinates rather than
cell ones.

Use `absolute inset-0`. It still creates the positioned, z-indexed stacking
context #6036 needed, and insets to the cell so the coordinates land where
they were measured.

Add a browser regression test for the anchoring, and a hit test that holds
#6036's own invariant: the z-[44] handle layer still wins the pixels it
shares with the toolbar. jsdom cannot catch either one, it has no layout.

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

* test(e2e): key the annotator z-bands off z-index, not `div.fixed`

The z-order test found each stacking band with `closest('div.fixed')`, a
class-name stand-in for "the wrapper that creates the band". The toolbar's
wrapper is `absolute` now, because the popup's coordinates are book-cell
relative and a fixed wrapper re-anchors it to the viewport, so the selector
stopped matching and `layers.toolbar` came back null.

Walk up to the nearest ancestor that sets a z-index instead. That is what
actually makes a band, it reads the same values off the live DOM, and it
holds whichever way either layer ends up positioned.

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

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 17:00:48 +02:00
Huang Xin
dd9a8daa3f
feat(reader): zoom shortcuts adjust font size in reflowable books, closes #5694 (#6067) 2026-09-05 20:19:07 +08:00
Huang Xin
88ea2de55f
fix(annotator): keep the annotation toolbar below the range handles (#6036)
The Android E2E lane went red on two counts.

getCustomHandles counted `div.cursor-grab`, and #6031 made the highlight
style strip carry that class on every selection when the highlight tool
is on the toolbar, so the handle count was off by one and every wait on
it timed out. Key the query on the handle's test id instead.

With that fixed the two end-handle drag tests still failed, for a real
reason: #6013 moved the handle layer from z-50 down to z-[44], below the
selection popup. The toolbar opens against the selection, which is where
the end handle hangs, so the popup swallowed the bottom of the handle:
elementFromPoint at the grab point resolved to .selection-buttons. The
covered part of the handle stopped dragging and fired whichever tool
button it landed on instead. Give the toolbar its own band at z-[43],
below the handles but still above the paragraph and TTS chrome, so the
rest of #6013 (handles under the footnote popup, side panels and
dialogs) is preserved.

Add an Android test that hit-tests the overlap directly, and flip the
web e2e z-order assertion to match the new band.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-03 04:31:26 +02:00
Huang Xin
6df90139dc
fix(reader): write a new note on the selection, not in the sidebar (#6013)
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (rust) (push) Waiting to run
Publish Docker image / build (linux/amd64, ubuntu-latest) (push) Waiting to run
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Publish Docker image / merge (push) Blocked by required conditions
Build with Nix / tests (push) Waiting to run
PR checks / test_web_app (2) (push) Waiting to run
PR checks / nix_flake_check (push) Waiting to run
PR checks / rust_lint (push) Waiting to run
PR checks / koplugin_rust_lint (push) Waiting to run
PR checks / build_web_app (push) Waiting to run
PR checks / test_web_app (1) (push) Waiting to run
PR checks / test_extensions (push) Waiting to run
PR checks / build_tauri_app (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Deploy to vercel on merge / build_and_deploy (push) Waiting to run
* fix(reader): write a new note on the selection, not in the sidebar, closes #5987, #5957

0.12.6 moved the Annotate action out of the Notebook: it highlighted the
selection, opened the annotations sidebar and asked the matching row to start
editing. That hub lists notes in reading order and virtualizes them, so a note
made further down the current page kept its row outside the mounted window. The
editor never rendered. Users got an annotation count that went up and nothing
else - no note to see, no caret to type into - then found the note "at the
bottom" later, or in an order that looked arbitrary from note to note.

Annotate now opens the editor where the user is already looking. On desktop it
takes over the annotation toolbar popup, the same surface that already hosts an
existing note's inline editor. Below sm (or in short landscape) it opens as a
bottom sheet snapped to 60% of the screen, so the field clears the on-screen
keyboard - the same call DictionarySheet makes for the same reason. Both
surfaces render one AnnotationNoteEditor: text area on top, Cancel/Save pinned
bottom-right, autofocused.

The sidebar is left alone. Cancelling still takes back the placeholder
highlight Annotate created, but never one the user had already made (#4791),
and dismissing the popup counts as cancelling. With nothing setting an edit
target any more, annotationEditTargets and BooknoteItem's startEditing /
placeholderIds / onFinishEditing plumbing are gone; the sidebar keeps its own
Edit button.

Verified in Chrome against a 70-annotation book: annotating the last line of a
page used to leave the panel parked at the top with no editor in the DOM at
all. Now the editor opens on the selection, saves the typed note, and Cancel
drops the placeholder (77 -> 76 live annotations) on both surfaces.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(annotator): keep the range handles off the note editor, and edit notes in it

Two follow-ups on the new note editor.

The range editors are fixed full-screen overlays rendered after the popups, so
their handles floated on top of the note-editor sheet - the #5815 bug, whose
gate only listed the dictionary, translator and proofreader. Widen it to every
surface that opens over the page, and drop the selection as each of them opens:
the app-drawn handles and (on iOS) the native selection highlight both paint
above web content, so a live selection under a sheet is a selection on top of
it. The flag is cleared before deselect() so the selectionchange that fires
can't dismiss the surface being opened - the recipe #5585 already established
for the instant dictionary, generalised.

The pencil on a note bubble now opens that same editor instead of swapping the
bubble for an editor of its own. One way to write a note, wherever it starts
from, and on a phone it gets the bottom sheet rather than a text field wedged
into a popup card. AnnotationNoteItem loses its inline editor entirely.

Verified in Chrome at 500x632: the bubble's pencil opens the sheet seeded with
the existing note, saving rewrites it, and no handles are drawn over either the
sheet or the toolbar-opened editor.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(annotator): draw the range handles below the popup layer, keep #5213

CI caught the real cost of the previous commit: dropping the selection when a
lookup opens breaks #5213, where dismissing the dictionary, translator or
proofreader is supposed to land back on the selection toolbar. Three e2e tests
say so. Only the note editor consumes its selection - the annotation it just
created replaces it, and there is no toolbar to return to - so the deselect
stays there and comes back out of the three lookups.

That leaves the rendering bug the deselect was papering over. The handle layer
and the popup layer were both z-50 in the same stacking context, so the tie
broke on DOM order, and the range editors are rendered after the popups: their
handles drew on top of every surface. #5815 worked around it by unmounting them
for the three lookup popups, which is why the note editor - a fourth surface
that never joined that gate - got handles over its sheet.

Put the handle layer at z-[44] instead: above the book and the paragraph / TTS
chrome (z-40), below the popups, the dialogs and the side panels' overlay. The
#5815 gate stays as the product behaviour it is, but a surface that forgets to
join it is no longer covered by handles.

The new e2e reads both layers' computed z-index off the live DOM rather than
mirroring the class names; it fails on z-50 and passes on z-[44]. All 13
annotation specs pass, #5213 and #5815 included.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(annotator): take the platform's selection grabbers off a lookup popup

The z-order fix only reaches the app's own handles. iOS draws the selection
grabbers and the callout bar as UIKit views over the whole web layer, outside
the DOM, so no z-index puts a popup above them - not z-50, not a dialog in the
top layer. They sit on the dictionary sheet regardless of stacking.

Deselecting is off the table for a lookup: #5213 wants the selection alive so
dismissing the popup lands back on the selection toolbar. So take the grabbers
away and leave the selection. useTextSelector already knows how, for Android
cross-page drags: empty the selection for one painted frame, then put the same
range back programmatically. The engine only draws grabbers for a
user-initiated selection, so they stay gone, and `handlesSuppressed` hands the
job to the app's own handles - which do stack below the popup now.

Generalise that into `suppressNativeSelectionHandles` (mobile only; desktop has
no grabbers and the dance would just churn the selection the popup is anchored
to), export it, and call it from the dictionary, translator and proofread
openers. It keeps the existing guard so the selectionchange it fires can't
dismiss the popup being opened, and backs off if a competing gesture re-selects
during the empty frame.

Covered by useTextSelector-nativeHandles.test.ts: the range comes back
identical, the selection state flips to handlesSuppressed, desktop is a no-op,
and a competing gesture aborts it. Verified by mutation - dropping the
removeAllRanges fails the first case.

NOT verified on an iOS device; the mechanism is the one already shipping for
Android cross-page, but the grabber behaviour it relies on deserves a device
check before release.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(annotator): drop the note placeholder on any dismiss, not just Cancel

CodeRabbit caught this on the PR, and it is worse than it read: Cancel was the
only path that took back the empty highlight Annotate creates for a note to
hang on, but it is not the only way the editor stops being presented. Opening
the sidebar dismisses the popup from an effect, and so does a page relocate -
and the relocate guard is `isTextSelected.current`, which the previous commit
now clears when the editor opens, so that path went from unreachable to live.
Either one left a highlight the user never asked for.

Hang the #4791 cleanup off the target going away instead of off any one dismiss
path, which is what the pre-#5928 Notebook did: remember the placeholder ids
while the editor is up, take them back when it goes, and clear them on save
(the placeholder carries a note by then, so it is a real annotation).

Regression test drives the sidebar-opening dismiss rather than Cancel; it fails
on the old code with the placeholder still live.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(annotator): drop Insert into Notebook, and match the note editors

Four bits of polish on the annotation surfaces.

The Insert into Notebook action goes: it was a third destination for a note
nobody reaches for, and it took the notebook document store, the sidebar store
and the mobile-sheet dance out of BooknoteItem with it. Its string is pruned
from all 34 locales by the extractor.

daisyUI's `btn` carries a 1px border that `btn-ghost` only colours in on hover,
which `hover:bg-transparent` never touched - so a box appeared around every
icon button and around Cancel/Save. Keep the border for geometry, keep it
invisible: `hover:border-transparent` on the row's icons, on the note bubble's
pencil, and on TextButton, which fixes Cancel/Save everywhere at once.

The sidebar's inline editor now has the same anatomy as AnnotationNoteEditor -
the field, then a bottom-right Cancel/Save row, with the same placeholder - so
a note reads the same whichever editor opened it. It keeps its content height,
since it sits in a list row rather than a sized popup or sheet.

And it now matches on size. `.content.font-size-sm` is 0.875*em*, so it depends
on the ancestor that carries `.content`'s responsive base (16 / 18.4 / 20px).
The sidebar row has it from `li.content`; the popup and sheet did not, so they
fell back to the root 16px and rendered a size smaller. Give the editor
`content` and both land on the same number - measured 14px text and 14px
buttons in both, side by side.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-01 19:29:17 +02:00
Huang Xin
69872d372d
fix(annotator): hide the range editor handles while a lookup popup is open, closes #5815 (#5829)
The selection and annotation range editors (the app-drawn handles that
replace the native ones after an Instant Highlight hold, a tap on an
existing highlight, or the Android hyphen-bounds suppression) are fixed
full-screen overlays rendered after the dictionary / translator /
proofread popups, so their handles floated on top of the dictionary
sheet and overlapped its content.

Hide both editors while a lookup popup is open. They belong to the
toolbar: a lookup dismissed back to the toolbar (#5213) brings them back,
and the full dismiss drops them with the selection.

The e2e spec covers the highlight-tap path on desktop; the Handle gets a
data-testid for it. Verified on a Xiaomi 13 (Android 16): Instant
Highlight hold and highlight tap, then Dictionary, show the sheet with no
handles; a live long-press selection still returns to its toolbar.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-22 20:52:34 +02:00
Huang Xin
07306093eb
fix(annotator): drop the selection when the instant dictionary opens, closes #5585 (#5730)
With Instant Dictionary on, dismissing the lookup popup opened the selection
toolbar. #5213 made every lookup popup return to the toolbar while a selection
is still live, and the in-app dictionary never deselects; on phones the lookup
renders as DictionarySheet, so a backdrop tap goes through onDismiss and raises
the toolbar, which is the report's "tap anywhere".

The instant quick action is the other side of that boundary: the word was
tapped to be looked up, not selected, so the lookup owns the gesture end to
end. It now clears isTextSelected and deselects as the popup opens. The order
is load bearing: view.deselect() fires a selectionchange whose empty selection
branch dismisses the popup while the flag is still set.

The same change fixes the iOS report that the selection grabbers and the blue
highlight paint on top of the dictionary window, since WKWebView draws
selection UI in a native overlay above web content.

The selection toolbar route into the dictionary is untouched: keeping its
selection alive so the word can still be highlighted or copied is exactly what
issue #5213 asked for.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-15 19:11:08 +02:00
ChuwuYo
d8abda1586
fix(annotator): return to the selection toolbar after closing a lookup popup (#5213) (#5526)
* fix(annotator): return to the selection toolbar after closing the dictionary (#5213)

The in-app dictionary path never deselects (handleDictionary only flips
popup flags), so dismissing its popup left the webview selection live
but unreachable — no toolbar, no way to highlight or copy the still-
selected text. Closing the popup or sheet now returns to the selection
toolbar whenever a genuine selection is still alive and the toolbar has
tools, which also covers the quick-action flow the report is about:
look up a word, close the popup, then highlight or copy.

Word Lens gloss taps and taps on an existing highlight synthesize their
selection with isTextSelected left false, and an empty toolbar has
nothing to return to: all keep the full dismiss, as do the system-
dictionary, translator, and proofread paths.

The issue's other ask — firing the dictionary quick action only for
single words — is intentionally not addressed: multi-word terms are
legitimate lookups, so any length gate would be an unreliable
predicate. The issue stays open.

* fix(annotator): cover translator and proofread in the toolbar return (#5213)

The translator and proofread popups keep the selection alive by the same
mechanism as the dictionary — handleTranslation / handleProofread only
flip popup flags — so leaving them on the full dismiss made the dismiss
boundary carry two semantics. Generalize the handler
(handleDismissPopupShowToolbar) and wire it to all three lookup popups.

The consuming actions are a different class by design and stay put:
copy, share, search, and TTS spend the selection (TTS deselects
deliberately to avoid leaving a stray highlight once playback starts),
and highlight / annotate replace it with the created annotation, moving
the context to the highlight options or the notebook note editor.

handleShowAnnotPopup now also hides the proofread popup, so the
transition leaves exactly one popup visible — the toolbar.
2026-08-06 04:49:11 +02:00
Huang Xin
e5cff97caf
feat(reader): jump to an entered page number from the progress label (#5524)
The footer bar's progress label is now an in-place page-number input:
clicking it selects the current page inside the "94 / 251" text so a
target page can be typed over it, and Enter jumps there. The input keeps
its text and width when entering edit mode (an invisible sizer span
reserves the label width), so the surrounding controls never shift.
Reflowable books map the page onto the reading fraction, fixed layout
books go to the spine page directly, and the reference progress style
resolves the book's page-list href when one exists. On mobile, the
progress panel gains the same control as a pill label above the slider.

Closes #3392

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-05 19:00:59 +02:00
Huang Xin
da86aba6b2
fix(reader): stop the header hover strip from covering the page text (#5478)
The header bar's invisible hover trigger was 44px tall, sized to the
toolbar it reveals, which only matched the default top margin. Any
smaller content top left it hanging over the first line of text and
swallowing the press that should have started a selection: the page
header off (compact 16px margin), a reduced top margin, or vertical
writing mode.

Making it inert on mobile fixed the native iPad and Android apps in
#5429, but that gate reads the platform from the user agent, and iPad
Safari reports a desktop one, so the web build kept the bug on the very
device the report came from. Size the strip to the content top instead
of guessing the platform: it now stops where the renderer's margin-top
puts the text, capped at the old 44px, so it cannot cover text anywhere.

Covered by getHeaderTriggerHeight unit cases and a Playwright case that
turns the page header off and hit-tests the first line of text; desktop
Chromium is non-mobile, so it is the only lane where the strip is armed.

Closes #4977

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 19:49:31 +02:00
Huang Xin
a5da9291fb
feat(annotator): add an opt-in Copy Link tool to the selection toolbar (#5464)
Copying a permanent link to a highlight required leaving the reader:
open the sidebar, find the note in a position-sorted list, then tap Copy
there. The selection toolbar's own Copy and Share only ever handled the
plain selected text.

Add a `copylink` tool that copies the annotation URL for whatever the
selection points at. It resolves the note anchored at the selection CFI
so a just-made highlight yields its own link; with no note there yet the
link still targets the position, since deep-link resolution keys off the
CFI. The link form (readest:// or https://) follows the existing note
export `linkType` setting.

The tool ships off the default toolbar, like `share`: it is listed in
ALL_ANNOTATION_TOOL_TYPES but not in DEFAULT_ANNOTATION_TOOLBAR_ITEMS,
so it appears in the Available tray of Settings > Behavior > Customize
Toolbar and only reaches the popup when the user adds it.

Closes #5452

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 15:39:59 +02:00
Huang Xin
be5f07ef88
feat(reader): centralize notes and highlights in the annotations hub, closes #5398, #3870 (#5448)
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (rust) (push) Waiting to run
Publish Docker image / build (linux/amd64, ubuntu-latest) (push) Waiting to run
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Publish Docker image / merge (push) Blocked by required conditions
PR checks / test_web_app (1) (push) Waiting to run
PR checks / test_web_app (2) (push) Waiting to run
PR checks / test_extensions (push) Waiting to run
PR checks / rust_lint (push) Waiting to run
PR checks / build_web_app (push) Waiting to run
PR checks / build_tauri_app (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Deploy to vercel on merge / build_and_deploy (push) Waiting to run
* feat(reader): add filterBooknotes helper for the annotations hub

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(reader): add note bubble transition helpers

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(reader): one click booknote navigation and inline note editing

Clicking a booknote item now only navigates (#3870). With the new
inlineNoteEditing prop the sidebar edits notes in place, including
Add Note on bare highlights, reconciling the note bubble overlay.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(reader): add annotations toolbar with search, filter chips and actions menu

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(reader): unify the sidebar annotations tab into the annotations hub (#5398, #3870)

Adds search, All/Highlights/Notes filter chips and an actions menu to
the annotations tab, suppresses position auto scroll while filtering,
and enables inline note editing on sidebar items.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(reader): reset nearest scroll target while filtering annotations

Clearing the annotations filter left the list stuck at the filtered
scroll offset because lastScrolledCfiRef kept its pre-filter value
throughout the filtering session, so the guard skipped scrollToIndex
once nearestCfi matched it again. Reset the ref on every filtered pass
so clearing the filter always re-centers on the reading position.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(reader): share booknote search semantics via filterBooknotes

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* chore(i18n): extract annotations hub strings

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(reader): compact annotations toolbar with filter dropdown and tap to search

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(reader): merge injected dropdown classes and normalize whitespace notes

AnnotationsMenu and AnnotationsFilterPanel dropped the menuClassName prop
that Dropdown injects, so the no-triangle class never reached the dropdown
card and the legacy triangle notch rendered flush and misaligned.

A whitespace-only inline note draft also saved verbatim, producing a
phantom note that showed as kind Notes and labeled Edit instead of Add
Note. Normalize the draft to an empty string before it is used for the
bubble transition decision and the saved record.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(reader): tighten the annotations toolbar layout

Add bottom padding to the toolbar row, drop the redundant three dot
actions menu (BookMenu in the sidebar header already offers export,
import and clear), and align the filter icon with the pin and info
icons on the same vertical line.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* chore(i18n): sync locales after background image scope switcher

The scope switcher in #5443 replaced the Background Image (Library)
and Background Image (Reader) keys with a shared title plus Library
and Reader labels but the extraction was not rerun. Prune the two
dead keys and translate the new Reader key in every locale, reusing
the wording from each locale's former Background Image (Reader)
translation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(reader): drive annotation search from the sidebar header icon

On the annotations tab the header search icon now toggles the
annotation search input instead of the in-book text search, so the
toolbar keeps only the filter icon. Tab switches close whichever
search is open. Hide horizontal overflow of the tab scroller so the
dropdown toggle's touch target halo cannot produce a horizontal
scrollbar.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(reader): fill the filter toggle only while filters are active

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(reader): reduce the notebook to the note editor and excerpts

The sidebar annotations hub owns browsing notes now, so the notebook
notes list is redundant. The notes tab keeps the note editor for the
annotate flow and the excerpts list; the notebook search now only
covers excerpts and its placeholder says so in every locale.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(reader): dismiss annotation popups on relocate and sidebar open

The note popup was never cleared by the shared dismiss path and no
popup listened for relocates, so it stayed floating over unrelated
text after page turns and scrolling, and on mobile it sat above the
sidebar sheet. Clear the note popup state in handleDismissPopup,
dismiss on real location changes (ignoring same position settle
relocates and in flight selection drags), and dismiss whenever the
sidebar opens so popups never stack above the sheet.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* style(reader): polish annotations toolbar spacing

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(e2e): assert saved notes in the annotations hub

The notebook no longer lists notes, so the add note spec now asserts
the note in the sidebar annotations tab. Opening that tab first closes
an unpinned notebook whose capture overlay would swallow the sidebar
clicks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 21:07:34 +02:00
Brendon
a8aa982c8f
feat(library): show import options from the bookshelf add button (#5247)
The bookshelf "+" tile and the empty-library "Import Books" button opened
the local file picker directly, so the Online Library, feeds and the other
platform-specific import methods were only reachable from the library
header. Both entry points now open the same ImportMenu the header "+"
button uses.

The tile lives inside the virtualized bookshelf scroller, which would clip
a regular dropdown-content, so the menu is rendered as a fixed overlay
anchored to the button that opened it: centered below it, flipped above
when there is no room, and clamped to the safe-area bounds.

Closes #5222

Co-authored-by: Huang Xin <chrox.huang@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-26 08:34:29 +02:00
Huang Xin
28a7785e5d
test(e2e): add a Playwright web e2e lane (reading & annotation flows) (#4214)
* feat(e2e): add Playwright web e2e lane

Adds a web-layer end-to-end suite that drives the Next.js web build
(`pnpm dev-web`) in a real browser, complementing the existing
WebdriverIO suite that drives the Tauri shell.

- playwright.config.ts: single Chromium project, auto-starts dev-web
- e2e/pages: BasePage/LibraryPage/ReaderPage page objects
- e2e/fixtures/base.ts: suppresses demo-book auto-import for a
  deterministic empty library
- e2e/tests: library shell + search, book import, reader open +
  pagination smoke specs
- e2e/fixtures/books: synthetic sample book for import tests
- scripts: test:e2e:web, test:e2e:web:ui, test:e2e:web:report

Tests run unauthenticated against isolated browser contexts;
authenticated/sync flows are out of scope until a test account is
provisioned.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test(e2e): cover reading and annotation flows

Expands the Playwright web e2e lane beyond library/import smoke tests to
exercise the major reading and annotation features against the real
sample-alice.epub fixture (src/__tests__/fixtures/data/).

Reading (reading.spec.ts): open + page turn, TOC chapter navigation,
in-book search, font-size change via the settings dialog, bookmark
toggle.

Annotation (annotation.spec.ts): selection popup, create highlight,
change highlight color, add a note, delete an annotation.

- ReaderPage POM gains sidebar/TOC, search, settings, bookmark and
  annotation actions; text selection is driven inside the section
  iframe (synthetic drags do not produce a selection through nested
  paginated foliate iframes)
- openBook fixture imports and opens a book so specs skip boilerplate
- books.ts centralises fixture book paths
- replaces the old reader.spec.ts smoke

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(e2e): add headed run script and always write HTML report

- test:e2e:web:headed runs the suite in a visible browser, one test at
  a time, with traces captured
- the HTML reporter now runs for local runs too, so every run writes
  playwright-report/ for test:e2e:web:report to open

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test(e2e): fix headed-run flakes in reading and annotation specs

The headed run (slower rendering) surfaced two races that the headless
run happened to pass:

- TOC navigation read reading progress before the section's async
  progress update landed — now polls with expect.poll.
- visibleSectionFrame required a paragraph fully inside the viewport,
  which intermittently matched nothing — now accepts any paragraph
  intersecting the viewport and tolerates frames detaching mid-navigation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* ci: run the Playwright web e2e suite in test_web_app

Adds `pnpm test:e2e:web` to the test_web_app job, after the unit/browser
tests. The job already installs the Chromium browser, and `.env.web` is
committed so the auto-started `pnpm dev-web` server has its config. On
failure the HTML report is uploaded as an artifact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test(e2e): exclude e2e specs from the vitest run

vitest's default glob matches `*.spec.ts`, so it picked up the new
Playwright `e2e/tests/*.spec.ts` files and crashed. Exclude `e2e/`
from vitest — those specs run via `pnpm test:e2e:web`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* ci(e2e): run the web e2e suite against a production build

`next dev` renders a full-screen error overlay when the app emits its
`next-view-transitions` "Transition was aborted" unhandled rejection,
and the overlay intercepts pointer events — making the suite flaky on
CI. CI now builds the web app (`pnpm build-web`) and the Playwright
webServer serves it via `pnpm start-web`; local runs still use
`pnpm dev-web`. Verified: 14/14 pass against the production build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* ci(e2e): run the web e2e suite in the build_web_app job

build_web_app already runs `pnpm build-web`, so the e2e suite belongs
there — it reuses that build (the CI Playwright webServer serves it via
`pnpm start-web`) instead of building a second time in test_web_app.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test(e2e): run the web e2e suite with 4 workers

Specs are isolated (a fresh browser context per test), so they are
safe to parallelize. `test:e2e:web:headed` keeps --workers=1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 08:22:17 +02:00