Skip to content

feat(usage): show Kiro subscription credits - #14001

Open
guanbear wants to merge 21 commits into
stablyai:mainfrom
guanbear:codex/kiro-usage-provider
Open

guanbear wants to merge 21 commits into
stablyai:mainfrom
guanbear:codex/kiro-usage-provider

Conversation

@guanbear

@guanbear guanbear commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca can already launch Kiro, but it cannot show how much of the current Kiro subscription credit allowance has been used. This adds a Kiro usage meter to the status bar using Kiro CLI's own local /usage command.

What Changed

  • Added a bounded Kiro usage fetcher that runs kiro-cli chat /usage --no-interactive --wrap never with no shell and a 20-second timeout.
  • Parses the plan name, covered credits, usage percentage, and monthly reset date from ANSI-formatted CLI output. Date-only resets remain display metadata instead of being presented as a fabricated UTC-midnight countdown.
  • Added Kiro to the shared rate-limit state, polling/stale-state handling, RPC schema, renderer store, status bar, provider menu, and settings search.
  • Uses Q as Kiro's compact narrow-layout badge so it remains distinct from Kimi's K.
  • Added a one-shot migration that enables the Kiro status item for existing profiles while preserving later user choices.
  • Added focused parser, service, state, migration, visibility, and agent-gating coverage.

Why

Kiro is already a first-class Orca agent, and the official CLI exposes subscription usage locally through /usage. Surfacing that existing information alongside Claude, Codex, Gemini, Grok, and other providers makes Orca's usage bar useful to Kiro users without copying credentials or depending on a private HTTP API.

Linked Issue

Related to #9559. This PR surfaces local subscription usage; it does not add Kiro account management.

Visual Proof

Both screenshots use a fresh isolated profile. The before image is upstream main at the earlier 3246b73a baseline; the after image is the PR at the same visual baseline. The current branch incorporates main at c43ac3fc3c6c, including the newly merged ZCode usage meter. The screenshots document the earlier visual baseline; the October 12 update was verified with product-code typechecks and focused tests, with full-check limitations documented below.

Before After
Appearance settings before Kiro usage Appearance settings with Kiro usage

The after view adds the Kiro usage toggle alongside Orca's existing provider meters. Compact layouts use Q so Kiro remains distinct from Kimi's K.

How To Test

  1. Install and sign in to the official kiro-cli.
  2. Confirm kiro-cli chat '/usage' --no-interactive --wrap never returns the Estimated Usage view.
  3. Launch Orca and enable Kiro Usage in the status-bar menu if it is hidden.
  4. Confirm the meter shows the subscription plan, percentage used, and reset date.
  5. Narrow the window and confirm Kiro uses Q while Kimi uses K.
  6. Temporarily remove kiro-cli from PATH and confirm the provider degrades to unavailable without exposing a local path or subprocess error.

Validation

Current update — 2026-10-12

Merged upstream main c43ac3fc3c6c and preserved the newly merged Claude usage messages and Kiro status/history/resume support. Cherry-picked @w-felipe360's 9cc7e7c1a6 (original authorship retained): local detection honors a valid KIRO_CLI_PATH, truncated usage output is killed and rejected, and non-ISO reset descriptions remain display text with no invented countdown. Adapted the fetcher and test mock to main's @orca/process-host boundary.

  • 4 fetcher/detection/lifecycle test files: 63 passed.
  • 3 tooltip/settings/preference test files: 118 passed.
  • All seven changed-code quality gates passed: 0 new findings across 42 changed source files.
  • TypeScript 7.0.2 Node, CLI and Web product-code checks passed using the repository configs with test-source files excluded. Full test-inclusive checks did not complete on this desktop; the TypeScript 6.0.3 fallback reached its 2 GiB heap limit. These are not full-suite typecheck passes.
  • A broad concurrent test rerun hit renderer timeouts; it is not counted as a passing full run. The final scoped runs are listed above.
  • Spec and Standards reviews: 0 remaining actionable findings (Codex reviews, not cross-model reviews).
  • Real local Kiro CLI 2.29.1: /usage exited 0; its credits and 2026-11-01 reset description parsed successfully. No account details are published.
  • No new rendered UI run for this update. The screenshots above show the earlier baseline.

