Skip to content

useTTSText のテンプレートで欠落していた終点アナウンスを補完 - #5920

Merged
TinyKitten merged 3 commits into
devfrom
fix/tts-terminus-announcements
May 11, 2026
Merged

TinyKitten merged 3 commits into
devfrom
fix/tts-terminus-announcements

Conversation

@TinyKitten

@TinyKitten TinyKitten commented May 11, 2026 •

Copy link
Copy Markdown
Member

概要

useTTSText の各テーマ NEXT / ARRIVING で欠落していた「次の駅が終点」のアナウンス(JA: 「終点」 / EN: "terminal" / "the last stop")を補完する。bug ラベル付き Issue #5915 への対応。

変更の種類

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

変更内容

  • src/hooks/tts/templates.ts: 以下のテンプレートに終点アナウンスを追加・調整した。
    • TOKYO_METRO NEXT JA(firstSpeech=true 側): 次は、X、終点です。 を発話。
    • TOKYO_METRO NEXT EN: The next stop is X. ... The last stop. を発話。
    • YAMANOTE NEXT EN: ARRIVING と同じ , terminal. 形を追加。
    • JR_WEST ARRIVING JA: ご乗車ありがとうございました。 の前に 終点、X です。 を追加。
    • JR_WEST ARRIVING EN: ... brief stop at X terminal ... を発話。
    • TOEI NEXT JA: 末尾に 、終点です を追加。
    • TOEI ARRIVING JA: まもなく、終点、X、X。 の prefix を追加。
    • TOEI NEXT/ARRIVING EN: , the last stop を追加。
  • src/hooks/tts/templates.ts: 副次バグ修正(Issue の ※1)。YAMANOTE / SAIKYO / JR_KYUSHU の ARRIVING で transferLines.length が真のときだけ thanks メッセージが出ていた問題を、ブロック構造を平坦化して isNextStopTerminus / nextStationIsBound のみで発話されるよう修正。
  • 判定ロジックは Issue の方針に従い、TOKYO_METRO / TY / YAMANOTE / SAIKYO / TOEI は isNextStopTerminus、JR_WEST / JR_KYUSHU は nextStationIsBound を使用。既存テーマの慣習に揃えている。
  • src/hooks/useTTSText.test.tsx: terminus announcement (#5915) describe を追加。
    • 各テーマで nextStation = stations[last] の状態で NEXT / ARRIVING を呼び、JA に 終点 / EN に terminal または last stop が含まれることを検証(全 14 ケース)。
    • JR_WEST / JR_KYUSHU は selectedBound を中間駅 (神保町) に設定したケースも追加検証(3 ケース)。
    • JR_WEST ARRIVING JA の 終点、X です。ご乗車... 連結を正規表現で検証。
    • ※1 修正検証: 終点駅から lines を削除して transferLines を空にしたうえで、YAMANOTE / SAIKYO / JR_KYUSHU の ARRIVING で thanks 文が発話されることを検証。

テスト

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

検証メモ:

  • npm test: 1509 / 1509 passed(useTTSText.test.tsx 単体は 67 / 67 passed)。
  • npm run typecheck: exit 0。
  • npm run lint: 当該変更前後で Found 20 errors. のまま増減なし。20 件はすべて Windows 環境固有の CRLF フォーマット差分で、CI 環境(Linux)では発生しない既知のローカル差分。

関連Issue

Closes #5915

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

Summary by CodeRabbit

  • 改善

    • 終点(ラストストップ/terminal)表現を複数路線テーマ(日本語・英語)で調整し、到着/次発時の案内文をより自然で正確に表示するよう改善しました
    • 乗換・終点に関する条件付けを整理し、案内の冗長さや欠落を低減しました
  • テスト

    • 終点表現の挙動を検証する包括的なテストスイートを追加しました

Review Change Stack

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

coderabbitai Bot commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: be7f819c-e23d-409d-bde8-9e4090e8c77a

📥 Commits

Reviewing files that changed from the base of the PR and between d9372f9 and 9537f9c.

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

📝 Walkthrough

Walkthrough

複数 TTS テーマの NEXT/ARRIVING テンプレートで終点条件を明示する文言を追加し、その動作を検証する Jest テストスイートを導入しました。エクスポートや非テンプレートロジックの変更は含みません。

Changes

終点アナウンス実装

Layer / File(s) Summary
テンプレート条件付き終点フレーズ
src/hooks/tts/templates.ts
Tokyo Metro/Yamanote/Saikyo/Toei/JR West/JR Kyushu の NEXT/ARRIVING テンプレートを更新し、isNextStopTerminus / nextStationIsBound 等の条件で JA/EN の終点句(例: 「終点」、"terminal", "the last stop")を挿入。また JR Kyushu JA の ARRIVING は転線と感謝フレーズを個別の inline #if に分離。
終点アナウンステストスイート
src/hooks/useTTSText.test.tsx
describe('terminus announcement (#5915)') を追加。useTerminusHelper で Jotai 状態を設定し、複数テーマの NEXT/ARRIVING で JA/EN の終点表記を検証。JR_WEST/JR_KYUSHU の selectedBound オーバーライドケースや、ARRIVING における「終点」プリフィックス/感謝文の出力も確認。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

終点が呼ぶよ、ぴょんと跳ぶ🐇
テンプレートに言葉を入れたよ
JAもENも声を揃え
テストが確かめる道しるべ
乗客へ届け、正しい案内

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main objective: adding missing terminus announcements to the useTTSText templates that were not present before.
Description check ✅ Passed The description comprehensively follows the provided template, with all required sections completed: summary, change type, detailed changes, test results, and linked issue reference.
Linked Issues check ✅ Passed The PR fully addresses all coding requirements from Issue #5915: terminus announcements added to 8 template variants (TOKYO_METRO/YAMANOTE/JR_WEST/TOEI NEXT/ARRIVING), secondary bug fix applied, correct judgment logic (isNextStopTerminus vs nextStationIsBound), and comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are strictly within scope: 19 lines added/modified in templates.ts addressing terminus announcements, 201 lines added for terminus-specific tests, and one secondary bug fix explicitly mentioned in the issue description.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/tts-terminus-announcements

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

@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: 3

🤖 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/tts/templates.ts`:
- Around line 106-107: The Japanese template uses isNextStopTerminus for the
terminus check while the English template uses nextStationIsBound, causing
inconsistent behavior; update the JA template fragment that references
isNextStopTerminus to use nextStationIsBound instead (same variable used in EN)
so terminus announcements match for cases like when a middle station is set as
selectedBound; locate the template lines using isNextStopTerminus and replace
that predicate with nextStationIsBound wherever terminus wording is emitted.

In `@src/hooks/useTTSText.test.tsx`:
- Around line 696-700: MID_BOUND_CASES is missing the JR_WEST / ARRIVING
scenario causing a bound-detection regression; add an entry to the
MID_BOUND_CASES array such as { theme: 'JR_WEST', state: 'ARRIVING' as
HeaderStoppingState, en: 'terminal' } (matching the existing shape used for
JR_KYUSHU/JR_WEST) so tests exercise the JR_WEST ARRIVING mid-bound case and
prevent regressions in the bound logic.
- Line 613: Reformat the useEffect dependency array so it matches the project's
Biome formatting rules (two-space indentation, single quotes, UTF-8, and ES5
trailing commas) — specifically update the closing of the useEffect block (the
line with "}, [boundIndex, headerState, nextStationIndex, setLineState,
setStationState, theme]);") to follow Biome's expected spacing and
trailing-comma style (e.g., ensure the array elements and closing
brackets/parenthesis are formatted and include the trailing comma if required).
Run the equivalent of "biome check --write" or apply the project's formatter to
the useEffect dependency array in useTTSText.test.tsx (the useEffect block
containing the dependency list) so CI formatting errors are resolved.
🪄 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: eb33333d-cff7-4f2a-a95f-321f2df12d17

📥 Commits

Reviewing files that changed from the base of the PR and between b8a6090 and 09cc64b.

📒 Files selected for processing (2)
  • src/hooks/tts/templates.ts
  • src/hooks/useTTSText.test.tsx

Comment thread src/hooks/tts/templates.ts Resolved
Comment thread src/hooks/useTTSText.test.tsx Resolved
Comment thread src/hooks/useTTSText.test.tsx Resolved
@TinyKitten

Copy link
Copy Markdown
Member Author

Fixes Applied Successfully

Fixed 2 file(s) based on 2 CodeRabbit feedback item(s).

Files modified:

  • src/hooks/tts/templates.ts
  • src/hooks/useTTSText.test.tsx

Commit: 9537f9c92

The latest autofix changes are on the fix/tts-terminus-announcements branch.

@TinyKitten
TinyKitten merged commit e0ebda5 into dev May 11, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the fix/tts-terminus-announcements branch May 11, 2026 00:15
This was referenced May 11, 2026
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.

useTTSText: 終点アナウンスが欠落しているテーマ/状態がある

1 participant