Skip to content

feat(reader): auto-scroll for EPUB, Markdown, and PDF - #490

Closed
libravault-pipeline-bot[bot] wants to merge 2 commits into
devfrom
feature/reader-autoscroll
Closed

libravault-pipeline-bot[bot] wants to merge 2 commits into
devfrom
feature/reader-autoscroll

Conversation

@libravault-pipeline-bot

Copy link
Copy Markdown
Contributor

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):

  • Continuous pixel scroll (ScrollableState.scrollBy in a tick loop)
    for Markdown's ScrollState (always continuous) and PDF's
    LazyListState in scrolling mode.
  • Timed page-advance (goForward(animated = true) / currentPage++
    on a delay loop) for PDF's paginated mode and EPUB in both scroll
    modes. Readium's EpubNavigatorFragment (pinned 3.0.0-beta.2) only
    exposes page-granular goForward(animated)/goBackward(animated) —
    confirmed directly against the pinned readium-navigator jar's real
    bytecode (javap), since its own "scroll" mode is per-chapter
    continuous 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-advance
    treatment 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 going
idle — at the end of the content, and for the continuous-scroll case,
when a manual drag gesture preempts a scroll tick (Compose's
ScrollableState.scrollBy runs at MutatePriority.Default, so a
higher-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/autoScrollSpeed are session-only fields on
ReaderSettings, same lifecycle as the existing scrollMode/warmth
fields (reset to off every time the reader screen reopens) — not
persisted, matching this codebase's existing pattern for reader-session
settings (only theme writes through to a stored preference).

Risk / uncertainty callouts

  • EPUB's page-advance interval is a product-feel judgment call, not
    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): Boolean
    signature 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/s
    at 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.
  • No new persistence layer was added deliberately (see above) — if
    product wants auto-scroll speed to survive reopening the reader,
    that's a separate, larger change touching the same
    SharedPreferences-backed mechanism ReadingThemePreference uses.

Test plan

  • :feature:reader:compileDebugKotlin — clean compile (manually run
    in this sandboxed environment; verified against real Gradle +
    the real pinned Readium dependency, not guessed)
  • Unit tests added for the new pure logic
    (ScrollableState.autoScroll/autoAdvancePages termination
    conditions, ReaderSettings/ReaderViewModel coercion)
  • ./gradlew testDebugUnitTest — full local run (see commit history
    for status)
  • Manual on-device verification of page-turn pacing feel (see risk
    callout above) — left to review, no device available here

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.
@libravault-pipeline-bot
libravault-pipeline-bot Bot force-pushed the feature/reader-autoscroll branch from 674254d to 5eefdfe Compare August 24, 2026 04:55
@github-actions github-actions Bot added the status:needs-info Dev/QA agent needs more detail before proceeding label Aug 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Collaborator

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:

"stop_reason": "tool_use"
"terminal_reason": "max_turns"
"subtype": "error_max_turns"
"errors": ["Reached maximum number of turns (120)"]

dev-agent.yml's triage-and-implement step is already configured at --max-turns 120 on current dev (higher than the 90 cap from #267 that this routine was tracking) — so this issue already ran against the current cap and still exhausted it. Per this routine's rules, that's not eligible for another silent retry (never retry a confirmed hard-crash against the same cap twice).

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

@libravault-xyz

Copy link
Copy Markdown
Collaborator

Closing without merging — two separate blockers stacked up on this one:

  1. dev-agent hit a hard max_turns crash (120-turn cap) producing this PR (confirmed via the job log: stop_reason: tool_use, terminal_reason: max_turns, errors: ["Reached maximum number of turns (120)"]), leaving the "Test plan" checklist genuinely incomplete — no full testDebugUnitTest run confirmed, no on-device pacing verification. Not retry-eligible against the same cap (same pattern independently hit Code review cleanup batch: 8 low-severity findings (L1-L8) #530 and Dependency/supply-chain hygiene: readium beta pin, vendored sherpa-onnx provenance, OSV in CI #531 the same day). Raised the cap 120→150 in fix(ci): raise dev-agent's --max-turns from 120 to 150 #583, and split [enhancement] Autoscroll for ePub and PDF #5's three-format scope into four smaller issues (Auto-scroll: shared plumbing — ReaderSettings, ReaderViewModel, Settings UI (#5) #585 shared foundation, Auto-scroll for Markdown reader (#5, depends on #585) #586/Auto-scroll for PDF reader (#5, depends on #585) #587/Auto-scroll for EPUB reader (#5, depends on #585) #590 per-format) sized to fit comfortably under even the old cap.
  2. Now has real merge conflicts with dev, caused by [Vault Unification Phase 1] Introduce ContentSource abstraction, unify EPUB/PDF/Markdown reading, delete VaultReaderScreen #505/PR feat(vault): unify EPUB/PDF/Markdown reading via ContentSource, delete VaultReaderScreen (#505 Phase 1) #543 landing today — that PR restructured exactly the files this one touches (ReaderViewModel.kt's ReaderUiState.item → contentSource/title/format, its init{} rewritten into a 3-way branch, ReaderScreen.kt, ReaderSettings.kt, ReaderViewModelTest.kt). This PR's diffs would need reconciling against that new shape, not just conflict-resolving.

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 goForward-only API constraint was already verified against the real pinned jar via javap, worth reusing rather than re-deriving). The architecture (AutoScroll.kt's two mechanisms, chosen per what each renderer actually exposes), the self-stopping behavior, and the test coverage (verified-red-then-green per the PR description) all carry forward as the reference implementation for the split issues.

@libravault-xyz
libravault-xyz deleted the feature/reader-autoscroll branch August 25, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:needs-info Dev/QA agent needs more detail before proceeding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[enhancement] Autoscroll for ePub and PDF

1 participant