Skip to content

直近で発車した駅を接近判定の対象から除外して発車直後の「まもなく当該駅」誤表示を防ぐ - #6138

Merged
TinyKitten merged 1 commit into
devfrom
claude/approaching-station-display-jwzegb
Jun 9, 2026
Merged

TinyKitten merged 1 commit into
devfrom
claude/approaching-station-display-jwzegb

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jun 9, 2026 •

Copy link
Copy Markdown
Member

概要

GPS現在地基準で接近駅を算出する useApproachingStation で、直近に発車した(到着済みの現在)駅が接近候補に残っていたため、発車直後にまだ当該駅の接近圏内にいる間「まもなく(発車した駅)」と誤表示されていた問題を修正します。例: 浅草線で泉岳寺方面選択時、五反田を発車した直後に「まもなく五反田」と表示されていたものを、正しく次の停車駅「まもなく高輪台」と表示します。

変更の種類

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

変更内容

  • useApproachingStation の接近候補(停車駅)から、直近で発車した現在駅(stationState.station)を id / groupId で除外
  • これにより発車直後でも次の停車駅を接近駅として扱い、「まもなく(発車した駅)」の誤表示を防止
  • 除外対象は常に進行方向の後方に限られるため、これから接近する前方の駅が消えることはない(station の値が古い場合でも安全)。既存の「最寄り停車駅を通過したら次駅へ」距離比較による自己修復も従来どおり機能する
  • useApproachingStation.test.tsx に「直近で発車した駅は接近判定の対象から除外する」ケースを追加

テスト

  • npm run lint が通ること
  • npm test が通ること(164 suites / 1778 tests 全パス)
  • npm run typecheck が通ること

関連Issue

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


Generated by Claude Code

Summary by CodeRabbit

バグ修正

  • 発車直後に前の駅が「接近中」と表示される問題を修正しました。到着済みの駅を接近判定から除外し、次の停車駅を正しく表示するようになりました。

テスト

  • 発車済み駅の除外処理に関するテストケースを追加しました。

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

coderabbitai Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

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: e34c19c3-a82a-48c4-8578-073083c4ebbb

📥 Commits

Reviewing files that changed from the base of the PR and between c37df2c and 71aa9b7.

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

📝 Walkthrough

Walkthrough

useApproachingStation フックの接近判定ロジックを拡張し、発車直後の駅(departedStation)を除外対象に加えることで、発車直後の誤った「まもなく」表示を防止する。テストヘルパーを更新し、新しい除外ロジックを検証するテストケースを追加。

Changes

発車駅除外ロジックと検証

Layer / File(s) Summary
発車駅除外フィルタ実装
src/hooks/useApproachingStation.ts
validStops のフィルタ条件を拡張し、通過駅と座標無効駅に加えて、到着済みの departedStation と同一 id または同一 groupId の駅を除外。useMemo 依存配列を departedStation?.id と departedStation?.groupId に更新して、状態変更を反映。
テストヘルパー更新と新テストケース
src/hooks/useApproachingStation.test.tsx
setLocation ヘルパーが currentStation 引数を受け取り、LOCATION_ATOM モック返却で station フィールドを含める。「発車済み駅は接近判定対象から除外される」新テストケースで、期待される次駅 ID が返ることを検証。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • TrainLCD/MobileApp#6135: 同一の「まもなく表示」ロジックを useApproachingStation/useDisplayNextStation で修正し、この PR でさらに発車駅/グループの除外機能を精密化。

Suggested labels

react

Poem

🐰 発車した駅は後ろにして
次の停車へ視線移して
フィルタが整い、テストも確か
接近判定も自己修復さ!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PRタイトルは、GPS現在地基準の接近駅算出ロジックで直近発車駅を除外する主要な変更内容を明確かつ簡潔に要約しており、変更セットの中核を正確に反映しています。
Description check ✅ Passed PR説明は必須セクション(概要、変更の種類、変更内容、テスト)をすべて完備し、バグ修正の詳細と実装方針、テスト実施済み状況を明確に記載しています。
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.

✏️ 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 claude/approaching-station-display-jwzegb

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

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