Skip to content

fix(browser): clear default cookies signs out This-device pages of a paired server - #47105

Merged
AmoabaKelvin merged 4 commits into
mainfrom
fix/remote-clear-default-cookies-target
Nov 22, 2026
Merged

AmoabaKelvin merged 4 commits into
mainfrom
fix/remote-clear-default-cookies-target

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When Settings › Browser is set to a paired Orca server, "Import cookies" signs in the pages this desktop shows for that server. "Clear default cookies" said it worked but cleared a different store, so those pages stayed signed in and the "Imported from …" label stayed. Clear now empties the store that import filled.

Files Added Deleted Net
Test 0 0 0 0
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​141 $\color{#cf222e}{\Huge{\mathbf{−}}}$​60 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​81

What Changed

  • Before: with a paired server as the Settings browser host, import goes to this desktop's cookie store for the server's This-device pages and records an "Imported from …" label on this desktop. Clear only called the server's browser.profileClearDefaultCookies, which empties the server's own store. The toast said "Default cookies cleared.", but This-device pages stayed signed in and the label stayed.
  • After: Clear empties both stores of the Default profile: this desktop's store for the server's This-device pages, and the server's own store as before. The desktop-side label is removed with it.
  • Mechanism:
    • New clearClientRouteDefaultCookies in main finds the jar the same way import does (bindRoutePartition(routeIdentity, 'default')).
    • It removes the label first, like the local clear, then restores the jar's saved session cookies, like the Google cookie clear does. Without that restore, the lazy restore on the next page would undo the clear.
    • It then clears the cookies while holding the cookie mutation lock, so it can't run in the middle of an import.
    • It is exposed as IPC browser:session:clearDefaultCookiesForClientHost. That returns null when this desktop doesn't host the server's pages, in which case only the server store is cleared, as before.
  • The label store (client-route-cookie-import-source-store.ts) now reads and writes its file asynchronously, with changes queued. The clear path added a second caller, and it should not block the main thread; the ratchet baselines shrink to match.

Why

The Default row in Settings is the server's Default profile. Its logins live in two jars: this desktop's jar for This-device pages, which is where import puts them, and the server's jar for Server (streamed) pages, phones and server agents. The confirm dialog says "This may sign you out of sites in this profile."

Clearing only the desktop jar would stop clearing the server jar, which Clear does today. Clearing only the server jar is the bug. So Clear now clears both. This holds whether we later keep two stores per server or merge them into one, which is still an open question.

This reuses the existing route-jar pieces: the import's bindRoutePartition, the Google clear's restore-then-clear order, and the shared mutation lock. It does not add a second remote-only clear.

Linked Issue

No GitHub issue. This is gap NEW-2 from the remote browser parity audit (2026-11-22).

Visual Proof

Settings › Browser, host = paired server, with a This-device page of that server open.

Before (main): after Import, then Clear, the row still read "Firefox (default-release)" and the This-device page's jar still held the imported cookie (.example.com:wrbcc_site=yes). It looked like this:

after-import.png

After (this branch): Clear → "No cookies imported", and the This-device jar is empty ([]), also after an app restart.

after-clear.png

Testing

Real remote runtime on macOS:

  • Setup:

    • A headless orca serve built from this worktree, paired to a hidden dev build (ORCA_BACKGROUND_LAUNCH=1, mock keychain, scratch HOME). The import source is a Firefox profile in the scratch HOME, so no real browser data or keychain is touched.
    • On the paired server, a folder workspace with a This-device page open, which starts the client host.
    • Jar contents were read over CDP Network.getAllCookies on that page's webview.
  • main: Import put .example.com:wrbcc_site=yes into the This-device jar. Clear returned true and toasted, but the jar still held the cookie, and both the desktop label and the Settings row still showed Firefox.

  • This branch:

    • Import, then Clear. The This-device jar is [], the label file is {}, and the row reads "No cookies imported".
    • The server's own Default profile was also imported first, through browser.profileImportFromBrowser. After Clear its source is null, so the server jar was cleared too.
    • The jar was still empty after restarting the desktop.
  • Local host: import then Clear still clears the label, through the unchanged local path.

  • pnpm check:changed passes.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

No unit test was added. The renderer side is IPC wiring, and the main side is Electron session calls that a test could only reach through mocks. The real paired run above is the proof.

Performance

None, because this only runs when the user confirms "Clear default cookies". The label store's file reads and writes moved off the main thread.

Risk

The riskiest part is moving the label store to async file reads and writes. If it went wrong, an "Imported from …" label could be missing or stale. Cookies themselves are not affected. Writes are queued, so an overlapping import and clear can't drop each other's write.

Older peers: no wire change. The server RPC is unchanged, and the new IPC is between this desktop's own main process and renderer. Older servers work as before, phones are untouched, and the web client's stub returns null, which means only the server store is cleared. SSH hosts can't be chosen as the Settings browser host, so SSH is unchanged.

Back out with a plain revert.

Level: Low

AI Disclosure

Review

One review-loop round, with Codex and a Claude subagent. No P0 or P1 findings. Two P2s were left out of this PR:

  • Clear during a running import. Clear confirmed while an import into the same jar is still running can leave the label on an emptied jar, because the import writes its label after it releases the lock. The local clear has the same race. A real fix would disable Clear while an import runs, which is a UI change, so it's left as a follow-up.
  • Label when this desktop no longer hosts the server's pages. In that case Clear can't find the jar, so it keeps the label. That jar still holds the cookies and is used again when This-device hosting resumes, so removing the label would hide cookies that are really still there.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Security: the IPC checks isTrustedBrowserRenderer and the argument type. Main derives the jar from the live route identity, never from a renderer-supplied partition.
  • Cross-platform: Electron session APIs and fs/promises only.
  • Mobile and SSH: unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The change adds an IPC and preload API for clearing default cookies in a client-hosted route. The clear operation removes the default-profile import source and clears cookies in the route partition. Import-source storage now uses asynchronous filesystem operations and serialized updates. The renderer attempts client and server cookie clearing concurrently and refreshes profiles if either succeeds and the selected host is unchanged.

Merge Risk: Low · up to ab7dc

Clearing default cookies for a paired server now also clears this desktop's jar and its label. In the rare case where the label file cannot be written, the "Imported from …" label may reappear after a restart. This is low risk and mergeable, with an optional follow-up.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Clear default cookies now clears the This-device pages of a paired server, which the changeset implements. It uses the conventional fix(browser) prefix and is specific…
Description check Passed The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue (explains no GitHub issue exists, which the template requires for outside contributors, but the author is …
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.
Full details: Title check

Explanation

The title names the main change: Clear default cookies now clears the This-device pages of a paired server, which the changeset implements. It uses the conventional fix(browser) prefix and is specific. The title is 82 characters, slightly longer than ideal, but it is clear.

Full details: Description check

Explanation

The description follows the repository template. It has ELI5, What Changed, Why, Linked Issue (explains no GitHub issue exists, which the template requires for outside contributors, but the author is a maintainer-style contributor and the audit reference is given), Visual Proof with before/after images, Testing with a detailed real paired-runtime run, Performance, Risk with level and revert method, AI Disclosure left empty, Review, Agent skill boundary, Notes, and Checklist. Gaps: the Linked Issue section has no 'Fixes #' issue reference, the AI Disclosure section is empty, and the Performance line is completed. The Risk section names the riskiest change and the back-out method. The Testing checkbox for automated tests is unchecked with a reason given.

  • 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a3b4844d-23fe-4968-b578-23a0d3eb0a10
Commits

Reviewing files that changed from the base of the PR and between 2178e7c and 80f3d63.

Files selected for processing: 11

  • config/main-blocking-helper-baseline.txt
  • config/main-sync-fs-baseline.txt
  • src/main/browser/cookies/client-route/browser-client-route-cookie-clear.ts
  • src/main/browser/cookies/client-route/browser-client-route-cookie-import.ts
  • src/main/browser/cookies/client-route/client-route-cookie-import-source-store.ts
  • src/main/ipc/browser/browser-client-host-cookie-import-ipc.ts
  • src/preload/api/browser/browser-bridge-page-interaction-and-sessions.ts
  • src/preload/api/browser/browser-session-cookie-api.ts
  • src/renderer/src/store/slices/browser/browser-slice-test-harness.ts
  • src/renderer/src/store/slices/browser/profiles/browser-cookie-import-actions.ts
  • src/renderer/src/web/preload-api/browser/web-browser-api.ts
Files with no reviewable changes: 1

  • config/main-sync-fs-baseline.txt

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

…red server

Settings import for a paired server fills this desktop's route jar for its
This-device pages, but Clear only called the server's RPC, so those pages
stayed signed in and the Imported badge stayed. Clear now empties that jar
and its badge too, alongside the server's own jar.
…synchronously

The clear path added a second caller of the badge store; reading and
writing it on the main thread would block it.
@AmoabaKelvin
AmoabaKelvin force-pushed the fix/remote-clear-default-cookies-target branch from 80f3d63 to ab7dcb6 Compare November 22, 2026 20:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ea43d114-ef24-49f7-9d33-7ea371e6c7ab
Commits

Reviewing files that changed from the base of the PR and between 80f3d63 and ab7dcb6.

Files selected for processing: 1

  • src/main/browser/cookies/client-route/client-route-cookie-import-source-store.ts

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

@AmoabaKelvin
AmoabaKelvin merged commit 8c6a270 into main Nov 22, 2026
33 checks passed
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