Skip to content

feat: show local reset time alongside countdown in /usage hints#1914

Open
huanglizhuo wants to merge 2 commits into
MoonshotAI:mainfrom
huanglizhuo:feat/usage-reset-local-time
Open

feat: show local reset time alongside countdown in /usage hints#1914
huanglizhuo wants to merge 2 commits into
MoonshotAI:mainfrom
huanglizhuo:feat/usage-reset-local-time

Conversation

@huanglizhuo

@huanglizhuo huanglizhuo commented Jul 19, 2026

Copy link
Copy Markdown

Related Issue

Resolve #1915

Problem

See linked issue.

What changed

  • The reset hint now combines both forms: resets in 2h 30m (at 14:30). This applies uniformly to rows backed by an absolute timestamp (reset_at/resetAt/...) and to rows backed by relative seconds (reset_in/ttl), where the absolute moment is derived from the fetch time.
  • The absolute moment is rendered in the terminal's local timezone via local Date getters, with date context graded by distance so a bare clock time is never ambiguous: HH:MM within the same day, MM-DD HH:MM within the same year, YYYY-MM-DD HH:MM across years.
  • Existing fallbacks are preserved: already-elapsed windows still render reset, and unparseable timestamps still fall back to resets at <raw value>.
  • Tests updated and extended to lock the new format, including the same-day / cross-day / cross-year boundaries and the relative-seconds path.

Before vs After

Screenshot 2026-07-19 at 20 23 05

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b7cfc42

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code-oauth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@huanglizhuo huanglizhuo changed the title feat(oauth): show local reset time alongside countdown in /usage hints feat: show local reset time alongside countdown in /usage hints Jul 19, 2026
@huanglizhuo
huanglizhuo marked this pull request as ready for review July 19, 2026 11:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fee69b6b79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/oauth/src/managed-usage.ts Outdated
Comment thread packages/oauth/test/managed-usage.test.ts Outdated
resetHintFrom built the epoch from Date.now() and resetHintForEpoch read
the clock again before flooring the difference, so any elapsed millisecond
dropped a full second: reset_in 120 rendered "1m" and reset_in 1 rendered
"reset". Thread a single reference time through both, and use it for the
local-clock date comparison as well.

Pin the boundary tests to a frozen clock so they assert exact strings
instead of skipping on midnight/year edges, and cover the double-read
regression with a clock that ticks between calls.

Also correct the changeset to name the package that actually changed.
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.

feat: Show the absolute reset time alongside the countdown in /usage reset hints

1 participant