Skip to content

fix(rate-limits): keep Claude OAuth credits through live statusline updates - #29759

Merged
nwparker merged 1 commit into
stablyai:mainfrom
lurunzi:fix/claude-live-usage-retain-credits
Oct 28, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
lurunzi:fix/claude-live-usage-retain-credits

Conversation

@lurunzi

@lurunzi lurunzi commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

While you chat with Claude, Orca gets live usage updates from Claude's statusline. Those updates only carry the 5-hour and weekly percentages, not your extra-usage credit balance. Every live update was quietly erasing the credit balance Orca had already fetched, so the status bar lost it until the next background refresh. Now Orca keeps the last known credit balance across live updates.

What Changed

Before: Each live statusline post rebuilt Claude's usage snapshot in ingestClaudeStatuslineUsage and carried over only fableWeekly, so extraUsage reset to null and the credits disappeared from the status bar until the next OAuth poll.

After: Live statusline posts keep the last OAuth extraUsage snapshot next to fableWeekly, and the scheduled OAuth poll keeps refreshing both on its normal cadence.

Mechanism: src/main/rate-limits/service/service-fetch-policy.ts now sets extraUsage: inherited?.extraUsage ?? null when it merges a live post. The polling half of #29755 (shouldSkipAutomatedClaudeFetch skipping OAuth polls while live usage is fresh) no longer exists on main, because automated Claude polls are now gated only by Retry-After. That means no gating change is needed.

Why

Only the OAuth usage endpoint returns credits, so a live post has nothing to replace them with. Keeping the previous snapshot matches how fableWeekly is already handled and adds no network load. Triggering an extra OAuth fetch on every live post would fix the gap too, but it would increase request volume for no benefit.

Linked Issue

Fixes #29755

Original fix by @lurunzi in #29759; final version reworked during the bug bash.

Visual Proof

N/A: the change is a state merge in the main-process rate-limit service. It is covered by a unit test that fails on main (expected undefined to be 18) and passes on this branch.

Testing

  • Extended the existing live-usage test in src/main/rate-limits/service-live-claude-usage.test.ts: OAuth returns Fable and credits, 15 minutes of live posts follow, and the test asserts that credits and Fable survive each post and then refresh from the next scheduled OAuth poll.

  • pnpm test src/main/rate-limits: 876 passed. The new assertions fail on main and pass here.

  • CI static gates on the touched files (anti-slop, code-quality native plugins, ast-grep, changed-code quality) and oxfmt are clean.

  • Platform-neutral main-process logic, tested on macOS. Remote/mobile: the snapshot shape is unchanged, so mixed client and server versions are unaffected.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Reported by @lurunzi

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: b0fc5d55-2167-4ebc-b336-aa9cf4b46112
Commits

Reviewing files that changed from the base of the PR and between f03331d and e910859.

Files selected for processing: 2
  • src/main/rate-limits/service-live-claude-usage.test.ts
  • src/main/rate-limits/service/service-fetch-policy.ts

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

Walkthrough

Live Claude statusline updates now retain inherited fableWeekly and extraUsage values. The cadence test checks that both values remain at 18 during live posts and update to 39 after the next poll.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Low · up to e9108

OAuth credits can appear current after polling fails while live usage continues. This is a bounded display risk, not a merge blocker.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the main change: Claude OAuth credits (extraUsage) are kept through live statusline usage updates. It follows the conventional-commit style and is specific to the rate-limits fix. It i…
Description check Passed The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #29755), Visual Proof (N/A with reason), Testing, AI Disclosure guidance, Review, Agent ski…
Linked Issues check Passed The pull request satisfies the coding requirements in issue #29755. service-fetch-policy.ts retains inherited extraUsage during live Claude statusline merges. The current fetch policy no longer sk…
Out of Scope Changes check Passed The supplied whole-PR summary shows changes only in the Claude rate-limit fetch policy and its focused test. Both changes directly support issue #29755. No unrelated change is shown.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check

Explanation

The title names the main change: Claude OAuth credits (extraUsage) are kept through live statusline usage updates. It follows the conventional-commit style and is specific to the rate-limits fix. It is 75 characters, which is within a reasonable length for a title.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #29755), Visual Proof (N/A with reason), Testing, AI Disclosure guidance, Review, Agent skill upstream boundary, Notes, and Checklist sections. It explains the before and after behavior and the mechanism in service-fetch-policy.ts, and it justifies the chosen approach over the alternative of triggering an extra OAuth fetch. Minor gaps: the 'I manually tested these changes locally' box is unchecked, and the AI Disclosure section is left blank, which the template allows for internal contributors but may matter for outside contributors.

Full details: Linked Issues check

Explanation

The pull request satisfies the coding requirements in issue #29755. service-fetch-policy.ts retains inherited extraUsage during live Claude statusline merges. The current fetch policy no longer skips OAuth polling because live usage is fresh; Retry-After remains the polling gate. The focused test verifies credit and Fable retention across live posts and refresh after the next OAuth poll.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

  • 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.

…pdates

The statusline payload carries only the 5-hour and 7-day windows, so each
live post rebuilt Claude's usage without extraUsage and cleared the credit
balance until the next OAuth poll. Retain the last OAuth extraUsage alongside
fableWeekly. Automated Claude polls on main are gated only by Retry-After, so
credits keep refreshing on cadence.

Fixes stablyai#29755

Co-authored-by: lurunzi <lurunzi@gmail.com>
@nwparker
nwparker force-pushed the fix/claude-live-usage-retain-credits branch from f03331d to e910859 Compare October 28, 2026 08:30
@nwparker nwparker changed the title fix(rate-limits): retain Claude OAuth credits across live usage updates fix(rate-limits): keep Claude OAuth credits through live statusline updates Oct 28, 2026
@nwparker
nwparker merged commit ce595fa into stablyai:main Oct 28, 2026
37 checks passed
@lurunzi
lurunzi deleted the fix/claude-live-usage-retain-credits branch November 8, 2026 23:26
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.

[Bug]: Live Claude statusline updates clear OAuth extraUsage credits and skip polling them

2 participants