Skip to content

Count Read Aloud media session controls as user activity - #1597

Open
cdrini wants to merge 1 commit into
internetarchive:masterfrom
cdrini:user-action-capture-listeners
Open

cdrini wants to merge 1 commit into
internetarchive:masterfrom
cdrini:user-action-capture-listeners

Conversation

@cdrini

@cdrini cdrini commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Description

Patrons listening to a book with Read Aloud can have it returned out from under them ("This book has been returned due to inactivity"). A 1-hour browse loan only auto-renews when ia-book-actions sees a BookReader:userAction, and BookReader only emitted that on page-index changes and navbar button clicks — so someone who is listening rather than clicking looks idle.

Media session controls (lock screen, notification shade, headset buttons) now count as user activity, so using them renews the loan. The signal is also widened generally: it now comes from listeners over the whole reader, including the read aloud toolbar's dropdowns and the item-navigator side menu, instead of an enumerated list of navbar buttons.

This helps but does not fully fix it — a patron who listens for a straight hour without touching anything can still be returned. That needs a different strategy.

Testing

  1. Go to https://deploy-preview-1597--ia-bookreader.netlify.app/bookreaderdemo/demo-internetarchive?ocaid=theworksofplato01platiala
  2. In the console, run: window.addEventListener('BookReader:userAction', () => console.log('userAction', new Date()))
  3. Start Read Aloud, then pause/resume from your OS media controls (lock screen, notification shade, or headset button) — each press should log userAction.
  4. Click the read aloud toolbar buttons, the speed and voice dropdowns, and anything in the side menu — each should log userAction.
  5. Check the navbar still behaves normally: page turn, zoom, view mode and fullscreen should all work, and log userAction once per click.

Co-Authored-By: Drini Cami <cdrini@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cdrini
cdrini force-pushed the user-action-capture-listeners branch from f25b572 to 1698eab Compare September 14, 2026 18:50
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.90476% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.79%. Comparing base (882adbc) to head (1698eab).

Files with missing lines Patch % Lines
src/plugins/tts/WebTTSEngine.js 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1597      +/-   ##
==========================================
- Coverage   63.81%   63.79%   -0.02%     
==========================================
  Files          69       69              
  Lines        6256     6272      +16     
  Branches     1391     1394       +3     
==========================================
+ Hits         3992     4001       +9     
- Misses       2225     2232       +7     
  Partials       39       39              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants