Repository navigation
usage: always show the subscription usage chip (#157) - #163
Conversation
The studio showed the subscription usage only once a warning threshold was
crossed: updateRateLimit() returned early for status:'allowed' below it and
cleared the badge, and the single _rlInfo slot forgot one window as soon as
the other one arrived (five_hour and seven_day are separate events of the
same rate_limit frame type).
Now the chip is an indicator, not only an alert:
- public/index.html keeps the last known utilisation per window under
rl_usage (migrating a timestamped rl_info once), so both figures survive
a reload and one event never erases the other.
- The chip label lists every fresh window ("5h 43% · 7d 12%"), the tooltip
carries one block per window with the used percentage and the reset time
the CLI reported, plus how old the data is.
- A window whose reset time has passed is dropped instead of rendered as
0%: the old figure says nothing about the current window.
- Colour and text still follow the existing alerts: neutral below 80%
(rl-ok: no pulse, no dismiss button), amber while warning, red at 95% or
rejected. Threshold toasts, the browser notification and the rejected
modal are unchanged.
- New strings in all five languages (uk/en/ru/fr/he).
The Subscription engine (tmux) still has no source for rate_limit_event, so
nothing is shown there yet; wiring it to the TUI status line is the follow-up
the issue itself calls unverified.
Evidence (Node 24.22.1): test/usage-indicator.test.js 19 passed - it runs the
real renderer in a vm and pins that an allowed event below the threshold now
renders the chip instead of clearing it, that the two windows keep separate
slots, that a stale window is dropped, and that the chip follows the alert
thresholds. i18n-completeness 139 passed, render suites 122 passed, and
responsive-ui / section-controls-ux / settings-ux / secondary-navigation /
frontend-recovery / terminal-keys / file-preview-copy / sidebar-ux all rc=0.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f96b9cf6df
ℹ️ 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".
| function _rlRenderUsage() { | ||
| const badge = $i('rlBadge'); | ||
| if (!badge) return; | ||
| const fresh = _rlUsageFresh(_rlUsageLoad()); |
There was a problem hiding this comment.
Keep live usage state independent of localStorage writes
When localStorage writes fail, such as when the origin's storage quota is exhausted, _rlUsageNote() silently loses the new event and this renderer reloads either empty or outdated state. A fresh 85% event consequently leaves the badge hidden if nothing was previously stored. Before this change, persistence was best-effort and the badge still rendered directly from the received event. Keep the per-window state in memory and use localStorage only for persistence so storage failures do not suppress or freeze the live indicator.
Useful? React with 👍 / 👎.
| if (!Object.keys(_rlUsageLoad()).length) { | ||
| const raw = localStorage.getItem(RL_STORAGE_KEY); | ||
| const legacy = raw ? JSON.parse(raw) : null; | ||
| if (legacy && legacy.rateLimitType && legacy.ts) _rlUsageNote(legacy, legacy.ts); |
There was a problem hiding this comment.
Migrate the legacy records that the previous version actually wrote
On an upgrade with an unexpired warning saved under rl_info, this condition prevents the existing indicator from being restored: the previous _rlSave() serialized info directly and did not add ts. Thus ordinary records written by the previous version fail the migration and the badge disappears until another rate-limit event arrives, whereas the previous restore path displayed them through their reset time. Accept legacy records without a timestamp when their reported reset time is still in the future, handling the unknown observation age separately.
Useful? React with 👍 / 👎.
|
Merged as Verification:
|
Part of #157 (the API-engine half). The studio showed the subscription usage only once a warning threshold was crossed:
updateRateLimit()returned early forstatus:'allowed'below it and cleared the badge, and the single_rlInfoslot forgot one window as soon as the other one arrived (five_hourandseven_dayare separate events of the samerate_limitframe type).Now the chip is an indicator, not only an alert:
public/index.htmlkeeps the last known utilisation per window underrl_usage(migrating a timestampedrl_infoonce), so both figures survive a reload and one event never erases the other.5h 43% · 7d 12%); the tooltip carries one block per window with the used percentage and the reset time the CLI reported, plus how old the data is.rl-ok: no pulse, no dismiss button), amber while warning, red at 95% orrejected. Threshold toasts, the browser notification and the rejected modal are unchanged.The Subscription engine (tmux) has no
rate_limit_eventyet, so nothing is shown there; wiring it to the TUI status line is the follow-up the issue itself calls unverified.Evidence (Node 24.22.1):
test/usage-indicator.test.js19 passed — it runs the real renderer in avmand pins that an allowed event below the threshold now renders the chip instead of clearing it, that the two windows keep separate slots, that a stale window is dropped, and that the chip follows the alert thresholds.i18n-completeness139 passed, render suites 122 passed, andresponsive-ui/section-controls-ux/settings-ux/secondary-navigation/frontend-recovery/terminal-keys/file-preview-copy/sidebar-uxall rc=0. The fullnpm testcannot finish on this host (task-backlog.test.jsbinds::1forHOST=localhost), so CI is the complete run.