Repository navigation
プリセット保存時の始発駅指定フローを廃止して経路内の最寄駅から自動解決 - #6640
Conversation
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PWNLSQntywfT1pGEFs9bvb
📝 WalkthroughWalkthroughプリセット保存時の方向選択UIを削除しました。駅一覧、目的駅、現在駅または最寄駅から保存方向を自動解決します。保存名モーダルは、トリム済みの名前だけを送信します。方向解決と保存処理のテストを追加しました。 Changesプリセット保存方向
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant SelectBoundModal
participant resolvePresetSaveDirection
participant SavePresetNameModal
participant SavedRoutes
User->>SelectBoundModal: プリセット保存を開始する
SelectBoundModal->>resolvePresetSaveDirection: 駅一覧、目的駅、現在駅を渡す
resolvePresetSaveDirection-->>SelectBoundModal: 保存方向を返す
SelectBoundModal->>SavePresetNameModal: 名前入力画面を表示する
User->>SavePresetNameModal: プリセット名を送信する
SavePresetNameModal-->>SelectBoundModal: トリム済みの名前を返す
SelectBoundModal->>SavedRoutes: 自動解決した方向で保存する
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/utils/presetRouteEndpoints.test.ts (1)
149-267: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
afterEachでモック状態をリセットしてください。このテストファイルには
jest.clearAllMocks()を呼び出すafterEachがありません。テスト規約に従い、共通クリーンアップを追加してください。As per coding guidelines,
afterEachではjest.clearAllMocks()を呼び出すこと。🤖 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/utils/presetRouteEndpoints.test.ts` around lines 149 - 267, Add an afterEach cleanup for the resolvePresetSaveDirection test suite that calls jest.clearAllMocks(), following the file’s existing test setup conventions. Ensure mock state is cleared after every test without changing the test cases or their assertions.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.
Inline comments:
In `@src/components/SelectBoundModal.tsx`:
- Around line 642-650: Update the presetSaveDirection useMemo in
SelectBoundModal to pass the actual current station using station ??
confirmedStation, rather than effectiveStation ?? confirmedStation. Preserve
coordinate-based nearest-station resolution when the current station is outside
the route, and add a SelectBoundModal test covering an unset station with
confirmedStation on the opposite side of the destination.
---
Nitpick comments:
In `@src/utils/presetRouteEndpoints.test.ts`:
- Around line 149-267: Add an afterEach cleanup for the
resolvePresetSaveDirection test suite that calls jest.clearAllMocks(), following
the file’s existing test setup conventions. Ensure mock state is cleared after
every test without changing the test cases or their assertions.
🪄 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: 6df842b8-a929-4105-991d-9b4cd4c55275
📒 Files selected for processing (6)
assets/translations/en.jsonassets/translations/ja.jsonsrc/components/SavePresetNameModal.tsxsrc/components/SelectBoundModal.tsxsrc/utils/presetRouteEndpoints.test.tssrc/utils/presetRouteEndpoints.ts
💤 Files with no reviewable changes (2)
- assets/translations/ja.json
- assets/translations/en.json
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PWNLSQntywfT1pGEFs9bvb
概要
プリセット保存時、終点を明示的にユーザーが設定した場合にだけ表示されていた「始発駅を選択」フローを廃止しました。代わりに、保存する経路内の最寄駅から始発駅(保存される
direction)を自動で解決します。ユーザーはプリセット名を入力するだけで保存できます。変更の種類
変更内容
SavePresetNameModalから始発駅選択セクション(方向カード2枚・選択必須バリデーション・不透明度アニメーション)を削除。DirectionOption型とdirectionOptionsprop も撤去し、onSubmitを(name: string) => voidに簡素化src/utils/presetRouteEndpoints.tsにresolvePresetSaveDirectionを追加。保存する経路は行き先を境に片側だけなので、経路内の最寄駅がどちら側にあるかでdirection(=駅一覧のどちら側の終端から乗るか)が一意に決まる。最寄駅は「現在駅が駅一覧に含まれていればその駅 → 含まれなければ座標距離で最も近い駅」の順に解決するgetPresetOriginStationが駅一覧の並び順の食い違いを検知するための前提(従来は保存時UIのフィルタが担保していたもの)を引き継ぐためSelectBoundModalのpresetDirectionOptionsをpresetSaveDirectionに置き換え。方向解決には生のpendingStation(無ければ GPS 確定駅)を渡す。effectiveStationは区間外だとstations[0]へ倒れて実際の現在地を表さないためeffectiveStations(notifyStationIdsの絞り込み範囲)をpresetSaveDirectionから導出するよう変更。復元時のusePresetStops.presetStopsと同じ切り方に揃えることで、保存する向きと通知駅の絞り込み範囲が構造的にズレないようにしたselectStartStationTitle/departureを ja/en 双方から削除resolvePresetSaveDirectionのユニットテストを11件追加(終端ケース、座標フォールバック、現在駅=行き先のケース、解決不能時の null など)SelectBoundModal.render.test.tsxに、乗車駅未設定時に GPS 確定駅の座標から向きが決まることを検証するテストを追加実際の始発駅は復元時に既存の
usePresetStopsのnearestPresetStation(経路内の最寄中間駅)が解決するため、「保存した経路内の最寄駅から乗る」挙動はランタイムで成立します。影響範囲・リグレッションリスク
saved_routesテーブル)は変更していないため、既存プリセットの互換性に影響なしdirectionの意味・復元ロジック(getPresetOriginStation/getPresetRouteEndpoints)は不変。変わるのは保存時にdirectionを誰が決めるか(ユーザー選択 → 自動解決)だけeffectiveStationsの導出変更により、行き先が駅一覧の先頭にある場合の絞り込み範囲が[行き先]の1駅から経路全体に変わる(保存されるdirectionと整合する側へ修正)テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ることnpm testは 215 suites / 2274 tests すべて成功。追加したリグレッションテストは、修正前のコードではINBOUNDを返して失敗することも確認済みです。なお本セッションの環境にはシミュレータ/エミュレータが無いため、実機でのUI確認は未実施です。関連Issue
スクリーンショット(任意)
Summary by CodeRabbit
新機能
改善