Skip to content

fix(antigravity): read quota from selected WSL runtime - #31542

Closed
zzz163519 wants to merge 7 commits into
stablyai:mainfrom
zzz163519:fix/antigravity-wsl-usage
Closed

zzz163519 wants to merge 7 commits into
stablyai:mainfrom
zzz163519:fix/antigravity-wsl-usage

Conversation

@zzz163519

@zzz163519 zzz163519 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Read Antigravity quota from the selected Windows/WSL account runtime, and discard the previous runtime's quota when that selection changes.

What Changed

  • Use the existing WSL runner and cached guest environment to execute agy in the selected running distro; keep command output separate from login-shell environment probing.
  • Reuse the local account runtime policy for quota routing, including Kimi's existing target selection. Scope unsupported-command latches to the resolved runtime.
  • Clear old quota/cooldown state immediately on a runtime change and reject superseded results, including switching away and back.
  • Leave a hidden meter idle after startup/runtime changes; only a real fetch sets the fetching state.
  • Report unresolved WSL login-environment discovery as a transient read error, rather than claiming the CLI is absent. Successful default-PATH execution still works.

This update preserves the maintainer's shared-runner and runtime-isolation commits, including the maintainer's hidden-meter correction, with an additional fix for unresolved-environment classification.

Why

The status bar should report the selected account, without starting stopped distros or spending model quota. Existing WSL process and quota-service mechanisms supply the required execution and state boundaries.

Linked Issue

Fixes #31541

Related: #25847. Native account-vault recognition/switching remains outside this quota-routing change.

Visual Proof

N/A — background quota service change. A regression test reproduces a hidden WSL meter remaining fetching before the fix and idle afterward, with no Antigravity command invocation.

Testing

Final six-suite quota/runtime/WSL run: 110 tests passed on aa17b580cdbb (base 7a9abe48f3a5). Formatting, lint and diff checks passed for the full 15-file patch.

pnpm check:changed --maxWorkers=1 passed 21 non-test gates, including typechecks and selected ratchets, on the preceding candidate with identical production code. Its expanded related-test run was interrupted after 14 minutes and is not claimed complete. The final maintainer integration changes only a service test relative to that candidate; it retains the equivalent existing hidden-meter regression instead of adding a duplicate. Independent final hidden/ABA probes passed.

Linux/WSL2 validation used controlled subprocesses, isolated fixtures and runtime contracts with ORCA_BACKGROUND_LAUNCH=1. Native Windows/macOS, GUI/PTY interaction, mobile devices, live SSH and actual WSL account quota were not exercised. Full repository suites and release builds remain for CI.

AI Disclosure

Implemented and maintained with Codex; a separate fresh-context Codex audited the complete integrated update. Maintainer-authored changes are retained in the branch history.

Review

Fresh Codex: PASS on the complete integrated patch. Two confirmed issues (hidden-meter fetching state and uncertain PATH treated as absence) were fixed and independently re-tested. Ten final independent probes and three targeted contract tests passed; 108 repository tests passed on the preceding candidate. The review used the real shared WSL runner with isolated subprocess fixtures to verify startup stderr separation, CLI-only errors, stderr version output and sign-in cooldown, plus runtime/ABA isolation. No unresolved actionable findings.

The shared WSL runner retains its existing explicit WSLENV forwarding contract; this version does not claim a probe-specific host-environment allowlist. Its environment discovery may still run for a pre-aborted request, while the actual CLI execution honors cancellation. These shared-runner boundaries are unchanged by the follow-up fix.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer source copied.

Author

GitHub: @zzz163519. X/Twitter handle: not provided.

Checklist

  • Focused change; behavior, regression evidence and limitations described.
  • Cross-platform, remote, compatibility, performance and security reviewed.
  • Full repository lint/typecheck/test/release build (targeted checks above; remaining validation left to CI).

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6e1024ce-405a-46d9-920c-fbed583bad6b
Commits

Reviewing files that changed from the base of the PR and between f494a5f and c1f0867.

Files selected for processing: 2
  • src/main/rate-limits/service-antigravity-usage.test.ts
  • src/main/rate-limits/service/service-configuration.ts
Files skipped from review as they are similar to previous changes: 2
  • src/main/rate-limits/service/service-configuration.ts
  • src/main/rate-limits/service-antigravity-usage.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Walkthrough

Antigravity quota fetching now supports host and selected WSL runtimes. The rate-limit service captures runtime targets and generations during fetch cycles, rejects results from outdated generations, and refreshes after runtime target changes. Provider setup uses the local account usage target for both Antigravity fetching and Kimi home resolution. WSL process execution now forwards cancellation signals.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · previous review c1f08

The selected-runtime quota change is ready to merge after normal checks; no unresolved issue was identified in the reviewed changes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "fix(antigravity): read quota from selected WSL runtime" matches the main change. The PR routes Antigravity quota fetching to the selected running WSL distro instead of the host CLI, and the…
Linked Issues check Passed Direct issue [#31541] requires Antigravity quota polling to use the selected WSL runtime. The fetcher accepts a runtime target and runs both version and /usage through runWslProcess for that distr…
Out of Scope Changes check Passed The changes stay within [#31541]. The shared runtime-target resolver and key support Antigravity target selection and generation fences. The Kimi helper removal preserves the prior host-or-WSL target …
Description check Passed The pull request description is complete and follows the required template. It explains the change, rationale, linked issue, testing, limitations, AI usage, review outcome, cross-platform consideratio…
Full details: Title check

Explanation

The title "fix(antigravity): read quota from selected WSL runtime" matches the main change. The PR routes Antigravity quota fetching to the selected running WSL distro instead of the host CLI, and the title names the provider, the action, and the WSL target. It follows the conventional commit style and is specific enough for a teammate scanning history.

Full details: Linked Issues check

Explanation

Direct issue [#31541] requires Antigravity quota polling to use the selected WSL runtime. The fetcher accepts a runtime target and runs both version and /usage through runWslProcess for that distro. The host resolver runs only for host targets. The WSL path checks that the distro is running, does not start stopped distros, and treats exit 127 as command-not-found only for WSL. The version gate, background-updater environment, and per-runtime unsupported-usage latch remain in place. setAntigravityFetchTarget clears Antigravity state and increments its generation. The target synchronizer performs targeted Claude/Codex refreshes before the full refresh. The service applies only results with the current generation. The changed tests cover WSL routing, stopped distros, runtime latches, stale results, and refresh ordering. Native account recognition, vault management, and account switching from contextual issue [#25847] are not requirements for this PR.

Full details: Out of Scope Changes check

Explanation

The changes stay within [#31541]. The shared runtime-target resolver and key support Antigravity target selection and generation fences. The Kimi helper removal preserves the prior host-or-WSL target behavior through the shared resolver. WSL cancellation support is used by the Antigravity probe. Synchronizer, service-state, and service-cycle changes clear stale Antigravity data and prevent stale results after a runtime change. The added and updated tests verify these changes. No change implements the separate account-card, credential-vault, or account-switching work referenced by [#25847].

Full details: Description check

Explanation

The pull request description is complete and follows the required template. It explains the change, rationale, linked issue, testing, limitations, AI usage, review outcome, cross-platform considerations, and checklist status. The Visual Proof section correctly uses N/A for a background service change. The optional Notes section is not present, but its required concerns are addressed elsewhere.

Full details: Docstring Coverage

Explanation

Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 11 functions across 15 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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: 3


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 96f34ac5-045a-4282-86a7-f2ce7801b4ce
📥 Commits

Reviewing files that changed from the base of the PR and between fd8b2dc and d2d0babe333e676a118e856b9bf7efddf0d2c79d.

📒 Files selected for processing: 11
  • src/main/provider-account-services.ts
  • src/main/rate-limits/account-runtime-target-sync.test.ts
  • src/main/rate-limits/account-runtime-target-sync.ts
  • src/main/rate-limits/antigravity-usage-fetcher.ts
  • src/main/rate-limits/antigravity-usage-runtime.ts
  • src/main/rate-limits/antigravity-usage-wsl.test.ts
  • src/main/rate-limits/service-antigravity-usage.test.ts
  • src/main/rate-limits/service/service-configuration.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-state.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@zzz163519
zzz163519 force-pushed the fix/antigravity-wsl-usage branch from cdd15e3 to 6ed0400 Compare October 25, 2026 01:44
@sojiro-o

Copy link
Copy Markdown
Contributor

One stderr finding from #31741 still applies at 6ed0400. With the actual modules and fake shell/CLI fixtures, startup “Not authenticated” output was classified as missing credentials. Startup browser-sign-in text also triggered the new one-hour cooldown and could override a genuine CLI 503 error.

The WSL wrapper fences only stdout; both failure classification and browser-sign-in detection still read raw stderr. Merging CLI stderr inside the fence before clearing raw stderr preserved genuine errors and stderr-only version output, but lost the browser-sign-in cooldown because its detector reads only result.stderr. Please preserve that detection when isolating CLI diagnostics from shell startup output. Tests distinguishing startup noise from genuine CLI sign-in stderr would protect both behaviors. No real account or app was used.

# Conflicts:
#	src/main/rate-limits/antigravity-usage-fetcher.ts
#	src/main/rate-limits/service/service-full-cycle-application.ts
#	src/main/rate-limits/service/service-full-cycle-preparation.ts
…e shared WSL runner

Route the Antigravity usage probe through runWslProcess and the same local-account
usage target Kimi uses, key the unsupported-CLI latch per runtime, and drop a
previous runtime's reading instead of keeping it as stale. Replaces the PR's
parallel wsl.exe plumbing, fetch generation, invalidation and supersede states.

@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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 433690df-ef3d-4ba1-bb76-c01e71c01511
Commits

Reviewing files that changed from the base of the PR and between 6ed0400 and f494a5f.

Files selected for processing: 15
  • src/main/kimi/kimi-runtime-home.test.ts
  • src/main/kimi/kimi-runtime-home.ts
  • src/main/provider-account-services.ts
  • src/main/rate-limits/account-runtime-target-sync.test.ts
  • src/main/rate-limits/account-runtime-target-sync.ts
  • src/main/rate-limits/antigravity-usage-fetcher.test.ts
  • src/main/rate-limits/antigravity-usage-fetcher.ts
  • src/main/rate-limits/service-antigravity-usage.test.ts
  • src/main/rate-limits/service/service-configuration.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-state.ts
  • src/main/wsl/wsl-runner.ts
  • src/shared/local-account-runtime.test.ts
  • src/shared/local-account-runtime.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

nwparker pushed a commit that referenced this pull request Nov 6, 2026
When Orca's local-account runtime is WSL on Windows, the Antigravity usage
meter still ran the host `agy`, so it showed the wrong account or "not
installed". Route the probe through runWslProcess for the selected distro
(never booting a stopped one), key the unsupported-CLI latch per runtime,
tag readings with the runtime as provenance, and drop another runtime's
last reading instead of keeping it as stale. Settings changes retarget
the fetcher and reread usage.

A WSL target without a distro now names the default through
resolveWslDefaultDistro (registry DefaultDistribution) rather than
listWslDistrosAsync()[0], which skips docker-desktop, falls back to
registry order, and caches the list for the process lifetime.

Ported from #31542 onto current main: reuses main's antigravity fetch
generation (#34165) instead of adding a second one, follows moved WSL and
provider-account-services paths, and keeps only the tests that cover the
new behavior.

Co-authored-by: Jinwoo-H <[email protected]>
nwparker added a commit that referenced this pull request Nov 6, 2026
When Orca's local-account runtime is WSL on Windows, the Antigravity usage
meter still ran the host `agy`, so it showed the wrong account or "not
installed". Route the probe through runWslProcess for the selected distro
(never booting a stopped one), key the unsupported-CLI latch per runtime,
tag readings with the runtime as provenance, and drop another runtime's
last reading instead of keeping it as stale. Settings changes retarget
the fetcher and reread usage.

A WSL target without a distro now names the default through
resolveWslDefaultDistro (registry DefaultDistribution) rather than
listWslDistrosAsync()[0], which skips docker-desktop, falls back to
registry order, and caches the list for the process lifetime.

Ported from #31542 onto current main: reuses main's antigravity fetch
generation (#34165) instead of adding a second one, follows moved WSL and
provider-account-services paths, and keeps only the tests that cover the
new behavior.

Co-authored-by: CAVIN <[email protected]>
Co-authored-by: Jinwoo-H <[email protected]>
@nwparker

nwparker commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Thank you @zzz163519! This landed in #38985, which ports your fix onto current main with you as author. Closing as superseded.

@nwparker nwparker closed this Nov 7, 2026
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.

Antigravity quota polling ignores the selected WSL account runtime

4 participants