Skip to content

fix(cli): honor --json on billing manage + logout, self-revoke on logout (AIT-164, AIT-153) - #16

Merged
ord669 merged 1 commit into
mainfrom
ait-164-json-contract-no-side-effects
Jul 12, 2026
Merged

fix(cli): honor --json on billing manage + logout, self-revoke on logout (AIT-164, AIT-153)#16
ord669 merged 1 commit into
mainfrom
ait-164-json-contract-no-side-effects

Conversation

@ord669

@ord669 ord669 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Problem (AIT-164)

The --json contract is a machine interface: emit valid JSON and take no
interactive side effect. Two commands broke it:

  • billing manage --json printed human text (Opening your Billing page...)
    AND opened a browser.
  • logout --json printed ✓ Logged out instead of JSON.

billing upgrade --json was already correct (guards on --json) and is the
reference pattern.

Changes

  • billing manage --json now emits { "billingUrl": "..." } and opens no
    browser.
  • logout --json now emits { "status": "logged_out", "revoked": <bool> }
    instead of the human line.
  • AIT-153 (CLI half): logout now best-effort revokes an agent credential
    server-side (DELETE /agent/credentials/:publicId, the backend's
    agent self-revoke route) before clearing local credentials, so a leaked/idle
    API key can't keep being used after logout. Best-effort: an offline host or
    an already-revoked key still clears local credentials. WorkOS user sessions
    carry no CLI-side revoke and are unchanged.

Sweep

Audited every browser-open / interactive side effect: channels connect and
billing upgrade already guard --json; login's browser open is the auth
handshake itself (inherently interactive). billing manage was the only
remaining side-effect-in-json offender.

Verification

  • New tests: billing manage --json emits URL + opens nothing; logout --json
    emits JSON and suppresses the human line; agent-credential logout calls the
    self-revoke endpoint; revoke failure still clears local creds.
  • Full suite green (934 tests), tsc --noEmit clean, build succeeds.

…out (AIT-164, AIT-153)

`billing manage --json` printed human text and opened a browser instead of
emitting JSON; `logout --json` printed the human check line. Both broke the
--json machine contract (a side effect + no clean JSON).

- billing manage --json now emits { billingUrl } and opens no browser.
- logout --json now emits { status, revoked } instead of the human line.
- logout now best-effort revokes an agent credential server-side (DELETE
  /agent/credentials/:publicId) before clearing local credentials, so an
  API key can't keep being used after logout (AIT-153). Best-effort: an
  offline host or already-revoked key still clears local credentials. WorkOS
  sessions have no CLI-side revoke and are unaffected.
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 01cf348e-5188-4336-a36b-0c72cfd03a6b

📥 Commits

Reviewing files that changed from the base of the PR and between f9d4376 and eaeebac.

📒 Files selected for processing (4)
  • src/auth/__tests__/logout.test.ts
  • src/auth/logout.ts
  • src/commands/__tests__/billing.test.ts
  • src/commands/billing.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ait-164-json-contract-no-side-effects

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

@ord669
ord669 merged commit cd28a66 into main Jul 12, 2026
3 checks passed
@ord669
ord669 deleted the ait-164-json-contract-no-side-effects branch July 12, 2026 17:03
ord669 added a commit that referenced this pull request Aug 12, 2026
…out (AIT-164, AIT-153) (#16)

`billing manage --json` printed human text and opened a browser instead of
emitting JSON; `logout --json` printed the human check line. Both broke the
--json machine contract (a side effect + no clean JSON).

- billing manage --json now emits { billingUrl } and opens no browser.
- logout --json now emits { status, revoked } instead of the human line.
- logout now best-effort revokes an agent credential server-side (DELETE
  /agent/credentials/:publicId) before clearing local credentials, so an
  API key can't keep being used after logout (AIT-153). Best-effort: an
  offline host or already-revoked key still clears local credentials. WorkOS
  sessions have no CLI-side revoke and are unaffected.
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.

1 participant