UI: fix pause in task audio playing (with glm-5.1 model help)#2893
UI: fix pause in task audio playing (with glm-5.1 model help)#2893
Conversation
|
Frontend test coverage: 72.32% (-0.13% compared to 72.45% on base) |
|
Frontend test coverage: 72.31% (-0.14% compared to 72.45% on base) |
lifeart
left a comment
There was a problem hiding this comment.
A few concerns with the approach:
Fix the root cause in onIdle, not at every call site. The simpler fix is in studying-timer.ts:
onIdle() {
if (player.audio?.isPlaying) return;
player.pause();
}That removes the need for resetIdle(), the three scattered call sites in task-player, and the guard in onPauseStateChanged. Every new audio site won't have to remember to call resetIdle().
Silent catch in resetIdle(). idle-js is pinned to a specific version, so the "may not support stop/start cycle" justification doesn't hold. Drop the try/catch or at least console.error(_e).
onPauseStateChanged change breaks user-initiated pause. studyingTimer.isPaused is shared between idle-pause and user-clicked-pause. With && !this.audio.isPlaying, clicking the pause button while audio is playing no longer stops audio. If the root-cause fix above is applied, this guard goes away and user-pause keeps working.
resetIdle() is misnamed. It also force-resumes a paused timer and calls relaunchStartedTimer(). The name suggests a passive idle-watcher refresh. Either split or rename (e.g. keepActive()).
Redundant calls. audio.startPlayTask() calls resetIdle(), and the component calls it again before setAudioElements/playAudio in listen/interact modes. Pick one layer.
Tests:
- The new unit test reimplements the component logic inline ("Reproduce the logic from TaskPlayerComponent") — it passes whether or not the real component matches. Not a regression guard.
resetIdle()itself is untested.- No test for the actual reported scenario: 5+ playbacks without mouse movement. Without it this can silently regress.
Minor:
audio.ts:37— useimport typeforStudyingTimerService.index.gts:295— restored blank line is unnecessary diff churn.- Comments on the new calls describe what, not why. Drop or shorten.
|
Two corrections to my earlier review:
The other points stand: user-pause UX regression ( |
Move the audio-vs-idle reconciliation into studying-timer's onIdle handler instead of resetting the idle watcher around every playback. StudyingTimer now skips pause via maybeIdlePause() when audio is playing, so user-initiated pause still stops audio immediately. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Frontend test coverage: 72.49% (+0.09% compared to 72.4% on base) |
|
Frontend test coverage: 72.42% (+1.16% compared to 71.26% on base) |
|
|
Frontend test coverage: 71.26% (-1.21% compared to 72.47% on base) |



##GithubTaskNumber
Исправлено: аудио останавливается после ~5 воспроизведений из-за idle-таймера
Корневая причина
Библиотека
idle-js(конфигidleTimeout: 10000= 10 сек) определяла «бездействие» пользователя (нет движений мыши) и ставила упражнение на паузу черезstudyingTimer.pause(). Это вызывалоaudio.stop(), и упражнение зависало до следующего движения мыши.Изменённые файлы (4 файла)
1.
frontend/app/services/studying-timer.ts— добавлен методresetIdle():isPaused, если таймер на паузе2.
frontend/app/services/audio.ts— инжекцияstudying-timer+ вызовresetIdle():@service('studying-timer') studyingTimerstartPlayTask()вызываетсяthis.studyingTimer.resetIdle()перед воспроизведением3.
frontend/app/components/task-player/index.gts— защита аудио от idle-прерывания:onPauseStateChanged(): теперь НЕ останавливает аудио, если оно сейчас играет (!this.audio.isPlaying)listenModeTask: добавленthis.studyingTimer.resetIdle()перед каждым воспроизведением словаinteractModeTask: добавленthis.studyingTimer.resetIdle()перед воспроизведением4.
frontend/tests/unit/components/task-player/component-test.js— обновлены тесты:isPlayingв мокcreateComponentonPauseStateChangedв тестахКак это работает теперь
isPlaying)