Skip to content

feat(browser): import a cookie file from Settings > Browser - #415

Merged
Hona merged 6 commits into
devfrom
browser-settings/pr2b
Nov 21, 2026
Merged

Hona merged 6 commits into
devfrom
browser-settings/pr2b

Conversation

@Hona

@Hona Hona commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Adds "Import cookie file" to Settings > Browser > Advanced, using WS-1's #286 cookie store. It matches official anomalyco/opencode at b9a60d9d078d87bfb90f039e431090508f88ac02.

Official reference (b9a60d9d078d87bfb90f039e431090508f88ac02)

  • The row, settings.tsx:230-255:
    • Its second card in Advanced, with title settings.import.file.title and description settings.import.file.description.
    • A Choose file button that shows busy while the import runs.
    • When an import finishes, its outcome replaces the description, in red if it failed.
  • The file picker, settings.tsx:56-61: titled settings.import.file.pick and limited to txt and json files.
  • Reading the file, profile/index.ts:503-516 (importFile): files over 32 MiB are refused; a file that cannot be read gives read; a file that does not parse gives format.
  • Outcome messages, jobs.ts:186-276:
    • Failures: signins.failed.read.file, signins.failed.format, signins.failed.storage.
    • Some cookies lost: signins.imported.incomplete (count plus the number skipped).
    • Otherwise: signins.imported (count).
    • No answer from the app: settings.failed.import.
  • Time limit, jobs-machine.ts:87: the import fails after 60 s without an answer.

Changes

  • apps/desktop/src/surfaces/browser/cookie_import.rs (new):
  • Browser:ImportCookieFileAsync(title): only the built-in browser plugin can call it. MCP tools and other plugins get browser.cookies.denied.
  • Settings: the row with official's messages and busy state. Now that both the remote-sign-ins and cookie-file rows exist, the Advanced summary shows official's full text.
  • Strings: 9 English keys with official's names and text.

Not in this PR

Round 2 (READER-12 read 3, notes/review-rd294.md #415 items 1-5): head 3bc4a37

  1. Cookie host validated (critical):
    • valid_cookie_host accepts only a plain hostname (alphanumerics, -, _; labels at most 63; at most 253 in all) or an IPv4/IPv6 literal, with at most one leading dot. It refuses @, ?, #, %, ports, stray :, controls and spaces.
    • It runs in two places: prepare_for_import (crates/browser-pane/src/cookies/format.rs), where an invalid host counts as skipped as official's cookieDetails would, and the engine's to_cef_cookie, which every write goes through.
    • The engine then parses the cookie's URL with url and requires no user info, no password, no port, and the same host.
  2. Large files (critical):
    • The file is read and parsed on a worker thread.
    • The JSON shape is chosen by its first byte ([ or {) instead of an untagged enum, so the text is parsed once.
    • Cookies go to the engine in batches of at most 1,000 cookies or about 2 MiB, one wire line each.
    • The 60 s limit restarts at every answered batch. The import fails at once if the engine goes away.
  3. Caller guard and picker title: require_settings_caller requires in_flight.is_empty() (merged from dev). The picker title is cut to 200 characters with control characters removed.
  4. Other callers' engine answers are kept: the import takes only its own CookiesImported answers, through a new BrowserHost::take_profile_events_matching. Every other profile event stays queued for whoever asked for it.
  5. prepare_for_import is now called: expired, nameless or invalid-host cookies count as skipped, not failed.

Store limits (parity): official's writeCookies (profile/import.ts:10-38 at db2d889c) writes every cookie with no per-site cap and no warning, and Chromium evicts past its own limits. Ours does the same; recorded in ours.md.

Proof (proof/previews/cookie-file/import-after.json, scratch engine profile):

  • Hostile hosts: [email protected] (as a __Host- cookie), github.com?x=…, github.com#…, github.com:8443, github%2ecom and 0x7f.1 were all refused: imported 0, failed 6, and no cookie exists on any github host.
  • Valid hosts: .example.test, app.example.test and [::1] were imported (3).
  • Large import: 60,000 cookies (13.2 MB of cookie text) went in 60 lines, the largest 337 KB, far under the engine's 32 MiB line cap. All 60,000 were imported, 0 failed, in 54 s.

Hona added 3 commits November 21, 2026 15:39
# Conflicts:
#	apps/desktop/src/plugin_host/native/browser.rs
#	apps/desktop/src/surfaces/browser/mod.rs
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

PR test build retired — merged into dev. Install or auto-update OpenCode (Rune) from https://anoma.ly/release/opencode/desktop-rune/dev/macos-arm64-dmg.

@Hona
Hona merged commit 3f474f9 into dev Nov 21, 2026
@Hona
Hona deleted the browser-settings/pr2b branch November 21, 2026 12:55
Hona added a commit that referenced this pull request Nov 21, 2026
… pane (#550)

* feat(browser): import a cookie file from Settings > Browser

* fix(browser): validate cookie hosts, batch file imports, and parse them off the UI thread (READER-12 #415)

* feat(browser): offer sign-ins and history from another browser on the pane, as official's SignInOffer

* fix(browser): the sign-in bar shows only over a page with an address; the new tab page has the card

* fix(browser): list other browsers off the UI thread so the pane's sign-in offer never stalls a draw

* fix(browser): keep the browsers' listing beside the icons so surfaces/browser/mod.rs stays under 800 lines
@Hona

Hona commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Smoke after merge (FLEET.md:156, missed before the merge): #550's PR CI build 6e85ed3 contains this PR; tools/smoke.ps1 9/9 (plugins load, settings 14/14 incl. browser, browser tab loads, clean quit). Lines on #550.

Hona added a commit that referenced this pull request Nov 21, 2026
…og (#611)

* feat(browser): import a cookie file from Settings > Browser

* fix(browser): validate cookie hosts, batch file imports, and parse them off the UI thread (READER-12 #415)

* feat(browser): offer sign-ins and history from another browser on the pane, as official's SignInOffer

* fix(browser): the sign-in bar shows only over a page with an address; the new tab page has the card

* fix(browser): list other browsers off the UI thread so the pane's sign-in offer never stalls a draw

* feat(plugins): ui.checkbox, Desktop's compact checkbox with its label (contract 1.7)

* feat(browser): Sign-ins and Browsing history boxes in the import dialog, as official's

* fix(browser): keep the browsers' listing beside the icons so surfaces/browser/mod.rs stays under 800 lines

* fix(browser): history comes only after sign-ins that did not fail, and never fails an import (official main.ts:285-296)

* fix(browser): the import dialog takes official's frame: header with its close button, body 16 in, footer buttons
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