Skip to content

feat(claude): add opt-in cost breakdown with accurate periods - #3244

Merged
steipete merged 3 commits into
steipete:mainfrom
Yuxin-Qiao:feat/claude-tokscale-detail-clean
Sep 8, 2026
Merged

feat(claude): add opt-in cost breakdown with accurate periods#3244
steipete merged 3 commits into
steipete:mainfrom
Yuxin-Qiao:feat/claude-tokscale-detail-clean

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Add codexbar cost --provider claude --breakdown for opt-in daily token/cost rows and a top-five model ranking. Both sections use one selection and one accurate period label: the last seven calendar days (or a shorter requested interval), with an explicitly labeled recorded-day fallback when that interval has no rows.

Maintainer repair of @Yuxin-Qiao's contribution, integrated with current main. The ranking no longer calls a seven-day subset “Last 30 days,” and merged unpriced usage retains its partial qualifier. Default text, other providers, and JSON remain unchanged. The implementation keeps the configured bucket calendar, checked token accumulation, stable ranking order, and existing source boundaries.

Regression coverage includes sparse history with custom summary labels, singular intervals, recorded-day fallback, DST, exclusion of older models, integer overflow, mixed priced/unpriced merged reports, and other-provider isolation with the flag enabled.

Built CLI proof on d168aa8e628d593df6982605227384ee037e2fae, with compact synthetic Claude logs, isolated child-process home/config/cache, and a seeded pricing catalog:

  • Today plus an eight-day-old model: ordinary output retains the 30-day total of 2,200 tokens. --breakdown shows only today's 1,100-token model under matching “last 7 calendar days” headings.
  • Only the eight-day-old model: both headings say “last 1 recorded day.”
  • JSON with and without --breakdown is equal after excluding the per-call updatedAt timestamp; ordinary text contains neither added section.

make check passed. Local and committed-branch autoreview are clean through P2; all 41 focused architecture gatekeeper tests passed. Full make test passed all 1,034 selections across 87 groups without retries or timeouts. Exact-head CI succeeded; all nine checks are green.

Release-note context is collected in the batch's separate notes PR: add opt-in Claude CLI cost breakdowns with accurate calendar/recorded periods and partial-attribution labels; thanks @Yuxin-Qiao.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd3b8472f9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCLI/CLICostCommand.swift Outdated

@steipete steipete left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Yuxin-Qiao. I reviewed dd3b8472f95258eb880f3068e10dd4614ca659d6. This is now the intended two-file change, without the unrelated provider additions or lint relaxations from #3238. The independent unknown-cost/token state, partial-ranking qualification, stable tie-breaker, and cold/debounced journal-cache pruning are substantive improvements. I am not repeating those resolved findings.

The remaining rendering issues need focused regressions:

  1. Use the configured bucket calendar throughout. runCost creates the fetcher with bucketCalendar, but claudeDailyBreakdownLines creates Calendar.current and the text-rendering call receives no bucket calendar. At August 27 00:30 UTC, a UTC-bucketed snapshot rendered on a Los Angeles host can omit its August 27 row while still matching six older days, so the recorded-day fallback never runs. Pass the existing calendar through; cover a pinned timezone differing from the host, midnight, and DST.

  2. A populated-row count is still not an elapsed-day interval. Inside the calendar-filtered branch, rows for August 21 and August 27 produce “last 2 days.” The fallback fixes only the case where there are no recent rows. Label the actual seven-day interval, or accurately describe recorded dates in both branches. Test sparse recent history as well as entirely old history.

  3. Checked aggregation must reach the new model renderer. cur.tokens = (cur.tokens ?? 0) + t can overflow across individually representable days. For the same model, Int.max - 1 followed by 2 traps before the unknown-state flag can help. Use checked accumulation and keep an invalid total unknown on later additions, with an isolated multi-day renderer test. These helpers run across providers, including local readers handling untrusted counters.

  4. An empty breakdown is also missing attribution when the day has usage. The guard let breakdowns catches nil but not []. A positive-usage day with an empty model list, alongside another model-attributed day, still yields an unqualified ranking of the latter subset. Preserve the partial distinction for both representations; cover positive unattributed usage, truly zero days, and mixed model coverage.

The diff still adds no tests for the new renderer or the conditional journal-cache reconciliation. Please add the isolated empty/unknown/partial/explicit-zero/metered/cross-provider/tied-ranking cases and temporary-root journal tests covering cold cache, debounce/memo reuse, force refresh, and valid nested transcripts. The journal filter remains defensive unless a versioned producer sample establishes a real counting error; the pinned upstream comments say current journal records already parse to zero.

The output-scope point from the previous review also remains: this changes ordinary text output for every provider with daily data, not just Claude. Keep that decision explicit and use shared rendering or descriptor-owned policy, rather than a misleading Claude-specific helper or an arbitrary provider conditional. The existing local Claude reader is not newly introduced by this PR; please keep the description precise.

This is source review, not execution of this head. Formatting and parser-hash checks do not prove these cases. The focused tests, unchanged make check, and full suite are still required before landing.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed September 8, 2026, 12:42 AM ET / 04:42 UTC.

ClawSweeper review

What this changes

Adds an optional Claude CLI cost breakdown showing daily usage and ranked models with matching calendar or recorded-day periods and partial-attribution warnings.

Merge readiness

Ready for maintainer review

Keep open as a useful, maintainer-supported addition absent from current main and the latest release. The revised patch resolves the applicable earlier findings, and exact-head CLI evidence supports the changed behavior. No blocking defect remains.

Priority: P2
Reviewed head: d168aa8e628d593df6982605227384ee037e2fae

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused implementation, resolved prior findings, substantial regression coverage, and exact-head CLI observations support readiness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The exact-head built CLI exercised the existing log scanner and changed renderer using isolated on-disk Claude history, demonstrating matching periods, recent-model exclusion, recorded fallback, and unchanged default/JSON output.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The exact-head built CLI exercised the existing log scanner and changed renderer using isolated on-disk Claude history, demonstrating matching periods, recent-model exclusion, recorded fallback, and unchanged default/JSON output.
Evidence reviewed 8 items Repository policy: Read the complete root AGENTS.md. A repository-wide search found no nested AGENTS.md, and .agents contains skills but no maintainer-notes directory. Applied provider isolation, focused CLI validation, and avoidance of credential-accessing probes; this review did not run builds or tests.
Complete introduced patch: Inspected all six introduced files against the pinned merge base, including the complete new test file. Production changes only add flag handling and text rendering; architecture-test changes adjust existing line anchors. No scanner, JSON contract, persistence, dependency, or workflow changes are introduced.
Prior findings addressed: Both sections consume the same selected entries and period label. Selection uses the configured bucket calendar and caps recorded fallback by the requested interval; daily costs inspect unpriced coverage and model costs, while ranking preserves unknown values and checks token overflow. Former JSON-total and Cursor changes are absent from the introduced patch.
Findings None None.
Security None None.

How this fits together

CodexBar’s cost command reads local usage logs into shared daily reports. This change formats those existing reports into optional Claude text details without changing scanning, stored data, or JSON output.

flowchart TD
  A[Local Claude and mirror logs] --> B[Existing cost scanner]
  B --> C[Daily usage snapshot]
  C --> D{Claude text with breakdown enabled}
  D -->|Yes| E[Select shared calendar or recorded days]
  E --> F[Daily rows and ranked models]
  D -->|No| G[Existing output]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC Production +184/-7; tests +333/-8; docs +1 Production growth implements the requested optional text view, supported by focused rendering and parser coverage.

Technical review

Best possible solution:

Retain the opt-in presentation layer over existing cost reports, with shared periods and explicit partial attribution.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a new optional view; the supplied built-CLI observations directly exercise its recent-day selection, recorded fallback, and output compatibility.

Is this the best way to solve the issue?

Yes. The patch reuses existing scanner reports, confines the addition to explicitly requested Claude text output, and follows the owner-approved scope.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2a71b479a5d4.

Labels

Label justifications:

  • P2: This is a bounded, maintainer-supported CLI improvement with unchanged default behavior.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The exact-head built CLI exercised the existing log scanner and changed renderer using isolated on-disk Claude history, demonstrating matching periods, recent-model exclusion, recorded fallback, and unchanged default/JSON output.
  • proof: sufficient: Contributor real behavior proof is sufficient. The exact-head built CLI exercised the existing log scanner and changed renderer using isolated on-disk Claude history, demonstrating matching periods, recent-model exclusion, recorded fallback, and unchanged default/JSON output.

Evidence