Earlier verification — 2026-10-09

Current update: upstream main 820277c20778, 2026-10-09.

  • Real installed Kiro CLI 2.28.0 /usage succeeded and the current parser returned status ok. No account quota or credentials are included here.
  • Current-head focused run: 842 tests passed, one platform-specific test skipped, across 64 files covering the rate-limit service and status-bar reset/tooltip paths. The newly merged Cursor/OpenCode Go suites now mock Kiro consistently with the shared harness.
  • Node, CLI, and renderer TypeScript checks pass.
  • All seven changed-code quality checks pass with zero new findings across 40 source files. Scoped pre-commit oxlint, React Doctor lint rules, formatting, and the PR diff whitespace check pass.
  • Spec and Standards reviews of this update have no remaining actionable findings.
  • The screenshots above document the earlier baseline; no new current-head rendered screenshots are claimed.

Security And Privacy

  • Uses the shared runProcess utility with a fixed argument list and no shell, cancellation support, a 20-second timeout, and a 1 MiB output limit. Nonzero exits and timed-out/signalled processes are rejected even when stdout looks valid.
  • Does not read, copy, persist, or log Kiro credentials.
  • Does not log raw CLI failures or resolved executable paths.
  • Parses only the bounded output of Kiro's local usage command.
  • Supports KIRO_CLI_PATH and known install locations while preserving the same no-shell execution path.

Review

  • Security: reviewed the fixed-argument, no-shell CLI execution path and bounded output handling.
  • Compatibility: unavailable or signed-out Kiro CLI states degrade without affecting other providers.
  • Performance: refreshes use the existing provider polling/stale-state lifecycle and a 20-second subprocess timeout.
  • UX: the compact Q badge remains distinct from Kimi's K; the full provider menu and tooltip still say Kiro.

AI Disclosure

Implemented and validated with OpenAI Codex. This October update received separate Spec and Standards reviews using Codex; these are not cross-model reviews.

Checklist

  • Focused implementation with no credential persistence or private API dependency.
  • Existing settings and migration behavior remain backward compatible.
  • Historical screenshots and the current UI verification limitation are documented.
  • Self-reviewed for correctness, security, performance, and failure behavior.
  • Focused tests, changed-file lint, and diff checks pass on current main.

Author

@guanbear
guanbear requested a review from brennanb2025 as a code owner August 12, 2026 08:01
@guanbear

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 27cc3dbb-84f4-4396-9dee-a5b92efc644f


📥 Commits

Reviewing files that changed from the base of the PR and between a3b472d and 0577bb2d9a8cc1ecf42bfe6b797fbf096359ace1.


📒 Files selected for processing (30)
  • src/main/codex-accounts/service.test.ts
  • src/main/rate-limits/kiro-usage-fetcher.test.ts
  • src/main/rate-limits/kiro-usage-fetcher.ts
  • src/main/rate-limits/service.test.ts
  • src/main/rate-limits/service.ts
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/renderer/src/components/settings/appearance-status-bar-grok-toggle-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-kiro-toggle-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-search.ts
  • src/renderer/src/components/stats/GrokUsagePane.test.tsx
  • src/renderer/src/components/status-bar/StatusBar.tsx
  • src/renderer/src/components/status-bar/status-bar-agent-gating.test.ts
  • src/renderer/src/components/status-bar/status-bar-agent-gating.ts
  • src/renderer/src/components/status-bar/status-bar-provider-letter.test.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.ts
  • src/renderer/src/components/status-bar/tooltip.test.ts
  • src/renderer/src/components/status-bar/tooltip.tsx
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/renderer/src/components/status-bar/usage-provider-settings-target.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/store/slices/rate-limits.ts
  • src/renderer/src/store/slices/ui.test.ts
  • src/renderer/src/store/slices/ui.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/persisted-ui-state-types.ts
  • src/shared/rate-limit-types.test.ts
  • src/shared/rate-limit-types.ts
  • src/shared/status-bar-defaults.ts
  • src/shared/ui-chrome-types.ts

🚧 Files skipped from review as they are similar to previous changes (27)
  • src/main/codex-accounts/service.test.ts
  • src/shared/ui-chrome-types.ts
  • src/shared/rate-limit-types.test.ts
  • src/renderer/src/components/status-bar/usage-provider-settings-target.ts
  • src/shared/status-bar-defaults.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/store/slices/ui.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.ts
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/shared/persisted-ui-state-types.ts
  • src/shared/rate-limit-types.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/renderer/src/components/status-bar/status-bar-provider-letter.test.ts
  • src/renderer/src/store/slices/rate-limits.ts
  • src/renderer/src/components/status-bar/status-bar-agent-gating.test.ts
  • src/renderer/src/store/slices/ui.test.ts
  • src/main/rate-limits/service.test.ts
  • src/renderer/src/components/settings/appearance-status-bar-kiro-toggle-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-search.ts
  • src/renderer/src/components/status-bar/tooltip.test.ts
  • src/renderer/src/components/status-bar/status-bar-agent-gating.ts
  • src/renderer/src/components/stats/GrokUsagePane.test.tsx
  • src/renderer/src/components/status-bar/StatusBar.tsx
  • src/renderer/src/components/status-bar/tooltip.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/main/rate-limits/service.ts


📝 Walkthrough
📝 Walkthrough

Walkthrough

Adds Kiro as a supported rate-limit provider. The change parses and fetches usage data from the Kiro CLI, integrates results into refresh and failure handling, and exposes Kiro usage in the status bar. It adds provider visibility gating, reset labels, icons, context-menu controls, settings search, localization, persisted default-item migration, shared state fields, and test coverage.


Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 17.65% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly and concisely describes the main change: displaying Kiro subscription credit usage.
Description check Passed The description is complete and relevant. It covers the user-facing change, implementation, rationale, linked issue, visual proof, testing steps, validation results, security, compatibility, performan…

  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d30d2c91-ccfa-442c-bb2f-c68bdab57d2b

📥 Commits

Reviewing files that changed from the base of the PR and between 36d45af and bb39fddf8673f01e974ba1723570586418e2bbc4.

📒 Files selected for processing (26)
  • src/main/codex-accounts/service.test.ts
  • src/main/rate-limits/kiro-usage-fetcher.test.ts
  • src/main/rate-limits/kiro-usage-fetcher.ts
  • src/main/rate-limits/service.test.ts
  • src/main/rate-limits/service.ts
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/renderer/src/components/settings/appearance-status-bar-kiro-toggle-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-search.ts
  • src/renderer/src/components/stats/GrokUsagePane.test.tsx
  • src/renderer/src/components/status-bar/StatusBar.tsx
  • src/renderer/src/components/status-bar/status-bar-agent-gating.test.ts
  • src/renderer/src/components/status-bar/status-bar-agent-gating.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.ts
  • src/renderer/src/components/status-bar/tooltip.tsx
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/renderer/src/components/status-bar/usage-provider-settings-target.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/store/slices/rate-limits.ts
  • src/renderer/src/store/slices/ui.test.ts
  • src/renderer/src/store/slices/ui.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/rate-limit-types.test.ts
  • src/shared/rate-limit-types.ts
  • src/shared/status-bar-defaults.ts
  • src/shared/types.ts

Comment thread src/renderer/src/components/status-bar/StatusBar.tsx Outdated
@guanbear
guanbear force-pushed the codex/kiro-usage-provider branch 2 times, most recently from 8b18923 to 55daad2 Compare August 12, 2026 15:34
@guanbear

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@guanbear

Copy link
Copy Markdown
Contributor Author

@coderabbitai summary

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Summary regeneration triggered.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e202022-5caa-433e-87f2-a3f0047701d9

📥 Commits

Reviewing files that changed from the base of the PR and between 3246b73 and 8b580a3c86981b47be5e9fde27da4e5d57834ce6.

📒 Files selected for processing (28)
  • src/main/codex-accounts/service.test.ts
  • src/main/rate-limits/kiro-usage-fetcher.test.ts
  • src/main/rate-limits/kiro-usage-fetcher.ts
  • src/main/rate-limits/service.test.ts
  • src/main/rate-limits/service.ts
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/renderer/src/components/settings/appearance-status-bar-kiro-toggle-search.ts
  • src/renderer/src/components/settings/appearance-status-bar-search.ts
  • src/renderer/src/components/stats/GrokUsagePane.test.tsx
  • src/renderer/src/components/status-bar/StatusBar.tsx
  • src/renderer/src/components/status-bar/status-bar-agent-gating.test.ts
  • src/renderer/src/components/status-bar/status-bar-agent-gating.ts
  • src/renderer/src/components/status-bar/status-bar-provider-letter.test.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.ts
  • src/renderer/src/components/status-bar/tooltip.test.ts
  • src/renderer/src/components/status-bar/tooltip.tsx
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/renderer/src/components/status-bar/usage-provider-settings-target.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/store/slices/rate-limits.ts
  • src/renderer/src/store/slices/ui.test.ts
  • src/renderer/src/store/slices/ui.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/rate-limit-types.test.ts
  • src/shared/rate-limit-types.ts
  • src/shared/status-bar-defaults.ts
  • src/shared/types.ts
🚧 Files skipped from review as they are similar to previous changes (25)
  • src/shared/rate-limit-types.ts
  • src/shared/status-bar-defaults.ts
  • src/renderer/src/components/stats/GrokUsagePane.test.tsx
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts
  • src/renderer/src/components/status-bar/usage-provider-settings-target.ts
  • src/renderer/src/components/status-bar/status-bar-provider-letter.test.ts
  • src/shared/types.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/renderer/src/store/slices/rate-limits.ts
  • src/shared/rate-limit-types.test.ts
  • src/renderer/src/store/slices/ui.ts
  • src/renderer/src/components/settings/appearance-status-bar-kiro-toggle-search.ts
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/renderer/src/i18n/locales/en.json
  • src/main/rate-limits/kiro-usage-fetcher.test.ts
  • src/main/codex-accounts/service.test.ts
  • src/renderer/src/store/slices/ui.test.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.ts
  • src/renderer/src/components/settings/appearance-status-bar-search.ts
  • src/renderer/src/components/status-bar/status-bar-agent-gating.ts
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/renderer/src/components/status-bar/status-bar-agent-gating.test.ts
  • src/main/rate-limits/service.test.ts
  • src/main/rate-limits/service.ts
  • src/renderer/src/components/status-bar/StatusBar.tsx

Comment thread src/main/rate-limits/kiro-usage-fetcher.ts Outdated
Comment thread src/renderer/src/components/status-bar/tooltip.tsx Outdated
@guanbear
guanbear force-pushed the codex/kiro-usage-provider branch from 8b580a3 to 3db3907 Compare August 14, 2026 03:47
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@guanbear

Copy link
Copy Markdown
Contributor Author

@brennanb2025 gentle ping when you have a chance — the two CodeRabbit threads are addressed (3a6ab81e for the non-date reset labels, ad228dc3 for routing .cmd/.bat shims through cmd.exe), and the touched suites (Kiro parser/service/migration/visibility + status-bar tooltip) pass locally with typecheck clean. CI doesn't run from my fork, so checks would need a trigger from your side. Happy to rebase or adjust anything to make review easier.

@guanbear

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (e12b22c4) and aligned the provider search catalog with the current max-lines/localization gates.

Fresh validation:

  • 10 affected Vitest files: 399 passed
  • Node TypeScript check passed
  • full pnpm run lint passed, including type-aware audits, reliability gates, max-lines ratchet, and localization checks
  • git diff --check passed

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

@guanbear, I will review the rebased changes and the current diff.


🧠 Learnings used
Learnt from: slashdevcorpse
Repo: stablyai/orca PR: 0
File: :0-0
Timestamp: 2026-07-16T19:10:55.339Z
Learning: For PR `#9052`, the `/* oxlint-disable max-lines */` suppression at Line 1 of the affected file is grandfathered and byte-identical to `origin/main`; the PR changes only Lines 4398–4403. `pnpm lint` and `check:max-lines-ratchet` pass, so this PR does not introduce a new max-lines bypass.

Learnt from: Devin345458
Repo: stablyai/orca PR: 5522
File: src/renderer/src/i18n/locales/ja.json:596-597
Timestamp: 2026-06-16T21:44:14.183Z
Learning: In the `stablyai/orca` repository, locale files use an English-fallback localization convention for new strings: new strings are auto-keyed using SHA1 of file path plus source text, `pnpm run sync:localization-catalog` propagates the English source text into all locale files, and human translations for es/ja/ko/zh are handled in a separate localization pass rather than inline in feature PRs. Review localization diffs for catalog parity rather than requiring immediate translation of newly added strings.

Learnt from: yoyoys
Repo: stablyai/orca PR: 12201
File: src/renderer/src/i18n/locales/ja.json:9206-9210
Timestamp: 2026-08-03T05:26:30.599Z
Learning: In stablyai/orca, when `sync:localization-catalog` adds new entries to `src/renderer/src/i18n/locales/*.json`, `verify:localization-catalog` enforces locale catalog parity. Do not request removal of English fallback entries from non-English locale catalogs solely because they are untranslated when the synchronization workflow generated them; removing them fails the localization validation. The translation pipeline replaces these entries later.

Learnt from: dcieslak19973
Repo: stablyai/orca PR: 12111
File: src/renderer/src/i18n/locales/en.json:8403-8404
Timestamp: 2026-08-02T15:30:42.805Z
Learning: In stablyai/orca, when new i18n keys exist only in `src/renderer/src/i18n/locales/en.json` and are absent from `es.json`, `ja.json`, `ko.json`, or `zh.json`, do not flag this as a localization gap requiring the key to be copied into the non-English catalogs. The repo's `locale-english-regression.test.ts` documents the rationale: a missing key falls through to the English default inline in `translate()`, which is visibly distinct to tooling and translators from a genuinely untranslated key. Copying an English value into a non-English catalog (e.g., via `pnpm sync:localization-catalog`, which by design updates `en.json` only) would instead create an entry that looks translated but is not, indistinguishable from the regression that test file guards against. Missing keys in non-English locales are expected and acceptable; do not request adding English-fallback values to `es/ja/ko/zh.json` to achieve key parity.
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@guanbear
guanbear force-pushed the codex/kiro-usage-provider branch from 0577bb2 to b0732f2 Compare August 16, 2026 11:25
@guanbear

Copy link
Copy Markdown
Contributor Author

Rebased onto current main, migrated Kiro provider mocks/UI migration assertions to the split test layout, and fixed the settings helper import exposed by the current shared-type split. Validation: 153 affected tests passed; Node and Web typechecks passed; changed-file oxlint and diff check passed. Fork workflow runs are awaiting maintainer approval.

@nwparker nwparker removed the P2 label Aug 19, 2026
@guanbear
guanbear force-pushed the codex/kiro-usage-provider branch from b0732f2 to 1ceb70a Compare August 24, 2026 02:35
@guanbear

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (1ceb70ac) to clear the conflicts from #15876: kept the upstream codexFetchGated / resolveCodexHome structure and re-added Kiro on top, unioned the i18n keys, and declared the Kiro fetcher mock in the new Antigravity service test. Full rate-limits + status-bar suites pass locally (726 tests) with typecheck clean.

formatRateLimitResetLabel returned null for human-readable
resetDescription values such as "Thu" or "2:30 PM" because only ISO
dates were recognized. Return non-date descriptions unchanged so the
status bar keeps a valid reset label.
execFile cannot launch configured .cmd/.bat paths directly on Windows.
Route the Kiro usage command through getSpawnArgsForWindows like the
other usage fetchers; native binaries keep the direct execFile path.
The Antigravity coverage landed upstream after this branch last
rebased. Its test file predates the Kiro provider, so the shared
resetRateLimitProviderMocks harness now fails on the unmocked
fetchKiroRateLimits import. Declare the same vi.mock the other service
test files use.
Upstream now feeds a ticking `now` into ProviderRateLimitWindowSection;
`formatRateLimitResetLabel` gains an optional `now` (default Date.now())
so the label keeps re-rendering on the clock without inventing reset times.
Signed-off-by: guanbear <123guan@gmail.com>
@guanbear
guanbear force-pushed the codex/kiro-usage-provider branch from ae77061 to b28b50e Compare September 28, 2026 02:14
@guanbear

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (0b2dd0a99b) and resolved the Cursor/Kiro overlap in provider state, polling, status-bar rendering, and one-shot default migration. Kiro polling now applies independently from the Grok/Cursor result pair, so a slow Kiro CLI does not delay those providers or the main batch. I also updated the moved OpenCode Go test mock and preserved both Cursor and Kiro paths. Validation on Node 24: typecheck passed; 7 affected suites / 150 tests passed; changed-file oxlint, formatting, and diff checks passed. GitHub now reports this PR mergeable. Please re-review when convenient.

# Conflicts:
#	src/main/rate-limits/rate-limit-service-test-harness.ts
#	src/main/rate-limits/service-account-target-selection.test.ts
#	src/main/rate-limits/service-inactive-account-previews.test.ts
#	src/main/rate-limits/service-live-claude-usage.test.ts
#	src/main/rate-limits/service-minimax-usage.test.ts
#	src/main/rate-limits/service-refresh-orchestration.test.ts
#	src/main/rate-limits/service-window-activation.test.ts
#	src/main/rate-limits/service/service-full-cycle-application.ts
#	src/main/rate-limits/service/service-full-cycle-preparation.ts
#	src/main/rate-limits/service/service-polling.ts
#	src/main/rate-limits/service/service-state.ts
#	src/main/rate-limits/service/service-types.ts
#	src/renderer/src/components/settings/appearance-status-bar-search.ts
#	src/renderer/src/components/status-bar/StatusBarProviderSegment.tsx
#	src/renderer/src/components/status-bar/StatusBarVisibilityMenu.tsx
#	src/renderer/src/components/status-bar/status-bar-agent-gating.test.ts
#	src/renderer/src/components/status-bar/status-bar-agent-gating.ts
#	src/renderer/src/components/status-bar/status-bar-provider-visibility.ts
#	src/renderer/src/components/status-bar/usage-provider-settings-target.ts
#	src/renderer/src/components/status-bar/use-status-bar-controller.ts
#	src/renderer/src/i18n/locales/en.json
#	src/renderer/src/store/slices/ui-hydration-workspace-preferences.test.ts
#	src/renderer/src/store/slices/ui/ui-slice-hydration-status-bar-items.ts
#	src/shared/persisted-ui-state-types.ts
#	src/shared/rate-limit-state-factory.ts
#	src/shared/rate-limit-types.test.ts
#	src/shared/rate-limit-types.ts
#	src/shared/rpc-contract/client-ui-params.ts
#	src/shared/status-bar-defaults.ts
#	src/shared/ui-chrome-types.ts
@guanbear

Copy link
Copy Markdown
Contributor Author

Thanks for your patience. I brought this branch up to current main (3dd7d29455) and resolved the Kiro/ZCode overlap in the rate-limit cycle, status-bar visibility, settings, and one-shot defaults while preserving both providers. I also replaced the remaining Kiro type assertions to satisfy the current changed-code gate. GitHub now reports the PR as mergeable, and I updated the description's stale validation notes.

On the current head, Node 24 pnpm tc, full pnpm lint, 13 affected suites / 195 tests, the final 7 Kiro fetcher tests, changed-code quality (zero new findings), and the PR diff check pass locally. The new Actions run is awaiting maintainer approval. I'd appreciate approval when convenient; I'll review the CI results once it runs. Thank you.

# Conflicts:
#	src/renderer/src/components/status-bar/StatusBarProviderSegment.tsx
#	src/renderer/src/i18n/locales/en.json
@guanbear

guanbear commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for your patience. I merged the latest main (a134d1259e) into this branch and resolved the status-bar and localization overlap while keeping both upstream's overflow chip and Kiro's Q badge. GitHub now reports the PR as mergeable.

On this head, pnpm tc, 61 focused test files (422 tests), the pre-commit lint/format checks, and changed-code quality (zero new findings) pass locally. I updated the PR description to distinguish these checks from earlier validation. The new PR Checks run is marked action_required and needs maintainer approval before it can run. I'd appreciate approval when convenient; I'll check the results afterward. Thank you.

@guanbear

guanbear commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for your review and patience. I have updated the branch against main 952898b8b95c and preserved the current ZCode/Antigravity refresh guards, account-settings destination, and provider visibility behavior. Kiro remains independent of slow sibling providers.

The fetcher now uses the shared runProcess utility, with cancellation, a 20-second timeout and 1 MiB output bound. Nonzero exits, timeouts and signals do not accept valid-looking stdout. Date-only resets remain display metadata.

The real Kiro CLI 2.28.0 usage output parsed successfully. All three TypeScript projects, seven changed-code quality checks, pre-commit lint/format checks and the diff check pass. The two status-bar suites pass all 64 tests; the PR description records the broad run and successful reruns of its eight initially failing cases accurately. Existing screenshots are marked as an earlier visual baseline.

Could you please approve the fork workflow run when convenient? I appreciate your guidance.

@w-felipe360

w-felipe360 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Correction to my earlier note: #14001 stays the home for the Kiro usage work. I rebuilt #26639 on top of this PR's current head (b9af9b94), so it now only adds Kiro agent status (pets, sidebar, completion notifications) and Kiro conversations in Agent session history. Its single commit touches no usage/rate-limit/status-bar files.

Please disregard the suggestion to close this one. #26639 should land after it. @guanbear thanks for keeping this up to date.

w-felipe360 added a commit to w-felipe360/orca that referenced this pull request Oct 8, 2026
Carries forward the fixes from stablyai#26390 that the stablyai#14001 head does not have:

- Local agent detection validates a configured KIRO_CLI_PATH with the same
  resolution the usage fetcher uses, so a Kiro CLI outside PATH keeps its
  meter and menu toggle; an invalid configured command is not detected,
  and WSL detection is unaffected.
- The usage command is killed at the 1 MiB output cap and truncated output
  is rejected instead of being parsed as a valid total.
- Reset descriptions that are not ISO dates (for example "01/01") are kept
  as display text instead of failing to parse.
@guanbear

guanbear commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @w-felipe360 for clarifying the scope and keeping #26639 separate. I have updated this PR against current main (820277c20778) and resolved the localization conflict, preserving the upstream removal of the old Claude usage copy. The new Cursor/OpenCode Go service suites now include the Kiro mock.

Validation on this update: 842 focused tests passed (one platform-specific skip); Node, CLI, and renderer typechecks and the changed-code quality gates passed. The screenshots in the description remain explicitly labeled as the earlier visual baseline.

This PR remains the home for Kiro usage. #26639 can follow it; its stacked base may need refreshing to the new head. Thank you!

@w-felipe360

w-felipe360 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Hi @guanbear, quick update. I moved the Kiro agent status and session history work into its own PR on top of main: #26695 (fixes #26694). It doesn't touch any usage files and doesn't depend on this PR, so I closed #26639.

That leaves three usage fixes from my old #26390 that this branch still doesn't have. They fit better here, next to the fetcher, so feel free to take them as they are:

  1. A Kiro CLI outside PATH, set through KIRO_CLI_PATH, isn't detected, so its usage meter and menu toggle disappear. The fix checks the configured command locally with the same resolution the fetcher uses. A broken configured command stays undetected, and WSL detection doesn't change.
  2. /usage output is capped at 1 MiB, but a cut-off read can still parse as a real total. Killing the process at the cap and rejecting outputTruncated avoids that.
  3. Only YYYY-MM-DD reset dates parse today, so something like 01/01 shows a parse error. The fix keeps whatever description Kiro prints as display text, and resetsAt stays null.
--- a/src/main/rate-limits/kiro-usage-fetcher.ts
+++ b/src/main/rate-limits/kiro-usage-fetcher.ts
@@ const runCommand: CommandRunner = async (command, args, signal) => {
     maxOutputBytes: 1024 * 1024,
+    killOnOutputLimit: true,
     signal
   })
-  if (result.code !== 0 || result.timedOut || result.signal !== null) {
+  if (result.code !== 0 || result.timedOut || result.signal || result.outputTruncated) {
     throw new Error('Kiro usage command failed')
@@ export function parseKiroUsageOutput(output: string): ProviderRateLimits {
-  const header = readable.match(
-    /Estimated Usage\s*\|\s*resets on (\d{4}-\d{2}-\d{2})\s*\|\s*([^\n]+)/i
-  )
+  const header = readable.match(/Estimated Usage\s*\|\s*resets on\s+([^|\n]+?)\s*\|\s*([^\n]+)/i)
+  const resetDescription = header?.[1].trim()
@@
-  if (!header || usedPercent === null || !Number.isFinite(usedPercent)) {
+  if (!header || !resetDescription || usedPercent === null || !Number.isFinite(usedPercent)) {
@@
-      resetDescription: header[1]
+      resetDescription
--- a/src/main/preflight/agent-detection.ts
+++ b/src/main/preflight/agent-detection.ts
+import { resolveKiroCommand } from '../rate-limits/kiro-usage-fetcher'
@@ export async function detectInstalledAgents(context?: PreflightRuntimeContext): Promise<string[]> {
+  const wslTarget = getPreflightWslTarget(context)
   ...
-  return resolveDetectedTuiAgentIds(
+  const detected = resolveDetectedTuiAgentIds(
     ...
   )
+  if (!wslTarget && process.env.KIRO_CLI_PATH?.trim()) {
+    const kiro = await findRunnableLocalCommand(resolveKiroCommand())
+    return kiro.status === 'available'
+      ? [...new Set([...detected, 'kiro'])]
+      : detected.filter((id) => id !== 'kiro')
+  }
+  return detected

If you'd rather cherry-pick, the full commit with tests is w-felipe360/orca@9cc7e7c1a6. It covers the non-ISO reset, the output-limit kill, truncated output and three KIRO_CLI_PATH cases. Thanks for the usage work!

guanbear and others added 3 commits October 12, 2026 16:41
Carries forward the fixes from stablyai#26390 that the stablyai#14001 head does not have:

- Local agent detection validates a configured KIRO_CLI_PATH with the same
  resolution the usage fetcher uses, so a Kiro CLI outside PATH keeps its
  meter and menu toggle; an invalid configured command is not detected,
  and WSL detection is unaffected.
- The usage command is killed at the 1 MiB output cap and truncated output
  is rejected instead of being parsed as a valid total.
- Reset descriptions that are not ISO dates (for example "01/01") are kept
  as display text instead of failing to parse.
@guanbear

Copy link
Copy Markdown
Contributor Author

Thanks @w-felipe360 for separating the status/history work and sharing the usage fixes. I cherry-picked 9cc7e7c1a6 with your authorship retained, merged main at c43ac3fc3, and adapted the process-host import to the current main boundary. The configured-path detection, truncated-output rejection and non-ISO reset text now have regression coverage.

The final scoped runs pass: 63 fetcher/detection/lifecycle tests and 118 tooltip/settings/preference tests. All seven changed-code quality gates and TypeScript 7 Node/CLI/Web product-code checks pass. Full test-inclusive typechecks could not complete on this desktop, and a broad concurrent test rerun hit renderer timeouts; those limitations are recorded in the description. Real local Kiro 2.29.1 /usage exited 0 and its credits/reset text parsed successfully. No new UI recording is claimed.

The usage change remains separate from the merged #26695 status/history/resume feature. Could a maintainer approve the fork CI checks for this updated head when convenient? Thank you.

@w-felipe360

Copy link
Copy Markdown
Contributor

I tested this head (399748b083) on Windows 11 with Kiro CLI 2.28.0 and a real Kiro subscription. It works.

Before (merge base c43ac3fc3) After (this PR)
Status bar without Kiro usage Status bar with Kiro usage

Both builds ran from build:electron-vite in a hidden window with a fresh profile. The kiro-cli launcher wasn't on PATH in that shell, so I pointed KIRO_CLI_PATH at the CLI executable. That also exercised the configured-path detection. The refresh returned kiro with status ok and 75.5% of monthly credits, and the bar shows 76% 30d next to Claude, Codex and Cursor. On the merge base the Kiro meter is absent and the other meters are unchanged. Full window.

The checks you couldn't finish locally:

  • Full pnpm tc, test sources included, passes.
  • src/main/rate-limits/, src/renderer/src/components/status-bar/ and the other test files this PR touches: 1437 passed, 22 failed. The same 22 tests fail on the merge base without this PR, so they come from this machine and not from the change. The causes I saw were currency formatted for a pt-BR locale, backslash paths, and WSL target selection. No test fails only on this branch.

I didn't check the tooltip, the narrow Q badge, or what happens when the CLI is missing.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants