Repository navigation
feat(reader): auto-scroll for EPUB, Markdown, and PDF - #490
libravault-pipeline-bot[bot] wants to merge 2 commits into
Conversation
Adds a Settings-sheet toggle + speed slider that continuously advances reading position without manual input, across all three reader formats. Two mechanisms, chosen per what the underlying renderer exposes (see AutoScroll.kt's doc): - Continuous pixel scroll for Markdown's ScrollState and PDF's LazyListState (scrolling mode) via ScrollableState.scrollBy. - Timed page-advance for PDF's paginated mode and EPUB (both scroll modes) via a delay loop — Readium's EpubNavigatorFragment (pinned 3.0.0-beta.2) only exposes page-granular goForward(animated), not a pixel-offset scroll API; confirmed against the actual pinned jar. Auto-scroll stops itself (flips the toggle back off) rather than silently going idle, both at the end of the content and when a manual scroll gesture preempts a continuous scroll tick. Session-only, same lifecycle as the reader's other transient settings (scrollMode, warmth) — resets to off each time the reader reopens.
…ngs UI Unit tests for AutoScroll.kt's termination conditions (end of content, manual-gesture preemption, non-positive speed) using a bounded ScrollableState fake, plus ReaderViewModel's clamp/toggle behavior and the Settings-sheet's Auto-scroll switch/slider (Robolectric). Also gives ReaderSettingsSheet's two new callback params defaults so the pre-existing ReaderSettingsSheetUiTest call sites that predate this change keep compiling unchanged. Verified each new AutoScrollTest/ReaderViewModelTest assertion can actually fail: temporarily neutered the end-of-content check (loops forever, red via UncompletedCoroutinesError) and the speed clamp (red via AssertionFailedError), confirmed red, then reverted.
674254d to
5eefdfe
Compare
|
The dev agent's run failed (crashed or exhausted its turn budget) while producing this PR — routed to a human instead of silently advancing an unconfirmed fix to QA. See the workflow run log for what happened. |
|
Automated pipeline health check: Checked the job log for run 32690307736 behind the "crashed or exhausted its turn budget" comment above. This is a genuine hard max-turns cutoff, not a near-miss success or infra flake:
This needs a fresh human decision: raise the cap again, or split #5's scope (EPUB + Markdown + PDF autoscroll, per the UX spec added today) into smaller per-format issues so each fits comfortably under 120 turns. Not self-healing. Generated by Claude Code |
|
Closing without merging — two separate blockers stacked up on this one:
Nothing here is being thrown away — the code itself was reviewed and is solid (see #585/#586/#587/#590, each points back to this PR's specific diff as the starting point for its slice, plus the note that EPUB's Readium |
Summary
Adds a Settings-sheet toggle + speed slider (0.5x–3.0x) that continuously
advances the reading position without manual input, across all three
reader formats (EPUB, Markdown, PDF), per the UX spec on #5 (trigger
lives in the reader's own Settings sheet — the same surface as
theme/font/scroll-mode controls — not a tap-zone or floating in-reader
control).
Closes #5
Approach
Two distinct mechanisms, chosen per what each renderer actually exposes
(see
AutoScroll.kt's doc comment for the full rationale):ScrollableState.scrollByin a tick loop)for Markdown's
ScrollState(always continuous) and PDF'sLazyListStatein scrolling mode.goForward(animated = true)/currentPage++on a delay loop) for PDF's paginated mode and EPUB in both scroll
modes. Readium's
EpubNavigatorFragment(pinned3.0.0-beta.2) onlyexposes page-granular
goForward(animated)/goBackward(animated)—confirmed directly against the pinned
readium-navigatorjar's realbytecode (
javap), since its own "scroll" mode is per-chaptercontinuous scroll stitched together with an internal chapter pager,
not a publicly exposed pixel-offset scroll API (see also
readium/kotlin-toolkit#313,
which documents the components a true cross-chapter continuous scroll
would need as
internal). So EPUB gets the same timed-advancetreatment as PDF's paginated mode rather than a smooth scroll — this
is a real capability gap in the underlying library, not an arbitrary
implementation choice.
Both mechanisms stop themselves (flip the Settings-sheet toggle back to
off via
onAutoScrollEnabledChanged(false)) rather than silently goingidle — at the end of the content, and for the continuous-scroll case,
when a manual drag gesture preempts a scroll tick (Compose's
ScrollableState.scrollByruns atMutatePriority.Default, so ahigher-priority user gesture cancels it mid-tick). Leaving the toggle
showing "on" while nothing is actually advancing would be a silently
broken control, not a paused one.
autoScrollEnabled/autoScrollSpeedare session-only fields onReaderSettings, same lifecycle as the existingscrollMode/warmthfields (reset to off every time the reader screen reopens) — not
persisted, matching this codebase's existing pattern for reader-session
settings (only
themewrites through to a stored preference).Risk / uncertainty callouts
something I could verify against a real device/emulator (no Android
build/emulator available in this environment). I time-boxed manual
verification to: confirming the exact
goForward(Boolean): Booleansignature against the real pinned jar (not guessed), and a careful
read of the call graph. The actual pacing (
AUTO_SCROLL_BASE_PAGE_INTERVAL_MS= 5s at 1.0x) and pixel rate (
AUTO_SCROLL_BASE_PX_PER_SECOND= 30px/sat 1.0x) are my best estimate of a reasonable default, not something
CI's unit tests can validate — worth a deliberate look from whoever
reviews this on a real device before merge.
product wants auto-scroll speed to survive reopening the reader,
that's a separate, larger change touching the same
SharedPreferences-backed mechanismReadingThemePreferenceuses.Test plan
:feature:reader:compileDebugKotlin— clean compile (manually runin this sandboxed environment; verified against real Gradle +
the real pinned Readium dependency, not guessed)
(
ScrollableState.autoScroll/autoAdvancePagesterminationconditions,
ReaderSettings/ReaderViewModelcoercion)./gradlew testDebugUnitTest— full local run (see commit historyfor status)
callout above) — left to review, no device available here