Add Alibaba Coding Plan provider with web/API support#453
Add Alibaba Coding Plan provider with web/API support#453jnd0 wants to merge 3 commits intosteipete:mainfrom
Conversation
Implement Alibaba provider settings, region-aware console RPC parsing, tests, and docs; also fix cookie header normalization to avoid truncating values containing '-b', which caused false login-required failures for valid manual cookies.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb2cd354ea
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let hasToken = !context.settings.alibabaCodingPlanAPIToken.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty | ||
| let hasManualCookie = | ||
| context.settings.alibabaCodingPlanCookieSource == .manual && | ||
| !context.settings.alibabaCodingPlanCookieHeader.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty | ||
| return hasToken || hasManualCookie |
There was a problem hiding this comment.
Treat auto-cookie Alibaba setups as available
This availability check only returns true for API tokens, env cookies, or manual-cookie mode, so users who enable Alibaba with the default .auto cookie source and rely on browser cookie import are filtered out by enabledProviders() and never fetched. In that common setup the new web flow cannot run unless users also set an API key or manual cookie, which breaks the provider’s advertised auto web mode.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 55d90b2: removed the strict app-side availability gate so Alibaba no longer gets filtered out for default .auto cookie mode. Auto-import setups now remain available and can fetch via web strategy as intended.
| { | ||
| let source = instanceInfo ?? payload | ||
| let status = self.anyString(for: ["status", "instanceStatus"], in: source)?.uppercased() | ||
| guard status == "VALID" || status == "ACTIVE" || instanceInfo != nil else { return nil } |
There was a problem hiding this comment.
Require active status before creating fallback quota window
The fallback guard accepts any non-nil instanceInfo (|| instanceInfo != nil), so payloads with inactive plans (for example status: EXPIRED) still produce a synthetic fiveHourUsedQuota=0/fiveHourTotalQuota=100 snapshot when quota fields are missing. That reports an active-looking quota window for inactive plans instead of failing parsing, which can show incorrect usage state.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 55d90b2: fallback now only synthesizes a quota window for active/valid (or unspecified) status, and no longer does so for explicitly inactive statuses like EXPIRED.
|
Follow-up pushed in 352ea6b with final UX polish based on live validation:\n\n- keep countdown reset text (e.g. ) for Alibaba windows\n- show request usage detail under each bar ()\n- normalize 5-hour reset timestamps when backend returns near-now/stale values so we avoid incorrect \n- improve auto cookie import reliability for Alibaba by prioritizing Safari and filtering for authenticated cookie sets\n\nRe-tested with a live Alibaba Coding Plan account; menu now shows stable countdowns + request usage values across 5-hour/weekly/monthly windows. |
|
Follow-up pushed in 352ea6b with final UX polish based on live validation:
Re-tested with a live Alibaba Coding Plan account; menu now shows stable countdowns plus request usage values across 5-hour, weekly, and monthly windows. |
Summary
Alibabaprovider (displayed as Alibaba / CLIalibaba-coding-plan) with full registry wiring, settings UI, icon, docs, and test coverage.sec_token+ form-encodedparams) with API-key fallback, intl/cn region handling, and resilient payload parsing for nestedDataV2structures.CookieHeaderNormalizerwhere-bregex matching could trigger inside cookie values (e.g....-Br...), truncating manual Cookie headers and causing falseConsoleNeedLoginfailures.What changed
Sources/CodexBarCore/Providers/Alibaba/*Sources/CodexBar/Providers/Alibaba/*UsageProvider.alibaba,IconStyle.alibababailian-*-cs*host)params,region,sec_tokencornerstoneParamfields to mirror console calls./tool/user/info.jsonfallback.data.DataV2.data.data) and quota fields.EXPIRED)..autocookie setups.docs/alibaba-coding-plan.md,docs/providers.md).CookieHeaderNormalizernow anchors--cookie/-bpattern matching to command boundaries so cookie-value substrings no longer get misparsed.Testing
swift test --filter AlibabaCodingPlan./Scripts/compile_and_run.shManual validation against a live Alibaba Coding Plan account:
Visual representation: