Repository navigation
WEBDEV-8991: Keep browse loan alive during read aloud - #1598
Open
nsharma123 wants to merge 1 commit into
Open
nsharma123 wants to merge 1 commit into
nsharma123 wants to merge 1 commit into
Conversation
A patron reported their book being auto-returned "due to inactivity" after an hour while actively listening to read aloud. ia-book-actions only learns a patron is still there from `userAction`, which is otherwise triggered solely by an index change (see BookReader.prototype.updateFirstIndex) or a navbar click. Read aloud produces neither reliably: in 2up the engine reads both visible pages before it flips, so a spread can easily outlast the 15 minute window the loan renewal allows, and the loan lapses mid-playback. Once it lapses, renewal has to pass an availability check it would have skipped while the loan was still held, so the book can be lost to another patron entirely. Drive the signal off playback progress instead: - emit `userAction` per chunk in beforeChunkPlay, throttled to once a minute since chunks are paragraphs and short ones would otherwise signal every few seconds for no benefit - emit on resume as well, which picks up inside the current chunk and would otherwise wait for the next chunk boundary to register No change needed on the ia-book-actions side, which already treats `userAction` as a page change for renewal purposes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1598 +/- ##
=======================================
Coverage 63.81% 63.81%
=======================================
Files 69 69
Lines 6256 6256
Branches 1391 1391
=======================================
Hits 3992 3992
Misses 2225 2225
Partials 39 39 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
A patron reported their book being auto-returned "due to inactivity" after an hour while actively listening to read aloud — WEBDEV-8991.
ia-book-actionsdecides a browse loan is still in use from theBookReader:userActionevent. That event is triggered in exactly two places today:BookReader.prototype.updateFirstIndex()— the displayed index changedNavbar.js— a navbar control was clickedRead aloud produces neither reliably. It only turns a page incidentally, via
maybeFlipToIndex(), and in 2up the engine reads both visible pages before it flips — so a single spread can easily outlast the 15 minute window the renewal allows (pageChangedInLast). The renewal check at minute 49 then sees no recorded activity and the loan lapses mid-playback.This is worse than a late renewal. While the loan is still held,
Lending::do_renewtakes the$true_renewalbranch and skips the availability/policy gate. Once it lapses, the next attempt has to pass that gate — so the book can be lost to another patron outright.Fix
Drive the activity signal off playback progress rather than the incidental page flip:
beforeChunkPlay()emitsuserAction, so every paragraph spoken counts.throttle(fn, threshold, false)fires leading-edge, so the first chunk signals immediately.No change is needed in
ia-book-actions— it already mapsuserActiononto its page-changed path for renewal purposes.Testing
max-len; indent/semi/no-unused all satisfied).BookReaderPlugin's constructor does not callsetup()—BookReader.jsconstructs the plugin, then callssetup()as a separate statement — sosignalUserIsActiveis initialized before theresumehandler is registered.ttsEngine.eventsis a jQuery emitter andAbstractTTSEnginealready registers a class-field arrow the same way, so the idiom matches existing code.I was not able to run the jest suite locally (no
node_modulesin my checkout); relying on CI here. There is currently noplugin.tts.test.js— happy to add one covering the emit + throttle if reviewers want it in this PR.Out of scope
The "Are you still there?" warning modal is acknowledge-only —
dismissWarningModal()closes it without renewing, and sets a flag that suppresses every later warning. That lives inia-book-actionsand likely deserves its own ticket.🤖 Generated with Claude Code