fix(mobile): reader bug sweep — TOC + progress + selection + save + relaunch#247
Open
mrviduus wants to merge 2 commits into
Open
fix(mobile): reader bug sweep — TOC + progress + selection + save + relaunch#247mrviduus wants to merge 2 commits into
mrviduus wants to merge 2 commits into
Conversation
…elaunch 5 user-reported mobile reader bugs + senior architecture refactor. Bugs fixed: - TOC sheet rendered empty silently → loading/empty states + minHeight - Save word didn't close toolbar → setSelection(null) + race guard - SelectionActionBar had no close button → X + native selection clear - Progress bar showed chapter % not book % → computeBookProgress shared utility - App relaunch on 'random screens' → ColdResetOnResume after 30min, route-aware Architecture (extracted to @textstack/shared): - bookProgress.ts — pure book-wide % calculation - progressPayload.ts — payload builder + parseScrollLocator (multi-colon defense) - continueReading.ts — LWW merge picker for home card - lib/pathPrefix.ts — PII-safe analytics path compression Mobile hooks: - useReaderProgress (existing) refactored - useUserBookProgress (new) — sibling hook with identical contract - useFlushOnBackground — Android OS-kill mitigation, reentry-safe Telemetry: - app_resumed_from_background event for post-launch debug - bucket_minutes + path_prefix + protected_route flag Tests: - 144 unit (5 reader modules + pathPrefix) + 9 properties (~2300 cases) - Behavioral coverage 100% on shared/reader + shared/lib - E2E TOC regression guard in reader-smoke.spec.ts Docs: - ADR-011 mobile reader progress architecture - ADR-007 cross-link to ADR-011 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Five Android mobile reader bugs blocking Play Store launch, plus senior architecture refactor extracting pure logic to
@textstack/sharedso both catalog and user-book readers share the same formulas (book-progress, LWW merge, locator parsing).Bugs fixed
minHeightsetSelection(null)after success + race guardcomputeBookProgress()+LocalProgress.bookPercentcacheColdResetOnResumeafter 30 min background, route-aware (skips reader)Architecture (new in
@textstack/shared)reader/bookProgress.ts— pure book-wide % calculation (word-count weighted + chapter-index fallback)reader/progressPayload.ts— payload builder +parseScrollLocator(handles slug-with-colons via split-from-right)reader/continueReading.ts— LWW merge picker for homeContinueReadingCardlib/pathPrefix.ts— PII-safe pathname compression for analyticsMobile hooks
useUserBookProgress(new) — sibling ofuseReaderProgresswith identical contractuseFlushOnBackground(new) — Android OS-kill mitigation, reentry-safe, try/catch isolateduseReaderProgress(existing) refactored to useuseFlushOnBackgroundTelemetry
app_resumed_from_backgroundanalytics event with PII-safebucket_minutes+path_prefix+was_in_protected_route+reset_to_home— for post-launch dashboard debugging of "random screens" reportsTests
shared/reader+shared/lib. Uncovered branches are defensive dead code (e.g.parseIntafter strict-digits regex)apps/mobile/e2e/tests/reader-smoke.spec.tsextended with TOC regression guardDocs
docs/01-architecture/adr/ADR-011-mobile-reader-progress-architecture.md) — documents Android-first platform priority, client-side book-progress strategy, sibling-hooks decisionVerification
Rollback plan
Single revert —
git revert <merge-sha>. No DB migrations, no feature flags, no API changes. Local AsyncStorage entries (bookPercent) are additive and ignored by older builds.Notes
Date.parse('garbage')returned NaN silently — now guarded viaparseEpochMs()accepting both ISO string + epoch numbersplit(':')locator parsers in both readers would break on chapter slugs containing:— centralised in sharedparseScrollLocator()with round-trip property teststrack()only console.debug — Firebase/Sentry SDK wire is next slice)🤖 Generated with Claude Code