Repository navigation
Try each browser session for Factory - #916
Conversation
Factory web usage now tries each browser session in the shared browser order and moves on when Factory rejects one (401/403), instead of stopping at the first browser that held any Factory cookie. A pasted Cookie header is still used alone, and other errors still stop the search. Ports the upstream v0.76.0 steipete#4461 behavior through the shared BrowserCookieSessions helper from #905.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
@coderabbitai review |
|
Factory now overrides owns_browser_cookie_resolution, so the shell no longer pins the first browser's cookie header into the fetch context for auto, browser, or web. Before this, a pre-resolved header made fetch_via_web use only that browser and skip the per-browser session loop. Adds provider and shell tests for the override, the missing-cookie gate with zero requests, and stored-cookie passthrough.
Drop the Firefox Beta, Developer Edition, and Nightly claim, which has no matching browser variants in this port, and the upstream steipete#4461 attribution, which covers Firefox channel imports rather than moving on after a rejected session.
Summary
Factory web usage now tries each browser's session in the shared browser order and moves on to the next browser when Factory rejects a session (401/403). Before, the first browser holding any Factory cookie was the only one tried, so a stale session in that browser hid a valid login in a later browser.
Behavior changes:
AuthRequired) moves on to the next browser. When every session is rejected, the provider reportsAuthRequired(sign-in needed), as before for a single browser.NoCookies.Routing fix: the shell used to pre-resolve the first browser's Factory cookie into
FetchContext::manual_cookie_headerfor Auto, Browser and Web.fetch_via_webthen used that one header and the per-browser loop never ran.FactoryProvidernow overridesowns_browser_cookie_resolution()to returntrue, the same pattern as Zed, so the shell defers browser discovery to the provider. Stored and pasted cookies still pass through unchanged.Implementation:
rust/src/providers/factory/mod.rsusesbrowser_cookie_sessions(the #905BrowserCookieSessionshelper) and afetch_web_sessionsloop that follows the cursor, zed and notion loops. The HTTP base is a parameter so tests can use a mock server.Upstream reference: upstream v0.76.0 steipete#4461 (
9ebd90017f2c216528ae3ac201599cda0516d855, "fix(factory): import sessions from every Firefox channel") covers the Factory browser order, Firefox Beta / Developer Edition / Nightly imports, and not aborting when a browser has no readable cookie store. It does not cover moving on after a rejected session, which is this port's change. This port has one Firefox browser type. Its profile scan treats any profile name containingdefaultas the default profile (rust/src/browser/detection.rs), so Developer Edition profiles are found. Separate Beta, Developer Edition and Nightly browser types are not added here.Divergence from upstream, deliberate: upstream continues to the next session on any per-session fetch error. This port continues only on a rejected session, to match the shared #905 pattern used by the other self-resolving cookie providers on Win-CodexBar. Network or server errors therefore stop the search here.
Tests
Provider tests in
rust/src/providers/factory/tests.rs(in-memory browser store, mockito Factory host, no real browser read):rejected_browser_session_moves_on_to_the_next_browser: Chrome 401, Edge 200 gives success; Firefox is never read.forbidden_browser_session_also_moves_on: Chrome 403, then Edge is accepted.every_rejected_browser_session_reports_auth_required: Chrome 401 and Edge 401 giveAuthRequired.server_error_from_a_browser_session_stops_the_search: Chrome 500 givesOther; Edge is never requested.no_browser_cookies_reports_no_cookies_without_a_request: empty store givesNoCookies.factory_owns_browser_cookie_resolution: the provider reports the override.missing_manual_cookie_gate_reports_no_cookies_without_any_request: withmanual_cookie_missingset and two browsers holding cookies, the result isNoCookies, with zero auth and usage requests (mockitoexpect(0)) and no browser store read.Shell tests in
apps/desktop-tauri/src-tauri/src/commands/fetch_context_tests.rs:factory_browser_cookie_sources_leave_session_choice_to_the_provider: cookie source Auto, Browser or Web gets no pre-resolved header and is not marked missing.factory_stored_cookie_passes_through_unchanged: a stored cookie is forwarded unchanged for Auto and Manual.Commands run
On the merged head (after merging
origin/main):cargo fmt --all -- --check: passcargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings: cleancargo clippy --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml --all-targets -- -D warnings: cleancargo test --manifest-path rust/Cargo.toml factory: 22 passed, 0 failedcargo test --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml fetch_context: 11 passed, 0 failedNot run in this pass: the full
cargo testfor either manifest.Not UI-affecting: the change is provider fetch logic plus one CHANGELOG bullet, so no CUA proof is required.
Summary by CodeRabbit