Skip to content

プリセット保存時に始発・終着を保存するか選べるチェックボックスを追加 - #6654

Merged
TinyKitten merged 1 commit into
devfrom
claude/preset-save-checkbox-mncl5y
Aug 10, 2026
Merged

TinyKitten merged 1 commit into
devfrom
claude/preset-save-checkbox-mncl5y

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 10, 2026 •

Copy link
Copy Markdown
Member

概要

プリセット保存モーダルに「始発・終着駅もそのまま保存する」チェックボックスを追加しました。デフォルトはオンで既存の挙動と同じです。オフにすると、行き先と始発駅で絞り込まずに停車パターンだけをプリセットとして保存できます。

変更の種類

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

変更内容

  • src/components/Checkbox.tsx を新規追加。LEDテーマ対応の汎用チェックボックスで、行全体がタップ領域。accessibilityRole="checkbox" を付与している
  • SavePresetNameModal にチェックボックスを追加。デフォルトはオンで、モーダルを開くたびにオンへリセットされる。onSubmit のシグネチャを (name, keepEndpoints) に変更し、チェックボックス自体は新規 prop showKeepEndpointsOption が真のときだけ表示する
  • SelectBoundModal 側は行き先を指定しているときのみ選択肢を出す(showKeepEndpointsOption={!!wantedDestination})。行き先が未指定ならそもそも絞り込みが無く、チェックの有無で保存結果が変わらないため
  • オフで保存した場合は wantedDestinationId / originStationId / direction をすべて null にする。結果としてプリセット表示時は路線の両端がそのまま始発・終着になる
  • オフのときは通知駅の絞り込み範囲も全区間(stations)に戻す。区間で絞らない以上、範囲外の通知駅を落とすのは不整合なため
  • オフで保存したときは「保存済み(削除ボタン)」表示に切り替えない。保存したプリセットは現在の選択(行き先で絞った経路)とは別物で findSavedRoute が一致せず、フラグを立てても直後の再検索で戻ってしまうため
  • presetKeepEndpointsLabel / presetKeepEndpointsDescription を ja / en の翻訳に追加

退行リスクと緩和策

  • SavePresetNameModal.onSubmit の引数が 1 個から 2 個に増えるが、呼び出し元は SelectBoundModal の 1 箇所のみ(rg で確認済み)。型チェックも通過している
  • 既定値がオンのため、チェックボックスを触らない限り保存されるプリセットの内容は従来と完全に同一。既存プリセットのデータ移行は不要
  • オフで保存したプリセットは direction: null になるが、これは originStationId 追加前の古いプリセットと同じ形で、getPresetRouteEndpoints / usePresetStops は既に null を扱えるようになっている
  • チェックボックスが増えることでモーダルが縦に伸びるため、小さい端末での見切れが理論上の懸念点。CustomModal の avoidKeyboard 配下にあるため通常は問題にならない想定だが、実機確認が未実施(下記参照)

テスト

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

ローカルで実行したコマンド:

npm install          # 依存が未インストールだったため。package-lock.json の差分は revert 済み
npm run format
npm run lint         # Checked 631 files, No fixes applied
npm run typecheck    # エラーなし
npm test             # 218 suites / 2303 tests 全パス

追加したテスト:

  • src/components/SavePresetNameModal.test.tsx(新規 4 件)— チェックボックスの表示条件、既定オン、オフ時に keepEndpoints: false が渡ること、再表示でオンへ戻ること
  • src/components/SelectBoundModal.render.test.tsx(新規 6 件)— 行き先の有無による選択肢の出し分け、オン/オフでの wantedDestinationId / originStationId / direction の保存内容、通知駅の絞り込み範囲

関連Issue

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

実行環境に iOS シミュレータ/Android エミュレータが無いため、UI のスクリーンショットは未添付です。マージ前に実機での見た目確認をお願いします。


Generated by Claude Code

Summary by CodeRabbit

  • 新機能
    • プリセット保存時に、始発駅・終着駅を保持するか選択できるようになりました。
    • 端点を保持しない場合、駅の指定を除いた停車パターンとして保存できます。
    • 保存した条件に応じて、通知対象駅が自動的に設定されます。
    • 保存ダイアログに、設定内容を説明するチェックボックスを追加しました。
  • テスト
    • 端点保持設定や保存内容に関する動作確認を追加しました。

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

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

プリセット保存時に、始発駅と終着駅を保持する設定を追加しました。SavePresetNameModal が選択状態を受け取り、SelectBoundModal が端点、保存区間、通知対象駅の保存内容を切り替えます。関連する翻訳とテストも追加しました。

Changes

プリセット端点保持

Layer / File(s) Summary
端点保持オプションのUI
assets/translations/*.json, src/components/Checkbox.tsx, src/components/SavePresetNameModal.tsx
端点保持用のチェックボックスを追加しました。設定の初期値はオンです。モーダルを再表示するとオンへ戻ります。
プリセット保存内容の切り替え
src/components/SelectBoundModal.tsx
端点保持時は端点情報と保存区間を保存します。非保持時は始点、方向、行き先を未設定にし、全区間の通知対象駅を保存します。
端点保持動作の検証
src/components/SavePresetNameModal.test.tsx, src/components/SelectBoundModal.render.test.tsx
オプションの表示条件、選択状態、再表示時のリセット、端点と通知対象駅の保存内容を検証します。

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

Sequence Diagram(s)

sequenceDiagram
  participant 利用者
  participant SavePresetNameModal
  participant SelectBoundModal
  利用者->>SavePresetNameModal: プリセット名と端点保持設定を入力
  SavePresetNameModal->>SelectBoundModal: nameとkeepEndpointsを送信
  SelectBoundModal->>SelectBoundModal: 端点と通知対象駅を保存内容に設定
  SelectBoundModal-->>利用者: プリセット保存を完了
Loading

Possibly related PRs

Poem

にんじん片手に設定オン、
始発と終着、しっかり保存。
オフにすれば停車パターン、
通知駅も区間に合わせる。
うさぎはテストを駆け回る。 🐇

<fიქxed_issue_severity>Low</fixed_issue_severity>

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは、プリセット保存時に始発・終着駅の保存を選択できるチェックボックスの追加という主要変更を正確に示しています。
Description check ✅ Passed 概要、変更内容、テスト結果、変更種別、UI確認の未実施理由を記載しており、テンプレートの必須情報を満たしています。
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/preset-save-checkbox-mncl5y

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.

🧹 Nitpick comments (1)
src/components/SelectBoundModal.render.test.tsx (1)

399-413: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

端点を保存しない場合の保存済み表示を検証してください。

このテストは保存ペイロードだけを確認します。
保存後に saveCurrentRoute のままであり、removeFromSavedRoutes に切り替わらないことも確認してください。
この分岐で setSavedRoute(saved) が追加されても、現在のテストは検出できません。

テスト追加例
 await waitFor(() => expect(mockSaveRoute).toHaveBeenCalled());
 expect(mockSaveRoute.mock.calls[0][0]).toMatchObject({
   wantedDestinationId: null,
   originStationId: null,
   direction: null,
 });
+expect(screen.getByText('saveCurrentRoute')).toBeTruthy();
+expect(screen.queryByText('removeFromSavedRoutes')).toBeNull();
🤖 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/components/SelectBoundModal.render.test.tsx` around lines 399 - 413,
Update the test case for saving without endpoints to also verify the saved-state
callback remains unchanged: assert that removeFromSavedRoutes is not called and
saveCurrentRoute remains the active action after saving. Keep the existing
payload assertions intact and use the existing mock/state symbols from the test
setup.
🤖 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.

Nitpick comments:
In `@src/components/SelectBoundModal.render.test.tsx`:
- Around line 399-413: Update the test case for saving without endpoints to also
verify the saved-state callback remains unchanged: assert that
removeFromSavedRoutes is not called and saveCurrentRoute remains the active
action after saving. Keep the existing payload assertions intact and use the
existing mock/state symbols from the test setup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 129f35af-4b27-4fba-b272-7f76a3a239f0

📥 Commits

Reviewing files that changed from the base of the PR and between b6aa334 and 5b465dc.

📒 Files selected for processing (7)
  • assets/translations/en.json
  • assets/translations/ja.json
  • src/components/Checkbox.tsx
  • src/components/SavePresetNameModal.test.tsx
  • src/components/SavePresetNameModal.tsx
  • src/components/SelectBoundModal.render.test.tsx
  • src/components/SelectBoundModal.tsx

@TinyKitten
TinyKitten merged commit 4d33dfc into dev Aug 10, 2026
6 checks passed
@TinyKitten
TinyKitten deleted the claude/preset-save-checkbox-mncl5y branch August 10, 2026 14:23
This was referenced Aug 10, 2026
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