From 994048e6a4cf1988ef7232cd4c5258dcb5c85e3a Mon Sep 17 00:00:00 2001 From: Zero Clover Date: Sat, 26 Sep 2026 18:49:51 +0800 Subject: [PATCH] fix(ui): show reset countdown for idle usage windows with known reset time UsageProgressBar returned 'now' whenever showNowWhenIdle was set and utilization was 0%, ignoring resetsAt. OpenAI Codex 7d windows at 0% usage still carry a future reset time, so the admin account list hid it. Only fall back to 'now' when no reset time is known. --- frontend/src/components/account/UsageProgressBar.vue | 8 +++----- .../components/account/__tests__/UsageProgressBar.spec.ts | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/account/UsageProgressBar.vue b/frontend/src/components/account/UsageProgressBar.vue index 1f7cde1645..c8dc46fa87 100644 --- a/frontend/src/components/account/UsageProgressBar.vue +++ b/frontend/src/components/account/UsageProgressBar.vue @@ -188,13 +188,11 @@ const shouldShowResetTime = computed(() => { // Format reset time const formatResetTime = computed(() => { - // For rolling windows, when utilization is 0%, treat as immediately available. - if (props.showNowWhenIdle && props.utilization <= 0) { - return t('usage.resetNow') + if (!props.resetsAt) { + // Idle rolling window without a known reset time: treat as immediately available. + return props.showNowWhenIdle && props.utilization <= 0 ? t('usage.resetNow') : '-' } - if (!props.resetsAt) return '-' - const date = new Date(props.resetsAt) const diffMs = date.getTime() - now.value.getTime() diff --git a/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts b/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts index e92268e597..7c5016ecba 100644 --- a/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts +++ b/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts @@ -22,7 +22,7 @@ describe('UsageProgressBar', () => { vi.useRealTimers() }) - it('showNowWhenIdle=true 且利用率为 0 时显示“现在”', () => { + it('showNowWhenIdle=true 且利用率为 0 但有未来 resetsAt 时显示倒计时', () => { const wrapper = mount(UsageProgressBar, { props: { label: '5h', @@ -33,8 +33,8 @@ describe('UsageProgressBar', () => { } }) - expect(wrapper.text()).toContain('usage.resetNow') - expect(wrapper.text()).not.toContain('2h 30m') + expect(wrapper.text()).toContain('2h 30m') + expect(wrapper.text()).not.toContain('usage.resetNow') }) it('showNowWhenIdle=true 但利用率大于 0 时显示倒计时', () => {