Repository navigation
種別を自動選択した際に駅一覧を系統全体へ揃えて始発駅と終着駅のずれを防ぐ - #6644
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PWNLSQntywfT1pGEFs9bvb
Contributor
📝 WalkthroughWalkthrough
Changes駅一覧選択
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant handleLineSelected
participant StationAPI
participant StationState
User->>handleLineSelected: 路線を選択
handleLineSelected->>handleLineSelected: 選択世代を更新
handleLineSelected->>StationAPI: 駅・列車種別を取得
StationAPI-->>handleLineSelected: 取得結果を返却
handleLineSelected->>StationAPI: groupIdで系統駅一覧を取得
StationAPI-->>handleLineSelected: 系統駅一覧を返却
handleLineSelected->>StationState: 最新世代の駅状態を設定
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Contributor
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/hooks/useLineSelection.test.tsx`:
- Around line 336-380: Update the test around handleLineSelected to exercise
groupId-based pending-station reconciliation: set the selected line station to
id 10 with groupId 100, include a group station with id 110 and groupId 100, and
assert pendingStation.id is 110. Keep the existing group fetch and pending
station assertions otherwise unchanged.
In `@src/hooks/useLineSelection.ts`:
- Around line 171-188: Update handleLineSelected to record the current selection
generation when each invocation begins, then after the
fetchStationsByLineGroupId await, update pendingStations and pendingStation only
if that generation still matches the current selection. Ensure stale requests
from earlier selections cannot overwrite the newer atom state.
🪄 Autofix
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: 69f626d5-4d48-4ed1-ac17-e6af79ef2dd4
📒 Files selected for processing (2)
src/hooks/useLineSelection.test.tsxsrc/hooks/useLineSelection.ts
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PWNLSQntywfT1pGEFs9bvb
This was referenced Aug 10, 2026
Merged
Merged
Merged
4 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
種別を持つ路線を選んだとき、プリセットの始発駅・終着駅が意図しない終端になる問題を修正します。
useLineSelection.handleLineSelectedは、駅の指定種別(station.trainType)をpendingTrainTypeへ自動選択する一方、駅一覧pendingStationsは路線単独のlineStationsのままでした。系統全体を取り直す処理はバス経路(fallbackTrainType)にしか掛かっていません。その結果、同じプリセットが2つの異なる駅一覧で表現されます。
handleLineSelected):hasTrainType: trueとtrainTypeIdを保存する一方、directionや通知駅は路線単独の並びで解決するhandlePresetPress→openModalByTrainTypeId):lineGroupStationsで直通を含む系統全体を取得する保存時の並びで決めた
directionを、範囲も並びも異なる系統全体のリストへ当てるため、始発駅・終着駅がずれます。東京メトロ副都心線のように直通運転で系統が複数路線にまたがるほど差が大きくなります。既存テストでも、バス経路には「最初の種別を自動選択し lineGroup の駅を取得する」ケースがある一方、鉄道で
station.trainTypeが指定されているケースはテストも再取得もありませんでした。同じ目的の処理がバス側にだけ入っていることから、取得漏れと判断しています。変更の種類
変更内容
lineGroupStationsの再取得条件をfallbackTrainType(バスの自動選択のみ)からinitialTrainType(指定種別とバスの自動選択の両方)へ拡張。種別を自動選択したら駅一覧も同じ系統へ揃え、handleTrainTypeSelect/openModalByTrainTypeIdと同じ状態になるようにしたlineGroupStationsが空で返った場合は路線単独の駅一覧を残すガードを追加(従来は空配列で潰していた)pendingStationの引き当てにgroupIdによるフォールバックを追加handleLineSelectedに選択世代(selectionGenerationRef)を導入し、Promise.all の直後とfetchStationsByLineGroupIdの直後で世代を照合。路線を選び直した際に、前の選択の取得結果が新しいpendingStations/pendingStationを上書きしないようにした(前者は元からあった同種の穴も塞ぐ)groupIdフォールバックで乗車駅を引き当てることを検証するテストを追加lineGroupStationsが空のときに路線単独の駅一覧を維持することを検証するテストを追加影響範囲・リグレッションリスク
handleTrainTypeSelect)やプリセット復元時(openModalByTrainTypeId)と同じ状態であり、従来はこの経路だけが食い違っていたlineGroupStationsの取得が1回増えるが、fetchStationsByLineGroupIdLoadingは既に方面選択モーダルのローディング判定に含まれているためスケルトン表示となり、UXの退行はないinitialTrainTypeはfallbackTrainTypeを含むため)。空応答時に駅一覧を潰さなくなる点のみ改善されるhandleLineSelectedにのみ導入しており、handleTrainTypeSelect/openModalByTrainTypeIdの挙動は変えていないテスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること追加した3件のテストは、いずれも対応する修正を個別に戻すと落ちることを確認済みです。
npm testは 215 suites / 2280 tests すべて成功。なお、この環境には API の接続情報も実機も無いため、実際の副都心線データでの表示確認は行えていません。修正はロジックの整合性とユニットテストで担保しています。
関連Issue
スクリーンショット(任意)
Summary by CodeRabbit