Skip to content

feat: show account limits in CLI and TUI status bars - #16652

Open
grig2277 wants to merge 1 commit into
NousResearch:mainfrom
grig2277:feat/cli-account-limit-status
Open

feat: show account limits in CLI and TUI status bars#16652
grig2277 wants to merge 1 commit into
NousResearch:mainfrom
grig2277:feat/cli-account-limit-status

Conversation

@grig2277

@grig2277 grig2277 commented Apr 27, 2026

Copy link
Copy Markdown

Summary

  • Shows compact active-account limits in both the classic CLI and Ink TUI status bars.
  • Refreshes provider usage only in background workers; session.info, message.complete, and status rendering return cached/stale data immediately.
  • Uses single-flight stale-while-revalidate caches keyed to a non-secret fingerprint of the active runtime credential.
  • Preserves current Codex credential-resolution safeguards and derives ChatGPT-Account-Id only from the already-selected live token.
  • Displays a credential label only when the active token exactly matches its credential-pool entry.
  • Budgets the Ink account-limit HUD as one optional tail segment, so status/model/context remain pinned and quota text is omitted whole on narrow terminals.

Example: Codex main 5h 83% • weekly 37%.

Review fixes

Addresses the July 12 review:

  • No synchronous provider usage fetches remain in TUI hot paths.
  • Cold misses and stale entries schedule at most one background refresh per credential key.
  • Failures preserve stale data and retry after a short backoff.
  • Credential rotation cannot reuse another account's cached payload or label.
  • AccountLimitHud participates in the existing essentialWidth / fits() width budget.
  • Ink regression coverage includes a long credential label, multiple windows, wide rendering, and whole-segment omission on a narrow terminal.

PR consolidation

This remains the combined CLI + TUI account-limit status PR and supersedes the earlier TUI-only draft #16644.

Verification

Rebuilt from current main at 7b5ba2054721dde998ed47fd4a0f031955278e99; replacement commit: 1b3d9b34c872908fab6d61bec85af3b5b7df9420.

  • Python targeted regression: 228 passed.
  • Ink targeted render/event regression: 102 passed.
  • TypeScript typecheck: passed.
  • TUI production build: passed.
  • Ruff: passed.
  • ESLint: passed.
  • git diff --check: passed.

CI status

GitHub created CI run 29208048955, but it is currently action_required: a repository maintainer/admin must approve the fork workflow before jobs can start.

Broader local-suite caveats are environment/baseline-only: the isolated gateway suite lacks a Chromium binary, while unrelated unchanged Ink tests include SSH-environment assertions and one existing timeout. All changed and newly added tests pass.

Closes #16643

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 27, 2026
@grig2277
grig2277 force-pushed the feat/cli-account-limit-status branch from 3d88e99 to b068f38 Compare April 27, 2026 22:16
@grig2277 grig2277 changed the title feat(cli): show account limits in status bar feat: show account limits in CLI and TUI status bars Apr 27, 2026
@grig2277

Copy link
Copy Markdown
Author

Added follow-up fix for account-limit status binding.

What changed:

  • Runtime provider now carries selected credential_id / credential_label forward.
  • CLI/TUI agents pin that selected credential metadata.
  • CLI/TUI fallback labels from credential pool only apply when the pool entry token matches the active agent.api_key.
  • Credential rotation updates pinned credential metadata too.

Local verification:

  • pytest tests/hermes_cli/test_runtime_provider_resolution.py tests/tui_gateway/test_make_agent_provider.py tests/test_tui_gateway_server.py tests/test_account_usage.py tests/cli/test_cli_status_bar.py -q → 214 passed
  • npm --prefix ui-tui run type-check → passed
  • npm --prefix ui-tui run test -- src/__tests__/createGatewayEventHandler.test.ts → 23 passed
  • py_compile / git diff --check → passed
  • Live TUI check showed Codex main 5h ... • weekly ...

@grig2277
grig2277 force-pushed the feat/cli-account-limit-status branch from 8afb84f to 32ffa26 Compare April 28, 2026 15:42
@grig2277

Copy link
Copy Markdown
Author

Rebased on latest main and added a small regression-test fix so TUI provider-resolution tests are isolated from local HERMES_MODEL / HERMES_TUI_PROVIDER env overrides.

Latest local verification:

  • py_compile cli.py agent/account_usage.py hermes_cli/runtime_provider.py tui_gateway/server.py run_agent.py gateway/run.py — passed.
  • Targeted Python: tests/test_account_usage.py tests/cli/test_cli_status_bar.py tests/test_tui_gateway_server.py tests/hermes_cli/test_runtime_provider_resolution.py tests/tui_gateway/test_make_agent_provider.py — 232 passed.
  • Gateway/tool regressions — 6 passed.
  • npm run type-check — passed.
  • npm run test -- src/__tests__/createGatewayEventHandler.test.ts — 23 passed.
  • Full TUI suite — 389 passed.
  • npm exec eslint ... — passed.
  • npm run build — passed.

@grig2277
grig2277 marked this pull request as ready for review April 28, 2026 15:42
@grig2277
grig2277 force-pushed the feat/cli-account-limit-status branch 4 times, most recently from 700cb45 to f6aa3b2 Compare May 3, 2026 11:15
@grig2277

grig2277 commented May 3, 2026

Copy link
Copy Markdown
Author

Rebased this PR on the latest main and refreshed the fork branch.

Current head: f6aa3b2a0b7423fc0d0c9b1e33133a2ee478006c

Local verification after the rebase:

  • py_compile cli.py agent/account_usage.py hermes_cli/runtime_provider.py tui_gateway/server.py run_agent.py gateway/run.py — passed
  • npm --prefix ui-tui run build — passed
  • The rebuilt TUI bundle includes the account-limit HUD/status-line code
  • Local checkout is up to date with origin/main

GitHub Actions currently appear blocked for this fork PR: the check suites have conclusion=action_required, so no check runs are reported until a maintainer/admin approves workflows.

Could a maintainer approve the workflow run when convenient?

Also, this PR touches TUI/gateway paths in addition to CLI:

  • tui_gateway/server.py
  • ui-tui/src/...

The linked issue already has comp/tui and comp/gateway; adding those labels here too may help route review. If possible, I would also appreciate reconsidering the priority from P3: this is currently a recurring maintenance pain because daily updates drop the local status-line patch until the PR is merged.

@grig2277
grig2277 force-pushed the feat/cli-account-limit-status branch 3 times, most recently from 86b80c5 to 214501b Compare May 5, 2026 12:18
@grig2277

grig2277 commented May 5, 2026

Copy link
Copy Markdown
Author

Refreshed this PR again on current main and fixed a likely post-approval CI blocker.

Current state:

  • Base: 436672de0
  • Head: 214501b4b
  • Compare: behind_by=0, ahead_by=7

What changed in the latest push:

  • Rebased the branch onto latest main.
  • Added "grig2277@mail.ru": "grig2277" to scripts/release.py AUTHOR_MAP so the repo's Contributor Attribution Check should not fail after workflows are approved.

Latest local verification:

  • py_compile cli.py agent/account_usage.py hermes_cli/runtime_provider.py tui_gateway/server.py run_agent.py gateway/run.py — passed.
  • npm --prefix ui-tui run build — passed.
  • npm --prefix ui-tui run type-check — passed.
  • npm --prefix ui-tui test -- src/__tests__/createGatewayEventHandler.test.ts — 38 passed.
  • pytest tests/cli/test_cli_status_bar.py tests/test_account_usage.py tests/tui_gateway/test_make_agent_provider.py tests/test_tui_gateway_server.py -k 'not test_session_create_drops_pending_title_on_valueerror' — 208 passed.
  • py_compile scripts/release.py — passed.
  • Local Contributor Attribution Check logic for grig2277@mail.ru — passed.

Known baseline note:

  • tests/test_tui_gateway_server.py::test_session_create_drops_pending_title_on_valueerror still fails on the full targeted set.
  • I reproduced the same failure on clean origin/main, so it appears to be an upstream baseline failure, not caused by this PR.

Could a maintainer/admin please approve the fork workflow runs when convenient? They are currently all stopped with action_required.

Also, this PR touches TUI/gateway paths in addition to CLI (tui_gateway/server.py, ui-tui/src/...). The linked issue already has comp/tui and comp/gateway; adding those labels to the PR too may help route review. If maintainers would prefer this split into smaller backend/CLI/TUI PRs instead of one combined PR, I’m happy to reshape it.

@grig2277
grig2277 force-pushed the feat/cli-account-limit-status branch 3 times, most recently from 7d7e8d5 to 30422df Compare May 9, 2026 10:05
@grig2277

