Repository navigation
DevOverlayの精度履歴をreact-native-svgの折れ線グラフで再実装 - #6125
Conversation
📝 WalkthroughWalkthrough精度履歴表示をASCII文字ベースから SVG 折れ線グラフへ移行します。ユーティリティ層で点系列データ型と閾値ベースの色判定を新規実装し、新しい React Native コンポーネント AccuracyHistoryChart でグラフをレンダリング、DevOverlay に統合することで視覚的な精度トレンド表示を実現します。 Changes精度チャート表示の完全移行
Sequence DiagramsequenceDiagram
participant DevOverlay as DevOverlay
participant buildAccuracyChartSeries as buildAccuracyChartSeries
participant getAccuracyColor as getAccuracyColor
participant ACCURACY_CHART_COLORS as ACCURACY_CHART_COLORS
participant AccuracyHistoryChart as AccuracyHistoryChart
participant SVGRenderer as SVGRenderer
DevOverlay->>AccuracyHistoryChart: 精度履歴 + width/height を渡す
AccuracyHistoryChart->>buildAccuracyChartSeries: 精度履歴配列を渡す
buildAccuracyChartSeries->>buildAccuracyChartSeries: NaN/Infinity/負値をフィルタリング
buildAccuracyChartSeries->>buildAccuracyChartSeries: min/max から正規化値を計算
loop 各点ごと
buildAccuracyChartSeries->>getAccuracyColor: 正規化値で色を決定
getAccuracyColor->>ACCURACY_CHART_COLORS: 閾値に基づいて色種別を選択
ACCURACY_CHART_COLORS-->>getAccuracyColor: good/warning/danger 色HEXを返す
getAccuracyColor-->>buildAccuracyChartSeries: 点カラーが決定
end
buildAccuracyChartSeries-->>AccuracyHistoryChart: AccuracyChartPoint[] を返す
alt 点列が存在
AccuracyHistoryChart->>AccuracyHistoryChart: SVG座標計算(x: 等間隔、y: 正規化値)
AccuracyHistoryChart->>SVGRenderer: 折れ線 + 円を描画
else 点列が空
AccuracyHistoryChart->>SVGRenderer: プレースホルダ(---)を描画
end
SVGRenderer-->>DevOverlay: レンダリング完了
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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)
Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
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)
7-131:⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
afterEachでjest.clearAllMocks()を追加してください。このテストファイルに
afterEachが無く、モック状態の持ち越しを防ぐ統一ルールに未準拠です。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 7 - 131, Add a global afterEach hook to this test file that calls jest.clearAllMocks() to prevent mock state leakage between tests; place it at top-level (outside the describe blocks) in the file that contains the describe('buildAccuracyChartSeries'...) and describe('getAccuracyColor'...) suites so all tests (including those exercising buildAccuracyChartSeries and getAccuracyColor) run with cleared mocks after each spec.
🧹 Nitpick comments (1)
src/utils/accuracyChart.test.ts (1)
119-129: ⚡ Quick win閾値境界テストの固定値は定数参照に置き換えると安全です。
Line 120, Line 124, Line 128 の
2000/200/199は、MAX_PERMIT_ACCURACY/BAD_ACCURACY_THRESHOLDを直接使う方が将来の閾値変更に追従できます。🤖 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 119 - 129, Replace hard-coded numeric literals in the tests with the corresponding constants so they follow future threshold changes: update the assertions in tests referencing getAccuracyColor and ACCURACY_CHART_COLORS to use MAX_PERMIT_ACCURACY instead of 2000, BAD_ACCURACY_THRESHOLD instead of 200 for the boundary case, and BAD_ACCURACY_THRESHOLD - 1 instead of 199 for the just-below-boundary case; this ensures tests remain correct when MAX_PERMIT_ACCURACY or BAD_ACCURACY_THRESHOLD values change.
🤖 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/AccuracyHistoryChart.test.tsx`:
- Around line 6-87: Add an afterEach hook that calls jest.clearAllMocks() in the
AccuracyHistoryChart test suite: inside the describe('AccuracyHistoryChart',
...) block add afterEach(() => { jest.clearAllMocks(); }) so all mocks are reset
between tests (ensures tests using getAllByTestId / processColor /
ACCURACY_CHART_COLORS are not affected by prior mock state).
---
Outside diff comments:
In `@src/utils/accuracyChart.test.ts`:
- Around line 7-131: Add a global afterEach hook to this test file that calls
jest.clearAllMocks() to prevent mock state leakage between tests; place it at
top-level (outside the describe blocks) in the file that contains the
describe('buildAccuracyChartSeries'...) and describe('getAccuracyColor'...)
suites so all tests (including those exercising buildAccuracyChartSeries and
getAccuracyColor) run with cleared mocks after each spec.
---
Nitpick comments:
In `@src/utils/accuracyChart.test.ts`:
- Around line 119-129: Replace hard-coded numeric literals in the tests with the
corresponding constants so they follow future threshold changes: update the
assertions in tests referencing getAccuracyColor and ACCURACY_CHART_COLORS to
use MAX_PERMIT_ACCURACY instead of 2000, BAD_ACCURACY_THRESHOLD instead of 200
for the boundary case, and BAD_ACCURACY_THRESHOLD - 1 instead of 199 for the
just-below-boundary case; this ensures tests remain correct when
MAX_PERMIT_ACCURACY or BAD_ACCURACY_THRESHOLD values change.
🪄 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: CHILL
Plan: Pro
Run ID: f5c18256-69e6-4d59-92c8-dc0c50147036
📒 Files selected for processing (6)
src/components/AccuracyHistoryChart.test.tsxsrc/components/AccuracyHistoryChart.tsxsrc/components/DevOverlay.test.tsxsrc/components/DevOverlay.tsxsrc/utils/accuracyChart.test.tssrc/utils/accuracyChart.ts
概要
DevOverlay の精度履歴表示を、ASCII ブロック文字(
▇▆▅▄▃▂▁)による擬似バーからreact-native-svgベースの折れ線グラフに再実装した。変更の種類
変更内容
src/components/AccuracyHistoryChart.tsxを新規追加し、react-native-svgのSvg/Line/Circleで精度履歴を折れ線グラフ描画。値が大きい(=精度が悪い)サンプルほど上端側に配置する。#38bdf8/ 警告=#facc15/ 超過=#f87171、DevOverlay のメトリクスカード配色と統一)。線分は両端のうち精度が悪い側の色で塗り、悪化区間を強調する。---プレースホルダー、1 サンプルのみの場合は中央に 1 点を表示する。src/utils/accuracyChart.tsのgenerateAccuracyChart(ブロック文字生成)を、描画サイズ非依存の正規化済み点列を返すbuildAccuracyChartSeriesに置き換え、色定数ACCURACY_CHART_COLORSを公開。src/components/DevOverlay.tsxの縦・横レイアウト双方のチャート描画をAccuracyHistoryChartに差し替え、不要になったTextimport・generateAccuracyChart・chartValue系スタイルを削除。accuracyChart.test.tsを新 API 向けに刷新、AccuracyHistoryChart.test.tsxを新規追加、DevOverlay.test.tsxのチャート系アサーションを描画点数ベースへ更新)。テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
Generated by Claude Code
Summary by CodeRabbit
リリースノート
新機能
テスト