fix(review): address Copilot PR feedback

- Add compile-time interface assertion for sessionWindowMockRepo
- Fix flaky fallback test by capturing time.Now() before calling UpdateSessionWindow
- Replace stale hardcoded timestamps with dynamic future values
- Add millisecond detection and bounds validation for reset header timestamp
- Use pause/resume pattern for interval in UsageProgressBar to avoid idle timers on large lists
- Fix gofmt comment alignment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
haruka
2026-03-17 10:19:20 +08:00
parent 668e164793
commit 869952d113
3 changed files with 46 additions and 13 deletions

View File

@@ -56,7 +56,7 @@
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { computed, ref, watch } from 'vue'
import { useIntervalFn } from '@vueuse/core'
import { useI18n } from 'vue-i18n'
import type { WindowStats } from '@/types'
@@ -72,11 +72,28 @@ const props = defineProps<{
const { t } = useI18n()
// Reactive clock for countdown (updates every 60s)
// Reactive clock for countdown — only runs when a reset time is shown,
// to avoid creating many idle timers across large account lists.
const now = ref(new Date())
useIntervalFn(() => {
now.value = new Date()
}, 60_000)
const { pause: pauseClock, resume: resumeClock } = useIntervalFn(
() => {
now.value = new Date()
},
60_000,
{ immediate: false },
)
if (props.resetsAt) resumeClock()
watch(
() => props.resetsAt,
(val) => {
if (val) {
now.value = new Date()
resumeClock()
} else {
pauseClock()
}
},
)
// Label background colors
const labelClass = computed(() => {