Skip to content

地下でETAが現在地を独占駆動して勝手に動くデグレを解消しETAをGPSの到着判定補助(R1)に限定、設定に手動A/Bトグルを追加 - #6369

Merged
TinyKitten merged 13 commits into
devfrom
claude/eta-subway-support-v5jhtl
Jul 9, 2026

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jul 8, 2026 •

Copy link
Copy Markdown
Member

概要

先行PR #6366 で入れた ETA フォールバックのうち、GPSが喪失した区間で ETA が現在地・到着を単独駆動する部分(R2) が、地下鉄で重大なデグレを起こすことが実機で判明したため撤去する。具体的には、駅に到着後も ETA の時刻進行にしたがって現在地が勝手に動き、GPSの実測と喧嘩していた(クレームになりうるレベル)。

GPSが完全凍結した区間では「待機/走行/遅延」を位置から区別できず、ETA単独で位置を進めるのは原理的に安全に行えない。そこで ETA は「GPSの補助」に役割を限定する:

  • 到着・現在地・接近は常にGPS(useRefreshStation)が権威。ETA はこれらを一切駆動しない。
  • ETA は推定フェーズ(etaPhaseAtom)の公開に徹し、精度劣化時に 「ETAが同じ駅で停車を示すときだけ、その駅の到着しきい値を緩和する」補助(R1、既存) にのみ使う。到着判定自体はGPSが行う。

あわせて、この ETA 補助を切り替えられるよう、設定画面の試験的機能にトグルを追加する。Remote Config eta_assist_enabled をマスタースイッチとし、それが false のときは手動トグルも操作不可にする。

注: 本PRは「精度向上」ではなく主に「デグレの除去」。R1 が体感精度を上げるかは未検証で、追加したトグルで今後検証する前提。

変更の種類

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

変更内容

  • R2(ETA単独の位置・到着駆動)を撤去(src/hooks/useEtaFallback.ts): 発動/解除/drive/座標スナップ/etaFallbackActiveAtom の駆動をすべて削除し、useEtaFallback は毎tick estimateEtaPhase を評価して etaPhaseAtom を公開するだけにした。位置・到着・接近・現在駅は書き換えない(GPSを唯一の権威に保つ)。
  • ETA補助(R1)は維持(src/hooks/useRefreshStation.ts): 精度劣化時に etaPhaseAtom が最寄り駅で DWELLING を示すときだけ到着しきい値を緩和する既存ロジックはそのまま。到着はGPSが確定する。
  • アンカー記録(src/hooks/useEtaAnchor.ts): 到着中/発車(arrived true→false)を etaAnchorAtom へ記録し、etaPhaseAtom の仮想時計の起点にする。ETAは位置を駆動しないため、仮に静止中の強制未到着で DEPARTED が記録されても、R1は最寄り駅とETA停車駅が一致する時だけ効き、GPS復帰で自己修復する。
  • 設定の試験的機能に「到着判定の改善」トグルを追加(src/screens/ExperimentalSettings.tsx ほか): etaAssistManualEnabledAtom+ETA_ASSIST_MANUAL_ENABLED で永続化し、起動時に Permitted.tsx で復元。実効有効 = Remote Config(マスター)AND 手動トグル。Remote が false のときはトグルを disabled にして手動でも有効化できない(isEtaAssistRemoteEnabled を切り出し)。翻訳キー etaAssistTitle / etaAssistDescription を ja/en に追加。
  • 不要コードの撤去: R2撤去で参照ゼロになった etaFallbackActiveAtom(+useRefreshStation の2ライターゲート)、staleness用の lastAcceptedFix* atom を削除。ETAが位置を駆動しなくなったことで役割を失った実移動検知(recordMotion / lastMovingAtMsAtom / isRecentlyMoving)も撤去。
  • DevOverlay: ETA補助が無効なときはETA診断カード(FALLBACK / ANCHOR)を表示せず、フェーズ表示の警告色は精度劣化時のみ点灯するよう調整。
  • 対応するユニットテストを追加・更新(useEtaFallback はフェーズ公開のみ&状態非駆動、remoteConfig/ExperimentalSettings のマスタースイッチ挙動、DevOverlay の無効時非表示ほか)。

テスト

  • npm run lint が通ること
  • npm test が通ること(2005件パス)
  • npm run typecheck が通ること

関連Issue

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新機能

    • ETA補助の手動切り替え設定を追加し、設定画面から有効/無効を変更できるようになりました。
    • ETA推定フェーズに応じた表示を導入し、到着判定や補助情報の見え方を改善しました。
  • 変更

    • 地下などでGPS精度が落ちる場面でも、ETA補助の表示がより安定して反映されるようになりました。
    • アンカー表示や各種通知の挙動を整理し、状態更新の一貫性を向上しました。

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

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

ETAフォールバックの状態駆動(駅状態を前進させるロジック)を撤去し、etaPhaseAtomによるETAフェーズ公開のみに限定した。ETA補助機能はリモート許可と手動トグル(新規atom・永続化キー・設定画面UI)の両方が有効な場合にのみ動作するよう変更し、関連する参照箇所・翻訳・テストを更新した。

Changes

ETA補助の再構成

Layer / File(s) Summary
ETAフェーズ公開への置換
src/hooks/useEtaFallback.ts, src/hooks/useEtaFallback.test.tsx, src/store/atoms/etaFallback.ts
useEtaFallbackからGPS不良判定・状態前進駆動・etaFallbackActiveAtomを削除し、etaPhaseAtom公開のみに限定。関連テストとatomコメントも更新。
ETAアンカーのフォールバック依存解除
src/hooks/useEtaAnchor.ts, src/hooks/useEtaAnchor.test.tsx
useEtaAnchorからetaFallbackActiveAtom参照を削除し、DEPARTED記録とAT_STATION定期更新をフォールバック中でも継続するよう変更。
通知と表示のETAフェーズ参照
src/hooks/useRefreshStation.ts, src/hooks/useRefreshStation.test.tsx, src/components/DevOverlay.tsx, src/components/DevOverlay.test.tsx
通知抑制条件と表示条件がetaFallbackActiveからetaPhaseAtom/etaAnchorAtom/etaAssistEnabled基準へ変更。
リモート許可と手動トグルによる有効判定
src/lib/remoteConfig.ts, src/lib/remoteConfig.test.ts, src/constants/storage.ts
isEtaAssistRemoteEnabledを新設し、isEtaAssistEnabledはリモート許可と手動トグル両方が真の場合のみ有効。永続化キーETA_ASSIST_MANUAL_ENABLEDを追加。
ETA補助の手動設定UIと永続化
src/components/Permitted.tsx, src/screens/ExperimentalSettings.tsx, src/screens/ExperimentalSettings.test.tsx, assets/translations/en.json, assets/translations/ja.json
起動時読み込みと設定画面での手動トグル(disabled対応)を追加し、翻訳文言を追加。
実移動検知テストとlastAcceptedFix系の整理
src/store/atoms/location.ts, src/store/atoms/location.test.ts
lastAcceptedFixAtMsAtom/lastAcceptedFixAccuracyAtomのリセット処理を削除し、テストをlastMovingAtMsAtom検証へ置換。

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ExperimentalSettings
  participant etaAssistManualEnabledAtom
  participant storage
  participant remoteConfig
  participant DevOverlay
  ExperimentalSettings->>remoteConfig: isEtaAssistRemoteEnabled()
  remoteConfig-->>ExperimentalSettings: 許可状態
  ExperimentalSettings->>etaAssistManualEnabledAtom: 手動トグルをset
  ExperimentalSettings->>storage: ETA_ASSIST_MANUAL_ENABLEDを保存
  remoteConfig->>remoteConfig: isEtaAssistEnabled = remote && manual
  DevOverlay->>remoteConfig: isEtaAssistEnabled参照
  DevOverlay->>DevOverlay: etaPhaseAtom/etaAnchorAtomを表示
Loading

Possibly related PRs

  • TrainLCD/MobileApp#6141: useRefreshStation.tsの駅接近通知useEffectの条件ロジックが同様に変更されており衝突し得る。
  • TrainLCD/MobileApp#6366: useEtaAnchor/useEtaFallback/etaFallbackでetaFallbackActiveAtomを中核に実装しており、本PRは同箇所をetaPhaseAtom基準へ置き換えているため強く関連。

Poem

フォールバック卒業、うさぎも一安心 🐰
フェーズだけを空へ掲げ、GPSに道を譲る
リモートと手動、二つのスイッチ揃えば
ETAアシストがそっと灯る
ぴょんと跳ねて、次の駅へ🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 主要変更であるETA補助への限定と手動トグル追加を具体的に表しており、変更内容と整合しています。
Description check ✅ Passed テンプレートの主要項目(概要、変更の種類、変更内容、テスト、関連Issue、スクリーンショット)を概ね満たしています。
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.
✨ 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 claude/eta-subway-support-v5jhtl

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

@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: 4

🤖 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/hooks/useEtaAnchor.test.tsx`:
- Around line 115-136: `useEtaAnchor` のテストに `MOVING_RECENCY_MS`
の境界ケースを追加してください。現在は `lastMovingAtMsAtom` が null
の場合しか見ていないため、`lastMovingAtMsAtom` に値はあるが `MOVING_RECENCY_MS` を超えて古いときに
`arrivedAtom` が false へ倒れても `DEPARTED` を記録しないことを、`etaAnchorAtom` と `arrivedAtom`
の振る舞いで検証してください。既存の `renderWithStore` と `createStore` を使い、`useEtaAnchor` の motion
gate が時間しきい値を正しく判定することを確認できる形にしてください。

In `@src/hooks/useEtaAnchor.ts`:
- Around line 61-76: The motion-gate check for “recently moving” is duplicated
between useEtaAnchor and useEtaFallback’s tick logic. Extract the shared
`lastMovingAtMs != null && now - lastMovingAtMs < MOVING_RECENCY_MS` condition
into a common helper in `src/utils/etaFallback.ts` (for example,
`isRecentlyMoving(lastMovingAtMs, nowMs)`), then replace both local checks with
that helper so the behavior stays consistent when the threshold or rule changes.

In `@src/store/atoms/location.test.ts`:
- Around line 288-296: The current location tests cover coarse-to-coarse
behavior, but they miss the low-precision to high-precision transition where
recordMotion may wrongly treat a resumed accurate fix as real movement after a
degraded sample. Add a test in location.test.ts around setLocation and
lastMovingAtMsAtom that first establishes a coarse baseline, then feeds a
high-precision update with distance over the normal threshold but still
representing a stationary case, and assert that the motion state is not
incorrectly updated. Use the existing recordMotion behavior and the same helpers
like makeLocation, setLocation, and store.get(lastMovingAtMsAtom) to keep the
scenario aligned with the implementation.

In `@src/store/atoms/location.ts`:
- Around line 93-125: `recordMotion` の移動判定を強化してください。`lastMotionSampleAtom`
には位置だけでなく前回の `accuracy` も保存し、現在の `accuracy` と前回の `accuracy` の両方を使って `threshold`
を決めるようにしてください。あわせて、`recordMotion` 内で `dtSec <= 0` の場合は `speed` を 0
にせずその場で判定を中断し、同一時刻や時刻逆行時に `lastMovingAtMsAtom` が誤打刻されないようにしてください。
🪄 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: 21022d64-5ca8-4088-8e32-144b288a2d11

📥 Commits

Reviewing files that changed from the base of the PR and between 6b5f59f and 0289a83.

📒 Files selected for processing (7)
  • src/hooks/useEtaAnchor.test.tsx
  • src/hooks/useEtaAnchor.ts
  • src/hooks/useEtaFallback.test.tsx
  • src/hooks/useEtaFallback.ts
  • src/store/atoms/location.test.ts
  • src/store/atoms/location.ts
  • src/utils/etaFallback.ts

Comment thread src/hooks/useEtaAnchor.test.tsx Resolved
Comment thread src/hooks/useEtaAnchor.ts Resolved
Comment thread src/store/atoms/location.test.ts Resolved
Comment thread src/store/atoms/location.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.

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)

96-141: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

src/store/atoms/location.ts:96-141 の速度判定は長時間停車後に過小評価されます
lastMotionSampleAtom が移動確定時しか更新されないため、停車が長いほど dtSec が肥大化し、単発の劣化フィックスでも speed = dist / dtSec が MAX_PLAUSIBLE_SPEED を下回って lastMovingAtMsAtom を誤更新できます。直近 fix 基準の判定にするか、複数回連続で閾値超過した場合のみ打刻してください。

🤖 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 96 - 141, `recordMotion` の速度判定が
`lastMotionSampleAtom` を移動確定時にしか更新しないため、長時間停車後に `dtSec`
が大きくなって単発の劣化フィックスを見逃す問題があります。`recordMotion` と `lastMotionSampleAtom`
の扱いを見直し、直近の受理 fix を基準に速度を計算するか、`lastMovingAtMsAtom` を更新する前に複数回連続で `dist` と
`speed` の閾値超過を確認するようにしてください。
🤖 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 96-141: `recordMotion` の速度判定が `lastMotionSampleAtom`
を移動確定時にしか更新しないため、長時間停車後に `dtSec` が大きくなって単発の劣化フィックスを見逃す問題があります。`recordMotion` と
`lastMotionSampleAtom` の扱いを見直し、直近の受理 fix を基準に速度を計算するか、`lastMovingAtMsAtom`
を更新する前に複数回連続で `dist` と `speed` の閾値超過を確認するようにしてください。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 445a17db-fd27-468d-95e5-47b03c95875a

📥 Commits

Reviewing files that changed from the base of the PR and between 0289a83 and d887920.

📒 Files selected for processing (7)
  • src/hooks/useEtaAnchor.test.tsx
  • src/hooks/useEtaAnchor.ts
  • src/hooks/useEtaFallback.test.tsx
  • src/hooks/useEtaFallback.ts
  • src/store/atoms/location.test.ts
  • src/store/atoms/location.ts
  • src/utils/etaFallback.ts

@TinyKitten TinyKitten changed the title GPS喪失時のETAフォールバックに実移動ゲートと持続喪失ゲートを追加して駅待機中の誤前進を防止 地下でETAが現在地を独占駆動して勝手に動くデグレを解消しETAをGPSの到着判定補助(R1)に限定、設定に手動A/Bトグルを追加 Jul 8, 2026

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/store/atoms/location.ts (1)

90-141: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

発車判定の基準サンプルを停車中にも前進させてください

lastMotionSampleAtom が「移動と判定できた時」しか更新されないため、長時間停車後は dtSec が膨らんだままになり、最初の発車サンプルが MOTION_MIN_SPEED_MPS を満たすまで lastMovingAtMsAtom が立ちません。useEtaAnchor は arrived true -> false の瞬間にしか lastMovingAtMsAtom を見ないので、この遅延で DEPARTED を取りこぼす可能性があります。ジッタ抑制用の基準と、最近の実移動判定用の基準は分けるのが安全です。

🤖 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 90 - 141, `recordMotion` only
advances `lastMotionSampleAtom` when motion is already detected, which leaves
the baseline stale during long stops and can delay or miss the first departure
transition. Update the sampling logic so the reference sample is advanced on
each accepted location fix (or split it into separate atoms for jitter
suppression vs. motion detection), while keeping `lastMovingAtMsAtom` gated on
the existing distance/speed checks. Use the existing `recordMotion`,
`lastMotionSampleAtom`, and `lastMovingAtMsAtom` flow so `useEtaAnchor` can
observe the departure promptly.
src/hooks/useEtaFallback.test.tsx (1)

33-52: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

station は共通ファクトリへ寄せてください src/utils/test/factories.ts の createStation で置き換えられます。routeStop と BASE_LOCATION は共通ヘルパーが見当たらないので、そのままで問題ありません。

🤖 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/hooks/useEtaFallback.test.tsx` around lines 33 - 52, The local station
helper in useEtaFallback.test.tsx should be removed and replaced with the shared
createStation factory from src/utils/test/factories so the test uses the common
Station setup instead of duplicating it. Keep routeStop and BASE_LOCATION as-is,
and update the test setup to call createStation wherever station is currently
used.

Source: Path instructions

🤖 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/DevOverlay.tsx`:
- Around line 413-414: The ETA FALLBACK warning state is being driven by
etaPhase presence, which makes the card look urgent during normal assisted
operation instead of only when fallback is actually active. Update the warning
condition in DevOverlay.tsx so the card uses the real fallback/assist-active
signal (the previous isEtaFallbackActive-style logic) rather than etaPhase !=
null, and apply the same fix to the other ETA fallback display blocks referenced
by the ETA card rendering.

In `@src/screens/ExperimentalSettings.tsx`:
- Around line 122-137: `handleToggleEtaAssist` repeats the same
toggle/persist/rollback pattern used by `handleTogglePortraitMode` and
`handleToggleTelemetry`, so extract this boolean preference flow into a shared
hook/helper and have these handlers call it with their specific atom setter,
storage key, and alert message. Keep the existing behavior intact: flip the
current value, update the atom, persist via `storage.set`, and on failure roll
back the atom and show the error alert.

---

Outside diff comments:
In `@src/hooks/useEtaFallback.test.tsx`:
- Around line 33-52: The local station helper in useEtaFallback.test.tsx should
be removed and replaced with the shared createStation factory from
src/utils/test/factories so the test uses the common Station setup instead of
duplicating it. Keep routeStop and BASE_LOCATION as-is, and update the test
setup to call createStation wherever station is currently used.

In `@src/store/atoms/location.ts`:
- Around line 90-141: `recordMotion` only advances `lastMotionSampleAtom` when
motion is already detected, which leaves the baseline stale during long stops
and can delay or miss the first departure transition. Update the sampling logic
so the reference sample is advanced on each accepted location fix (or split it
into separate atoms for jitter suppression vs. motion detection), while keeping
`lastMovingAtMsAtom` gated on the existing distance/speed checks. Use the
existing `recordMotion`, `lastMotionSampleAtom`, and `lastMovingAtMsAtom` flow
so `useEtaAnchor` can observe the departure promptly.
🪄 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: af4eade9-a0e9-4b1a-956c-f816d7a0e508

📥 Commits

Reviewing files that changed from the base of the PR and between d887920 and 5719a71.

📒 Files selected for processing (20)
  • assets/translations/en.json
  • assets/translations/ja.json
  • src/components/DevOverlay.test.tsx
  • src/components/DevOverlay.tsx
  • src/components/Permitted.tsx
  • src/constants/storage.ts
  • src/hooks/useEtaAnchor.test.tsx
  • src/hooks/useEtaAnchor.ts
  • src/hooks/useEtaFallback.test.tsx
  • src/hooks/useEtaFallback.ts
  • src/hooks/useRefreshStation.test.tsx
  • src/hooks/useRefreshStation.ts
  • src/lib/remoteConfig.test.ts
  • src/lib/remoteConfig.ts
  • src/screens/ExperimentalSettings.test.tsx
  • src/screens/ExperimentalSettings.tsx
  • src/store/atoms/etaFallback.ts
  • src/store/atoms/experimental.ts
  • src/store/atoms/location.test.ts
  • src/store/atoms/location.ts

Comment thread src/components/DevOverlay.tsx Resolved
Comment thread src/screens/ExperimentalSettings.tsx Resolved
@TinyKitten
TinyKitten merged commit 5db8984 into dev Jul 9, 2026
3 checks passed
@TinyKitten
TinyKitten deleted the claude/eta-subway-support-v5jhtl branch July 9, 2026 00:27

@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: 1

🤖 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/lib/remoteConfig.ts`:
- Around line 135-140: The ETA assist gate logic is duplicated between
isEtaAssistEnabled() and the JSX in ExperimentalSettings.tsx, so move the shared
Remote AND manual check into a reusable hook such as useEtaAssistEnabled() that
reads etaAssistRemoteEnabled and etaAssistManualEnabledAtom reactively. Update
ExperimentalSettings.tsx to use the new hook for rendering, and keep
isEtaAssistEnabled() as the synchronous helper for non-React callers like
DevOverlay by delegating to the same underlying gate logic.
🪄 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: 6a80d59d-e371-4057-8024-6f38d554f2f4

