feat(oauth): return structured managed usage rows - #2300
Merged
Conversation
🦋 Changeset detectedLatest commit: 9bbc504 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
commit: |
Stop formatting plan-usage labels and reset hints into English strings
at the oauth layer. The parser still absorbs backend field drift, but
now emits a stable structured row (name / window{duration,unit} / used
/ limit / resetAt) that kap-server passes through and clients localize
themselves:
- window: normalized from duration/timeUnit (minute/hour/day/week),
whole-hour minute windows fold to hours, unnamed summaries are the
weekly limit
- resetAt: absolute ISO timestamp; relative reset_in/ttl seconds are
converted at parse time
- TUI /usage panel formats labels and reset hints locally
liruifengv
force-pushed
the
feat/structured-managed-usage
branch
from
July 28, 2026 06:26
d66d18c to
884a5ff
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d66d18ca19
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…shape Drop the defensive drift tolerance (alternate reset-time spellings, reset_in/ttl seconds, remaining-derived used, title/scope names, top-level duration/timeUnit, fuzzy time-unit matching) and parse only what the platform actually sends: numeric strings, resetTime, nested detail/window records, TIME_UNIT_* enums.
…r structured rows
Merged
7723qqq
pushed a commit
to 7723qqq/kimi-code
that referenced
this pull request
Aug 15, 2026
* feat(oauth): return structured managed usage rows
Stop formatting plan-usage labels and reset hints into English strings
at the oauth layer. The parser still absorbs backend field drift, but
now emits a stable structured row (name / window{duration,unit} / used
/ limit / resetAt) that kap-server passes through and clients localize
themselves:
- window: normalized from duration/timeUnit (minute/hour/day/week),
whole-hour minute windows fold to hours, unnamed summaries are the
weekly limit
- resetAt: absolute ISO timestamp; relative reset_in/ttl seconds are
converted at parse time
- TUI /usage panel formats labels and reset hints locally
* refactor(oauth): parse managed usage strictly to the current payload shape
Drop the defensive drift tolerance (alternate reset-time spellings,
reset_in/ttl seconds, remaining-derived used, title/scope names,
top-level duration/timeUnit, fuzzy time-unit matching) and parse only
what the platform actually sends: numeric strings, resetTime, nested
detail/window records, TIME_UNIT_* enums.
* fix(node-sdk): update managed usage smoke example and facade tests for structured rows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
No linked issue — the problem is explained below.
Problem
GET /api/v1/oauth/usagereturned server-formatted English strings (label: "5h limit",reset_hint: "resets in 5d 12h 57m") instead of data. Every client that wanted to localize or reformat had to reverse-parse those strings with regexes — the web/desktop settings card did exactly that, and any unrecognized label fell through as raw English. Formatting policy was also frozen server-side, so clients could not adapt it (e.g. the 5-hour window arrives from the platform as300 MINUTEand was stringified as "5h limit" with no way to render it differently).What changed
The oauth parser keeps absorbing backend field drift (numeric strings,
used/remaining, four reset-time spellings, proto-style time units) but now emits a stable structured row, which kap-server passes through and clients localize themselves:UsageRow→{ name?, window?{ duration, unit }, used, limit, resetAt? }(wire: snake_casereset_at)window: normalized fromduration/timeUnittominute|hour|day|week; whole-hour minute windows fold to hours (300 MINUTE→5h); an unnamed summary row is the plan's weekly limit and gets{ 1, week }(parity with the previous hardcoded "Weekly limit" fallback)resetAt: absolute ISO timestamp; relativereset_in/ttlseconds are converted at parse time so clients never deal with relative mathlimitLabel/resetHintFrom/formatResetTime;formatDurationstays exported for the TUI/usagepanel formats labels and reset hints locally (English), same rendered output as beforeextra_usage) was already structured and is untouchedWire compatibility:
label/reset_hintare removed from the REST DTO — breaking for old clients, accepted since the desktop renderer and its embedded server ship together and the web UI is deployed in lockstep.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.