Skip to content

feat: display CO2 in kg when ≥ 1 000 g for readability#618

Merged
rajbos merged 1 commit intomainfrom
rajbos/fix-co2-kg-display
Apr 18, 2026
Merged

feat: display CO2 in kg when ≥ 1 000 g for readability#618
rajbos merged 1 commit intomainfrom
rajbos/fix-co2-kg-display

Conversation

@rajbos
Copy link
Copy Markdown
Owner

@rajbos rajbos commented Apr 18, 2026

Summary

Switches CO₂ display from always showing grams to an adaptive g/kg notation: values ≥ 1 000 g are shown as X.XX kg.

Heavy users accumulate tens of kilograms of CO₂ equivalent, which was previously displayed as unwieldy 5-digit gram values (e.g. 12345.678 gCO₂e). The new format shows 12.35 kgCO₂e instead.

Changes

VS Code extension — environmental webview

  • Added formatCo2Grams(grams) helper that wraps smartFixed() and switches unit at 1 000 g.
  • Used it for all four period cards (Today, Last 30 Days, Previous Month, Projected Year).

CLI — environmental command

  • Added formatCo2(grams) helper with the same threshold.
  • Used it for the per-period CO₂ row in printEnvironmentalStats.
  • Used it for the methodology tree-absorption line (21 000 g → 21.00 kg).
  • Removed the now-unused fmt import.

Testing

All 857 unit tests pass (npm run test:node).

Switch CO2 emissions display from always-grams to adaptive
kg/g notation: values >= 1 000 g are shown as X.XX kg.

- vscode-extension webview environmental panel: add formatCo2Grams()
  helper that wraps smartFixed(); use it for the 4 period cards
- cli environmental command: add formatCo2() helper; use it for the
  per-period CO2 row and the methodology tree-absorption line;
  remove unused mt import

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rajbos rajbos merged commit 7f12573 into main Apr 18, 2026
17 checks passed
@rajbos rajbos deleted the rajbos/fix-co2-kg-display branch April 18, 2026 09:45
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.

1 participant