codeburn icon indicating copy to clipboard operation
codeburn copied to clipboard

Add single-day review mode

Open ozymandiashh opened this issue 6 months ago • 3 comments

Summary

Adds a single-day review mode so users can inspect CodeBurn usage for an exact calendar day after the day has passed.

This is meant for the common “worked past midnight, review yesterday later” workflow: the CLI, TUI, JSON output, and macOS menubar can now select one specific day instead of only fixed rolling periods.

Root cause

CodeBurn had fixed period selectors such as Today, 7 Days, 30 Days, Month, and All. That made it hard to review a specific previous day once midnight passed, especially in the menubar where the selected period always mapped to a moving range.

The menubar also needed separate handling for selected historical days: the menu bar icon should continue showing today's spend, while the opened popover can display a chosen review day.

What changed

  • Add shared local-day helpers for exact day ranges.
  • Add --day <YYYY-MM-DD|today|yesterday> to codeburn report.
  • Add --day <YYYY-MM-DD|today|yesterday> to codeburn status --format menubar-json.
  • Reject ambiguous report --day usage with --from / --to.
  • Start the TUI in day mode when report --day is used.
  • Add TUI day navigation with day labels and clamping at today.
  • Add a menubar date selector for review days.
  • Keep the menubar status item pinned to today's spend while the popover can show a selected day.
  • Fix the menubar refresh race where selecting a day could briefly show a false “couldn't load day” error before valid data arrived.
  • Close the calendar popover automatically after selecting a date.
  • Document the new single-day menubar selector.

Behavior proof

I used a controlled Claude JSONL fixture with three adjacent days in the same session file:

2026-04-09T23:59:00Z  input 111  output 11
2026-04-10T12:00:00Z  input 222  output 22
2026-04-11T00:01:00Z  input 333  output 33

Before this PR, on origin/main, the exact-day selector does not exist:

codeburn --format json --provider claude --day 2026-04-10

error: unknown option '--day'

After this PR, the same fixture filtered with --day 2026-04-10 returns only the selected day. The day before and day after are excluded from the current report:

{
  "periodKey": "day",
  "period": "Day (2026-04-10)",
  "overview": {
    "cost": 0.000996,
    "calls": 1,
    "sessions": 1,
    "tokens": {
      "input": 222,
      "output": 22,
      "cacheRead": 0,
      "cacheWrite": 0
    }
  },
  "daily": [
    {
      "date": "2026-04-10",
      "calls": 1,
      "turns": 1,
      "editTurns": 1,
      "oneShotTurns": 1,
      "oneShotRate": 100
    }
  ],
  "topSessions": [
    {
      "project": "myapp",
      "date": "2026-04-10",
      "calls": 1
    }
  ]
}

The wider range over the same fixture proves there are three available days, so the single-day output above is actually filtering, not missing data:

{
  "period": "2026-04-09 to 2026-04-11",
  "overview": {
    "calls": 3,
    "tokens": {
      "input": 666,
      "output": 66
    }
  },
  "daily": [
    { "date": "2026-04-09", "calls": 1 },
    { "date": "2026-04-10", "calls": 1 },
    { "date": "2026-04-11", "calls": 1 }
  ]
}

The menubar JSON path uses the same selected day for the opened popover:

{
  "label": "Day (2026-04-10)",
  "cost": 0.000996,
  "calls": 1,
  "sessions": 1,
  "providers": {
    "claude": 0.000996
  },
  "topProjects": [
    {
      "name": "myapp",
      "sessions": 1,
      "sessionDates": ["2026-04-10"]
    }
  ]
}

Ambiguous CLI usage is rejected instead of silently mixing date modes:

codeburn --format json --provider claude --day 2026-04-10 --from 2026-04-09

Error: --day cannot be combined with --from or --to

The macOS menubar app was also installed locally and tested with the calendar selector. Demo video can be attached to this PR.

Validation

  • [x] npm test -- --run - 65 files / 932 tests passed.
  • [x] npm run build - passed.
  • [x] npx tsc --noEmit - passed.
  • [x] swift build - passed.
  • [x] git diff --check origin/main...HEAD - passed.
  • [x] Gemini 3.5 Flash High review - PASS.
  • [x] GPT 5.5 xhigh review - PASS.
  • [x] Claude Opus 4.7 effort max targeted review - PASS on the menubar refresh race and calendar auto-close fixes.

ozymandiashh avatar May 22 '26 23:05 ozymandiashh

Demo video for the macOS menubar day selector. I'm very happy with this feature because it fixes a real workflow gap for reviewing intense coding days after midnight. The attached video shows the macOS menubar day selector in action. If this looks good to you, please review the demo and merge when you're comfortable with it. @iamtoruk https://github.com/user-attachments/assets/8ea55471-fe55-43a0-bdc6-376c50621356

ozymandiashh avatar May 22 '26 23:05 ozymandiashh

Nice I was thinking in same direction.. I will take this PR and try add some addtions like user can select range of days or select multiple random days and also tune the ui

iamtoruk avatar May 24 '26 08:05 iamtoruk

Lovely

ozymandiashh avatar May 24 '26 09:05 ozymandiashh

Closing to keep my open-PR queue clean — this branch has gone stale and now conflicts with main. Happy to rebase and reopen if the change is still wanted.

ozymandiashh avatar Jun 21 '26 13:06 ozymandiashh