Repository navigation
LineBoardと駅接近通知の現在駅をヘッダーのまもなく表示に揃えて全表示面で一致させる - #6141
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 (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough複数の LineBoard コンポーネントで「表示基準の現在/次駅」フックに切替え、表示用に補正した現在駅を用いて駅インデックス・セル描画を統一しました。通知ロジックは接近通知と到着通知を分離し、接近駅基準で配信するよう変更しています。 ChangesDisplay station unification for rendering and notifications
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
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
🤖 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/components/LineBoardWest.test.tsx`:
- Line 17: The test adds a jest mock for useDisplayCurrentStation but never
fixes its return value, so tests run with undefined; in the test file ensure in
a beforeEach you set a deterministic mock return (e.g. (useDisplayCurrentStation
as jest.Mock).mockReturnValue(...) or mockImplementation(...) with the shape the
component expects) so all assertions see a stable "current station" value, and
also clear/reset the mock in afterEach or beforeEach to avoid cross-test
leakage; apply the same pattern for the other test blocks that mock
useDisplayCurrentStation.
In `@src/hooks/useRefreshStation.ts`:
- Around line 205-217: The calls to sendApproachingNotification in the
approaching and arrived branches (where approachingNotifiedIdRef.current and
arrivedNotifiedIdRef.current are set) can produce unhandled promise rejections;
update those branches to either await sendApproachingNotification(...) inside a
try/catch or append .catch(...) to the returned promise to swallow/log errors
(e.g., use try { await sendApproachingNotification(...); } catch (e) { /* log */
} or sendApproachingNotification(...).catch(e => {/* log */})); keep the logic
that sets approachingNotifiedIdRef.current and arrivedNotifiedIdRef.current
intact and only mark the notification as delivered after handling errors as
appropriate.
🪄 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: c767191a-9eae-4330-beb7-48fb13aedb79
📒 Files selected for processing (24)
src/components/LineBoard.test.tsxsrc/components/LineBoard.tsxsrc/components/LineBoardE231.tsxsrc/components/LineBoardEast.test.tsxsrc/components/LineBoardEast.tsxsrc/components/LineBoardJO.test.tsxsrc/components/LineBoardJO.tsxsrc/components/LineBoardJRKyushu.test.tsxsrc/components/LineBoardJRKyushu.tsxsrc/components/LineBoardLED.test.tsxsrc/components/LineBoardLED.tsxsrc/components/LineBoardSaikyo.test.tsxsrc/components/LineBoardSaikyo.tsxsrc/components/LineBoardToei.test.tsxsrc/components/LineBoardToei.tsxsrc/components/LineBoardWest.test.tsxsrc/components/LineBoardWest.tsxsrc/components/LineBoardYamanotePad.test.tsxsrc/components/LineBoardYamanotePad.tsxsrc/hooks/index.tssrc/hooks/useDisplayCurrentStation.test.tsxsrc/hooks/useDisplayCurrentStation.tssrc/hooks/useRefreshStation.test.tsxsrc/hooks/useRefreshStation.ts
概要
ヘッダーの「まもなく」は現在地基準(
useApproachingStation)で次の停車駅を出す一方、LineBoard と駅接近ローカル通知は記録上の現在駅(stationState.station)基準のままでした。このため到着取りこぼし(GPS精度劣化でarrived検知が漏れる等)時に、ヘッダーの「まもなく」駅と LineBoard の次駅・通知駅が食い違う不整合がありました。本PRで LineBoard と駅接近通知も現在地基準に揃え、全表示面(ヘッダー / LineBoard / ライブアクティビティ・Android Live Update / Apple Watch / TTS / 駅接近通知)が常に同じ駅を指すようにします。通常運行・通過駅が間にあるケース・発車直後・ループ線では従来挙動を完全維持し、変わるのは「取りこぼし時に header と一緒に自己修復する」点のみです。
変更の種類
変更内容
useDisplayCurrentStationを追加。接近中のみ「接近駅(次の停車駅)の1つ手前の停車駅」を現在駅として返し、到着取りこぼし時に header と一緒に自己修復する。非接近・GPS無し・通常運行・ループ線ではuseCurrentStation()に完全フォールバックし従来挙動を維持(前方への補正が必要なときだけ healed 値を返す不変条件)LineBoardの現在駅ソースをuseDisplayCurrentStationに統一。West は既存のprevStation/currentStationIndex === -1フォールバック挙動を保ち、前方補正時のみ追従。LED の「まもなく」テキストもuseDisplayNextStationに統一useRefreshStation)の接近(APPROACHING)通知の通知駅名・ターゲット判定をnearestStation→approachingStation(ヘッダーの「まもなく」と同一)に変更。発車駅除外・自己修復も反映。到着(ARRIVED)通知は「最寄り駅に到着」が正しいためnearestStation基準のままuseDisplayCurrentStation(非接近フォールバック / 通常運行 / 取りこぼし前方補正 / 通過駅スキップ / ループ線 / OUTBOUND)、接近通知が接近駅を通知すること、および各 LineBoard テーマのモック追従更新テスト
npm run lintが通ることnpm testが通ること(165 suites / 1785 tests 全パス)npm run typecheckが通ること関連Issue
スクリーンショット(任意)
Generated by Claude Code
Summary by CodeRabbit