Repository navigation
最大許容精度を1.5kmに戻し精度超過時は走行中扱いにする - #6122
Conversation
📝 WalkthroughWalkthroughこのPRは、GPS測位精度が許容値を超えた場合に外れ値フラグを立てて下流へ伝播させ、到着判定ロジックでそれを参照することで、信頼性の低い位置情報を段階的に除外するようにします。精度閾値を2000から1500に引き下げ、新しいJotai atom・setter・テストで完全に統合。 ChangesGPS精度外れ値フラグの追加と到着判定改善
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/store/atoms/location.ts (1)
54-76:⚠️ Potential issue | 🟠 Major | ⚡ Quick win外れ値フラグが継続測位以外の経路で解除されません。
setLocationAccuracyOutlier(false)はhandleTrackingLocationの正常系でしか実行されませんが、handleTrackingLocationのコメントどおりワンショット取得や手動選択はsetLocation()を直接呼びます。いったんこのフラグがtrueになると、その後に良好な位置を directsetLocation()で反映してもuseRefreshStationの Line 92-95 でarrived = falseが維持されます。受理した位置更新でフラグをクリアするか、継続測位由来の状態にだけ紐づくようにしてください。🤖 Prompt for 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. In `@src/store/atoms/location.ts` around lines 54 - 76, The outlier flag set by setLocationAccuracyOutlier(true) is never cleared when locations are applied via direct setLocation calls, causing arrived to stay false; modify the code so that whenever setLocation (the function that applies a newly accepted location from one-shot/manual selection) successfully updates locationAtom/rawLocationAtom you also call setLocationAccuracyOutlier(false) (or clear the flag inside setLocation), or alternatively scope the flag to “continuous-tracking” by tying it to lastFilteredLocationAtom updates; update setLocation and/or handleTrackingLocation accordingly so accepted direct updates clear the outlier state and downstream useRefreshStation logic sees arrived correctly.
🤖 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.
Outside diff comments:
In `@src/store/atoms/location.ts`:
- Around line 54-76: The outlier flag set by setLocationAccuracyOutlier(true) is
never cleared when locations are applied via direct setLocation calls, causing
arrived to stay false; modify the code so that whenever setLocation (the
function that applies a newly accepted location from one-shot/manual selection)
successfully updates locationAtom/rawLocationAtom you also call
setLocationAccuracyOutlier(false) (or clear the flag inside setLocation), or
alternatively scope the flag to “continuous-tracking” by tying it to
lastFilteredLocationAtom updates; update setLocation and/or
handleTrackingLocation accordingly so accepted direct updates clear the outlier
state and downstream useRefreshStation logic sees arrived correctly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 483a5033-ec47-4583-b2bb-728bc0ae177a
📒 Files selected for processing (6)
src/constants/location.tssrc/hooks/useRefreshStation.test.tsxsrc/hooks/useRefreshStation.tssrc/store/atoms/location.tssrc/utils/handleTrackingLocation.test.tssrc/utils/handleTrackingLocation.ts
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/utils/handleTrackingLocation.test.ts (1)
41-44: ⚡ Quick win
jest.clearAllMocks()はafterEachに寄せてください。今は
beforeEachでクリアしていますが、このリポジトリのテスト規約はafterEach指定です。ここも合わせておくと、モックの後始末の責務が揃います。As per coding guidelines: "テストの
afterEachでjest.clearAllMocks()を呼び出してください"Also applies to: 46-52
🤖 Prompt for 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. In `@src/utils/handleTrackingLocation.test.ts` around lines 41 - 44, Move the jest.clearAllMocks() call out of the beforeEach block and into an afterEach block so mock cleanup follows the repository test convention; keep mockIsDevApp = false initialization in beforeEach, and update the other test groups referenced (the other beforeEach at lines ~46-52) to remove their clearAllMocks() as well, adding a single afterEach(() => jest.clearAllMocks()) near the top of the test file to cover all tests.src/store/atoms/location.test.ts (1)
75-102: ⚡ Quick win
resetLocationState側の解除契約もここで固定したいです。この追加分で
setLocation経路は押さえられていますが、今回の変更範囲にあるresetLocationStateの外れ値フラグ解除は未カバーです。そこが戻ると前回の outlier 状態を引きずって到着判定が false に張り付くので、同じ describe に 1 ケース足しておくと安心です。Based on learnings: "When modifying behavior, update or add tests in the same change set; document skipped tests with TODOs and owner rationale"
🤖 Prompt for 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. In `@src/store/atoms/location.test.ts` around lines 75 - 102, Add a test that exercises resetLocationState to ensure it clears the outlier flag (locationAccuracyOutlierAtom) just like setLocation does: arrange a prior state with store.set(locationAccuracyOutlierAtom, true) and a previous location via setLocation(...), call resetLocationState() (or the exported function named resetLocationState) and assert that store.get(locationAccuracyOutlierAtom) is false and that locationAtom remains the expected value; place this spec inside the existing "外れ値フラグの解除" describe so the change set covers both setLocation and resetLocationState behaviors.
🤖 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.
Nitpick comments:
In `@src/store/atoms/location.test.ts`:
- Around line 75-102: Add a test that exercises resetLocationState to ensure it
clears the outlier flag (locationAccuracyOutlierAtom) just like setLocation
does: arrange a prior state with store.set(locationAccuracyOutlierAtom, true)
and a previous location via setLocation(...), call resetLocationState() (or the
exported function named resetLocationState) and assert that
store.get(locationAccuracyOutlierAtom) is false and that locationAtom remains
the expected value; place this spec inside the existing "外れ値フラグの解除" describe so
the change set covers both setLocation and resetLocationState behaviors.
In `@src/utils/handleTrackingLocation.test.ts`:
- Around line 41-44: Move the jest.clearAllMocks() call out of the beforeEach
block and into an afterEach block so mock cleanup follows the repository test
convention; keep mockIsDevApp = false initialization in beforeEach, and update
the other test groups referenced (the other beforeEach at lines ~46-52) to
remove their clearAllMocks() as well, adding a single afterEach(() =>
jest.clearAllMocks()) near the top of the test file to cover all tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 023f5985-314d-4302-89ba-0fd6ef6445a2
📒 Files selected for processing (4)
src/store/atoms/location.test.tssrc/store/atoms/location.tssrc/utils/handleTrackingLocation.test.tssrc/utils/handleTrackingLocation.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/store/atoms/location.ts
概要
地下鉄路線における位置情報の信頼度に応じて到着判定を出し分けるための改修。GPS精度が1.5km以内に収まる路線(例: 都営大江戸線)では従来どおり位置情報を信用してそのまま使い、精度1.5km超が観測される路線(例: 東京メトロ副都心線)では位置情報を信用せず走行中として扱う。
変更の種類
変更内容
MAX_PERMIT_ACCURACYを 2000 から 1.5km(1500) に戻す(最大許容精度を1.5kmから2kmに緩和 #6116 の緩和を取り消し)handleTrackingLocationでワープ対策フィルタが棄却した測位をlocationAccuracyOutlierAtom(外れ値フラグ)に記録する。棄却時は座標を破棄して位置が前回値で凍結し、精度悪化がlocationAtomに現れないことへの対処useRefreshStationの到着判定で外れ値フラグが立っている場合は座標が良好でもarrived=false(走行中)に強制する。フィルタを経由しないワンショット取得・手動選択向けに、保持している精度の直接チェックも併用setLocationに集約し、ワンショット取得・手動選択などhandleTrackingLocationを経由しない経路の良好な測位でも確実に解除されるようにする(フラグが残りarrivedがfalseに張り付く問題への対処)テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
Generated by Claude Code
Summary by CodeRabbit