Skip to content

Commit 0f1fc3e

Browse files
asizikovCopilot
andcommitted
fix: address budget simulation review feedback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent da7b2b3 commit 0f1fc3e

6 files changed

Lines changed: 150 additions & 107 deletions

File tree

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ function App() {
293293
&& parsedProductCopilotBudget === undefined
294294
) {
295295
setBudgetSimulation(null)
296-
setBudgetSimulationError('Enter a user-level, enterprise-level, or product-level budget in USD before running the simulation.')
296+
setBudgetSimulationError('Enter a user-level, account-level, or product-level budget in USD before running the simulation.')
297297
return
298298
}
299299

src/pipeline/aicEntitlements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ export async function createAicEntitlementAllocator(
319319
return new PooledAicEntitlementAllocator(entitlementContext.organizationEntitlementPool)
320320
}
321321

322-
function getIsoWeekStart(value: string): string | null {
322+
export function getIsoWeekStart(value: string): string | null {
323323
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value)
324324
if (!match) return null
325325

src/pipeline/productClassification.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { TokenUsageRecord } from './parser'
22

33
export const NON_COPILOT_CODE_REVIEW_PRODUCT = 'Code Review for Non-Copilot Users' as const
44
export const NON_COPILOT_CODE_REVIEW_USER_LABEL = 'Non-Copilot Users' as const
5-
export const PRODUCT_BUDGET_COPILOT_CODE_REVIEW = 'Copilot Code Review' as const
5+
export const PRODUCT_BUDGET_COPILOT_CODE_REVIEW = 'Code Review' as const
66
export const PRODUCT_BUDGET_SPARK = 'Spark' as const
77
export const PRODUCT_BUDGET_COPILOT = 'Copilot' as const
88

src/utils/enterpriseBudgetSimulation.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,31 @@ describe('simulateBudgetFromRecords', () => {
165165
})
166166
})
167167

168+
it('handles individual-scope weekly entitlements and per-user budgets independently', () => {
169+
const result = simulateBudgetFromRecords([
170+
createRecord({ date: '2026-06-01', username: 'mona', quantity: 40, aic_quantity: 40, aic_gross_amount: 4 }),
171+
createRecord({ date: '2026-06-02', username: 'mona', quantity: 40, aic_quantity: 40, aic_gross_amount: 4 }),
172+
createRecord({ date: '2026-06-08', username: 'mona', quantity: 40, aic_quantity: 40, aic_gross_amount: 4 }),
173+
createRecord({ date: '2026-06-08', username: 'octocat', quantity: 20, aic_quantity: 20, aic_gross_amount: 2 }),
174+
], { userBudgetUsd: 5 }, {
175+
reportPlanScope: 'individual',
176+
organizationEntitlementPool: 0,
177+
individualWeeklyEntitlements: 50,
178+
})
179+
180+
expect(result).toEqual({
181+
totalBill: 0,
182+
blockedUsers: 1,
183+
blockedRequests: 70,
184+
blockedEntitlementsAic: 80,
185+
budgetExhausted: false,
186+
firstUserBlockedDate: '2026-06-02',
187+
enterpriseBlockedDate: null,
188+
productBlockedDates: {},
189+
adjustedDailyNetCostByDate: [],
190+
})
191+
})
192+
168193
it('does not count entitlements that later get consumed by other usage', () => {
169194
const result = simulateBudgetFromRecords([
170195
createRecord({ username: 'mona', quantity: 50, aic_quantity: 50, aic_gross_amount: 5 }),

0 commit comments

Comments
 (0)