Skip to content

オートモードを到着時間推定の見込みで走らせるかをリモート設定のauto_mode_estimated_enabledで切り替えられるようにした - #7161

Merged
TinyKitten merged 1 commit into
devfrom
feature/auto-mode-estimated-flag
Oct 1, 2026
Merged

TinyKitten merged 1 commit into
devfrom
feature/auto-mode-estimated-flag

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

概要

オートモードを到着時間推定の見込み(trainRoute の model: Estimated、#7158)で走らせるか、従来の値(Legacy)で走らせるかを、Worker の /config/remote が配信する auto_mode_estimated_enabled で切り替えられるようにしました。

既定は Legacy です。true を配信したときだけ、見込みで走ります。

変更の種類

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

変更内容

切り替え方

Worker の KV config:remote に auto_mode_estimated_enabled を真偽値で入れます。TrainLCD/functions の /config/remote は、未知のキーも真偽値ならそのまま配信するので、Worker のコード変更は要りません。アプリは起動時に 1 回だけ値を取得するので、切り替えた後はアプリを起動し直すと反映されます。

リグレッションのリスク

canary には #7158 が、フラグなしで入っています(#7159)。この PR が入った後の canary は、KV に true を入れるまで Legacy で走ります。今の canary と同じ挙動で試すには、KV に true を入れてください。

テスト

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

関連Issue

Refs #7158

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

UI 変更なし: オートモードが区間の値をどの問い合わせで取るかを切り替える変更で、画面の見た目は変わりません。

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 機能改善
    • オートモードで、設定が有効な場合に駅の到着時間推定を走行速度の決定に利用するようになりました。
    • 推定機能が無効、設定が未取得、または推定に失敗した場合は、従来の速度情報を使用します。通常ルートと乗換ルートの両方に対応しています。
  • ドキュメント
    • 推定値を利用する条件と、従来の速度情報に切り替わる条件を追記しました。

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

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 38d45df8-9f04-4ab3-884e-755ae6dcae2a

📥 Commits

Reviewing files that changed from the base of the PR and between 1b711e8 and e3585a8.

📒 Files selected for processing (6)
  • docs/location-simulation.md
  • src/hooks/useAutoModeEstimatedEnabled.ts
  • src/hooks/useSimulationMode.test.tsx
  • src/hooks/useSimulationMode.ts
  • src/lib/remoteConfig.test.ts
  • src/lib/remoteConfig.ts

Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.


📝 Walkthrough

Walkthrough

Remote Config の設定値に応じて、オートモードが Estimated クエリまたは Legacy クエリを選択します。フラグ無効時や取得失敗時は Legacy を使用し、Estimated クエリがエラーの場合も Legacy に切り替えます。

Changes

到着時間推定の切り替え

Layer / File(s) Summary
Remote Config の設定値と購読
src/lib/remoteConfig.ts, src/lib/remoteConfig.test.ts, src/hooks/useAutoModeEstimatedEnabled.ts
設定キーと取得関数を追加しました。設定値をキャッシュし、未配信・取得失敗・真偽値以外の場合は false を返します。設定値の変更を購読するフックとテストも追加しました。
フラグに応じた経路クエリ選択
src/hooks/useSimulationMode.ts, src/hooks/useSimulationMode.test.tsx, docs/location-simulation.md
単一路線と乗換経路で、フラグに応じて Estimated クエリと Legacy クエリを切り替えます。Estimated クエリがエラーの場合は Legacy データを選択します。フラグ無効時のクエリ選択をテストし、設定条件を文書に追記しました。

Priority: ➖ Normal

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Worker
  participant remoteConfig
  participant useAutoModeEstimatedEnabled
  participant useSimulationMode
  participant StationAPI
  Worker->>remoteConfig: auto_mode_estimated_enabled を配信
  remoteConfig->>useAutoModeEstimatedEnabled: キャッシュ値を通知
  useAutoModeEstimatedEnabled->>useSimulationMode: 設定値を返す
  alt 設定が有効
    useSimulationMode->>StationAPI: Estimated クエリ
    StationAPI-->>useSimulationMode: 結果またはエラー
    useSimulationMode->>StationAPI: エラー時に Legacy クエリ
  else 設定が無効または未配信
    useSimulationMode->>StationAPI: Legacy クエリ
  end
Loading

Merge Risk: ⚪ Minimal · up to e3585

The change defaults to Legacy, enables Estimated only when explicitly configured, and falls back on errors. No actionable merge-blocking risk is established; merge after normal checks pass.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは、auto_mode_estimated_enabled によってオートモードの Estimated 使用を切り替える主な変更を正確に示しています。
Description check ✅ Passed 説明はテンプレートの各セクションを満たしています。変更内容、既定動作、切り替え方法、テスト結果、関連Issue、UI変更なしの理由が具体的に記載されています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 5…
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
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


うさぎは設定を読み取った
Estimated の道を走る
エラーなら Legacy に乗る
跳ねてテストを確かめる
月まで安全に到着する

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

@TinyKitten
TinyKitten merged commit 65249cc into dev Oct 1, 2026
7 checks passed
@TinyKitten
TinyKitten deleted the feature/auto-mode-estimated-flag branch October 1, 2026 13:26
This was referenced Oct 1, 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.

1 participant