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.
This commit is contained in:
Zero Clover
2026-09-26 18:49:51 +08:00
parent 20a94fbb56
commit 994048e6a4
2 changed files with 6 additions and 8 deletions
@@ -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()
@@ -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 时显示倒计时', () => {