Skip to content

DevOverlayの精度チャートとm表示の配色を最大許容精度に応じて調整 - #6113

Merged
TinyKitten merged 2 commits into
devfrom
claude/devoverlay-precision-chart-colors-BPrCZ
Jun 3, 2026
Merged

TinyKitten merged 2 commits into
devfrom
claude/devoverlay-precision-chart-colors-BPrCZ

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

概要

DevOverlay の測位精度ビジュアライズの配色を見直し、「最大許容精度(MAX_PERMIT_ACCURACY = 1500m)を超えると赤」になるよう統一しました。あわせて、精度チャートが黄色になる精度域では LOCATION ACCURACY の m 表示も黄字にして、数値とチャートの双方で精度悪化を示します。

変更の種類

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

変更内容

  • 精度チャート(src/utils/accuracyChart.ts)の赤色判定を BAD_ACCURACY_THRESHOLD(200m) 以上から、最大許容精度 MAX_PERMIT_ACCURACY(1500m) 超過に変更し、メトリクスカードの isAccuracyOverLimit 警告と整合させた。
  • 中間域(BAD_ACCURACY_THRESHOLD(200m) 以上・MAX_PERMIT_ACCURACY(1500m) 以下)を黄色に変更。
  • src/components/DevOverlay.tsx の LOCATION ACCURACY の m 表示を、チャートが黄色になる精度域では黄字(#facc15)、許容精度を超えた場合は従来どおり赤字(#f87171)で表示するよう調整。
  • 上記に合わせて accuracyChart.test.ts の色判定テストを更新し、DevOverlay.test.tsx に黄字表示・赤字優先・閾値未満は黄字にしないケースを追加。

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

関連Issue

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


Generated by Claude Code

Summary by CodeRabbit

リリースノート

  • 新機能

    • ロケーション精度メトリクスの表示状態を拡張しました。精度値に応じて正常(白)、注意(黄)、危険(赤)の3段階で視覚的にフィードバックを提供するようになりました。
  • 改善

    • 精度に関する閾値条件をより詳細に定義し直し、ユーザーが精度レベルをより正確に把握できるようにしました。

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

coderabbitai Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

位置精度(LOCATION ACCURACY)の表示色を、BAD_ACCURACY_THRESHOLD と MAX_PERMIT_ACCURACY の2つの閾値に基づいて3段階(白/黄/赤)に分ける実装です。色判定ロジックを accuracyChart.ts で更新し、DevOverlay UIと両方のテストスイートで整合性をとりました。

Changes

位置精度表示の色分け仕様更新

Layer / File(s) Summary
色判定ロジックの実装と検証
src/utils/accuracyChart.ts, src/utils/accuracyChart.test.ts
getAccuracyColor に accuracy > MAX_PERMIT_ACCURACY の即座の赤色返却条件を追加し、既存の BAD_ACCURACY_THRESHOLD 段階分岐を後段化しました。テスト入力値を境界値サンプル [50, 500, 2000] に置き換え、赤/黄/白の3ケースを明確に検証します。
DevOverlay コンポーネントへの統合
src/components/DevOverlay.tsx, src/components/DevOverlay.test.tsx
BAD_ACCURACY_THRESHOLD をインポートし、警告色スタイル(黄)を定義しました。ランドスケープ・ポートレート両モードで「LOCATION ACCURACY」値の条件分岐を統一し、isAccuracyWarning 判定で黄色、isAccuracyOverLimit で赤色を選択的に適用します。テストケースを新たに3区分の色期待値に対応させました。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • TrainLCD/MobileApp#6103: DevOverlay の「LOCATION ACCURACY」表示色を MAX_PERMIT_ACCURACY 超過時に赤で表示する変更が、本PRの色分岐ロジックと同一メトリクスを扱っています。

  • TrainLCD/MobileApp#6098: MAX_PERMIT_ACCURACY 定数の引き下げが、本PRの色分岐条件 accuracy > MAX_PERMIT_ACCURACY に直結しています。

Suggested labels

react, ui/styling

Poem

🐰 精度の三色に分かれて

白は安心、黄は用心

赤はおっと、限界超えて

表示色が教えてくれる、今の状態

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed タイトルはPRの主な変更内容である精度チャートとm表示の配色調整を「最大許容精度に応じて」という文脈とともに明確に表現しており、主な変更を効果的に要約しています。
Description check ✅ Passed テンプレートの「概要」「変更の種類」「変更内容」「テスト」セクションすべてが適切に記入され、変更の詳細な説明とテスト実施状況が明確に示されています。
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 claude/devoverlay-precision-chart-colors-BPrCZ

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

@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/utils/accuracyChart.test.ts (1)

3-195: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

afterEach で jest.clearAllMocks() を追加してください。

このファイルにも afterEach(() => { jest.clearAllMocks(); }) を入れて、テスト間のモック状態汚染を確実に防いでください。

As per coding guidelines **/*.test.{ts,tsx}: テストの afterEach で jest.clearAllMocks() を呼び出してください。

🤖 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/accuracyChart.test.ts` around lines 3 - 195, Add an afterEach hook
calling jest.clearAllMocks() to this test suite to prevent mock state leakage;
specifically, inside the describe('generateAccuracyChart', ...) block (near the
top of the file where the tests are declared and alongside other lifecycle
hooks), insert afterEach(() => { jest.clearAllMocks(); }) so every test of
generateAccuracyChart runs with cleared mocks.
🧹 Nitpick comments (1)
src/utils/accuracyChart.test.ts (1)

158-175: ⚡ Quick win

閾値のマジックナンバーは定数参照に寄せてください。

200/1500/1501 を BAD_ACCURACY_THRESHOLD と MAX_PERMIT_ACCURACY 参照に置き換えると、将来の閾値変更時にテストの追従漏れを防げます。

差分案
 import { generateAccuracyChart } from './accuracyChart';
+import { MAX_PERMIT_ACCURACY } from '../constants/location';
+import { BAD_ACCURACY_THRESHOLD } from '../constants/threshold';
@@
-    it('should use red color for accuracy > MAX_PERMIT_ACCURACY', () => {
-      const result = generateAccuracyChart([1501, 2000, 3000]);
+    it('should use red color for accuracy > MAX_PERMIT_ACCURACY', () => {
+      const result = generateAccuracyChart([
+        MAX_PERMIT_ACCURACY + 1,
+        MAX_PERMIT_ACCURACY + 500,
+        MAX_PERMIT_ACCURACY + 1500,
+      ]);
@@
-      const result = generateAccuracyChart([200, 750, 1500]);
+      const result = generateAccuracyChart([
+        BAD_ACCURACY_THRESHOLD,
+        750,
+        MAX_PERMIT_ACCURACY,
+      ]);
@@
-      const result = generateAccuracyChart([10, 100, 199]);
+      const result = generateAccuracyChart([
+        10,
+        100,
+        BAD_ACCURACY_THRESHOLD - 1,
+      ]);

Also applies to: 184-192

🤖 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/accuracyChart.test.ts` around lines 158 - 175, Replace magic
numbers in the accuracyChart tests with the threshold constants: update the test
cases that call generateAccuracyChart to use BAD_ACCURACY_THRESHOLD and
MAX_PERMIT_ACCURACY (and expressions based on them, e.g., BAD_ACCURACY_THRESHOLD
- 1, BAD_ACCURACY_THRESHOLD, MAX_PERMIT_ACCURACY, MAX_PERMIT_ACCURACY + 1)
instead of hard-coded 200/1500/1501 so the tests reference the constants
directly and follow future threshold changes.
🤖 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/utils/accuracyChart.test.ts`:
- Around line 3-195: Add an afterEach hook calling jest.clearAllMocks() to this
test suite to prevent mock state leakage; specifically, inside the
describe('generateAccuracyChart', ...) block (near the top of the file where the
tests are declared and alongside other lifecycle hooks), insert afterEach(() =>
{ jest.clearAllMocks(); }) so every test of generateAccuracyChart runs with
cleared mocks.

---

Nitpick comments:
In `@src/utils/accuracyChart.test.ts`:
- Around line 158-175: Replace magic numbers in the accuracyChart tests with the
threshold constants: update the test cases that call generateAccuracyChart to
use BAD_ACCURACY_THRESHOLD and MAX_PERMIT_ACCURACY (and expressions based on
them, e.g., BAD_ACCURACY_THRESHOLD - 1, BAD_ACCURACY_THRESHOLD,
MAX_PERMIT_ACCURACY, MAX_PERMIT_ACCURACY + 1) instead of hard-coded
200/1500/1501 so the tests reference the constants directly and follow future
threshold changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7f9dff97-3cc5-498e-a2c0-9ff6497d7106

📥 Commits

Reviewing files that changed from the base of the PR and between 90fda4f and ed6af40.

📒 Files selected for processing (4)
  • src/components/DevOverlay.test.tsx
  • src/components/DevOverlay.tsx
  • src/utils/accuracyChart.test.ts
  • src/utils/accuracyChart.ts

@TinyKitten
TinyKitten merged commit e0eb362 into dev Jun 3, 2026
6 checks passed
@TinyKitten
TinyKitten deleted the claude/devoverlay-precision-chart-colors-BPrCZ branch June 3, 2026 10:49
@TinyKitten TinyKitten mentioned this pull request Jun 3, 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