Skip to content

Import Trae CN cookies from the parent trae.cn domain - #1019

Merged
Finesssee merged 1 commit into
mainfrom
port/traecn-parent-cookies
Oct 24, 2026
Merged

Finesssee merged 1 commit into
mainfrom
port/traecn-parent-cookies

Conversation

@Finesssee

@Finesssee Finesssee commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Import Trae CN cookies from the parent trae.cn domain

Ports upstream CodexBar steipete#4732 ("fix(traecn): import session cookies from the parent trae.cn domain") to the Win-CodexBar Trae CN provider.

Summary

  • Trae CN keeps its session cookies on the parent trae.cn domain. Automatic browser import used to look only for api.trae.cn cookies, so it found nothing for a signed-in user.
  • Automatic browser import now reads the trae.cn cookies. It keeps only the cookies a browser would send to api.trae.cn (the same host-scoped read Gemini uses), so sibling hosts such as www.trae.cn and host-only trae.cn cookies are not sent to the API.
  • Requests still go to api.trae.cn. Pasted Cookie headers and the Trae CN cookie domain (ProviderId::TraeCn.cookie_domain() = api.trae.cn) are unchanged, so manual cookie storage, browser import into the manual field, and the provider registry snapshot do not change.
  • Browser sessions are still tried one browser at a time. A rejected session (401, 403, redirect, or the Trae "session expired" code) moves on to the next browser, as before.
  • Docs: docs/PROVIDERS.md (Trae CN section) now says automatic sessions come from trae.cn and are sent to api.trae.cn.
  • No CHANGELOG line (intentionally left for the release step).

Checks

  • cargo fmt --all -- --check: clean.
  • cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings: clean.
  • cargo test --manifest-path rust/Cargo.toml --lib providers::traecn: 24 passed, 0 failed (22 existing, 2 new).
  • cargo build --manifest-path rust/Cargo.toml --example fake_grok_acp, then the full cargo test --manifest-path rust/Cargo.toml: lib 5443 passed, 0 failed, 2 ignored; all other test binaries passed.
  • Tauri manifest clippy not run: no shared type or public API used by the Tauri crate changed.
  • New tests use the in-memory browser store and a local mock API only. No real browser profile, account, or network.
    • automatic_scan_reads_the_parent_domain_and_keeps_only_api_bound_cookies: reads trae.cn only, sends only the .trae.cn cookie to the API, and ignores www.trae.cn and host-only parent cookies.
    • parent_host_only_cookie_is_not_sent_to_the_api_origin: a host-only trae.cn cookie yields the sign-in prompt and no request is sent.
    • Existing rejection-walk, transient-failure, pasted-header, and empty-manual-source tests were moved to the parent-domain fixture shape.

Proof

Not run on a desktop in this change. Suggested proof (synthetic cookie source only): run the Trae CN provider with TRAE_CN_BASE_URL pointing at a local fake server, with an isolated APPDATA, LOCALAPPDATA, USERPROFILE, HOME, and CODEXBAR_CONFIG under a fresh %TEMP% directory. Seed a synthetic browser cookie row for .trae.cn named trae_session, and assert that the fake server receives exactly that Cookie header and that a api.trae.cn-only row is not sent.

Notes

  • Upstream's broker matching was not replicated line for line. The Windows code uses the existing CookieRequestScope (browser host-matching rules), which matches the commit's intent of sending only the cookies the API origin receives.
  • Settings "Import from browser" for Trae CN still reads api.trae.cn cookies into the manual field, as upstream does for API-origin manual cookies. In a real browser the session may live only on trae.cn, so that button may find nothing. Left unchanged here; a possible follow-up.

Summary by CodeRabbit

  • Bug Fixes

    • Automatic mode now checks browser cookies stored on the parent Trae CN domain and uses only those applicable to the API. It continues checking available browsers until it finds an eligible session.
    • Pasted or imported cookies remain scoped to the API domain, and session fallback behavior is unchanged.
  • Documentation

    • Updated the Trae CN setup guide to explain how automatic browser-session lookup handles cookies.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0db91d2 and d56d944.

Files selected for processing: 3
  • docs/PROVIDERS.md
  • rust/src/providers/traecn/mod.rs
  • rust/src/providers/traecn/tests.rs

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

Walkthrough

Automatic Trae CN browser-session lookup now scans cookies stored under trae.cn and retains cookies applicable to api.trae.cn. Manually supplied cookies remain scoped to the API host. Tests cover cookie eligibility and browser-session selection.

Changes: Trae CN cookie scope

Layer / File(s) Summary
Scope automatic browser lookup
rust/src/providers/traecn/mod.rs, docs/PROVIDERS.md
Automatic lookup uses a request scope that scans trae.cn and targets api.trae.cn. The provider and user documentation describe this scope and distinguish it from manual cookies.
Validate browser cookie selection
rust/src/providers/traecn/tests.rs
Fixtures and tests cover parent-domain lookup, API-host cookie eligibility, browser ordering, and manual-cookie behavior.

Priority: Normal

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

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · up to d56d9

The documented automatic cookie lookup change appears mergeable after normal checks; no actionable blocking risk is established.

Pre-merge checks: Passed 8
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: importing Trae CN cookies from the parent trae.cn domain. It is short, specific, and uses an imperative verb.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Provider Data Stays Siloed Passed The change stays within the Trae CN provider, its tests, and documentation. COOKIE_SCOPE reads trae.cn but retains only cookies applicable to api.trae.cn; the provider sends those cookies only t…
Secrets Handled Safely Passed No real secret is introduced or exposed by this change. The new automatic scan uses the existing CookieRequestScope and browser-cookie session helper, which filters cookies for api.trae.cn; the provid…
No Unapproved Dependencies Passed The pull request changes only docs/PROVIDERS.md and Trae CN Rust source/tests. The authoritative diff contains no Cargo.toml, package.json, npm/yarn lockfile, or pnpm package-manager change. The…
Ui Changes Include Windows Proof Passed The PR changes only Trae CN provider logic, provider tests, and documentation. It does not change files under apps/desktop-tauri/src, tray rendering, the float bar, settings, or window chrome. There…
Full details: Provider Data Stays Siloed

Explanation

The change stays within the Trae CN provider, its tests, and documentation. COOKIE_SCOPE reads trae.cn but retains only cookies applicable to api.trae.cn; the provider sends those cookies only to its own API. The shared cookie helper is generic and unchanged. No changed code logs or persists identity, plan, account labels, or email, and no new ProviderId branching was added to shared code.

Full details: Secrets Handled Safely

Explanation

No real secret is introduced or exposed by this change. The new automatic scan uses the existing CookieRequestScope and browser-cookie session helper, which filters cookies for api.trae.cn; the provider sends cookies and the short-lived JWT only in HTTP headers. Changed code logs only browser-session errors/counts, not cookie or token values, and user errors do not include response bodies or credentials. The changed tests contain only explicit synthetic values. The PR changes only documentation, provider logic, and tests, with no credential-file or keyring deletion or overwrite.

Full details: No Unapproved Dependencies

Explanation

The pull request changes only docs/PROVIDERS.md and Trae CN Rust source/tests. The authoritative diff contains no Cargo.toml, package.json, npm/yarn lockfile, or pnpm package-manager change. The PR description also contains no maintainer-approval exception because no dependency addition occurred.

Full details: Ui Changes Include Windows Proof

Explanation

The PR changes only Trae CN provider logic, provider tests, and documentation. It does not change files under apps/desktop-tauri/src, tray rendering, the float bar, settings, or window chrome. Therefore, it has no UI change covered by this check, and Windows screenshots or a fresh-build proof note are not required.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • 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.

@Finesssee
Finesssee merged commit 4e97c19 into main Oct 24, 2026
4 checks passed
Finesssee added a commit that referenced this pull request Oct 24, 2026
Docs only: CHANGELOG entries for the p084 parity batch (#1019-#1023).
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.

1 participant