Skip to content

feat(widget): add TotalCost widget for cumulative cross-session cost tracking#360

Open
badoriie wants to merge 1 commit intosirmalloc:mainfrom
badoriie:feat/total-cost-example
Open

feat(widget): add TotalCost widget for cumulative cross-session cost tracking#360
badoriie wants to merge 1 commit intosirmalloc:mainfrom
badoriie:feat/total-cost-example

Conversation

@badoriie
Copy link
Copy Markdown

@badoriie badoriie commented May 7, 2026

Summary

Adds a new total-cost widget that tracks cumulative Claude Code spend across all sessions — complementing the existing session-cost widget which only shows the current session.

How it works:

  • On each status line render, the current session cost is persisted to <config-dir>/costs/<session-id> (alongside settings.json)
  • The widget sums all cost files and displays the running total
  • Session IDs are sanitized before use as filenames
  • Uses the ccstatusline config directory so it respects --config path overrides

Usage:

{ "id": "1", "type": "total-cost", "color": "green" }

Renders as Total: $12.34 (or $12.34 in raw/minimalist mode).

Test plan

  • 10 new unit tests covering: preview, persistence, multi-session summing, update-on-render, zero-cost skipping, raw mode, session ID sanitization, and corrupted file resilience
  • All new tests pass (vitest run src/widgets/__tests__/TotalCost.test.ts — 10/10)
  • Pre-existing test failures (10 files, 81 tests) confirmed present on upstream main before this change — not introduced here

Adds a new `total-cost` widget that tracks and displays the running total
cost across all Claude Code sessions. On each render, the current session
cost is persisted to `<config-dir>/costs/<session-id>`. The widget sums
all persisted cost files and displays the total.

Co-Authored-By: a.nasari <a.nasari@reply.de>
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