Skip to content

バス路線の列車種別を自動選択し長い系統名表示に対応#5992

Merged
TinyKitten merged 3 commits into
devfrom
feature/bus-route-support
May 14, 2026
Merged

バス路線の列車種別を自動選択し長い系統名表示に対応#5992
TinyKitten merged 3 commits into
devfrom
feature/bus-route-support

Conversation

@TinyKitten
Copy link
Copy Markdown
Member

@TinyKitten TinyKitten commented May 14, 2026

概要

バス路線で hasTrainTypes === true のとき、系統選択を行わなくても先頭の列車種別が自動選択されるようにする。あわせて、バスの系統名は長くなりがちなため CommonCard のタイトル表示を縮小・複数行に対応させる。TrainTypeKind にバス系統用の BusRoute を追加した。

変更の種類

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

変更内容

  • TrainTypeKindBusRoute を追加し、シミュレーション速度マップ (TRAIN_TYPE_KIND_MAX_SPEEDS_IN_M_S) にも対応エントリを追加(isBus 早期分岐により値自体は実質参照されないため null)。
  • useLineSelection.handleLineSelected で、バス路線かつ hasTrainTypes の場合に駅側の trainType が無いケースを検出し、fetchedTrainTypes[0]pendingTrainType として自動選択。続けて fetchStationsByLineGroupId でその系統の駅一覧を取得し pendingStations を差し替える。鉄道路線は従来挙動を維持。
  • CommonCard の title 用 TypographyadjustsFontSizeToFit を付与し、isBusLine(line) のとき numberOfLines を 2 に拡張。長いバス系統名がフォント縮小と 2 行で収まるようにする。
  • 上記挙動の回帰防止として useLineSelection.test.tsx にバス自動選択ケースと「鉄道は自動選択しない」ガードケースを追加。

テスト

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

関連Issue

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

Summary by CodeRabbit

リリースノート

  • New Features

    • バス路線に対応しました。バス系統の表示設定を最適化し、シミュレーションモード内でバスの速度パラメータを適用可能にしました。
  • Bug Fixes

    • バス路線の駅選択時に列車種別が正しく初期化されるよう改善しました。

Review Change Stack

@TinyKitten TinyKitten self-assigned this May 14, 2026
@github-actions github-actions Bot added the react label May 14, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

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: 25436542-2c87-4e30-8b68-f73c4e9b4bb2

📥 Commits

Reviewing files that changed from the base of the PR and between fb358b5 and 4e1604a.

📒 Files selected for processing (5)
  • src/@types/graphql.d.ts
  • src/components/CommonCard.tsx
  • src/constants/simulationMode.ts
  • src/hooks/useLineSelection.test.tsx
  • src/hooks/useLineSelection.ts

📝 Walkthrough

Walkthrough

TrainTypeKind enumにバス路線を追加し、路線選択時のバス路線対応フォールバック処理を実装。UI表示と定数を拡張し、バス/鉄道路線の選択動作をテスト検証。

Changes

バス路線サポート機能の追加

Layer / File(s) Summary
型定義拡張: TrainTypeKind enumバス路線追加
src/@types/graphql.d.ts
TrainTypeKind enumに BusRoute = 'BusRoute' を追加し、型システムでバス路線を区別可能にします。
路線選択ロジック実装: バス路線のフォールバック処理
src/hooks/useLineSelection.ts
handleLineSelectedisBusLine importを追加し、列車種別未指定時にフェッチ済み列車種別の先頭をフォールバック選択、グループIDがある場合はグループ駅を追加取得する処理を実装し、依存配列を更新します。
UI表示調整と定数マッピング
src/components/CommonCard.tsx, src/constants/simulationMode.ts
バス路線時に CommonCard のタイトル行数を2行化し文字サイズ調整を有効化、TRAIN_TYPE_KIND_MAX_SPEEDS_IN_M_S にバス路線のnull値マッピングを追加します。
テストケース: バス/鉄道路線の選択動作検証
src/hooks/useLineSelection.test.tsx
TransportType importを追加し、バス路線での自動列車種別選択・グループ駅フェッチフロー、および鉄道路線でのフォールバック非実行を検証するテストケースを追加します。

🎯 3 (Moderate) | ⏱️ ~25 minutes

react

🐰✨ バスも線路も同じ物語
フォールバック選ぶ、表示も調整
型も定数も整然と並ぶ
テスト通りて完成だね 🚌🚆

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR タイトルはバス路線の列車種別自動選択と長い系統名表示対応という本PR の主要な変更内容を明確かつ簡潔に要約しており、開発者視点から重要な変更を適切に反映しています。
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 feature/bus-route-support

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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

@TinyKitten TinyKitten merged commit 62da251 into dev May 14, 2026
7 checks passed
@TinyKitten TinyKitten deleted the feature/bus-route-support branch May 14, 2026 17:52
@TinyKitten TinyKitten mentioned this pull request May 14, 2026
9 tasks
@TinyKitten TinyKitten mentioned this pull request May 15, 2026
9 tasks
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.

1 participant