From cfc0a06bb12f9c4adc3ce97faba40326949ead02 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Thu, 4 Dec 2025 20:49:16 +0100 Subject: [PATCH] Fix race condition with autoCenter/autoScroll during loadBlob (#4187) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed a race condition where autoScroll and autoCenter would sometimes cause the scroll position to jump to the beginning when loading a blob. The issue occurred when renderProgress was called while the audio data was still being loaded/decoded (duration temporarily 0 or invalid), which triggered scrollIntoView to scroll to position 0. The fix adds a guard to only call scrollIntoView when valid audio data exists with a duration > 0, preventing the race condition. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .gitignore | 1 + src/renderer.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 427f60e06..016cb5d81 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ cypress/**/__diff_output__/ .env coverage/ eslint_report.json +.beads/ diff --git a/src/renderer.ts b/src/renderer.ts index a3ca21617..4ba50190b 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -725,7 +725,8 @@ class Renderer extends EventEmitter { ? `translateX(-${progress * this.options.cursorWidth}px)` : '' - if (this.isScrollable && this.options.autoScroll) { + // Only scroll if we have valid audio data to prevent race conditions during loading + if (this.isScrollable && this.options.autoScroll && this.audioData && this.audioData.duration > 0) { this.scrollIntoView(progress, isPlaying) } }