Skip to content

feat(usage): add live end time option for custom date range#4438

Open
arichyx wants to merge 4 commits into
farion1231:mainfrom
arichyx:feat/usage-live-end-time
Open

feat(usage): add live end time option for custom date range#4438
arichyx wants to merge 4 commits into
farion1231:mainfrom
arichyx:feat/usage-live-end-time

Conversation

@arichyx

@arichyx arichyx commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary / 概述

Add a "End time follows current time" checkbox in the custom date range picker. When enabled, the end time field becomes read-only and automatically tracks the current moment, so usage data always reflects up-to-the-second consumption from the chosen start time.

在自定义日期范围选择器中新增 "结束时间跟随当前时刻" 复选框。勾选后,结束时间字段变为只读并自动跟随当前时刻,使使用统计数据始终反映从选定开始时间到此刻的实时消耗。

Motivation / 背景

Currently, when selecting a custom date range, the end time is a fixed snapshot — it's set to the moment you click "Confirm" and never updates afterward. To see the latest data, you have to close and reopen the picker every time.

This is especially painful under the Coding Plan 5-hour quota window. Users need to monitor how much of their 5h quota has been consumed from the window start time to right now. With the current fixed end time, the data becomes stale the moment you confirm — you can never see real-time consumption within a custom window.

目前选择自定义时间范围时,结束时间是点击"确认"那一刻的固定快照,之后不会更新。要看最新数据,必须反复关闭再打开选择器。

这在 Coding Plan 5 小时额度窗口 下尤其不便。用户需要监控从窗口开始时间到此刻的 token 消耗,但固定的结束时间让数据在确认的那一刻就过时了——无法在自定义窗口内查看实时消耗。

What this PR does / 改动内容

  • UsageRangeSelection — add optional liveEndTime?: boolean field
  • resolveUsageRange() — when liveEndTime is true, endDate resolves to Date.now() instead of the fixed customEndDate snapshot
  • UsageDateRangePicker — add a checkbox below the end time field; when checked:
    • End time field becomes read-only with disabled styling (opacity-50, cursor-not-allowed, pointer-events-none)
    • A 1-second interval keeps the displayed end time ticking while the popover is open
    • Calendar clicks only affect the start date
  • UsageDashboard — when liveEndTime is true, the range label shows "start → Now" instead of a stale end timestamp
  • i18n — added usage.liveEndTime and usage.liveEndTimeNow keys for en/zh/zh-TW/ja

Screenshots / 截图

Before / 修改前 After / 修改后
image image

Checklist / 检查清单

  • pnpm typecheck passes / 通过 TypeScript 类型检查
  • pnpm format:check passes / 通过代码格式检查
  • cargo clippy passes (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)— N/A, no Rust changes
  • Updated i18n files if user-facing text changed / 如修改了用户可见文本,已更新国际化文件

arichyx added 4 commits June 18, 2026 11:16
Add a "End time follows current time" checkbox in the custom date range
picker. When enabled, the end time becomes read-only and automatically
tracks the current moment, so usage data always reflects up-to-the-second
consumption from the chosen start time.

This is especially useful under the Coding Plan 5-hour quota window —
users can set the start time to when their 5h window began and keep
the end time live to monitor real-time token consumption.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant