Skip to content

iOSで日本語TTS完了前に英語TTSへ進む不具合を修正 - #6381

Merged
TinyKitten merged 3 commits into
devfrom
agent/fix-tts-playback-order
Jul 10, 2026
Merged

TinyKitten merged 3 commits into
devfrom
agent/fix-tts-playback-order

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

概要

iOSで日本語TTSの再生完了前に英語TTSへ進み、日本語アナウンスへ割り込む不具合を修正します。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • expo-audio のiOS実装が完了イベントの currentTime を常に duration で上書きする挙動を考慮
  • 完了イベントの報告位置だけでなく、プレイヤー本体の実再生位置を優先して終端到達を判定
  • プレイヤー位置が0へリセットされた場合に備え、通常の状態更新で最後に観測した再生位置へフォールバック
  • 実際の終端より前なら日本語TTSをその位置から再開し、英語TTSへ進ませないよう修正
  • 正のプレイヤー位置を使う既存テストを維持しつつ、プレイヤー位置が0へリセットされた場合の保存位置フォールバックを直接検証する回帰テストを追加

根本原因は、早期完了イベントでも currentTime === duration となるため、既存の終端判定が途中終了を正常終了と誤認していたことです。

回帰リスクとして、完了イベント受信時の位置取得に失敗すると再生完了が遅れる可能性があります。プレイヤー本体、直前の状態更新、イベント報告値の順にフォールバックし、位置通知がない短い音声は従来どおり完了として扱うことで影響を限定しています。

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

実行結果:

  • npm exec -- jest --runInBand src/hooks/useTTS.test.ts src/utils/ttsAudioPlayer.test.ts: 2スイート、40テスト成功
  • npm run lint: 成功
  • npm run typecheck: 成功
  • git diff --check: 成功

Windowsでは既存の npm test に含まれるUnix形式の TZ=UTC を直接解釈できないため、PowerShellで同じ環境変数を設定して関連Jestテストを実行しました。全テストスイートは未実行です。

関連Issue

なし

スクリーンショット(任意)

UI変更なし

@TinyKitten TinyKitten self-assigned this Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

iOSのdidJustFinishでcurrentTimeが終端へ上書きされる場合に、最後に観測した再生位置を使って再開または正常完了を判定する処理と回帰テストを追加しました。

Changes

iOS音声再生位置補正

Layer / File(s) Summary
再生位置補正と回帰テスト
src/utils/ttsAudioPlayer.ts, src/utils/ttsAudioPlayer.test.ts
妥当な再生位置を保持し、didJustFinish時に実位置へシークして再開するケースと、終端付近でシークせず完了するケースを検証します。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • TrainLCD/MobileApp#6282: ttsAudioPlayer.tsのdidJustFinish終端判定と再開シーク処理に関する変更です。

Suggested labels: react

Poem

ぴょんと跳ねても終端へ飛ばず
うさぎは実時間をそっと保存
近ければ完了、遠ければ再開
音声は迷わず走り出す
ぴょんぴょん再生、にんじん拍手!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed 変更内容の主題であるiOSのTTS完了判定不具合修正を簡潔に表しており、タイトルとして適切です。
Description check ✅ Passed テンプレートの必須セクションが揃っており、概要・変更内容・テスト結果まで具体的に記載されています。
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/fix-tts-playback-order

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the react label Jul 10, 2026
@TinyKitten
TinyKitten marked this pull request as ready for review July 10, 2026 22:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.test.ts`:
- Around line 313-315: 両テストに、0秒へのリセット時に保存済み位置へフォールバックする分岐の直接検証を追加してください。まず
emitStatus で currentTime を10秒に設定し、次に mock.player.currentTime を0へ変更して
didJustFinish と currentTime 30秒の通知を発火し、seekTo
が10秒で呼ばれることを検証してください。対象テストと関連する再生状態処理を確認し、正の player.currentTime
を使う既存ケースだけに依存しないようにします。
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 979b651f-a617-4bd2-b932-cfb3199e3ff3

📥 Commits

Reviewing files that changed from the base of the PR and between 2ba62c1 and 4ab55c6.

📒 Files selected for processing (2)
  • src/utils/ttsAudioPlayer.test.ts
  • src/utils/ttsAudioPlayer.ts

Comment thread src/utils/ttsAudioPlayer.test.ts Resolved
@TinyKitten
TinyKitten merged commit 49c2a01 into dev Jul 10, 2026
6 checks passed
@TinyKitten
TinyKitten deleted the agent/fix-tts-playback-order branch July 10, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant