Repository navigation
まもなく表示の接近駅を現在地基準で算出した実際の接近駅としアプリ・ライブアクティビティ・ウォッチ・TTS全体で次駅表示に反映 - #6135
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 (1)
📝 WalkthroughWalkthroughGPS現在地基準で「実際に接近している次の停車駅」を算出する useApproachingStation と、接近中はそれを優先して表示用の次駅を返す useDisplayNextStation を追加し、複数の消費側フックへ統合しています。 Changes現在地基準の接近駅判定と表示統合
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/hooks/useRefreshStation.ts (1)
147-166:⚠️ Potential issue | 🟠 Major | ⚡ Quick win接近判定の基準変更が
approachingステート更新に反映しきれていませんLine [147] 以降で
isApproachingをapproachingStation基準にした一方、Line [267] は!getIsPass(nearestStation)を条件にしているため、最寄りが通過駅の区間でisApproaching === trueでもapproachingがfalseに潰れます。現在地基準での自己修復表示が欠落します。修正案
- approaching: !isArrived && !getIsPass(nearestStation) && isApproaching, + approaching: !isArrived && isApproaching,🤖 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/useRefreshStation.ts` around lines 147 - 166, The approaching flag update logic uses getIsPass(nearestStation) as the gate and thus clears approaching even when isApproaching (computed from approachingStation) is true; update the state-update condition (the code that currently checks !getIsPass(nearestStation) around where approaching is set) to include the isApproaching check (e.g., set approaching = true when isApproaching is true OR when the existing nearestStation pass logic allows it) so the approachingStation-based detection (isApproaching) can override/augment the nearestStation pass check; target the state update block that references getIsPass(nearestStation) and nearestStation and replace/augment its condition with a combined check using isApproaching.
🧹 Nitpick comments (1)
src/hooks/useRefreshStation.test.tsx (1)
70-74: ⚡ Quick win
useApproachingStationを常時同一座標に固定すると新ロジックの回帰を取りこぼしますこの共通セットアップだと
approachingStationとnearestStationが乖離するケースを検証できず、接近基準変更の要点が未固定です。approachingStationを別駅にしたケース(特に最寄りが通過駅)を1件追加して、approachingの反映を明示的に担保してください。
As per coding guidelines, "When modifying behavior, update or add tests in the same change set" に沿って、この差分の中で新基準のズレケースを固定化するのが安全です。🤖 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/useRefreshStation.test.tsx` around lines 70 - 74, 現在の共通セットアップは useApproachingStation を常に mockStation(nearest と同座標)に固定しており、approachingStation と nearestStation が乖離するケースを検証できません。テストファイルの useRefreshStation.test.tsx 内で jest.spyOn(useApproachingStationModule, 'useApproachingStation') の既存モックに加え、approachingStation を別駅(特に nearestStation が通過駅になるシナリオ)に設定した追加ケースを作成し、useRefreshStation 呼び出し後に期待どおり approaching の反映(state/returned value)が行われることをアサートしてください。対応箇所の識別には useApproachingStation, approachingStation, nearestStation, mockStation を参照してください。Source: Coding guidelines
🤖 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.
Outside diff comments:
In `@src/hooks/useRefreshStation.ts`:
- Around line 147-166: The approaching flag update logic uses
getIsPass(nearestStation) as the gate and thus clears approaching even when
isApproaching (computed from approachingStation) is true; update the
state-update condition (the code that currently checks
!getIsPass(nearestStation) around where approaching is set) to include the
isApproaching check (e.g., set approaching = true when isApproaching is true OR
when the existing nearestStation pass logic allows it) so the
approachingStation-based detection (isApproaching) can override/augment the
nearestStation pass check; target the state update block that references
getIsPass(nearestStation) and nearestStation and replace/augment its condition
with a combined check using isApproaching.
---
Nitpick comments:
In `@src/hooks/useRefreshStation.test.tsx`:
- Around line 70-74: 現在の共通セットアップは useApproachingStation を常に mockStation(nearest
と同座標)に固定しており、approachingStation と nearestStation が乖離するケースを検証できません。テストファイルの
useRefreshStation.test.tsx 内で jest.spyOn(useApproachingStationModule,
'useApproachingStation') の既存モックに加え、approachingStation を別駅(特に nearestStation
が通過駅になるシナリオ)に設定した追加ケースを作成し、useRefreshStation 呼び出し後に期待どおり approaching
の反映(state/returned value)が行われることをアサートしてください。対応箇所の識別には useApproachingStation,
approachingStation, nearestStation, mockStation を参照してください。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 125c4208-d6ab-4051-852f-21221a7f7bf5
📒 Files selected for processing (16)
src/hooks/index.tssrc/hooks/useAppleWatch.tssrc/hooks/useApproachingStation.test.tsxsrc/hooks/useApproachingStation.tssrc/hooks/useDisplayNextStation.test.tsxsrc/hooks/useDisplayNextStation.tssrc/hooks/useHeaderCommonData.test.tsxsrc/hooks/useHeaderCommonData.tssrc/hooks/useNumbering.test.tsxsrc/hooks/useNumbering.tssrc/hooks/useRefreshStation.test.tsxsrc/hooks/useRefreshStation.tssrc/hooks/useStoppingState.test.tsxsrc/hooks/useStoppingState.tssrc/hooks/useTTSText.tssrc/hooks/useUpdateLiveActivities.ts
|
@coderabbitai レビューありがとうございます。各指摘への対応です。 ① このゲートは意図的な既存挙動で、今回の変更でも維持します。理由:
② テスト追加(Nitpick)— 対応しました
Generated by Claude Code |
|
Tip For best results, initiate chat on the files or code changes.
① 説明いただいた内容は明確に理解しました。
設計の意図として理解しました。据え置きの判断を尊重します。 ② テスト追加について
( ˶ᵔ ᵕ ᵔ˶ ) ✏️ Learnings added
|
概要
「まもなく」表示時の接近駅を、最後に到着した駅を起点に算出する従来の次駅ではなく、GPSの現在地を起点に算出した「実際に接近している次の停車駅」に切り替えました。到着判定の取りこぼし等で次駅がずれた場合でも、接近検知・表示の双方が現在地に追従して自己修復します。
変更の種類
変更内容
useApproachingStationを追加(最寄り停車駅と次の停車駅への距離比較で、向かっている側の停車駅を返す)useDisplayNextStationを追加useRefreshStationの接近判定(isApproaching)を次駅基準から接近駅基準に変更useStoppingState)、iOS ライブアクティビティ/Android Live Update、Apple Watch、音声読み上げ(TTS)useApproachingStation/useDisplayNextStation)と、依存が変わった既存テスト(useStoppingState/useNumbering/useHeaderCommonData/useRefreshStation)のモック追従更新ネイティブ側(Swift/Watch)は JS が送る駅情報をそのまま描画するため、JS 層の修正のみで全機能をカバーしています。
テスト
npm run lintが通ることnpm testが通ること(164 suites / 1775 tests 全パス)npm run typecheckが通ること関連Issue
スクリーンショット(任意)
Generated by Claude Code
Summary by CodeRabbit
New Features
Tests
Refactor