What I checked:

  • Repository policy: Read the complete root AGENTS.md. A repository-wide search found no nested AGENTS.md, and .agents contains skills but no maintainer-notes directory. Applied provider isolation, focused CLI validation, and avoidance of credential-accessing probes; this review did not run builds or tests. (AGENTS.md:1, d168aa8e628d)
  • Complete introduced patch: Inspected all six introduced files against the pinned merge base, including the complete new test file. Production changes only add flag handling and text rendering; architecture-test changes adjust existing line anchors. No scanner, JSON contract, persistence, dependency, or workflow changes are introduced. (Sources/CodexBarCLI/CLICostCommand.swift:34, d168aa8e628d)
  • Prior findings addressed: Both sections consume the same selected entries and period label. Selection uses the configured bucket calendar and caps recorded fallback by the requested interval; daily costs inspect unpriced coverage and model costs, while ranking preserves unknown values and checks token overflow. Former JSON-total and Cursor changes are absent from the introduced patch. (Sources/CodexBarCLI/CLICostCommand.swift:228, d168aa8e628d)
  • Regression coverage: Read all nine new detail tests, covering default output, provider isolation, configured timezone, DST, overflow, attribution, sparse history, singular labels, and merged unpriced usage; an additional parser test verifies explicit opt-in. (Tests/CodexBarTests/CLICostClaudeDetailTests.swift:1, d168aa8e628d)
  • Current main still lacks the requested text view: Current main renders summary lines without daily or ranked-model text sections. The relevant command, help, and documentation files are unchanged between the pinned base and fetched main. Existing JSON model data supplies inputs but does not provide the requested human-readable view. (Sources/CodexBarCLI/CLICostCommand.swift:159, 2a71b479a5d4)
  • Latest release and related work: Inspection of the supplied v0.56.8 revision finds existing JSON breakdown mapping but no added text sections or flag. The earlier submission feat(claude): tokscale-inspired token breakdown and journal exclusion #3238 is closed unmerged. The open docs(changelog): collect spend refresh and Claude cost improvements #3491 collects release notes and explicitly depends on this code contribution. (Sources/CodexBarCLI/CLICostCommand.swift:513, 6ef82690b4a7)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Yuxin-Qiao: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-02T16:16:41.815Z sha 0e503f5 :: needs real behavior proof before merge. :: [P2] Preserve missing cost in the merged window total
  • reviewed 2026-09-02T17:59:03.381Z sha 4a4c258 :: needs real behavior proof before merge. :: [P2] Keep JSON totals unknown for partial-cost windows
  • reviewed 2026-09-02T19:33:44.386Z sha aff5476 :: needs real behavior proof before merge. :: [P2] Use the configured calendar for remote Cursor snapshots
  • reviewed 2026-09-03T01:36:45.667Z sha 1c80b88 :: needs real behavior proof before merge. :: [P1] Decide the non-Claude JSON total contract
  • reviewed 2026-09-03T03:27:18.670Z sha c4d296c :: needs real behavior proof before merge. :: [P1] Scope the new JSON total contract | [P2] Honor --days in the recorded-day fallback | [P2] Aggregate top models from the selected daily window
  • reviewed 2026-09-04T03:43:26.928Z sha 8420cc3 :: needs real behavior proof before merge. :: [P2] Label top models with the selected window
  • reviewed 2026-09-04T06:04:25.550Z sha 3ac64fc :: blocked before merge. :: [P2] Derive the model heading from the selected window
  • reviewed 2026-09-08T03:42:52.198Z sha d168aa8 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 28, 2026
@Yuxin-Qiao
Yuxin-Qiao force-pushed the feat/claude-tokscale-detail-clean branch from 7fd3cc9 to 192ce5d Compare August 29, 2026 14:13
@Yuxin-Qiao Yuxin-Qiao changed the title feat(claude): tokscale-inspired token breakdown and journal exclusion feat(claude): add tokscale-inspired CLI cost details Aug 29, 2026
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review\n\nRebased onto current main and replaced the previous journal-filtering scope with a Claude-only CLI detail change. Added focused calendar, provider-isolation, overflow, attribution, and fallback tests. Local verification: make check passed; make test passed all 80 groups on the first attempt with no retries or timeouts.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 29, 2026
@Yuxin-Qiao
Yuxin-Qiao force-pushed the feat/claude-tokscale-detail-clean branch from 192ce5d to a20e584 Compare September 2, 2026 10:59

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a20e584732

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCLI/CLICostCommand.swift Outdated
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. label Sep 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6961d27489

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCLI/CLICostCommand.swift Outdated
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Sep 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e503f5284

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCore/CostUsageModels.swift Outdated
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

Follow-up on current head 4a4c258cb:\n\n- Merged Claude daily/model summaries now become unknown when any usage-bearing row lacks a cost, instead of presenting a misleading priced subtotal.\n- Existing breakdown accumulation still preserves unknown cost provenance across model rows.\n- Regression coverage includes mixed priced/unpriced model rows and partial daily cost data.\n\nValidation: swift test --skip-build --filter CLIClaudeCostBreakdownRegressionTests (3/3) and make check passed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a4c258cb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCore/CostUsageModels.swift Outdated
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. and removed merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Sep 2, 2026
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

Addressed the current JSON-total correctness finding on 9d4dcfd3f.

codexbar cost --json now derives totals.totalCost from the same calendar-window summary as the text path. The snapshot summary fails closed when any usage-bearing day is unpriced (and rejects non-finite cost sums), so a priced subtotal is never emitted as an exact window total. Complete windows retain their existing total.

Verification:

  • swift test --filter CLIClaudeCostBreakdownRegressionTests — 4/4 passed, including mixed priced/unpriced JSON totals.
  • swift test --filter CLICost — 37 tests across CLI cost suites passed.
  • swift test --filter CostUsageWindowSummaryTests — 4/4 passed.
  • make check — passed, 0 SwiftLint violations.

No live account, browser-cookie, or Keychain reads were used; the regression is covered with synthetic snapshots.

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d4dcfd3fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCLI/CLICostCommand.swift Outdated
@Yuxin-Qiao
Yuxin-Qiao force-pushed the feat/claude-tokscale-detail-clean branch from 9d4dcfd to aff5476 Compare September 2, 2026 18:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aff54769e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCLI/CLICostCommand.swift Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ea9f1d058

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Sources/CodexBarCore/CostUsageFetcher.swift Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4d296c092

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

title = "Daily breakdown (last \(intervalDays) calendar day\(intervalDays == 1 ? "" : "s")):"
} else {
let sortedDaily = snapshot.daily.sorted { $0.date > $1.date }
recent = Array(sortedDaily.prefix(7))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor --days in the recorded-day fallback

When no rows match the current calendar window, such as when rendering a stale snapshot, this fallback always selects up to seven entries even if the user requested --days 1 or another shorter interval. That makes the new breakdown expose more history than requested; limit the fallback with intervalDays rather than a fixed seven.

Useful? React with 👍 / 👎.

private static func claudeTopModelsLines(snapshot: CostUsageTokenSnapshot, useColor: Bool) -> [String] {
var hasUnattributedDay = false
var modelAgg: [String: ClaudeModelAggregation] = [:]
for entry in snapshot.daily {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep top-model aggregation within the displayed history

When the daily section takes its recorded-day fallback because every row falls outside the current calendar window, this loop still aggregates every row in snapshot.daily, and the result is labeled Top models (Last N days). A stale snapshot with attributed historical rows can therefore present old models as if they belonged to the requested current window; aggregate the same selected entries as the daily section or label the ranking as recorded history.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 3, 2026
Keep only the Claude --breakdown daily and top-model detail. Drop the
cross-provider JSON fail-closed totals and Cursor calendar plumbing;
daily and model sections share one calendar-window selection with no
stale recorded-day fallback.
@Yuxin-Qiao
Yuxin-Qiao force-pushed the feat/claude-tokscale-detail-clean branch from c4d296c to 8420cc3 Compare September 4, 2026 03:38

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8420cc30c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +345 to +348
let baseLabel = snapshot.historyLabel ?? "Last \(snapshot.historyDays) days"
let title = isPartial
? "Top models (\(baseLabel) \u{2014} partial):"
: "Top models (\(baseLabel)):"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Label top models with their actual window

When --breakdown uses the default --days 30, claudeRecentEntries restricts the aggregation to seven calendar days, but this label still renders Top models (Last 30 days). Users may therefore interpret a seven-day ranking as covering the full requested history; derive the label from the same capped interval used to select entries.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. label Sep 4, 2026
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 4, 2026
Integrate current main, share the selected calendar or recorded interval
between daily and model headings, and preserve partial attribution for
merged unpriced usage. Keep ordinary text and JSON output unchanged.

Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
@steipete steipete changed the title feat(claude): add tokscale-inspired CLI cost details feat(claude): add opt-in cost breakdown with accurate periods Sep 8, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 8, 2026
@steipete

steipete commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Maintainer verification complete on d168aa8e628d593df6982605227384ee037e2fae.

  • make check passed; local and final branch autoreview are clean through P2. Full make test passed 1,034 selections across 87 groups with no retries or timeouts. The 41 focused architecture gatekeeper tests also passed.
  • The real built CLI ran with isolated synthetic Claude history and seeded pricing. With today plus an eight-day-old model, ordinary output retained its 30-day/2,200-token total; cost --provider claude --breakdown showed only the recent 1,100-token model under matching “last 7 calendar days” headings. With only the older model, both detail headings said “last 1 recorded day.” JSON with and without the flag matched after excluding updatedAt; default text omitted both new sections.
  • Regression coverage includes calendar/DST boundaries, custom summary intervals, sparse recorded-day fallback, overflow, and partial attribution from merged unpriced usage.
  • CI run 34184089534 succeeded on this exact head; all nine checks are green.

The August 27 changes-requested review remains attached to its old head. This rewrite addresses its calendar/interval/overflow/attribution concerns; the former journal-filter implementation was removed. No review was dismissed.

Changelog is consolidated in #3491. Land-ready; no merge performed here. Contributor credit remains preserved for @Yuxin-Qiao.

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 8, 2026
@steipete
steipete merged commit 4bfbbe2 into steipete:main Sep 8, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants