From 96468906382e4b31791f5739c7fdbda0e7c7edc5 Mon Sep 17 00:00:00 2001 From: Aditya Vikram Singh <247195684+avs-io@users.noreply.github.com> Date: Wed, 19 Aug 2026 20:07:02 +0530 Subject: [PATCH 1/4] fix(plans): call sticker-price bars a budget, not live quota SuperGrok Heavy is a $300/mo preset compared to parsed API-equivalent spend on a calendar month. CodexBar's live weekly window is a different class. TUI and desktop copy now say budget / calendar month and deny a live provider window. No Grok Connect is invented. --- app/renderer/sections/Plans.test.tsx | 2 +- app/renderer/sections/Plans.tsx | 4 ++- src/dashboard.tsx | 15 +++++--- tests/plan-budget-copy.test.ts | 54 ++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 tests/plan-budget-copy.test.ts diff --git a/app/renderer/sections/Plans.test.tsx b/app/renderer/sections/Plans.test.tsx index e3701696..6d884f70 100644 --- a/app/renderer/sections/Plans.test.tsx +++ b/app/renderer/sections/Plans.test.tsx @@ -119,7 +119,7 @@ describe('Plans', () => { expect(screen.getByRole('heading', { name: 'Budget plans' })).toBeInTheDocument() expect(screen.getByText('Cursor Pro')).toBeInTheDocument() - expect(screen.getByText('$20.00 / month · cursor')).toBeInTheDocument() + expect(screen.getByText('$20.00 / calendar month · API-equivalent budget, not live quota · cursor')).toBeInTheDocument() expect(screen.getByText('$8.20 · 41%')).toBeInTheDocument() const cursorFill = container.querySelector('[data-testid="plan-track-cursor"] i') expect(cursorFill).toHaveStyle({ width: '41%' }) diff --git a/app/renderer/sections/Plans.tsx b/app/renderer/sections/Plans.tsx index a11240ae..e51e2fa4 100644 --- a/app/renderer/sections/Plans.tsx +++ b/app/renderer/sections/Plans.tsx @@ -231,7 +231,9 @@ function PlanPanel({ plan }: { plan: JsonPlanSummary }) { const right = hasBudget ? `${formatConverted(plan.spent)} · ${fmtPct(plan.percentUsed)}${overage > 0 ? ` · ${formatConverted(overage)} over` : ''}` : `${formatConverted(plan.spent)} this cycle` - const detail = hasBudget ? `${formatConverted(plan.budget)} / month · ${plan.provider}` : `${plan.provider} · pay as you go, no plan` + const detail = hasBudget + ? `${formatConverted(plan.budget)} / calendar month · API-equivalent budget, not live quota · ${plan.provider}` + : `${plan.provider} · pay as you go, no plan` return ( diff --git a/src/dashboard.tsx b/src/dashboard.tsx index 7eeeaf35..0e5b1f0e 100644 --- a/src/dashboard.tsx +++ b/src/dashboard.tsx @@ -344,14 +344,19 @@ function planColor(planUsage: PlanUsage): string { : '#5BF58C' } -function planStatusText(planUsage: PlanUsage): string { +export function planBudgetHeadline(planUsage: PlanUsage): string { + return `${planLabel(planUsage)}: ${formatCost(planUsage.spentApiEquivalentUsd)} API-equivalent vs ${formatCost(planUsage.budgetUsd)}/mo budget` +} + +export function planStatusText(planUsage: PlanUsage): string { + const calendar = `Calendar-month budget, not a live provider window. Projected: ${formatCost(planUsage.projectedMonthUsd)}. Next calendar reset in ${planUsage.daysUntilReset} days.` if (planUsage.status === 'under') { - return `Well within plan. Projected month: ${formatCost(planUsage.projectedMonthUsd)} (reset in ${planUsage.daysUntilReset} days).` + return `Well within budget. ${calendar}` } if (planUsage.status === 'near') { - return `Approaching plan limit. Projected month: ${formatCost(planUsage.projectedMonthUsd)} (reset in ${planUsage.daysUntilReset} days).` + return `Approaching budget. ${calendar}` } - return `${(planUsage.spentApiEquivalentUsd / Math.max(planUsage.budgetUsd, 1)).toFixed(1)}x your subscription value. Projected month: ${formatCost(planUsage.projectedMonthUsd)} (reset in ${planUsage.daysUntilReset} days).` + return `${(planUsage.spentApiEquivalentUsd / Math.max(planUsage.budgetUsd, 1)).toFixed(1)}x the sticker price. ${calendar}` } function Overview({ projects, label, width, planUsages, durable }: { projects: ProjectSummary[]; label: string; width: number; planUsages?: PlanUsage[]; durable?: DurableOverview }) { @@ -407,7 +412,7 @@ function Overview({ projects, label, width, planUsages, durable }: { projects: P return ( - {planLabel(planUsage)}: {formatCost(planUsage.spentApiEquivalentUsd)} API-equivalent vs {formatCost(planUsage.budgetUsd)} plan + {planBudgetHeadline(planUsage)} {renderPlanBar(planUsage.percentUsed, PLAN_BAR_WIDTH)} diff --git a/tests/plan-budget-copy.test.ts b/tests/plan-budget-copy.test.ts new file mode 100644 index 00000000..7ab7991f --- /dev/null +++ b/tests/plan-budget-copy.test.ts @@ -0,0 +1,54 @@ +import { describe, expect, it } from 'vitest' + +import { planBudgetHeadline, planStatusText } from '../src/dashboard.js' +import type { PlanUsage } from '../src/plan-usage.js' + +function usage(overrides: Partial = {}): PlanUsage { + return { + plan: { + id: 'supergrok-heavy', + monthlyUsd: 300, + provider: 'grok', + resetDay: 1, + setAt: '2026-08-01T00:00:00.000Z', + }, + periodStart: new Date('2026-08-01T00:00:00'), + periodEnd: new Date('2026-09-01T00:00:00'), + spentApiEquivalentUsd: 33.82, + budgetUsd: 300, + percentUsed: 11.273, + status: 'under', + projectedMonthUsd: 40, + daysUntilReset: 13, + ...overrides, + } +} + +describe('plan budget copy', () => { + it('labels SuperGrok as a calendar-month budget, not a live window', () => { + const text = planBudgetHeadline(usage()) + expect(text).toContain('/mo budget') + expect(text).not.toMatch(/\bplan\b/) + const status = planStatusText(usage()) + expect(status).toContain('not a live provider window') + expect(status).toContain('Calendar-month budget') + expect(status).not.toMatch(/Well within plan/) + }) + + it('uses the same budget language for every preset, not only Grok', () => { + const cursor = usage({ + plan: { + id: 'cursor-pro', + monthlyUsd: 20, + provider: 'cursor', + resetDay: 1, + setAt: '2026-08-01T00:00:00.000Z', + }, + budgetUsd: 20, + spentApiEquivalentUsd: 8.2, + status: 'near', + }) + expect(planBudgetHeadline(cursor)).toContain('/mo budget') + expect(planStatusText(cursor)).toContain('Approaching budget') + }) +}) From 610c70ecb974fc8864f965d3411a2bbfe71f73b6 Mon Sep 17 00:00:00 2001 From: Aditya Vikram Singh <247195684+avs-io@users.noreply.github.com> Date: Wed, 19 Aug 2026 20:53:18 +0530 Subject: [PATCH 2/4] fix(plans): update desktop FX budget-copy assertion --- app/renderer/sections/Plans.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/renderer/sections/Plans.test.tsx b/app/renderer/sections/Plans.test.tsx index 6d884f70..2ce7cfa7 100644 --- a/app/renderer/sections/Plans.test.tsx +++ b/app/renderer/sections/Plans.test.tsx @@ -214,7 +214,7 @@ describe('Plans', () => { render() - expect(await screen.findByText('€20.00 / month · cursor')).toBeInTheDocument() + expect(await screen.findByText('€20.00 / calendar month · API-equivalent budget, not live quota · cursor')).toBeInTheDocument() expect(screen.getByText('€8.20 · 41%')).toBeInTheDocument() }) From 911bd3f4862b99f3789b53cc1aeb01f59870f144 Mon Sep 17 00:00:00 2001 From: iamtoruk Date: Wed, 19 Aug 2026 11:30:07 -0700 Subject: [PATCH 3/4] fix(plans): say monthly budget, not calendar month, and fit 80 columns The budget window comes from computePeriodFromResetDay, which builds an anniversary period from plan.resetDay (1-28, settable per plan with `codeburn plan set --reset-day`). "Calendar-month budget" and "Next calendar reset" are therefore wrong for anyone who moved the reset day, which is the same class of inaccuracy this change set exists to remove. Say "budget" and "Next budget reset" instead, and use one wording across the TUI and the desktop cards. Both TUI lines truncate end-first at the terminal width. The headline had grown past the point where an 80-column terminal still showed the percentage, so it drops "vs ... /mo" for "/ $300.00 budget", and the status line drops the clause repeating "budget" from the headline. At 80 columns the longest label (custom plans carry their provider) now fits the percentage, and the status line still shows the projection. --- app/renderer/sections/Plans.test.tsx | 4 +-- app/renderer/sections/Plans.tsx | 2 +- src/dashboard.tsx | 16 +++++++--- tests/plan-budget-copy.test.ts | 48 +++++++++++++++++++++++----- 4 files changed, 54 insertions(+), 16 deletions(-) diff --git a/app/renderer/sections/Plans.test.tsx b/app/renderer/sections/Plans.test.tsx index 2ce7cfa7..18db5665 100644 --- a/app/renderer/sections/Plans.test.tsx +++ b/app/renderer/sections/Plans.test.tsx @@ -119,7 +119,7 @@ describe('Plans', () => { expect(screen.getByRole('heading', { name: 'Budget plans' })).toBeInTheDocument() expect(screen.getByText('Cursor Pro')).toBeInTheDocument() - expect(screen.getByText('$20.00 / calendar month · API-equivalent budget, not live quota · cursor')).toBeInTheDocument() + expect(screen.getByText('$20.00 / month budget · API-equivalent, not a live provider window · cursor')).toBeInTheDocument() expect(screen.getByText('$8.20 · 41%')).toBeInTheDocument() const cursorFill = container.querySelector('[data-testid="plan-track-cursor"] i') expect(cursorFill).toHaveStyle({ width: '41%' }) @@ -214,7 +214,7 @@ describe('Plans', () => { render() - expect(await screen.findByText('€20.00 / calendar month · API-equivalent budget, not live quota · cursor')).toBeInTheDocument() + expect(await screen.findByText('€20.00 / month budget · API-equivalent, not a live provider window · cursor')).toBeInTheDocument() expect(screen.getByText('€8.20 · 41%')).toBeInTheDocument() }) diff --git a/app/renderer/sections/Plans.tsx b/app/renderer/sections/Plans.tsx index e51e2fa4..127944d2 100644 --- a/app/renderer/sections/Plans.tsx +++ b/app/renderer/sections/Plans.tsx @@ -232,7 +232,7 @@ function PlanPanel({ plan }: { plan: JsonPlanSummary }) { ? `${formatConverted(plan.spent)} · ${fmtPct(plan.percentUsed)}${overage > 0 ? ` · ${formatConverted(overage)} over` : ''}` : `${formatConverted(plan.spent)} this cycle` const detail = hasBudget - ? `${formatConverted(plan.budget)} / calendar month · API-equivalent budget, not live quota · ${plan.provider}` + ? `${formatConverted(plan.budget)} / month budget · API-equivalent, not a live provider window · ${plan.provider}` : `${plan.provider} · pay as you go, no plan` return ( diff --git a/src/dashboard.tsx b/src/dashboard.tsx index 0e5b1f0e..86ba2145 100644 --- a/src/dashboard.tsx +++ b/src/dashboard.tsx @@ -344,19 +344,25 @@ function planColor(planUsage: PlanUsage): string { : '#5BF58C' } +// Headline and status share one line's worth of terminal each, both truncated +// end-first, so the headline stays short enough to keep the percentage visible +// at 80 columns and the status leads with the disclaimer, not the arithmetic. export function planBudgetHeadline(planUsage: PlanUsage): string { - return `${planLabel(planUsage)}: ${formatCost(planUsage.spentApiEquivalentUsd)} API-equivalent vs ${formatCost(planUsage.budgetUsd)}/mo budget` + return `${planLabel(planUsage)}: ${formatCost(planUsage.spentApiEquivalentUsd)} API-equivalent / ${formatCost(planUsage.budgetUsd)} budget` } export function planStatusText(planUsage: PlanUsage): string { - const calendar = `Calendar-month budget, not a live provider window. Projected: ${formatCost(planUsage.projectedMonthUsd)}. Next calendar reset in ${planUsage.daysUntilReset} days.` + // The period is anniversary-based (plan.resetDay, 1-28, settable per plan via + // `codeburn plan set --reset-day`), so this is a monthly budget window, not a + // calendar month. The headline already says "budget"; do not repeat it here. + const detail = `Not a live provider window. Projected: ${formatCost(planUsage.projectedMonthUsd)}. Next budget reset in ${planUsage.daysUntilReset} days.` if (planUsage.status === 'under') { - return `Well within budget. ${calendar}` + return `Well within budget. ${detail}` } if (planUsage.status === 'near') { - return `Approaching budget. ${calendar}` + return `Approaching budget. ${detail}` } - return `${(planUsage.spentApiEquivalentUsd / Math.max(planUsage.budgetUsd, 1)).toFixed(1)}x the sticker price. ${calendar}` + return `${(planUsage.spentApiEquivalentUsd / Math.max(planUsage.budgetUsd, 1)).toFixed(1)}x the sticker price. ${detail}` } function Overview({ projects, label, width, planUsages, durable }: { projects: ProjectSummary[]; label: string; width: number; planUsages?: PlanUsage[]; durable?: DurableOverview }) { diff --git a/tests/plan-budget-copy.test.ts b/tests/plan-budget-copy.test.ts index 7ab7991f..787df94f 100644 --- a/tests/plan-budget-copy.test.ts +++ b/tests/plan-budget-copy.test.ts @@ -24,15 +24,18 @@ function usage(overrides: Partial = {}): PlanUsage { } } +// The TUI truncates both lines end-first at the terminal width, so the row is +// headline + two spaces + the 10-cell bar + a space + the percentage. +const PLAN_ROW_TAIL = ' ' + '#'.repeat(10) + ' ' +function planRow(planUsage: PlanUsage): string { + return planBudgetHeadline(planUsage) + PLAN_ROW_TAIL + planUsage.percentUsed.toFixed(1) + '%' +} + describe('plan budget copy', () => { - it('labels SuperGrok as a calendar-month budget, not a live window', () => { - const text = planBudgetHeadline(usage()) - expect(text).toContain('/mo budget') - expect(text).not.toMatch(/\bplan\b/) + it('labels SuperGrok as a budget, not a live window', () => { + expect(planBudgetHeadline(usage())).toBe('SuperGrok Heavy: $33.82 API-equivalent / $300.00 budget') const status = planStatusText(usage()) - expect(status).toContain('not a live provider window') - expect(status).toContain('Calendar-month budget') - expect(status).not.toMatch(/Well within plan/) + expect(status).toBe('Well within budget. Not a live provider window. Projected: $40.00. Next budget reset in 13 days.') }) it('uses the same budget language for every preset, not only Grok', () => { @@ -48,7 +51,36 @@ describe('plan budget copy', () => { spentApiEquivalentUsd: 8.2, status: 'near', }) - expect(planBudgetHeadline(cursor)).toContain('/mo budget') + expect(planBudgetHeadline(cursor)).toBe('Cursor Pro: $8.20 API-equivalent / $20.00 budget') expect(planStatusText(cursor)).toContain('Approaching budget') }) + + // computePeriodFromResetDay builds an anniversary window from plan.resetDay + // (1-28, settable with `codeburn plan set --reset-day`), so a plan that resets + // on the 15th is NOT on a calendar month and must never be called one. + it('never calls an anniversary reset window a calendar month', () => { + for (const resetDay of [1, 15, 28]) { + const status = planStatusText(usage({ + plan: { id: 'supergrok-heavy', monthlyUsd: 300, provider: 'grok', resetDay, setAt: '2026-08-01T00:00:00.000Z' }, + daysUntilReset: 4, + })) + expect(status).not.toMatch(/calendar/i) + expect(status).toContain('Next budget reset in 4 days.') + } + }) + + // The row and the status each get one truncate-end line. At 80 columns the + // percentage must survive on the row and the projection on the status line. + it('keeps the percentage and the projection readable at 80 columns', () => { + for (const planUsage of [ + usage(), + usage({ status: 'over', spentApiEquivalentUsd: 640, percentUsed: 213.3 }), + usage({ plan: { id: 'custom', monthlyUsd: 300, provider: 'openrouter', resetDay: 1, setAt: '2026-08-01T00:00:00.000Z' } }), + ]) { + const row = planRow(planUsage) + expect(row.length).toBeLessThanOrEqual(80) + expect(row.slice(0, 80)).toContain(`${planUsage.percentUsed.toFixed(1)}%`) + expect(planStatusText(planUsage).slice(0, 80)).toContain('Projected: $40.00.') + } + }) }) From 6558a4feeee2b397a9c9030b8ffbc2c337075d25 Mon Sep 17 00:00:00 2001 From: iamtoruk Date: Wed, 19 Aug 2026 11:31:47 -0700 Subject: [PATCH 4/4] docs(changelog): note the plan budget copy fix User-visible on two surfaces and the branch had no entry. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bee3bad..cf6ef278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - **The resident `codeburn serve` child.** The first real panel request is also the cache warm-up, so startup never runs an artificial warm-up query beside a duplicate one-shot child; each served command carries its own read-only option allowlist, and anything outside it falls back to a normal spawn; the child exits when its stdin closes, so it can never outlive the app. Requests whose response exceeds the 16 MiB frame limit still replace the child, but that deliberate kill no longer spends the resident's unexpected-death budget. (#972) ### Fixed +- **Plan rows for sticker-price presets read as a budget instead of live provider quota.** There is no Grok quota endpoint, so a SuperGrok row was parsed API-equivalent spend divided by the plan's sticker price on a monthly reset — but the TUI labelled that math "plan" and "reset", which next to a client showing xAI's real weekly window read as CodeBurn being wrong. The bars and the arithmetic are unchanged; the words are not. Both the dashboard and the desktop app now say the number is an API-equivalent monthly budget and not a live provider window, in the same wording on both surfaces, and for every preset rather than as a SuperGrok special case. The window is anniversary-based (`plan.resetDay`, settable with `codeburn plan set --reset-day`), so it is called a budget reset rather than a calendar one. The row was also shortened to fit 80 columns: at that width the percentage and the projected month were being truncated away, including on custom plans, whose label carries the provider. - **A date-ranged run no longer republishes the month shards it never read.** A scoped load leaves an out-of-range month on disk, so the files it holds have no visible cache entry and the reconcile re-parses them — re-deriving the entry the shard already stores. That re-parse marked the unloaded month dirty, and the save merged and republished it under a fresh nonce name on every single run, byte-identical content and all, so a repeated `codeburn status --format json` churned old months (on a real corpus: claude/2026-03, cursor/2026-02 and warp/2026-03 renamed every run) and left the retired shards for the sweeper. A merge into an unloaded month that neither adds, changes nor removes an entry now keeps the published shard, so unchanged months keep their names and their bytes. (#1032) - **`models` and `audit` no longer show two identical `Grok 4.5` rows.** `grok-4.5-build` — the Grok Build harness's variant id — fell into the `grok-4.5` display entry by prefix, and since rows bucket by model id, not display name, the two came out as visually identical rows with different numbers. The variant now shows as `Grok 4.5 (build)`. Display only: no id is rewritten and no cost moves. (#1029) - **An upgrade no longer loses history for days whose transcripts have only PARTLY aged out.** The never-lose contract carried a cached (day, provider) slice forward only when the re-derivation found NOTHING for it, but transcripts expire per FILE rather than per day: on a day whose sources are mostly gone, a handful of turns from surviving later files still bucket onto it, so the fresh slice came back non-empty but truncated and REPLACED the full cached one. On a real cache upgrading from the last shipped daily-cache version, 2026-07-16 fell from $1,685.17 / 12,530 calls to $385.44 / 560 calls, and 13 days lost $2,765.75, 19,209 calls and 520 sessions in total. A fresh slice now replaces a settled baseline slice only when it carries at least as many CALLS - the same or more evidence; fewer calls means the source set demonstrably lost data, and the baseline is kept whole. The comparison is on calls alone: cost and tokens are re-priced accounting on the same evidence, which is exactly what a legitimate re-derivation changes (the Grok accounting fix keeps its per-day calls and is unaffected), and session counts drift down by a few on days whose sources are entirely intact. Days inside a 7-day settle window stay authoritative - their session files are still on disk, so a shrink there is a real change rather than expiry. The trade-off is deliberate and matches the direction this cache has always chosen: a future fix that legitimately REDUCES calls on a settled day keeps the older, higher value until that day is re-derived at an equal or greater call count. The timezone-change re-derive gets the exact form of the same rule - what the fresh parse can no longer explain under the old bucketing is added on top of the fresh slice instead of being dropped - and the cross-file adoption union is unchanged, where the newer schema still wins per (day, provider).