Skip to content

TTS再生完了後もダッキングが残存する不具合を修正し、発話直前のみduckOthersを有効化するよう変更 - #6466

Merged
TinyKitten merged 3 commits into
devfrom
claude/tts-ducking-persistence-eqhgv9
Jul 23, 2026
Merged

TinyKitten merged 3 commits into
devfrom
claude/tts-ducking-persistence-eqhgv9

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

概要

変更の種類

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

変更内容

  • src/hooks/useTTS.ts: expo-audio の audio mode 既定を duckOthers から mixWithOthers(非ダッキング)に変更し、実際に Speech.speak() を呼ぶ直前にのみ duckOthers を有効化する setDuckingActiveAsync を追加
  • 全発話完了時(pending な発話が無い場合)にダッキングを mixWithOthers へ明示的に解除するよう finishPlaying を修正
  • 発話中のアンマウントや、タイムアウト・世代交代による無効化が発生した場合もダッキングを解除するようにフォールバックを追加
  • 発話中に backgroundEnabled 設定が変化しても、直近に要求したダッキング状態(duckingActiveRef)を維持したまま audio mode を再設定するよう修正し、設定変更で発話中のダッキングが誤って解除される不具合を防止(CodeRabbitレビュー指摘対応)
  • src/hooks/useTTS.test.ts: 発話直前のダッキング有効化、全発話完了後の解除、pending 発話継続中は解除しないこと、アンマウント時の解除、Speech.speak より前にダッキングする呼び出し順序、発話中の backgroundEnabled 変化でダッキング(iOS/Android 双方の interruptionMode)を維持することを検証する回帰テストを追加

テスト

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

関連Issue

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


Generated by Claude Code

Summary by CodeRabbit

  • 改善
    • 音声読み上げ中のみ、他のアプリの音声を適切に小さくするよう改善しました。
    • 読み上げ完了時や中断時、画面を離れた際には、他の音声が通常どおり再生されるようになりました。
    • 待機中の読み上げがある場合は、音声が途切れないよう音量調整を維持します。

Summary by CodeRabbit

  • 改善
    • 音声読み上げ中だけ、他アプリの音声を適切に小さくするダッキング挙動を改善しました(発話直前に反映)。
    • 読み上げの完了・中断・アンマウント時には、通常の音量状態へ確実に戻るよう改善しました。
    • バックグラウンド再生設定の変更や連続した発話時も、ダッキング状態を適切に維持するよう改善しました。

@github-actions github-actions Bot added the react label Jul 23, 2026
@TinyKitten TinyKitten self-assigned this Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

useTTS の音声ダッキングを発話中のみ有効化し、発話完了・失効・アンマウント時に解除する処理を追加した。保留中の発話や背景再生設定の変更時は、ダッキング状態を維持する。

Changes

音声ダッキング制御

Layer / File(s) Summary
ダッキング切替処理
src/hooks/useTTS.ts, src/hooks/useTTS.test.ts
通常時は mixWithOthers、発話中は duckOthers を設定し、backgroundEnabled の変更時も発話中のダッキング状態を維持する処理とテストを追加した。
発話ライフサイクルと検証
src/hooks/useTTS.ts, src/hooks/useTTS.test.ts
発話直前の有効化、保留発話時の維持、完了・失効・アンマウント時の解除を実装し、呼び出し順を含めて検証した。

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

Sequence Diagram(s)

sequenceDiagram
  participant useTTS
  participant AudioMode
  participant Speech
  useTTS->>AudioMode: 発話直前に duckOthers
  useTTS->>Speech: Speech.speak
  Speech-->>useTTS: 発話完了
  useTTS->>AudioMode: 保留なしで mixWithOthers
  useTTS->>AudioMode: アンマウント時に mixWithOthers
Loading

Possibly related PRs

  • TrainLCD/MobileApp#6453: useTTS の発話ライフサイクルに関する変更で、同じ音声再生コードを更新している。

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 不具合修正の主旨と「発話直前のみduckOthersを有効化」という変更点が明確で、内容に合っています。
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 claude/tts-ducking-persistence-eqhgv9

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

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hooks/useTTS.ts (1)

161-202: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

再生中の設定変更でダッキングが解除されたままになります。

backgroundEnabled の変更時に effect が常に mixWithOthers を設定します。発話中なら現在の duckOthers が解除され、その発話が終わるまで再設定されません。現在のダッキング状態を ref で保持し、設定変更時もその状態を維持してください。あわせて、発話中に backgroundEnabled を切り替えても duckOthers を維持する回帰テストを追加してください。

🤖 Prompt for 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.

In `@src/hooks/useTTS.ts` around lines 161 - 202, Update the audio-mode effect and
setDuckingActiveAsync in useTTS so the current ducking state is stored in a ref
and reused when backgroundEnabled changes, preserving duckOthers during active
speech instead of resetting to mixWithOthers. Update the ducking state whenever
setDuckingActiveAsync toggles it, and add a regression test covering
backgroundEnabled changes during speech while ducking remains enabled.
🤖 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.test.ts`:
- Around line 650-665: Update the useTTS test around the duckOthers and first
mockSpeak calls to assert call order, verifying mockSetAudioModeAsync enables
duckOthers before the initial Speech.speak invocation. Preserve the existing
assertions for mixWithOthers and duckOthers call presence.

---

Outside diff comments:
In `@src/hooks/useTTS.ts`:
- Around line 161-202: Update the audio-mode effect and setDuckingActiveAsync in
useTTS so the current ducking state is stored in a ref and reused when
backgroundEnabled changes, preserving duckOthers during active speech instead of
resetting to mixWithOthers. Update the ducking state whenever
setDuckingActiveAsync toggles it, and add a regression test covering
backgroundEnabled changes during speech while ducking remains enabled.
🪄 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: 5f348aee-4b82-4d75-b3d2-2988ca5024a1

📥 Commits

Reviewing files that changed from the base of the PR and between 1227046 and 43402d4.

📒 Files selected for processing (2)
  • src/hooks/useTTS.test.ts
  • src/hooks/useTTS.ts

Comment thread src/hooks/useTTS.test.ts Resolved

@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/hooks/useTTS.test.ts`:
- Around line 735-737: Update the useTTS audio-mode assertions to also verify
interruptionModeAndroid is set to 'duckOthers', both for the initial state and
after changing backgroundEnabled, while preserving the existing interruptionMode
checks.
🪄 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: fa3274e4-37af-4ab6-bc7f-a35a398b0e01

📥 Commits

Reviewing files that changed from the base of the PR and between 43402d4 and fc6df06.

📒 Files selected for processing (2)
  • src/hooks/useTTS.test.ts
  • src/hooks/useTTS.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/hooks/useTTS.ts

Comment thread src/hooks/useTTS.test.ts Resolved
@TinyKitten
TinyKitten merged commit ffbd8db into dev Jul 23, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the claude/tts-ducking-persistence-eqhgv9 branch July 23, 2026 12:53
@TinyKitten TinyKitten mentioned this pull request Jul 24, 2026
4 of 9 tasks
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.

2 participants