📥 Commits

Reviewing files that changed from the base of the PR and between 5719a71 and cc18cec.

📒 Files selected for processing (11)
  • src/components/DevOverlay.test.tsx
  • src/components/DevOverlay.tsx
  • src/hooks/useEtaAnchor.test.tsx
  • src/hooks/useEtaAnchor.ts
  • src/hooks/useEtaFallback.test.tsx
  • src/lib/remoteConfig.test.ts
  • src/lib/remoteConfig.ts
  • src/screens/ExperimentalSettings.test.tsx
  • src/screens/ExperimentalSettings.tsx
  • src/store/atoms/location.test.ts
  • src/store/atoms/location.ts
💤 Files with no reviewable changes (2)
  • src/store/atoms/location.test.ts
  • src/store/atoms/location.ts

Comment thread src/lib/remoteConfig.ts
Comment on lines +135 to +140
// ETA補助機能の実効的な有効/無効を同期的に取得する。Remote Config が許可(マスターON)し、
// かつ設定画面の手動トグルもONのときだけ有効。Remote が false のときは手動トグルの値に
// 関わらず無効。
export const isEtaAssistEnabled = (): boolean =>
isEtaAssistRemoteEnabled() && store.get(etaAssistManualEnabledAtom);

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.

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remote AND 手動の判定ロジックが2箇所に分散している。

