feat(usage): show provider account limits - #41571
Conversation
|
✅ Verified — Provider account-limit visibility in Reviewed the diff for TUI/gateway usage command account-limit integration.
Well-structured multi-file change with good test isolation. No issues found. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for carrying provider-limit visibility into the TUI. Current main still lacks this specific TUI surface: tui_gateway/server.py:6489-6512 returns only token usage and Nous credits_lines, while ui-tui/src/app/slash/commands/session.ts:582-619 renders no provider account block.
Problems
- The added
session.usagefetch is synchronous (tui_gateway/server.pyPR right-side line 4051). Provider usage requests use a 15-second HTTP timeout (agent/account_usage.py:509), while current dispatch invokes methods inline unless listed in_LONG_HANDLERS(tui_gateway/server.py:1271);session.usageis not currently listed. This can stall the TUI RPC reader. - The Codex credential change has been superseded by current main's resolver at
agent/account_usage.py:439-494. Commit130e2337c24810bc0afa793495795b832cf593behardens that path against wrong-account pool fallback; preserve that implementation during salvage.
Suggested changes
- Salvage the TUI RPC/type/rendering portion and run its account fetch on the long-handler worker path (or an equivalent bounded worker).
- Retain current-main Codex credential resolution and its newer regression coverage rather than restoring the older broad exception path.
This is an automated hermes-sweeper review.
| @@ -4023,6 +4051,9 @@ def _(rid, params: dict) -> dict: | |||
| usage["credits_lines"] = credits | |||
There was a problem hiding this comment.
session.usage is dispatched inline unless it is added to _LONG_HANDLERS; this call can issue a provider HTTP request with a 15-second timeout. Please run this RPC through the long-handler worker path (or offload this fetch) so a slow usage endpoint cannot block the TUI reader and delay control RPCs.
GottZ
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Summary
Four PRs address or reference this complex: #2486 introduced provider account limits for CLI and messaging /usage, #13428 rebuilt and merged that implementation onto current main, #41571 adds the still-missing TUI surface, and #56543 fixes a separate TUI source-resolution failure. The build changes in #41571 and #56543 are distinct: React/react-reconciler aliasing prevents duplicate-React hook failures, while the .js-to-TypeScript resolver fixes NodeNext imports during esbuild bundling.
Related pull requests
- #2486 [closed]
related— (+907/-108) — superseded by merged #13428: this was the original implementation of OpenAI Codex, Anthropic OAuth, and OpenRouter account-limit fetching plus CLI/gateway/usagewiring; #13428 preserved its account-usage module and authorship while rebuilding the integration against current main to avoid dropping later rate-limit and cached-agent behavior. - #13428 [merged]
related— (+678/-6) — merged reference implementation: it resolves the original CLI and messaging-gateway cause by appending provider quota and credit data to/usage, including persisted-provider fallback and off-event-loop gateway fetching, while retaining newer mainline usage behavior. - #41571
related— (+223/-12) — keep open for targeted salvage: the diff adds the missingsession.usageresponse field, TUI types, and rendering for provider account limits, but the contributor keep_open review on #41571 identifies a blocker because the synchronous provider fetch can hold the TUI RPC reader for up to 15 seconds. Movesession.usageonto the long-handler worker path or provide equivalent bounded off-reader execution, preserve current main's wrong-account-safe Codex resolver, and keep the React/react-reconciler aliasing only if independently justified and tested. - #56543
related— (+32/-2) — keep open as a separate fix: its esbuild resolver maps NodeNext-style relative.jsimports to existing.ts/.tsx/.jsxsources and directly addresses clean-checkout TUI rebuild failures. This is not the duplicate-React dependency-tree defect addressed by #41571's alias changes, and the contributor keep_open review reports no verified blocker.
Duplicates
#2486 and #13428 implement substantially the same core CLI/messaging account-limit feature, with #13428 being the current-main rebuild that superseded #2486. #41571 is only partially overlapping because its material addition is TUI exposure; #56543 is not a duplicate of #41571 because the two build changes address distinct defects.
Suggested consolidation
Merge #41571 only after addressing its contributor keep_open review by moving the provider fetch off the inline TUI RPC reader and preserving current main's hardened Codex credential resolver; then consolidate only its TUI RPC/type/rendering work and any independently validated React alias fix. #2486 can remain closed as superseded by merged #13428, while #56543 should remain open and be evaluated separately rather than closed as a duplicate.
Cross-PR triage: Reviewed 4 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 92 kB of PR diffs, 12 kB of issue/PR text, 4 kB of discussion (5 comments), 1 verify verdict. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
Summary
Adds account-limit visibility to
/usageacross gateway/TUI usage paths./usagerequests.session.usageresponse./usage, TUI gateway usage responses, and Codex account-usage credential handling.Notes
The OpenAI-side implementation is currently the
openai-codex/ChatGPT account-limit path used by Hermes OAuth-backed Codex provider credentials. Anthropic account-limit rendering remains OAuth-gated.The TUI build-related changes keep React/reconciler dependencies resolved from a single dependency tree and avoid pipe handle leakage in
resolveOnExitexec calls; these were needed to keep the local TUI build/runtime path healthy while validating the/usagechange.Test Plan
venv/bin/python -m pytest tests/test_account_usage.py tests/gateway/test_usage_command.py tests/test_tui_gateway_server.py -o 'addopts=' -q237 passed in 4.17snpm run build --prefix ui-tuinpm run type-check --prefix ui-tuinpm test --prefix ui-tui -- packages/hermes-ink/src/utils/execFileNoThrow.test.ts src/__tests__/createSlashHandler.test.ts src/__tests__/gatewayClient.test.ts72 passed | 1 skippedgit diff --cached --checkKnown local test note
A full
npm test --prefix ui-tui -- --runwas attempted and currently has unrelated failures in:src/__tests__/memoryMonitor.test.tssrc/__tests__/virtualHeights.test.tsIt also showed
slashParityskipping/parity probe issues because the systempython3used by that test lacksyaml. Targeted TUI tests for the touched areas passed.