Skip to content

fix(alibaba): restore Token Plan 5-hour and weekly windows - #2437

Closed
rohitsabu wants to merge 1 commit into
steipete:mainfrom
rohitsabu:fix/alibaba-token-plan-rate-windows
Closed

fix(alibaba): restore Token Plan 5-hour and weekly windows#2437
rohitsabu wants to merge 1 commit into
steipete:mainfrom
rohitsabu:fix/alibaba-token-plan-rate-windows

Conversation

@rohitsabu

Copy link
Copy Markdown
Contributor

Summary

  • fetch Alibaba Token Plan rate limits from the current authenticated console RPC
  • map fractional 5-hour and 1-week percentages plus millisecond reset timestamps into CodexBar rate windows
  • retain the existing subscription-summary request as a fallback and optional monthly credits window
  • add redacted parser and request-contract regression coverage

Regression evidence

The live authenticated international dashboard currently calls zeldaHttp.apikeyMgr./tokenplan/personal/api/v2/usage and returns per5HourPercentage, per1WeekPercentage, per5HourResetTime, and per1WeekResetTime inside a nested JSON envelope. No cookie, token, account identifier, or response value is included in this change.

A fail-then-pass isolated harness using the redacted fixture verified:

  • 0.0769 maps to 7.69% over 300 minutes
  • 0.0261 maps to 2.61% over 10,080 minutes
  • millisecond reset timestamps map to Date
  • legacy subscription-summary data remains the fallback

Verification

  • swift build --product CodexBarCLI on current main: pass
  • SwiftFormat for all four changed files: pass
  • git diff --check: pass
  • focused swift test --filter AlibabaTokenPlanProviderTests: environment-blocked locally because this Mac currently has Command Line Tools only and no Testing module; the test sources are included for full-Xcode CI

The change is provider-only: no mobile, signing, entitlement, credential, or private configuration files are touched.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 02161d9b35

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +69 to +70
let primary = fiveHour ?? monthlyCredits
let secondary = fiveHour == nil ? nil : sevenDay

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Label the restored rate windows by their durations

When the new rate-limit response succeeds, these assignments make the primary bar the 5-hour percentage and the secondary bar the 7-day percentage. MenuCardView+ModelHelpers.rateWindowLabels uses the Token Plan descriptor labels verbatim, but that descriptor still says Credits and Usage (rather than 5-hour and Weekly), so every successful rate-limit fetch presents the new percentage quotas under misleading labels. Update the Token Plan metadata alongside this remapping.

Useful? React with 👍 / 👎.

@rohitsabu

Copy link
Copy Markdown
Contributor Author

Release impact

This fixes a current production regression for authenticated Alibaba Token Plan users: the legacy subscription-summary response no longer supplies the 5-hour and weekly limits, so released builds show the provider identity but null usage windows. Merging this provider-only commit and including it in the next normal CodexBar patch release is sufficient for upstream desktop users.

For the mobile-enabled fork, the same commit can be cherry-picked without any entitlement or signing changes and published through the existing official o1xhack release pipeline. That restores the 300-minute and 10,080-minute windows for existing Mac users and for the unchanged iPhone snapshot/sync path. No special migration is needed.

Requested release action: merge after the focused provider tests pass in full-Xcode CI, then include it in the next ordinary patch release; no out-of-band or ad-hoc artifact is requested.

@rohitsabu
rohitsabu force-pushed the fix/alibaba-token-plan-rate-windows branch from 02161d9 to 9482737 Compare July 24, 2026 08:27
@clawsweeper

clawsweeper Bot commented Jul 24, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(alibaba): restore Token Plan 5-hour and weekly windows This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@rohitsabu

Copy link
Copy Markdown
Contributor Author

Full-Xcode validation is now complete on the current head 94827370f6746fb4a4599897d536a981af86ea83:

  • Xcode 26.6 (17F113), Swift 6.3.3
  • AlibabaTokenPlanProviderTests: 33 tests / 5 suites, 0 failures
  • full macOS swift test --parallel: exit 0 (test Keychain access suppressed)
  • repository locale + SwiftFormat lint: 0/1,575 files require formatting
  • corresponding mobile-fork commit 7604d2d15cc009f340f80489f9b9aaa2c7d3ef0b builds successfully for arm64 + x86_64 iOS Simulator with signing disabled

The provider fix itself is green and remains isolated to the Alibaba endpoint/parser/tests. Please merge and include it in the next ordinary signed patch release; the mobile fork can cherry-pick the corresponding commit and publish through its unchanged o1xhack signing pipeline.

@steipete

Copy link
Copy Markdown
Owner

Thanks @rohitsabu for digging into the Personal plan gap. Architecture decision from triage (recorded): Qwen Cloud Personal will land as a first-class provider based on #2361, and mainland/international Alibaba Personal (#2370/#2349) will become explicit variants with a shared Personal parser — so this PR won't proceed in its current shape.

Concrete issues found in review, for reference: the personal endpoint is only tried when secToken exists although mainland evidence shows cookie-only requests work; the API cookie header assembled for the old console host is reused on a different RPC host (losing host-scoped cookies); a successful personal fetch returns before the subscription-summary request so the promised combined monthly credits never render; and a weekly-only response is discarded because secondary is only emitted when the 5-hour value exists. Closing in favor of the coordinated variant work on #2370/#2349 — your fixtures and request-contract tests are useful references there.

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.

2 participants