isEtaAssistEnabled()のAND条件と、src/screens/ExperimentalSettings.tsxのJSX(etaAssistRemoteEnabled && etaAssistManualEnabled)が同じ業務ロジックを別々に実装しています。将来ゲート条件が増えた際に片方だけ更新され挙動がズレるリスクがあります。useAtomValue(etaAssistManualEnabledAtom) && isEtaAssistRemoteEnabled()をまとめた再利用可能なフック(例: useEtaAssistEnabled())に切り出すと、UI側(ExperimentalSettings.tsx)でもリアクティブに購読でき、非リアクティブなisEtaAssistEnabled()(DevOverlay等)とロジックを一元化できます。

♻️ 提案: 共通フックへの切り出し
+export const useEtaAssistEnabled = (): boolean => {
+  const manualEnabled = useAtomValue(etaAssistManualEnabledAtom);
+  return isEtaAssistRemoteEnabled() && manualEnabled;
+};
+
 export const isEtaAssistEnabled = (): boolean =>
   isEtaAssistRemoteEnabled() && store.get(etaAssistManualEnabledAtom);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// ETA補助機能の実効的な有効/無効を同期的に取得する。Remote Config が許可(マスターON)し、
// かつ設定画面の手動トグルもONのときだけ有効。Remote が false のときは手動トグルの値に
// 関わらず無効。
export const isEtaAssistEnabled = (): boolean =>
isEtaAssistRemoteEnabled() && store.get(etaAssistManualEnabledAtom);
// ETA補助機能の実効的な有効/無効を同期的に取得する。Remote Config が許可(マスターON)し、
// かつ設定画面の手動トグルもONのときだけ有効。Remote が false のときは手動トグルの値に
// 関わらず無効。
export const useEtaAssistEnabled = (): boolean => {
const manualEnabled = useAtomValue(etaAssistManualEnabledAtom);
return isEtaAssistRemoteEnabled() && manualEnabled;
};
export const isEtaAssistEnabled = (): boolean =>
isEtaAssistRemoteEnabled() && store.get(etaAssistManualEnabledAtom);
🤖 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/lib/remoteConfig.ts` around lines 135 - 140, The ETA assist gate logic is
duplicated between isEtaAssistEnabled() and the JSX in ExperimentalSettings.tsx,
so move the shared Remote AND manual check into a reusable hook such as
useEtaAssistEnabled() that reads etaAssistRemoteEnabled and
etaAssistManualEnabledAtom reactively. Update ExperimentalSettings.tsx to use
the new hook for rendering, and keep isEtaAssistEnabled() as the synchronous
helper for non-React callers like DevOverlay by delegating to the same
underlying gate logic.

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