Repository navigation
Add Trae CN credits provider - #1014
Conversation
Port the Trae CN credit allowance from upstream CodexBar (0703a0c, steipete#4682). The signed-in api.trae.cn browser session exchanges its cookies for a token at GetUserToken, reads the current entitlement list with that token, and shows credits used against the total, the remaining credits and the plan name. Browser sessions are tried in order and only move on after Trae rejects one. Zero allowance shows details without a gauge. No reset date is inferred.
Keep both Soniox and Trae CN (113 providers), keep pi at #4d9abf.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
@coderabbitai On the two pre-merge checks:
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
fd -a '^AGENTS\.md$'
cat AGENTS.md
ast-grep outline rust/src/core/provider_factory.rs
ast-grep outline rust/src/core/token_accounts.rs --match 'for_provider|TokenAccountSupport'
ast-grep outline rust/src/providers/traecn/mod.rs
rg -n -C 8 'TraeCn|fn (pace_capability|limit_reset_policy|cost_cli_extension_for|instantiate)' rust/src/core/provider_factory.rs
rg -n -C 8 'TraeCn|fn for_provider' rust/src/core/token_accounts.rs
sed -n '1,260p' rust/src/providers/traecn/mod.rs
sed -n '261,510p' rust/src/providers/traecn/mod.rs
gh pr view 1014 --repo nesszer/Win-CodexBar --json body --jq .bodyLength of output: 58506
The remaining gap is attached Windows proof, not a confirmed UI defect. The stated limits on real-account and browser-import coverage are clear. 🧠 Learnings used
You are interacting with an AI system. |
|
@coderabbitai On the Windows proof check: the screenshots stay on the proof machine and are not uploaded. They come from runs with isolated homes, and this PR flow has no image upload step. The PR body records what each one shows: a fresh debug build of the integration tree that contains this branch, the three card states (no cookie fails closed with the sign-in hint, synthetic cookie shows "Proof Pro" and Credits 80% left with Used 2,000 / Total 10,000 / Remaining 8,000, and an expired session shows the expired message with no stale numbers), and the tray-menu dump listing Trae CN in the Providers submenu. The change adds no new window, frame, theme or float-bar behavior. Trae CN uses the existing provider card and the existing Providers submenu, so the native checks that matter here are the card states and the menu entry, which the run covers. Tray menu pixels are not covered; the dump proves the entry, as you said. |
|
Tip For best results, initiate chat on the files or code changes. @Finesssee I couldn't produce a complete response to this request. Please try again.
🧠 Learnings usedYou are interacting with an AI system. |
Branch:
port/trae-cn-providerHead:
e14540f49, which merges currentmain(including Soniox, #1002) into the original commit21bc867a4Upstream: CodexBar
0703a0c01(steipete#4682)Summary
api.trae.cnusing the signed-in browser session or a pastedCookieheader.POST /cloudide/api/v3/common/GetUserTokenexchanges the cookies for a token, thenPOST /trae/api/v2/pay/user_current_entitlement_listreads the entitlements withAuthorization: Cloud-IDE-JWT <token>. The token lives for one refresh and is sent only back to the same API origin.Divergences from upstream
api.trae.cncookie header is forwarded, as upstream does.TRAE_CN_BASE_URL(see Proof override). Production always useshttps://api.trae.cn.Checks
On the merge with main (
e14540f49). Soniox and Trae CN together make 113 providers, soCOUNTinspec.rsandtest_provider_id_allare now 113. Thepiicon keeps main's#4d9abfbrand color.cargo test --manifest-path rust/Cargo.toml: 5422 passed, 0 failed, 2 ignored; plus 1 passed in a second target.cargo test --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml: 810 passed, 0 failed.cargo clippyon both manifests with-D warnings: clean.cargo fmt --all -- --check: clean.pnpm exec vitest run(Node v22.22.0): 164 files, 1630 tests passed.pnpm run buildnot run.Earlier, on
21bc867a4before the merge:cargo fmt --all -- --check: clean.cargo fmt --all: clean.cargo test traecn(rust manifest): 22 passed, 0 failed.cargo build --manifest-path rust/Cargo.toml --example fake_grok_acp: passed.cargo test --manifest-path rust/Cargo.toml(full): lib 5301 passed, 0 failed, 2 ignored; bin 1 passed, 0 failed.cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings: clean.registry_matches_snapshot): four new lines for TraeCn, from the branch's earlier snapshot regeneration; passes in the full lib run.pnpm test,pnpm run build): not re-run for the override commit, which changes no frontend file. Counts from the earlier draft (1617 tests) are not re-verified here.Proof override (
TRAE_CN_BASE_URL)TRAE_CN_BASE_URLreplaces the API origin (defaulthttps://api.trae.cn). It is read once when the provider is constructed. The two POST paths are appended as before.providers/sub2api/mod.rs,validated_sub2api_base_url):https://is accepted;http://only for a loopback host (127.0.0.1,localhost,[::1]). Userinfo, query, fragment, and encoded host delimiters are rejected. A rejected or blank value is ignored with a warning and production is used.invoke(...)commands were added, so no proof router handler is needed.docs/PROVIDERS.md(Trae CN section). Trae CN is cookie-based and has no API key hint, so none was changed.base_url_override_accepts_https_and_loopback_http,base_url_override_rejects_remote_plain_http_and_unsafe_forms,base_url_override_falls_back_to_production_when_unset_or_invalidinrust/src/providers/traecn/tests.rs.Desktop proof (fake server, isolated home)
Run on Windows 11 from a fresh debug build of
integ/p083at512c66790, which contains this branch's21bc867a4together with the other p083 branches. A fake Trae server ran on127.0.0.1:18102withTRAE_CN_BASE_URL=http://127.0.0.1:18102.APPDATA,LOCALAPPDATA,USERPROFILE,HOMEandCODEXBAR_CONFIGwere isolated under%TEMP%\p083-traecn. The app ran in proof mode on the second display and never took focus. The fixtures are synthetic.set_manual_cookie(traecn, <synthetic>)and a refresh, the fake log showsGetUserToken200 anduser_current_entitlement_list200. The card shows plan "Proof Pro", "Credits 80% left", and CREDITS Used 2,000, Total 10,000, Remaining 8,000. PASS.Screenshots (local):
%TEMP%\p083-traecn\shots\panel.png,panel-after-cookie.png,panel-expired.png. Not covered: a real trae.cn account and the browser cookie import path. The icon's contrast against the light theme was not measured.