fix(roi): repair $NaN / [object Object] in cco-roi cost table#31
Merged
Conversation
roi.js treated MODEL_COSTS[model] as a scalar price, but in utils.js the
values are objects ({ input, output, contextWindow }). So every cost
calculation (savings per session/day/month/year, team ROI) resolved to
NaN, and the "$/M tok" column printed "$[object Object]".
Same bug class as #29 fixed in report.js — just missed in roi.js. Use the
MODEL_INPUT_COST accessor that utils.js already exports for this purpose.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/cco-roiis fully broken in its money output — same bug class as #29, just insrc/roi.jsinstead ofsrc/report.js.Bug
roi.jstreatsMODEL_COSTS[model]as a scalar price per million tokens:But in
utils.jsthe values are objects:So
tokens * { input, output, ... }→NaN, and`$${cost}`→$[object Object]. The entire "Monthly Savings by Model" table and the "Team ROI" figures were garbage.Before:
Fix
Use the
MODEL_INPUT_COSTaccessorutils.jsalready exports for exactly this (input price per model), matching the #29 fix.After:
Verification
node --check src/roi.js→ OKnode src/roi.js→ real numbers, noNaN/[object Object]npm test→ 139/139 pass🤖 Generated with Claude Code