Repository navigation
継続測位の二重処理・ETA毎秒常駐タイマー・未使用GNSS購読を排除し、iOS向け省電力測位モードを実験的機能として追加 - #6375
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughETAフェーズを毎秒更新するアトムから、停車情報を入力として必要時に計算する関数へ移行しました。測位には重複排除を追加し、省電力測位モードの設定・永続化・精度切り替えを実装しました。GNSS購読処理も削除しています。 ChangesETAオンデマンド計算
測位重複排除
省電力測位モード
GNSS購読削除
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant ExperimentalSettings
participant Storage
participant PowerSavingAtom
participant LocationUpdates
ExperimentalSettings->>Storage: 省電力設定を保存
Storage-->>PowerSavingAtom: 保存値を読み込み
PowerSavingAtom->>LocationUpdates: 有効状態を提供
LocationUpdates->>LocationUpdates: 位置精度を選択して監視を開始
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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.
Inline comments:
In `@src/components/Permitted.tsx`:
- Line 49: 設定復元前に継続測位が開始されないよう、PermittedLayout の loadSettings() 完了状態を管理し、Main の
useStartBackgroundLocationUpdates()
が復元完了後にのみ起動するよう修正してください。powerSavingLocationEnabledAtom
の復元完了を開始条件に含め、復元前のデフォルト精度での起動と再起動を防いでください。
In `@src/hooks/useStartBackgroundLocationUpdates.test.tsx`:
- Around line 377-419: Add a symmetric test in the “power saving location mode”
describe block for disabled power-saving mode with permissions denied, setting
mockPowerSavingLocationEnabled to false and mockUseLocationPermissionsGranted to
return false. Render useStartBackgroundLocationUpdates, await the asynchronous
startup, and assert mockWatchPositionAsync is called with LOCATION_WATCH_OPTIONS
overridden to Location.Accuracy.Highest and any callback.
In `@src/screens/ExperimentalSettings.tsx`:
- Around line 161-177:
重複するトグル保存処理を共通化してください。handleTogglePowerSavingLocation、handleTogglePortraitMode、handleToggleEtaAssist、handleToggleTelemetry
の反転・atom更新・storage保存・失敗時ロールバック・ログ・Alert処理を、atom参照とStorageKeysを受け取る
usePersistedToggle または同等のヘルパーへ抽出し、各ハンドラはその共通処理を利用するよう変更してください。
🪄 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: ASSERTIVE
Plan: Pro
Run ID: fbc310e2-fee5-4dd9-b3ee-c7e85ccd3f05
📒 Files selected for processing (10)
assets/translations/en.jsonassets/translations/ja.jsonsrc/components/Permitted.tsxsrc/constants/location.tssrc/constants/storage.tssrc/hooks/useStartBackgroundLocationUpdates.test.tsxsrc/hooks/useStartBackgroundLocationUpdates.tssrc/screens/ExperimentalSettings.test.tsxsrc/screens/ExperimentalSettings.tsxsrc/store/atoms/experimental.ts
概要
実車利用時の電池消費・端末発熱の対策として、位置情報精度・到着判定精度に影響しない範囲で冗長な常駐処理を3点排除する。加えて、iOSの位置情報要求精度を一段下げて消費を抑える「省電力測位モード」を実験的機能として追加する(既定OFF・実車検証用)。既定の測位設定(
Accuracy.Highest/ 10m / 5秒 / フォアグラウンドサービス常駐)と到着判定ロジックには手を加えていない。変更の種類
変更内容
handleTrackingLocation): watchPositionAsyncの直接コールバックを併用してAndroid 16のJobSchedulerクォータによるバックグラウンド位置更新のスロットルを回避 #5427 で導入した TaskManager +watchPositionAsyncの2系統併用はそのまま維持しつつ、処理済みタイムスタンプ以下の測位(重複コピー・順序逆転した遅延バッチ)を共通入口で破棄。同一測位へのEMAスムージング二重適用と、下流(最寄り駅探索〜再レンダー)の二重実行を排除する。クォータでスロットルされた古いバッチが後着して位置が過去に引き戻される経路もこれで塞がる。システム時計巻き戻り時にガードが測位を凍結し続けないようリセット処理つきuseEtaFallback/ 新規utils/etaPhaseNow.ts): フェーズは「精度劣化(>200m)時のGPS到着判定補助(R1)」とDevOverlay表示でしか使われないため、1秒間隔のuseInterval+etaPhaseAtom公開をやめ、必要になった瞬間に純関数getEtaPhaseNowで計算する方式へ変更。useEtaFallbackはルート変更時に入力(停車駅リスト)をetaStopsAtomへ公開するだけになる。評価時点の時刻で計算するため、判定に使う値の鮮度は従来(最大1秒古い)より向上useTelemetrySender): 購読結果が ref に保存されるだけでどこからも読まれていなかったため削除。テレメトリ無効の本番ビルドを含む全Android端末で毎秒発生していたネイティブ→JSブリッジイベントを停止する(gnssModule.tsラッパー自体は温存)ExperimentalSettings/useStartBackgroundLocationUpdates): ONにすると継続測位の要求精度をAccuracy.Highest→Accuracy.Highへ一段下げる。iOSではkCLLocationAccuracyBest→kCLLocationAccuracyNearestTenMeters(約10m粒度)となり電池消費を抑えられる。Androidでは両者ともPRIORITY_HIGH_ACCURACYにマップされるため挙動は変わらない。到着判定の閾値は最小でも100m+精度ボーナスのため判定への実害はない想定だが、実車検証のため既定OFFのトグルとして追加(MMKVで永続化、切替時は継続測位を新しい精度で再起動)テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること188スイート・2020テスト全通過(
npm run lint && npm test && npm run typecheckをローカル実行)。関連Issue
スクリーンショット(任意)
Generated by Claude Code
Summary by CodeRabbit