Skip to content

fix(vscode): Display CLI cost cents as dollars - #256

Merged
mike1858 merged 1 commit into
mainfrom
fix/vscode-cost-cents
Sep 9, 2026
Merged

mike1858 merged 1 commit into
mainfrom
fix/vscode-cost-cents

Conversation

@mike1858

@mike1858 mike1858 commented Sep 9, 2026

Copy link
Copy Markdown
Member

Why

The VS Code extension reads stats.cost, but the CLI emits integer cents in stats.costCents. Missing-field fallbacks therefore show $0.00 in the dashboard and status bar popup even when the CLI reports non-zero costs. For example, costCents: 118 should display as $1.18.

Closes #255.

What changed

  • Correct the JSON stats interface and convert costCents to dollars in both summary functions and all three dashboard aggregations (hero, By Tool, By Model).
  • Preserve zero defaults, date filtering, token totals, formatting precision, and the existing approximate model allocation by message count.
  • Add four Node regression tests that execute the compiled summary functions and the dashboard's emitted script with stubbed VS Code/DOM plumbing. Wire them into npm test and exclude test sources from the extension package.

Validation

  • npm --prefix vscode-splitrail test — TypeScript compilation and all four tests pass.
  • The same tests against origin/main reproduce three failures: summary costs, dashboard totals, and model allocation all incorrectly return zero.
  • git diff --check — passed.
  • cargo build --quiet — passed.
  • cargo test --quiet — 453 tests passed.
  • cargo clippy --quiet -- -D warnings — passed.
  • cargo doc --quiet — passed.
  • cargo fmt --all --quiet — passed; worktree remains clean.

The dashboard checks execute its real rendering script but do not launch a VS Code extension host. No live VS Code screenshot or extension-host end-to-end validation is claimed.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected cost calculations in usage summaries and the dashboard by properly converting costs from cents to dollars.
    • Updated hero totals, tool-level costs, model allocations, and usage details to display accurate dollar amounts.
    • Improved handling of zero or missing cost data so summaries and dashboard views remain reliable.

Read costCents instead of the nonexistent cost field in usage summaries\nand dashboard aggregations. Keep dollar-valued summary outputs and\nexisting model allocation behavior.\n\nAdd executable summary and webview regression tests for non-zero costs,\nscoped totals, model shares, and missing or zero values.
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: afd5733a-8d28-4a3c-9922-fbdf4a4204b3

📥 Commits

Reviewing files that changed from the base of the PR and between 2a6496a and b05bd88.

📒 Files selected for processing (5)
  • vscode-splitrail/.vscodeignore
  • vscode-splitrail/package.json
  • vscode-splitrail/src/dashboardView.ts
  • vscode-splitrail/src/usageView.ts
  • vscode-splitrail/test/cost.test.cjs

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The extension now reads CLI costCents values, converts them to dollars in usage summaries and dashboard views, and defaults missing costs to zero. New CommonJS tests cover summaries and dashboard rendering. The test script compiles and runs these tests.

Changes

Cost reporting

Layer / File(s) Summary
Usage summary conversion
vscode-splitrail/src/usageView.ts
JsonInnerStats now uses costCents. Summary functions convert cents to dollars and treat missing values as zero.
Dashboard cost conversion
vscode-splitrail/src/dashboardView.ts
Hero, tool, and model cost calculations now use dollar values derived from costCents.
Validation and extension packaging
vscode-splitrail/test/cost.test.cjs, vscode-splitrail/package.json, vscode-splitrail/.vscodeignore
Tests cover summaries, scopes, allocations, empty data, and dashboard rendering. The test script runs the tests, and test files are excluded from the extension package.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to b05bd

The extension now reads CLI cost cents and displays dollar totals in usage summaries and dashboard breakdowns, with coverage for non-zero, scoped, allocated, missing, and zero-cost data. No concrete current-head merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #255 by reading costCents, converting cents to dollars in usage and dashboard views, and covering the hero total, tool totals, model totals, and status bar summaries. Regress…
Out of Scope Changes check ✅ Passed The test script update, test-source exclusion, and regression tests directly support the cost conversion fix and packaging behavior. No unrelated code changes are identified.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: converting CLI cost cents to dollar values in the VS Code extension.
Full details: Docstring Coverage

Explanation

Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/vscode-cost-cents

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

I count bright cents beneath the moon,
Then turn them into dollars soon.
The dashboard blooms with totals clear,
While tests hop softly, year to year.
No missing cost can hide from cheer.

Comment @coderabbitai help to get the list of available commands.

@mike1858
mike1858 merged commit 9934e07 into main Sep 9, 2026
8 checks passed
@mike1858
mike1858 deleted the fix/vscode-cost-cents branch September 9, 2026 00:33
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.

VS Code extension always shows $0.00 cost — reads stats.cost, CLI emits stats.costCents

1 participant