mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 02:39:13 +00:00
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.
This commit is contained in:
parent
a4384d28f2
commit
911bd3f486
4 changed files with 54 additions and 16 deletions
|
|
@ -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 }) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue