Problem
formatConfidence in apps/web/components/parsing/utils.ts can produce decimal percentages due to floating-point arithmetic. For example, a confidence of 0.876 becomes 87.6% instead of 88%.
The current implementation multiplies by 100 and strips trailing zeros, but preserves non-zero decimal digits:
const percentage = confidence * 100;
const normalized = percentage.toString();
const trimmed = normalized.includes(".")
? normalized.replace(/\.0+$/, "").replace(/(\.[0-9]*[1-9])0+$/, "$1")
: normalized;
return `${trimmed}%`;
Floating-point multiplication can also introduce artifacts (e.g., 0.1 * 100 = 10.000000000000002), and the current regex only strips trailing zeros — not all decimal digits.
Expected behavior
Confidence percentages should always display as integers (e.g., 88%, 100%, 75%).
Affected components
apps/web/components/parsing/event-card.tsx — confidence badge
apps/web/components/parsing/task-card.tsx — confidence badge
Suggested fix
Replace the string manipulation with Math.round:
export function formatConfidence(confidence: number | null | undefined): string {
if (typeof confidence !== "number") return "–";
return `${Math.round(confidence * 100)}%`;
}
Problem
formatConfidenceinapps/web/components/parsing/utils.tscan produce decimal percentages due to floating-point arithmetic. For example, a confidence of0.876becomes87.6%instead of88%.The current implementation multiplies by 100 and strips trailing zeros, but preserves non-zero decimal digits:
Floating-point multiplication can also introduce artifacts (e.g.,
0.1 * 100 = 10.000000000000002), and the current regex only strips trailing zeros — not all decimal digits.Expected behavior
Confidence percentages should always display as integers (e.g.,
88%,100%,75%).Affected components
apps/web/components/parsing/event-card.tsx— confidence badgeapps/web/components/parsing/task-card.tsx— confidence badgeSuggested fix
Replace the string manipulation with
Math.round: