Repository navigation
feat(reading): V2 reader page protocol for bars: tap position, direction, keys, flush (#1263) - #1287
Merged
Merged
Conversation
tap carries x, y (page viewport, scaled frames too); opened carries dir (foliate's book.dir); key forwards a closed list of navigation keys from a section; flush() plus a flush on hidden and pagehide. chrome.mjs: navKey and the hosts' readers, used by both hosts. tsrtl.epub fixture. BUDGET 263379. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
tap and keys from the page's own document too; keys only on the document itself, never Shift+arrow, with repeat; keyAction in chrome.mjs and both hosts turn on prev/next (repeats dropped); dir as the renderer pages (pagedDir) on opened and relocate; Hebrew fixture; onLoad pin restored; web pagehide gap documented. BUDGET 264121. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
highlightSelection of the live selection; page rebuilt, BUDGET 264403. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 12, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four additions to the V2 reader page's protocol that the reader chrome needs: a tap says where it landed, the page says which way the book pages, navigation keys pressed inside the book reach the host, and the host can ask for a pending save at once. Both hosts turn pages on the forwarded keys; bars and tap zones come in the next two PRs.
Stack: 2 of 4. Base is #1285 (selection event). Merge order: #1285 → this → Android bars → web bars. Full CI runs here only after GitHub retargets this PR to
main.Slice
Wave 14, B4/B5 (page half). Refs #1263, Refs #1264 (both are closed by the host PRs).
Protocol
Changes
tapcarries x/y, mapped likeword.rect(a scaled fixed-layout frame is right). Also posted for a click on the page's own document: in paginated flow the outer columns and the margin rows are outside every section frame, which is exactly where edge zones are. A press that dismisses a selection still sends onlyselection-cleared.diris the direction the renderer actually pages by: a fixed-layout book's page-progression direction; a reflowable book's shown section, read the way the paginator reads it. A Hebrew EPUB with no spine attribute isrtl; a spinertlover English text isltr. It ridesopenedand everyrelocate.key: a closed list of six keys, never with Ctrl/Alt/Meta, never an arrow with Shift (keyboard selection keeps working), only when the key's target is the document body (a focused<summary>, button, link, media control, form field keeps its key). Listened for on section documents and on the page's own document. The default is prevented for forwarded keys. Auto-repeats carryrepeat: true.relocate.moved: true only when the reader moved the place themselves (swipe, scroll,prev()/next()); false for the open and restore, an anchored re-layout (resize, rotation, font, flow) and a hostgoTo. It is the save rule's own test, computed once, so hosts stop guessing from CFI or fraction differences when to hide the bars.flush(), and the page flushes itself onvisibilitychange→ hidden and onpagehide.chrome.mjs(+.d.mts), shared by both hosts:navKey, the readersreadTap/readDir/readKey(bounded, closed lists, fresh objects; the page renders untrusted book content), andkeyAction({ key, shift, dir }) → 'prev'|'next'|'bars'|null.V2ReaderScreen.tsx,V2ReaderHost.tsx): keep the latestdir, drop repeats, turn the page onprev/next. So keyboard paging works on this PR alone, including Space in scrolled flow, which the page now cancels.BUDGET→ 264410 with ledger lines; generated page rebuilt. New fixturestsrtl.epub,tshe.epub.Tests
chrome.test.ts(readers incl. hostile payloads,navKeytargets, everykeyActionbranch),V2ReaderHost.test.tsx(keys → turns,dirfromopenedandrelocate, repeats dropped).<summary>; Shift+Arrow extends a selection; repeats;flush(), hidden,pagehideeach write once;dirfor the three direction cases.tsc0, vitest 1441; webtsc0, vitest 1178 passed / 3 skipped; web build,check:v2-reader,-formats,-sandbox,-prod-cspok.Rollback plan
Revert the PR. No server, schema or stored-data change.
Docs: updated (
apps/mobile/src/lib/v2reader/README.mdprotocol rows,flush()row)Notes
What the review changed (/code-review high, 10 findings; 8 fixed, 1 documented, 1 did not reproduce as written)
dircame from the spine attribute only, which is not what the paginator lays out by. An earlier row of this PR asserted the wrong value and was corrected.Known and left
pagehideflush cannot reach the host).visibilitychange→ hidden is covered.vertical-rl) is not mapped:dirreadsdirectiononly.relocateat all (foliate's#justAnchored), so that one scroll is not seen as a move; fixing it needs a fork change.Device checks owed by the owner
rtl.🤖 Generated with Claude Code