Repository navigation
駅名のカッコ書きを TTS で読み上げないように案内テンプレへ渡す前に取り除く (#1175) - #5926
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 (4)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughTTS音声出力時に駅名から括弧内テキスト(スポンサー表記など)を除外するフォーマッター機能を実装。新しい Changes駅名括弧除外フォーマッター
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22分 Poem
🚥 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: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/hooks/useTTSText.ts (1)
189-220:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
directionalStops経路が未対応のため、括弧読み上げが残る可能性があります。
nextStation系の前処理は入っていますが、boundForJa/boundForEnは未加工のdirectionalStopsを使っています。駅名括弧が方面案内側で再混入するため、同様にstripStationParensForTTSを適用してください。🤖 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/useTTSText.ts` around lines 189 - 220, The directionalStops path isn't being preprocessed so station-name parentheses can reappear in boundForJa/boundForEn; update the code that builds boundForJa and boundForEn to use a preprocessed directionalStops array (apply stripStationParensForTTS to each entry) similar to how nextStation/afterNextStation/slicedStations are handled — create a memoized strippedDirectionalStops from directionalStopsOrigin (or wherever directionalStops comes from) using stripStationParensForTTS and then reference that strippedDirectionalStops when computing boundForJa and boundForEn.
🧹 Nitpick comments (1)
src/hooks/useTTSText.test.tsx (1)
769-832: ⚡ Quick win全角カッコの統合テストも追加しておくと回帰耐性が上がります。
現在は半角
()中心の検証なので、実運用で問題になりやすい()をuseTTSText経路でも1ケース押さえるのを推奨します。🤖 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/useTTSText.test.tsx` around lines 769 - 832, Add a complementary test case that covers full-width Japanese parentheses so regressions are caught: either extend buildStationWithParens to also return a variant using full-width brackets `(` `)` or add a new helper (e.g., buildStationWithFullWidthParens) and a new test in the same describe block that calls useTTSTextWithJotaiAndNumbering (the hook under test) and asserts the JA and EN SSML (result.current.text) do not contain the full-width contents or the full-width paren characters; update test names to reflect full-width coverage and keep assertions analogous to the existing half-width checks.
🤖 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/formatters.ts`:
- Around line 12-15: stripParensForTTS currently removes parentheses via
ttsParensRegexp but leaves trailing or consecutive spaces, producing awkward TTS
output; update stripParensForTTS to, after applying ttsParensRegexp, collapse
multiple whitespace to a single space and trim leading/trailing spaces (e.g. use
replace(/\s+/g, ' ') and trim()) while preserving the generic return type T and
handling null/undefined the same way so callers like nameRoman or
nameTtsSegments get normalized strings.
In `@src/hooks/useBusTTSText.ts`:
- Around line 120-146: directionalStops used by boundForJa/boundForEn is not
sanitized for TTS and still contains parenthesized station names; apply the same
sanitization (use stripStationParensForTTS) to directionalStops before
boundForJa/boundForEn consume it. Locate where directionalStops is
created/derived in useBusTTSText (similar to slicedStationsOrigin handling) and
map each station through stripStationParensForTTS (preserving types and nullable
handling like nextStation/afterNextStation) so boundForJa and boundForEn always
receive sanitized station objects.
---
Outside diff comments:
In `@src/hooks/useTTSText.ts`:
- Around line 189-220: The directionalStops path isn't being preprocessed so
station-name parentheses can reappear in boundForJa/boundForEn; update the code
that builds boundForJa and boundForEn to use a preprocessed directionalStops
array (apply stripStationParensForTTS to each entry) similar to how
nextStation/afterNextStation/slicedStations are handled — create a memoized
strippedDirectionalStops from directionalStopsOrigin (or wherever
directionalStops comes from) using stripStationParensForTTS and then reference
that strippedDirectionalStops when computing boundForJa and boundForEn.
---
Nitpick comments:
In `@src/hooks/useTTSText.test.tsx`:
- Around line 769-832: Add a complementary test case that covers full-width
Japanese parentheses so regressions are caught: either extend
buildStationWithParens to also return a variant using full-width brackets `(`
`)` or add a new helper (e.g., buildStationWithFullWidthParens) and a new test
in the same describe block that calls useTTSTextWithJotaiAndNumbering (the hook
under test) and asserts the JA and EN SSML (result.current.text) do not contain
the full-width contents or the full-width paren characters; update test names to
reflect full-width coverage and keep assertions analogous to the existing
half-width 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: 1de08e57-484b-4b1f-a9de-21a3cbb1532a
📒 Files selected for processing (5)
src/hooks/tts/formatters.test.tssrc/hooks/tts/formatters.tssrc/hooks/useBusTTSText.tssrc/hooks/useTTSText.test.tsxsrc/hooks/useTTSText.ts
Fixes Applied SuccessfullyCodeRabbit のレビュースレッド 2 件に対する修正を適用しました。 Files modified:
反映内容:
Commit: The latest autofix changes are on the |
概要
駅名に併記されたカッコ書き (例: 命名権スポンサー名
電鉄富山(トヨタモビリティ富山)) が TTS で読み上げられてしまう問題を修正する。<sub alias="...">の中身 (= 実際に音声化される読み) にもスポンサー名が混入していたため、案内テンプレに渡す前段で駅データの TTS 関連フィールドからカッコと中身を取り除く方針に切り替える。表示用データには影響させない。変更の種類
変更内容
src/hooks/tts/formatters.tsに TTS 専用ヘルパを追加。stripParensForTTS(value): 半角・全角両対応で文字列からカッコと中身を取り除く。既存のparenthesisRegexpは半角のみで駅 API が全角を返すケースをカバーできないため別定義。stripStationParensForTTS(station):name/nameKatakana/nameRoman/nameTtsSegments[].surface/fallbackTextをまとめて落とした新しい Station を返す (非破壊)。src/hooks/useTTSText.ts:nextStation/slicedStations/afterNextStationをstripStationParensForTTS経由に。allStops/viaStation/lastAnnouncedStop/betweenNextStationも自動的にカバーされる。src/hooks/useBusTTSText.ts: 同様に適用。あわせてslicedStationsをuseMemo化し、型ガードもs is Stationで明示。src/hooks/tts/formatters.test.ts: 文字列ヘルパ (半角/全角/複数/非対象) と Station ヘルパ (各フィールド適用 / 非 TTS フィールド保持 / 非破壊) を検証。src/hooks/useTTSText.test.tsx:(トヨタモビリティ富山)を含む駅をモックし、JA/EN SSML にカッコと中身が出ない integration テストを追加。テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
Closes TrainLCD/Issues#1175
スクリーンショット(任意)
Summary by CodeRabbit
バグ修正
テスト