Repository navigation
TTS再生が途中で打ち切られ英語に飛ぶ不具合を修正(iOS早期didJustFinishガード/再生中の時間制限撤廃) - #6282
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughttsAudioPlayer で ChangesTTS再生完了判定と準備段階ウォッチドッグの改善
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/hooks/useTTS.ts`:
- Around line 26-31: The comment in the useTTS hook contains an incorrect
function reference. In the comment block explaining the playback watchdog
timeout behavior, change the reference from "armPlaybackWatchdog" to
"clearPlaybackWatchdog" on the line that mentions when the timeout is released
once actual audio playback begins. This will align the comment with the actual
function name that clears the timeout.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 66feae5d-2350-449a-add3-83cc76bc9e15
📒 Files selected for processing (2)
src/hooks/useTTS.test.tssrc/hooks/useTTS.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/utils/ttsAudioPlayer.ts`:
- Around line 61-100: In the handleDidJustFinish function, the
player.seekTo(position) call returns a Promise but player.play() is called
immediately afterward without awaiting the seek operation to complete. This can
cause playback to start from the wrong position before the seek finishes. Modify
the code to await the Promise returned by seekTo before calling play(), ensuring
the seek operation completes before playback begins. The try-catch block should
be updated to handle the async flow correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 843de881-c30e-400c-acfe-62b178fc1b4f
📒 Files selected for processing (3)
src/hooks/useTTS.tssrc/utils/ttsAudioPlayer.test.tssrc/utils/ttsAudioPlayer.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/hooks/useTTS.ts
概要
長い日本語アナウンスがiOSで途中で打ち切られ、英語アナウンスに飛んでしまう不具合を修正する。
調査の結果、JA→ENの切り替えトリガーはJAプレイヤーの
didJustFinish(再生完了報告)のみであることが分かった(useTTS.ts)。iOSは長尺音声で、音声セッションの一時中断やデコード境界などにより本来の終端より手前でdidJustFinishを誤報することがあり、これをそのまま「完了」と扱うため、日本語が途中で打ち切られて英語へ進んでしまっていた。ttsAudioPlayer.tsに終端到達判定ガードを追加し、終端付近に達していない完了報告は早期完了とみなして再生を継続するようにした。あわせて、当初の
PLAYBACK_TIMEOUT_MS(5分)は再生中でも強制的に打ち切る設計だったため、再生開始時に解除して健全な再生を時間で打ち切らないようにした(フェッチ・トークン取得段階のハング保護としては維持)。変更の種類
変更内容
src/utils/ttsAudioPlayer.ts:didJustFinish受信時に再生位置(status.currentTime)と長さ(status.duration)を確認し、終端付近(FINISH_END_EPSILON_SEC以内)に達していない完了報告を「早期完了」とみなすガードを追加。> 0)場合はその位置へseekToしてからplay()で再開し、途中打ち切り(=次言語への早期遷移)を防止。位置が0(リセット報告)や終端付近の場合は従来どおり完了として進めるため、最悪でも現状維持で劣化しない。MAX_RESUME_ATTEMPTSを設定。実機での原因特定用に早期完了時のcurrentTime/duration/playbackStateをconsole.warnに記録。src/hooks/useTTS.ts:PLAYBACK_TIMEOUT_MS(5分)を「再生開始前(フェッチ・トークン取得)のハング保護」専用に役割変更し、実際の再生開始時にclearPlaybackWatchdogで解除。再生中は時間によらず打ち切らない(進行停止検知はttsAudioPlayerのストール監視に委ねる)。armPlaybackWatchdog→clearPlaybackWatchdog、CodeRabbit指摘)。src/utils/ttsAudioPlayer.test.ts: 終端付近の完了は正常完了、終端手前の完了はseekToで再開、位置0の完了は再開せず完了、上限超過で完了として打ち切る、を検証。src/hooks/useTTS.test.ts: 再生開始後は時間が経過しても打ち切られないことを検証。テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること実行結果:
npx jest src/utils/ttsAudioPlayer.test.ts src/hooks/useTTS.test.ts→ 37 passednpx tsc --noEmit→ エラーなしnpx biome check(対象3ファイル)→ 問題なし関連Issue
スクリーンショット(任意)
Summary by CodeRabbit
リリースノート