# fix\(cost\): stop showing a pre-midnight scan as today's cost \(\#350\) · lucenx/codexbar-plasma

[View on GitCafe](https://git.cafe/lucenx/codexbar-plasma/commit/370cae740322fcf28ce043fa9aa9d96e830542b3)

Repository: [lucenx/codexbar-plasma](https://git.cafe/lucenx/codexbar-plasma)

Visibility: public

Requested revision: 370cae740322fcf28ce043fa9aa9d96e830542b3

Requested commit: 370cae740322fcf28ce043fa9aa9d96e830542b3

Commit: 370cae740322fcf28ce043fa9aa9d96e830542b3

Tree: 9cbe122578b8c45f9f6429fc1cfefc043eb2fb48

Author: Simone

Committer: GitHub

## Message

```
fix(cost): stop showing a pre-midnight scan as today's cost (#350)

* test(cost): show that Today presents a pre-midnight scan as today's spend

Adds the regression tests alone, so CI records them failing against the
unchanged cost presentation before the fix lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TyLjj3QgxCcyMUFLdNo5L8

* fix(cost): stop showing a pre-midnight scan as today's cost

The provider cost summary's Today tile shows the CLI's sessionCostUSD,
which is the total for the local day the cost scan ran. A snapshot
scanned before midnight stays on screen after it: history scans run at
most hourly, the provider tabs do not trigger one, and a failed refresh
keeps the previous snapshot by design. That day's spend was presented as
today's.

CostResponse now keeps the scan's local date (scanDay, from updatedAt),
privacy projection preserves it, and the pure
CostPresentation.todayAmounts reports today's amounts as unknown when
that date is before the live clock's. The tile then reads "Cost
unavailable" and "Tokens unavailable" until a scan from today arrives.
Snapshots without a usable updatedAt keep their amounts.

Docs: usage guide cost summary bullet, cost-history contract, and an
Unreleased Fixed entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TyLjj3QgxCcyMUFLdNo5L8

* refactor(cost): keep the range-match comment on its function

The todayAmounts helper was inserted between snapshotMatchesRange and
its doc comment, so that comment described the wrong function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FH68FN52tUdZCcBqB4BGNk

---------

Co-authored-by: Claude <noreply@anthropic.com>
```

## Parents

- [9855ad4d5373cf65faf13291f99484fd1ea16b4e](https://git.cafe/lucenx/codexbar-plasma/commit/9855ad4d5373cf65faf13291f99484fd1ea16b4e?format=markdown)

[Source at this commit](https://git.cafe/lucenx/codexbar-plasma/tree/370cae740322fcf28ce043fa9aa9d96e830542b3?format=markdown)