grig2277 commented May 9, 2026

Copy link
Copy Markdown
Author

Rebased and force-pushed this PR onto current main.

Current state:

  • compare is clean: behind_by=0, ahead_by=7
  • PR is mergeable
  • GitHub Actions are still blocked on fork workflow approval (action_required)
  • local targeted verification is reflected in the PR body

Could a maintainer/admin please approve the workflow runs when convenient?

Also, this PR touches TUI/gateway paths in addition to CLI (tui_gateway/server.py, ui-tui/src/...). If possible, adding comp/tui and comp/gateway labels here too may help route review. If maintainers would prefer this split into smaller CLI/gateway/TUI PRs, I’m happy to reshape it.

@grig2277
grig2277 force-pushed the feat/cli-account-limit-status branch 4 times, most recently from 4dcaea9 to aafc418 Compare May 15, 2026 09:39
@grig2277
grig2277 force-pushed the feat/cli-account-limit-status branch 3 times, most recently from 2437273 to ab643d9 Compare May 17, 2026 19:20
@grig2277
grig2277 force-pushed the feat/cli-account-limit-status branch 2 times, most recently from 6ff6cc7 to 637a457 Compare May 24, 2026 09:32
@grig2277
grig2277 force-pushed the feat/cli-account-limit-status branch 4 times, most recently from b214165 to 8120a6e Compare June 2, 2026 18:33
@grig2277
grig2277 force-pushed the feat/cli-account-limit-status branch from 8120a6e to 4aecc19 Compare June 4, 2026 04:58

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for combining the CLI and TUI work. The feature still addresses a gap: current main renders account limits through /usage (cli.py:9681-9702), while the classic status bar (cli.py:5055-5119) and Ink StatusRule do not display them.

Problems

  • The proposed TUI cache miss fetch is synchronous, yet the PR invokes it from both session.info and message.complete. A provider timeout would delay those hot paths rather than fail open.
  • AccountLimitHud bypasses the established essentialWidth/fits() progressive-disclosure budget in ui-tui/src/components/appChrome.tsx:466-533; narrow terminals can clip this new multi-window segment. The added tests cover gateway state, not narrow-width rendering.

Suggested changes

  • Refresh TUI limits in a background single-flight path and emit cached/stale data only from hot RPC/response paths.
  • Budget the HUD as a progressive segment and add a narrow-width render test.
  • Preserve the current Codex credential-resolution safeguards in agent/account_usage.py:439-494 when resolving the stale branch conflict.

Automated hermes-sweeper review.

@@ -488,6 +542,7 @@ export function StatusRule({
<Text color={barColor}>[{bar}]</Text> <Text color={barColor}>{pct != null ? `${pct}%` : ''}</Text>
</Text>
) : null}
<AccountLimitHud accountLimits={accountLimits} t={t} />
{showDuration ? (
<Text color={t.color.muted} wrap="truncate-end">
{' │ '}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please route this HUD through the same width budget as the other tail segments. essentialWidth/fits() above deliberately preserve the model and context on narrow terminals; this unbudgeted multi-window string can instead be clipped or displace those higher-priority fields. Add a narrow-width StatusRule render test with a long credential label and multiple windows.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
Refresh provider usage in background with single-flight stale caching keyed to the active credential. Add compact width-budgeted Ink rendering and regression coverage for credential rotation, failures, and narrow terminals.
@grig2277
grig2277 force-pushed the feat/cli-account-limit-status branch from 4aecc19 to 1b3d9b3 Compare July 12, 2026 20:36
@grig2277

Copy link
Copy Markdown
Author

Addressed the July 12 review in 1b3d9b34c872908fab6d61bec85af3b5b7df9420 and rebuilt the PR from current main.

Key fixes:

  • TUI hot paths are cache-only; provider usage refresh is background, stale-while-revalidate, and single-flight per active credential.
  • Cache identity and optional labels are bound to the active runtime token without storing token material in cache keys.
  • Ink quota rendering is one width-budgeted tail segment; narrow terminals keep status/model/context and omit the HUD whole.
  • Added regression coverage for cold miss, stale refresh, failures, credential rotation, long labels, multiple windows, and narrow/wide rendering.

Verification: 228 targeted Python tests and 102 targeted Ink tests passed; typecheck, build, Ruff, ESLint, and git diff --check also passed.

@teknium1, please re-review when convenient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show provider account limits in the TUI status bar

3 participants