diff --git a/frontend/src/components/quality/claude-pr-comparison.tsx b/frontend/src/components/quality/claude-pr-comparison.tsx
index 4d53336..c440b8a 100644
--- a/frontend/src/components/quality/claude-pr-comparison.tsx
+++ b/frontend/src/components/quality/claude-pr-comparison.tsx
@@ -1,7 +1,7 @@
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { CardSkeleton } from "@/components/shared/loading-skeleton"
import { useClaudePRComparison } from "@/hooks/use-api-queries"
-import { cn } from "@/lib/utils"
+import { cn, formatMetric } from "@/lib/utils"
import { GitPullRequest } from "lucide-react"
import type { PRGroupMetrics } from "@/types/api"
@@ -11,9 +11,9 @@ interface ClaudePRComparisonProps {
endDate?: string
}
-function formatMetric(value: number | null, suffix = ""): string {
- if (value == null) return "-"
- return `${value.toFixed(1)}${suffix}`
+function formatMetricWithSuffix(value: number | null, suffix = ""): string {
+ const base = formatMetric(value)
+ return base === "-" ? base : `${base}${suffix}`
}
function DeltaIndicator({ value }: { value: number | null }) {
@@ -56,8 +56,8 @@ function MetricRow({
return (
{label}
-
{formatMetric(claudeValue, suffix)}
-
{formatMetric(otherValue, suffix)}
+
{formatMetricWithSuffix(claudeValue, suffix)}
+
{formatMetricWithSuffix(otherValue, suffix)}
diff --git a/frontend/src/components/quality/quality-attribution-table.tsx b/frontend/src/components/quality/quality-attribution-table.tsx
index 1db6c30..e490cd5 100644
--- a/frontend/src/components/quality/quality-attribution-table.tsx
+++ b/frontend/src/components/quality/quality-attribution-table.tsx
@@ -1,4 +1,4 @@
-import { formatLabel } from "@/lib/utils"
+import { formatLabel, formatMetric } from "@/lib/utils"
import type { QualityAttributionRow } from "@/types/api"
interface Props {
@@ -18,10 +18,6 @@ function formatPercent(value: number | null): string {
return value == null ? "-" : `${(value * 100).toFixed(0)}%`
}
-function formatMetric(value: number | null, digits = 1): string {
- return value == null ? "-" : value.toFixed(digits)
-}
-
export function QualityAttributionTable({ rows }: Props) {
if (rows.length === 0) {
return (
diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts
index 5a23952..45a20de 100644
--- a/frontend/src/lib/utils.ts
+++ b/frontend/src/lib/utils.ts
@@ -27,12 +27,20 @@ export function formatCost(dollars: number): string {
return `$${dollars.toFixed(2)}`
}
+export function titleize(value: string): string {
+ return value.replaceAll("_", " ")
+}
+
export function formatLabel(value: string): string {
return value
.replaceAll("_", " ")
.replace(/\b\w/g, (char) => char.toUpperCase())
}
+export function formatMetric(value: number | null | undefined, digits = 1): string {
+ return value == null ? "-" : value.toFixed(digits)
+}
+
export function formatPercent(value: number | null | undefined): string {
if (value == null) return "-"
return `${(value * 100).toFixed(0)}%`