Repository navigation
feat(web): carry a key's request limits in the Add to ThinkWatch Lite link - #115
Merged
Merged
Conversation
… link The rotated-key dialog reads the key's own rate-limit rules and puts the ones Lite can hold exactly into the link's `limits` parameter: enabled, unexpired AI-gateway request rules over whole minutes up to 60 or whole hours up to 24 become Lite's rolling minute/hour windows. Token rules are left out (the gateway counts weighted tokens, Lite plain ones), as are sliding 7-day rules, budgets, MCP rules and the owner's limits. Duplicate windows keep the smaller count; at most 16 windows, the lowest rates. A link with limits needs Lite 2026.10.26, which the dialog states. When the rules cannot be read the link is built without them, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
The rotated-key dialog's Add to ThinkWatch Lite link now carries the key's own request limits in ThinkWatch Lite's
limitsimport-link parameter (Lite 2026.10.26+), where they mean the same limit there.Mapping
ai_gatewayrules withmetric: requests.minutewindow withevery= minutes; whole hours up to 24 becomehourwithevery= hours (60 s →minute, 300 s →minute|…|5, 3600 s →hour, 18000 s →hour|…|5, 86400 s →hour|…|24). Other windows, including the sliding 7 days, are left out: Lite's day/week/month are calendar periods.crates/gateway/src/proxy/accounting.rs,weighted_tokensfed tosliding::record; weights incrates/common/src/limits/weight.rs: per-model input/output weights, cache reads at 0.1x input and cache writes at 1.25x/2x by default), while Lite counts plain tokens with cache reads either fully in or out. Nocache_readssetting gives the same number.everyis omitted when it is 1.UI
AddToLitetakes an optionalkeyId. With it andrate_limits:read, it readsGET /api/admin/limits/api_key/{id}/rules(cached under the key-limits query key, so edits refresh it). Until the answer arrives, and on 403 or any error, the link is built without limits; the button is never held back.Tests
lite-link.test.ts: each console window, other whole-minute/hour windows, unmapped windows, token rules, disabled/expired/MCP rules, out-of-range counts, duplicate windows, more than 16 windows, none, and the encoding (|→%7C,;→%3B).api-keys.test.tsx: rotated-key dialog with mapped limits (link, description, install version), with no mapped rule, with a 403, and withoutrate_limits:read.pnpm check:i18n,pnpm lint,pnpm test,pnpm buildall pass. No Rust changes.🤖 Generated with Claude Code