Skip to content

Centralize formatMetric utility in utils.ts#116

Merged
ccf merged 1 commit intofeat/workflow-compare-modefrom
cursor/format-metric-utility-37fa
Mar 16, 2026
Merged

Centralize formatMetric utility in utils.ts#116
ccf merged 1 commit intofeat/workflow-compare-modefrom
cursor/format-metric-utility-37fa

Conversation

@cursor
Copy link

@cursor cursor bot commented Mar 16, 2026

Summary

Consolidates the duplicated formatMetric helper into frontend/src/lib/utils.ts, removing independent copies from three component files.

Changes

  • frontend/src/lib/utils.ts: Added centralized formatMetric(value, digits) function alongside existing formatting utilities (formatCost, formatPercent, etc.)
  • frontend/src/components/finops/workflow-compare-card.tsx: Removed local formatMetric, importing from utils.ts
  • frontend/src/components/quality/quality-attribution-table.tsx: Removed local formatMetric, importing from utils.ts
  • frontend/src/components/quality/claude-pr-comparison.tsx: Replaced local formatMetric with import from utils.ts; renamed the suffix-appending wrapper to formatMetricWithSuffix which delegates to the centralized version

Motivation

Three independent copies of null-safe numeric formatting logic (value == null ? "-" : value.toFixed(digits)) existed across the codebase. A bug fix in one copy could easily be missed in the others. This centralizes the logic in utils.ts where all other formatting functions live.

Open in Web Open in Cursor 

@ccf ccf marked this pull request as ready for review March 16, 2026 17:58
@ccf ccf merged commit cf9a279 into feat/workflow-compare-mode Mar 16, 2026
1 of 2 checks passed
@ccf ccf deleted the cursor/format-metric-utility-37fa branch March 16, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants