Skip to content

大江戸線都庁前の外回り/内回りをgroupIdで取り違える駅位置特定のバグを修正 - #6349

Merged
TinyKitten merged 2 commits into
devfrom
claude/oedo-station-index-groupid-ambiguity
Jul 4, 2026
Merged

TinyKitten merged 2 commits into
devfrom
claude/oedo-station-index-groupid-ambiguity

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

概要

大江戸線の都庁前(外回り/内回り)のように groupId は同一だが id は別々に採番されている駅について、groupId だけで駅配列内の現在地インデックスを特定していた箇所を id 優先のマッチングに修正しました。groupId ベースの findIndex は常に配列中で先に見つかる方(必ずしも実際の現在地と同じ出現ではない)に固定されてしまうため、行き先表示の区間切り出しや列車種別変更時の現在地補正が誤った位置を基準に行われる不具合がありました。

変更の種類

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

変更内容

  • useBounds.ts: 大江戸線の行き先/経由駅表示区間を切り出すための stationIndex を、groupId 一致から id 一致に変更
  • findNearestStation.ts: 列車種別変更時に現在駅が新しい駅リストに存在しない場合の位置探索を id ベースに変更(シグネチャも currentGroupId から currentStationId に変更)
  • useTrainTypeModal.ts: 上記シグネチャ変更に伴う呼び出し元の更新。あわせて、現在駅が新しい駅リストに存在するかの判定(currentInNewList)も id 一致に変更(groupId 一致だと無関係な出現を現在駅と誤認し、位置補正がスキップされてしまうため)
  • useBounds.test.tsx / findNearestStation.test.ts: groupId が同一で id が異なる駅(都庁前の外回り/内回り相当)がある場合に、正しい方の出現を基準に位置特定できることを検証するリグレッションテストを追加

テスト

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

関連Issue

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


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • 同一のグループに複数の駅がある場合でも、現在地と次の停車駅を正しく判定するよう改善しました(駅ID基準)。
    • 方面・行き先の切り替え時に、誤った駅が混入する可能性を低減しました。
  • Tests
    • 駅ID/方向ごとの境界ケースを追加・更新し、正しい結果になることを確認しました。

都庁前は外回り/内回りでgroupIdが共通だがidは別々に採番されており、groupIdだけの
findIndexでは配列中で先に見つかる方に固定され、実際の現在地と異なる位置を
基準に区間計算をしてしまっていた。useBounds(大江戸線の行き先表示区間切り出し)と
findNearestStation(列車種別変更時の現在地補正、呼び出し元のuseTrainTypeModalの
存在チェックも含む)をid優先のマッチングに変更した。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QYPA7eobZEejKS4Y3MrRuA
@github-actions github-actions Bot added the react label Jul 4, 2026
@coderabbitai

coderabbitai Bot commented Jul 4, 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: ASSERTIVE

Plan: Pro

Run ID: 34110ec4-8ffb-4540-b7cd-59d11e46161c

📥 Commits

Reviewing files that changed from the base of the PR and between 5d975e0 and 78f3dc6.

📒 Files selected for processing (1)
  • src/utils/findNearestStation.test.ts

📝 Walkthrough

Walkthrough

groupIdが同一でもidが異なる駅を区別するため、findNearestStation、useBounds、useTrainTypeModalの現在地特定と比較条件がid基準に変更され、関連テストも更新された。

Changes

id基準の現在地特定への変更

Layer / File(s) Summary
findNearestStationのid基準化とテスト
src/utils/findNearestStation.ts, src/utils/findNearestStation.test.ts
第3引数がcurrentStationIdに変わり、oldStationsの探索とnewStationsの参照がidベースに切り替わり、対応テストが更新・追加された。
useBoundsの大江戸線分岐id判定
src/hooks/useBounds.ts, src/hooks/useBounds.test.tsx
大江戸線分岐でのstationIndex探索がid一致に変更され、同一groupId・別idケースを検証するテストが追加された。
useTrainTypeModalのid基準判定
src/hooks/useTrainTypeModal.ts
現在駅の存在確認、findNearestStation呼び出し、useCallback依存配列がidベースに変更された。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • TrainLCD/MobileApp#6346: 同じく都営大江戸線で、同一groupIdでも別idの駅をid基準で扱う変更が入っているため、現在地・行き先判定の実装が近いです。

Poem

ぴょんと跳ねて駅を見た
groupIdだけじゃまだ迷う
idの札でぴたりと止まり
内回りも外回りもぴかり
うさぎの足跡、まっすぐ駅へ 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 変更内容の主軸である大江戸線都庁前の駅位置特定バグ修正を具体的に示しており、タイトルとして適切です。
Description check ✅ Passed 概要・変更内容・テスト・関連Issue・任意スクリーンショットの各項目が概ね揃っており、テンプレート要件を満たしています。
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.
✨ 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/oedo-station-index-groupid-ambiguity

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

@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: 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/hooks/useBounds.test.tsx`:
- Around line 202-207: The test data in useBounds.test.tsx is manually building
Station objects with a cast, which weakens type safety and consistency. Update
this case to use the shared createStation factory, overriding only the needed id
and groupId values so the stations array stays strongly typed and the `as
unknown as Station[]` cast can be removed. Refer to the test setup around the
stations array and keep the existing station ordering/semantics unchanged.

In `@src/utils/findNearestStation.test.ts`:
- Around line 189-209: The new regression test in findNearestStation should also
cover the OUTBOUND path, since the current case only verifies the INBOUND
branch. Add a symmetric test alongside the existing inner/outer/groupId
collision scenario using the same createStation setup and findNearestStation
call, but pass direction as OUTBOUND and assert the expected nearest station
result there as well. This will validate both branches of the findNearestStation
logic and guard against regressions in the OUTBOUND-specific flow.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 4df4ad53-2b1b-4c18-bb38-9978e82213eb

📥 Commits

Reviewing files that changed from the base of the PR and between e9f0478 and 5d975e0.

📒 Files selected for processing (5)
  • src/hooks/useBounds.test.tsx
  • src/hooks/useBounds.ts
  • src/hooks/useTrainTypeModal.ts
  • src/utils/findNearestStation.test.ts
  • src/utils/findNearestStation.ts

Comment thread src/hooks/useBounds.test.tsx Resolved
Comment thread src/utils/findNearestStation.test.ts Resolved
@TinyKitten
TinyKitten merged commit 95de837 into dev Jul 4, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the claude/oedo-station-index-groupid-ambiguity branch July 4, 2026 10:32
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