Merge pull request #6760 from wucm667/feat/issue-6752-weekly-cost-estimate

feat(accounts): show estimated weekly account cost
This commit is contained in:
Wesley Liddick authored and GitHub committed 2026-09-08 20:09:25 +08:00
commit 9bcf8a5b80
5 files changed
+113 -2

No files matched your search

@@ -134,6 +134,7 @@
:utilization="usageInfo.seven_day.utilization"
:resets-at="usageInfo.seven_day.resets_at"
:window-stats="usageInfo.seven_day.window_stats"
:estimated-total-cost="openAISevenDayEstimatedTotalCost"
:show-now-when-idle="true"
color="emerald"
/>
@@ -785,6 +786,25 @@ const hasOpenAIUsageFallback = computed(() => {
return !!usageInfo.value?.five_hour || !!usageInfo.value?.seven_day
})
const openAISevenDayEstimatedTotalCost = computed(() => {
const sevenDay = usageInfo.value?.seven_day
const utilization = sevenDay?.utilization
const currentCost = sevenDay?.window_stats?.cost
if (
typeof utilization !== 'number' ||
typeof currentCost !== 'number' ||
!Number.isFinite(utilization) ||
!Number.isFinite(currentCost) ||
utilization <= 0 ||
currentCost <= 0
) {
return null
}
const estimate = (currentCost * 100) / utilization
return Number.isFinite(estimate) && estimate > 0 ? estimate : null
})
const openAIUsageRefreshKey = computed(() => buildOpenAIUsageRefreshKey(props.account))
const shouldAutoLoadUsageOnMount = computed(() => {