From eee83d6cb98ae08800dc607e1d9ce9c12e0fbb39 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 11 Apr 2026 00:52:39 -0400 Subject: [PATCH] fix: Synchronize currentSpineIndex with position.spineIndex on position updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL BUG FIX: The UniversalReader interface had a duplicate spine index issue: - Top-level property: currentSpineIndex: number - Nested property: position.spineIndex: number When navigation updated the position object, only position.spineIndex was updated, but the top-level currentSpineIndex remained unchanged. This caused a mismatch that broke navigation across spine boundaries. ROOT CAUSE: - Navigation functions update position (which contains spineIndex) - updateCurrentPosition() only spread position, not currentSpineIndex - progress-indicator.ts reads from currentSpineIndex to get spine info - Result: Trying to access spine 0 when actually on spine 1, etc. THE FIX: Add currentSpineIndex to the returned object in updateCurrentPosition(): return { ...book, position, currentSpineIndex: position.spineIndex, // Keep them in sync }; IMPACT: ✅ Navigation works correctly across spine boundaries (e.g., cover → content) ✅ Progress indicator displays accurate chapter information ✅ Content rendering uses correct spine data ✅ No more state corruption when navigating between spines This fix ensures that both spine index properties stay synchronized, preventing the navigation failures that occurred when crossing from one spine item to another (e.g., from cover.xhtml to Frankenstein.xhtml). Related to: Spine boundary navigation, state synchronization --- web/src/reader/formats/reflowable/progress-tracker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/web/src/reader/formats/reflowable/progress-tracker.ts b/web/src/reader/formats/reflowable/progress-tracker.ts index af3dbf4..e39d05f 100644 --- a/web/src/reader/formats/reflowable/progress-tracker.ts +++ b/web/src/reader/formats/reflowable/progress-tracker.ts @@ -11,6 +11,7 @@ export function updateCurrentPosition( return { ...book, position, + currentSpineIndex: position.spineIndex, }; }