Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): honor disabled usage hub polling #10310

Mergedyashranaway(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/10310/headmerged by juliusmarminge View on GitHub

Disabling provider-health polling still refreshed usage hubs every minute because the loop used a fallback sleep without suppressing the HTTP refresh.

Keep the fallback sleep, then check the current resolved interval before running automatic work. This also prevents an extra poll when the setting is disabled while a positive timer is waiting. Positive intervals retain background-policy gating; startup, source-settings changes, and explicit refresh still work. Re-enabling polling is picked up on a later timer wake.

Maintainer takeover of #10310, credit to @yashranaway for the original fix. Contributor history is preserved and current main was merged. The rebuild uses the existing duration helper and reads current settings after sleep instead of retaining the original guard over a stale interval.

Verification:

  • Original two parameterized regression cases rewritten in the existing module test file; main's malformed-URL case preserved. All three cases pass.
  • Real service with mocked HTTP: exactly one startup read, disabled and enabled cadence, explicit refresh, source-settings refresh, background-policy gating, re-enabling, and disabling halfway through a pending timer.
  • Removing the interval guard causes the disabled case to read twice after a minute. The original implementation also fails both pending-timer disable checks. The restored implementation passes all three tests.
  • Scoped lint, format, server typecheck, and diff check pass.

Proof is headless service behavior using TestClock, published service snapshots, and observable HTTP reads. Real hubs, actual client leases/power state, browsers, packaged Electron, macOS, Windows, iOS, and Android were not exercised. No UI or contract changes require screenshots. Entering Usage → Limits can still trigger its existing one-time client-requested refresh, independently of periodic polling.

Implemented through T3 Code/Codex with gpt-6.1-sol; test rewrite by Codex gpt-6-astra and independent reviews by Claude claude-opus-5-5 and Codex gpt-6-sol.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — The production loop now suppresses recurring usage-hub HTTP refreshes when polling is disabled and rechecks settings across timer wakes, while preserving explicit and settings-triggered refreshes. The change is localized and well tested, but it gates whether a background workflow runs and therefore warrants human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. juliusmarminge added labelsmacroscope-review

    4. juliusmarminge assignedjuliusmarminge

    5. Taking over this one as maintainer for batch usage-billing-02. I will preserve contributor history, merge main, minimize tests, verify disabled polling and manual refresh, and run independent reviews. No merge is planned.

    6. Published the maintainer takeover at 7989567, preserving @yashranaway's history and merging main.

      Both independent full-diff reviews returned no findings. The rebuild checks the current interval after sleeping, covering both disabled startup polling and disabling while a timer is waiting. The three tests pass, preserving startup, explicit/source-settings refresh, positive polling, policy gating, and re-enabling. Scoped lint/format and server typecheck pass. Regression mutations failed as expected before restoration. Updated body includes proof and external verification limits. Waiting for fresh CI; no merge performed.

    7. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Warning

      Review limit reached

      Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.

      Next included review available in 5 minutes.

      Check out review usage here.

      View limit details

      Limit details: You’ve used all 10 included reviews currently available.

      Learn how review limits work.

      Review configuration:

      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: ee1ffa17-bc19-428d-bffd-82f376541c68
      📥 Commits

      Reviewing files that changed from the base of the PR and between 7989567a9f00ad25e12e76c8d266fc9b7e255974 and 897d1d792e87810bd15c2fa5eb630281461ca512.

      📒 Files selected for processing: 2
      • apps/server/src/usage/UsageLimitSources.test.ts
      • apps/server/src/usage/UsageLimitSources.ts

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 7caab3ca-bf24-4d67-af16-1a0f054630c0
      📥 Commits

      Reviewing files that changed from the base of the PR and between 5307c233b1f0ae72b8894dd39d94019aaf9e7cb8 and 7989567a9f00ad25e12e76c8d266fc9b7e255974.

      📒 Files selected for processing: 2
      • apps/server/src/usage/UsageLimitSources.test.ts
      • apps/server/src/usage/UsageLimitSources.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

      The provider-status refresh loop now checks the configured interval after waiting. It consults the background-work policy only when the interval is positive. Parameterized tests cover polling, explicit refreshes, settings changes, and background-work policy changes.

      Changes: Usage limit polling

      Layer / File(s)Summary
      Polling interval and refresh behavior
      apps/server/src/usage/UsageLimitSources.ts, apps/server/src/usage/UsageLimitSources.test.ts
      The refresh loop checks whether the interval is positive before consulting the background-work policy. Tests cover zero- and one-minute intervals, reads, explicit refreshes, settings changes, and background-work policy changes.

      Priority: ⬇️ Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Suggested reviewers: shivamhwp, juliusmarminge

      Merge Risk: ⚪ Minimal · up to 79895

      Disabled polling does not trigger an automatic refresh when a pending timer wakes. No issue identified here prevents merging after normal checks.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title is concise, conventional, and clearly describes the main fix: disabled Usage Hub polling no longer performs automatic refreshes.
      Description checkPassedThe description explains the problem, implementation, scope, contributor history, verification coverage, test results, and known limitations. It does not use the template headings exactly, and the app…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Description check

      Explanation

      The description explains the problem, implementation, scope, contributor history, verification coverage, test results, and known limitations. It does not use the template headings exactly, and the approval evidence is brief, but the required information is substantially present.

      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    8. juliusmarminge merged this9fae0e8

    9. juliusmarminge closed this

Sign in to join this conversation.