Skip to content

feat: Add support for chapter-completion estimate in reading status bar - #159

Open
kinland wants to merge 20 commits into
franssjz:masterfrom
kinland:feature/chapter-eta
Open

kinland wants to merge 20 commits into
franssjz:masterfrom
kinland:feature/chapter-eta

Conversation

@kinland

@kinland kinland commented Jul 29, 2026

Copy link
Copy Markdown

Summary

  • What is the goal of this PR? Supplement the existing Chapter Page progress indicator with a stat-informed time estimate to make it easier to plan reading sessions.
  • What changes are included?
  • The existing page indicator setting has been replaced with 4 toggle options: Pages (e.g. 8/32), Pages + Time (e.g. 8/32 (15m)), Time (e.g. 15m), and Hide

Additional Context

  • Tested only on an X3, as I have no X4 to test on, but since I'm not making use of the X3's clock, I don't think there should be a difference
  • I've read through about 5 chapters with this feature enabled and the estimates seem reasonably accurate (generally within 1m of initial/subsequent estimates)
  • Original implementation was based on chapter word count. I replaced this with a simpler page count based estimate - less accurate, but really only impacted by images or pages that are mostly whitespace, so the trade-off seemed acceptable.

Slightly out of date image, as I added spaces around the + in the setting name.
image


AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? YES

kinland added 20 commits July 27, 2026 18:33
- Add Customise Status Bar toggle 'Chapter Time Remaining Estimate' (under Chapter Page Count), including web settings
- Format as '8/32 (15m)' with page count, or '15m' alone (h/d/y supported)
- Estimate from remaining chapter words / word reading rate, not page-turn rate, so image/sparse pages do not inflate time
- Bump section cache to v41 to store per-page word counts; extrapolate unbuilt content from HTML byte density
- Track totalWordsRead plus current-session words in reading stats; blend historical and live rates (needs ~80 words and ~1 min before showing)
- Replace the dual Chapter Page Count / Chapter Time Remaining toggles with one Chapter Progress enum: Pages, Pages+Time, Time, Hide (default Pages)
- Migrate legacy dual-toggle and older status-bar settings into the combined enum
- Keep status bar formats 8/32, 8/32 (15m), and 15m, including web settings
- Persist session words even for short uncounted sessions so ETA rate stays aligned with credited reading time
- Credit each spine/page only once via a high-water mark to avoid back/forward double-counting
- Preserve totalWordsRead in the browser stats editor round-trip
- Remove unreachable dead code after loadSettingsDirect return
- Drop dual-toggle chapter-progress migration; map only the older page-count toggle to Pages/Hide
- Make getEffectiveWordsPerMs active-book-only and remove unused getActiveSessionWordsRead
- Inline estimateRemainingMs at the call site; DRY formatCompactDuration; one-pass estimateRemainingWords
- Store totalWordsReadingMs co-collected with totalWordsRead instead of using lifetime totalReadingMs
- Persist word samples immediately and drop unpaired historical words on load
- Restore dual-toggle chapter-progress migration; expose paired fields in the stats editor
- Credit words by page dwell with linger-based re-read; clear dwell on jumps so skipped pages are not counted
- Align remaining-word extrapolation with estimatedTotalPages and drop duplicate LUT word counts
- Harden compact duration formatting and share formatRemainingFromRate
- Index and cache per-page word counts with TXT page offsets
- Reuse dwell-based word credit and shared remaining-time formatter in the TXT status bar
- Tighten progress spacing and title padding when pages+time+% are shown
- Fix statusBarTitle clamp against the title enum
Clear dwell on jumps/menus, share credit helpers, persist word-rate samples, localize ETA units, and fall back to pages until a rate exists.
Restore resumeSession via openReaderSubactivity, share PageDwell and layout word counting, drop TXT per-page word RAM, and stop the editor from wiping sub-minute ETA samples.
Credit last-page words before endSession, keep TXT remaining exact via on-disk word counts, align UTF-8 layout word splits with EPUB, and drop dwell wrapper indirection.
Keep lastSessionSnapshot on idempotent endSession, cache TXT remaining words, share dwell credit helper, and document intentional ETA tradeoffs.
Drop the TXT remaining-words RAM cache, compose Pages+Time from existing strings, and harden dwell credit / overflow edge cases.
Cache TXT remaining words, share chapter-progress labels, avoid SD credit on the hot path, and keep EPUB known-word totals for ETA.
Drop the TXT per-page word table, remaining-words cache, and shared
utf8CountLayoutWords helper. Keep EPUB exact words; TXT credits average
words/page and estimates remaining from totalBookWords × pages left.
Collapse restart/noteEnteredIfChanged/creditMs/markCredited into
clear + noteEntered + takeCredit. Same min/re-read dwell rules; fewer
call-site branches in EPUB/TXT readers.
Move PageDwell to a header-only helper, chapter-progress labels onto
CrossPointSettings, and ETA duration formatting into ReaderUtils.
Credit one page per qualified dwell sample and estimate remaining time
from pages left ÷ pages/ms. Drop Section/TXT word tables, Page::countWords,
and word-sample stats fields in favor of paired page samples.
Rename page-credit helpers, keep Section cache at v40 with accurate
comments, move ETA formatters into ReaderUtils.cpp, restore const on
TXT cache save, and clarify chapter-progress / legacy word-field handling.
@kinland kinland changed the title Add support for chapter-completion estimate in reading status bar (feat) Add support for chapter-completion estimate in reading status bar Jul 29, 2026
@kinland kinland changed the title (feat) Add support for chapter-completion estimate in reading status bar feat: Add support for chapter-completion estimate in reading status bar Jul 29, 2026
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.

1 participant