Skip to content

逆走通知設定がOFFのときは検知ロジック自体を停止してCPU消費とatom書き込みを完全に止める - #5957

Merged
TinyKitten merged 1 commit into
devfrom
feature/wrong-direction-detector-disable-when-off
May 12, 2026
Merged

TinyKitten merged 1 commit into
devfrom
feature/wrong-direction-detector-disable-when-off

Conversation

@TinyKitten

@TinyKitten TinyKitten commented May 12, 2026 •

Copy link
Copy Markdown
Member

概要

逆走通知設定が OFF のときも検知ロジック (useWrongDirectionDetectorEffect) が常時動いていたため、位置情報更新のたびに getDistance 計算と atom 書き込みが発生していた。OFF のときは検知ロジック自体を完全停止し、CPU 消費とバッテリー消費を最小化する。

変更の種類

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

変更内容

  • useWrongDirectionDetectorEffect の早期 return 条件に wrongDirectionNotifyEnabled === false を追加。OFF のとき resetDetectionState() で atom を初期値に戻し、getDistance 計算と atom 書き込みを完全停止する。
  • notifyState atom を依存に追加し、wrongDirectionNotifyEnabled を useEffect の依存配列に含めることで、ON ⇄ OFF の切り替え時にリセットが反映されるようにした。
  • useWarningInfo のコードは一切触らない。OFF 時は isWrongDirection / isLoopLineWrongDirection が常に false で渡るので、useWarningInfo の逆走警告分岐 (useWarningInfo.ts:131-142) を素通りするだけで、他の警告(offline / badAccuracy / autoMode / longPressNotice 等)は従来通り表示される。
  • テスト追加 (useWrongDirectionDetector.test.tsx): OFF 時に検知が動かないこと、判定中に ON → OFF へ切り替えるとリセットされること。

回帰リスクと緩和

テスト

  • npm run lint が通ること
  • npm test が通ること(useWrongDirectionDetector.test.tsx 6 件全パス)
  • npm run typecheck が通ること

関連Issue

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


Generated by Claude Code

Summary by CodeRabbit

リリースノート

  • 新機能

    • 不正な方向検出機能の有効/無効を制御できるようにしました。
  • テスト

    • 不正な方向検出機能の制御フラグに関するテストカバレッジを拡充しました。

Review Change Stack

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

coderabbitai Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

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: 5bb90f80-9c7e-4ed3-982e-5a43d9ed3ff2

📥 Commits

Reviewing files that changed from the base of the PR and between 8d25ba0 and 50b77b0.

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

📝 Walkthrough

概要

useWrongDirectionDetectorフックにnotifyStateアトムからwrongDirectionNotifyEnabledフラグを統合し、通知が無効化されている場合に検出ロジックをゲートする機能を追加しました。テストも更新され、フラグの動作を検証します。

変更内容

間違った方向検出の機能フラグ統合

レイヤー / ファイル(s) 概要
フック実装と機能フラグのゲーティング
src/hooks/useWrongDirectionDetector.ts
notifyStateアトムをインポートし、フックでwrongDirectionNotifyEnabledフラグを読み込みます。距離更新エフェクトの開始時にガード条件を追加して、通知が無効な場合は検出をスキップします。エフェクトの依存配列をフラグに対応するように更新します。
テストヘルパーのパラメータ化と新しいテストケース
src/hooks/useWrongDirectionDetector.test.tsx
seedStoreテストヘルパーがオプション設定としてwrongDirectionNotifyEnabledを受け入れるように更新されます。seedStoreはnotifyStateを初期化するように拡張されます。フラグが偽の場合に検出が無効になること、およびフラグが真から偽に切り替わった場合に間違った方向の状態がリセットされることを検証するテストケースが追加されます。

🎯 2 (Simple) | ⏱️ ~12 分

🐰 機能フラグがちょこんと、
検出の息吹を静かに止め、
テストは確かに確認して、
不要な計算を救い出す! 🚂✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR タイトルは変更内容を明確に説明しており、逆走通知設定 OFF 時の検知ロジック停止という主要な変更を適切に要約している。
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/wrong-direction-detector-disable-when-off

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

@TinyKitten
TinyKitten merged commit b6ae277 into dev May 12, 2026
6 checks passed
@TinyKitten
TinyKitten deleted the feature/wrong-direction-detector-disable-when-off branch May 12, 2026 02:13
@TinyKitten TinyKitten mentioned this pull request May 12, 2026
4 of 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.

2 participants