Skip to content

isDevAppがfalseの場合に路線推定を無効化 - #5757

Merged
TinyKitten merged 3 commits into
devfrom
feature/disable-route-estimation-for-non-dev
Apr 3, 2026
Merged

TinyKitten merged 3 commits into
devfrom
feature/disable-route-estimation-for-non-dev

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Apr 3, 2026 •

Copy link
Copy Markdown
Member

Summary

  • useRouteEstimationとuseRouteEstimationControlを、isDevAppがfalseの場合にnoop実装に切り替えるようにガード
  • 本番ビルドでは路線推定関連のhooks・GraphQLクエリ・GPSバッファリングが一切実行されなくなる

Test plan

  • dev appビルドで路線推定が従来通り動作すること
  • 本番ビルドで路線推定の処理が実行されないこと
  • npm run typecheckが通ること

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • ルート推定の実装を再構成し、開発環境では詳細な推定・制御が動作し、本番では軽量なフォールバック動作が使われるようになりました。
  • Tests
    • テスト環境を調整し、開発モードの動作を確実に検証できるようにしました。

@github-actions github-actions Bot added the react label Apr 3, 2026
@coderabbitai

coderabbitai Bot commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

useRouteEstimationと関連制御フックが実装版(Impl)とno-op版に分割され、isDevAppフラグでどちらをエクスポートするかがモジュール初期化時に選択されるようになりました。テストでisDevAppを強制するモックが追加されました。

Changes

Cohort / File(s) Summary
Hook implementation & conditional export
src/hooks/useRouteEstimation.ts
useRouteEstimationとuseRouteEstimationControlをそれぞれImpl(実装)とNoop(no-op)に分離。モジュール起動時にisDevAppを基に適切な実装をエクスポートするよう変更(挙動は環境依存)。
Test environment mock
src/hooks/useRouteEstimation.test.tsx
~/utils/isDevAppのJestモックを追加し、テスト実行時にisDevApp: trueを強制するように変更。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 フックを分けて道を作ったよ、
開発は実装、非開発は休憩だよ。
環境の旗がくるりと回る、
モックでテストも晴れやかに。
ぴょんと祝う、コードの春。

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning 必須セクション(概要、変更の種類、変更内容)が不足しており、テンプレートと比較して形式が一致していない。サマリー形式で提供されているが、テンプレートで定義された標準的な構造に従っていない。 PR説明を「概要」「変更の種類」「変更内容」「テスト」などのテンプレートセクションに従って再構成し、より完全で体系的な形式に整え直してください。
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed タイトルはPRの主要な変更(isDevAppがfalseの場合に路線推定を無効化する機能)を明確に簡潔に表現しており、変更内容と完全に関連している。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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/disable-route-estimation-for-non-dev

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

@TinyKitten TinyKitten self-assigned this Apr 3, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/hooks/useRouteEstimation.ts`:
- Around line 337-341: useRouteEstimationControlNoop
が毎レンダーで新しいオブジェクト/関数参照を返しており、startEstimation と stopEstimation が
useTrainTypeMismatchDetector の依存配列を不必要に更新しています。対処として
useRouteEstimationControlNoop 内で返すオブジェクトを useMemo でメモ化し、startEstimation と
stopEstimation を useCallback(または同等の安定化手法)で固定して参照安定化してください; これにより
useTrainTypeMismatchDetector の依存配列に安全に含められるようになります(参照する識別子:
useRouteEstimationControlNoop, startEstimation, stopEstimation,
useTrainTypeMismatchDetector)。
- Around line 288-299: The noop hook currently creates a new object and
functions on every call (useRouteEstimationNoop), causing unstable references
(e.g., reset used in useTrainTypeMismatchDetector) and unwanted effect re-runs;
fix by defining a single module-level constant (e.g., NOOP_ESTIMATION_RESULT)
that contains frozen/stable no-op functions for selectCandidate and reset and
the bufferInfo payload, and return that constant from useRouteEstimationNoop so
the reference is stable across renders.
🪄 Autofix (Beta)

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: a32ae98b-9a45-4b23-824b-3762a320a389

📥 Commits

Reviewing files that changed from the base of the PR and between 775ade1 and 7032797.

📒 Files selected for processing (1)
  • src/hooks/useRouteEstimation.ts

Comment thread src/hooks/useRouteEstimation.ts Resolved
Comment thread src/hooks/useRouteEstimation.ts Resolved

@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/hooks/useRouteEstimation.test.tsx (1)

25-27: LGTM! テスト環境で Impl 実装を強制する適切なモック

isDevApp: true を強制することで、テストが実際のロジックを持つ *Impl バリアントを実行するようになっています。

💡 オプション: noop 実装のテスト追加

本番ビルドでの挙動を検証するために、isDevApp: false のケースをテストする別のテストファイルまたはテストブロックを追加することを検討できます。ただし、noop 実装は単に定数を返すだけなので、優先度は低いです。

// 例: 別のdescribeブロックで isDevApp: false をテスト
// jest.doMock を使用してモジュールを再読み込みする必要があります
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/useRouteEstimation.test.tsx` around lines 25 - 27, Add a new test
block that verifies the noop (production) variant by mocking isDevApp as false
using jest.doMock and re-importing the hook, e.g., set isDevApp: false, require
the module that exports useRouteEstimation, and assert the noop behavior (the
constant return values) of useRouteEstimation; ensure you restore or clear the
mock afterwards so the existing tests that rely on isDevApp: true remain
unaffected.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/hooks/useRouteEstimation.test.tsx`:
- Around line 25-27: Add a new test block that verifies the noop (production)
variant by mocking isDevApp as false using jest.doMock and re-importing the
hook, e.g., set isDevApp: false, require the module that exports
useRouteEstimation, and assert the noop behavior (the constant return values) of
useRouteEstimation; ensure you restore or clear the mock afterwards so the
existing tests that rely on isDevApp: true remain unaffected.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4779ce1e-9a4d-4213-b899-97ca3b026b2a

📥 Commits

Reviewing files that changed from the base of the PR and between 7032797 and c7bda75.

📒 Files selected for processing (2)
  • src/hooks/useRouteEstimation.test.tsx
  • src/hooks/useRouteEstimation.ts

@TinyKitten
TinyKitten merged commit 09770c5 into dev Apr 3, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the feature/disable-route-estimation-for-non-dev branch April 3, 2026 09:55
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