diff --git a/docs/changes/unreleased/863-greeting-spend-crosses-midnight.md b/docs/changes/unreleased/863-greeting-spend-crosses-midnight.md new file mode 100644 index 0000000000..d20f0a6d74 --- /dev/null +++ b/docs/changes/unreleased/863-greeting-spend-crosses-midnight.md @@ -0,0 +1,14 @@ +--- +kind: fixed +title: the greeting's spend fixture no longer fails between midnight and one +pr: 863 +surface: [chat] +invalidates: + - "`TestTheGreetingsFirstFrameCarriesTheSpend` (#842) dated the row it means to be TODAY'S at `now.Add(-time.Hour)`, which is yesterday for the first hour of any day — so `internal/tui3` was red on a clean `dev` every night between 00:00 and 01:00 and green again by morning. If you saw that failure and recorded it as a flake, it was the calendar." + - "`internal/tui3` has a second red this does not touch: `TestADecayedBeliefDrawsNoTail` sets its belief from the real `time.Now()` and reads the view at the fixed `timeNow()` test clock, so the decay stops firing once real time passes that date. It fails identically on a clean `origin/dev@84bf71d61`." +--- + +The current instant is the only time that is always inside today. + +Third fixture on this work to fail with no change under it, after #759's legacy cache aged past +its TTL overnight. A test whose result depends on the wall clock reports the calendar. diff --git a/internal/tui3/home_test.go b/internal/tui3/home_test.go index adeb98eedd..c0b830467d 100644 --- a/internal/tui3/home_test.go +++ b/internal/tui3/home_test.go @@ -1805,8 +1805,13 @@ func TestTheGreetingsFirstFrameCarriesTheSpend(t *testing.T) { now := time.Now() mine := lab.session("-tmp-alpha", "aaaa000000000001", "the one the door picked", "/tmp/alpha", now) lab.session("-tmp-alpha", "aaaa000000000002", "yesterday's chat", "/tmp/alpha", now.Add(-20*time.Hour)) + // TODAY'S ROW IS DATED NOW, NOT AN HOUR AGO. An hour before now is + // YESTERDAY for the first hour of any day, so this test failed every night + // between midnight and one — the greeting read today as 0 because the row + // meant to be today's had fallen out of the day. The current instant is the + // only time that is always inside today. writeUsageLines(t, filepath.Join(lab.root, session.UsageLedgerName), []session.UsageLine{ - {At: now.Add(-time.Hour), USD: 1.25, Calls: 1, Model: "anthropic/claude-opus-5"}, + {At: now, USD: 1.25, Calls: 1, Model: "anthropic/claude-opus-5"}, {At: now.AddDate(0, 0, -3), USD: 2.00, Calls: 1, Model: "anthropic/claude-opus-5"}, })