Skip to content

Commit 7d6c711

Browse files
ndemiancclaude
andcommitted
fix(ai): keep the per-turn decimal in the response bar (mirrors onetime PR #86)
creditCost() used the same unary-+ pattern the dashboard did, so it carried the same bug: 7.0 rendered as "7", and anything under 0.05 credits collapsed to "0" — a run that cost something reading as free. Fixed identically to AccountPage.tsx's rate(), with an explicit "<0.1" floor, so the editor and the website format a cost the same way rather than drifting. Verified: 23 suites, 0 failures; $0.0002 -> "<0.1", $0.70 -> "7.0", $0.46 -> "46". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 9e491f8 commit 7d6c711

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎extensions/levelcode-ai/media/chat.html‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2433,7 +2433,11 @@
24332433
function creditCost(micros){
24342434
const c = toCredits(micros);
24352435
if (c <= 0) { return '0'; }
2436-
return c < 10 ? String(+c.toFixed(1)) : Math.round(c).toLocaleString();
2436+
if (c >= 10) { return Math.round(c).toLocaleString(); }
2437+
// Fixed string, not +String(...): the unary + dropped the decimal (7.0 -> "7") and collapsed
2438+
// anything under 0.05 to "0" — a run that cost something reading as free. Same fix as the
2439+
// dashboard's rate(), kept identical so the two surfaces render a cost the same way.
2440+
return c < 0.05 ? '<0.1' : c.toFixed(1);
24372441
}
24382442

24392443
// Response action bar: (Retry) (Copy) (Helpful) (Unhelpful) … model · $cost · $left.

0 commit comments

Comments
 (0)