# feat\(desktop\): import browser cookies into a profile · PR \#7255 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/7255)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: merged

Source repository: pingdotgg/t3code

Source branch: browser-profile-import

Target branch: main

Head commit: c5dbc20c4cea1b3bfb72777150544105a198c10b

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/7255)

[Commits](https://git.cafe/pingdotgg/t3code/pull/7255/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/7255/diffs?format=markdown)

## Description

---

Stacked on #7272 (`shared-sqlite-client`).

Imports cookies from Helium on macOS into a T3 Code browser profile. Saved passwords and browsing history remain out of scope.

The app requests the browser key through the in-process Keychain API, so consent belongs to T3 Code. Denial stops the import; there is no permission bypass. Source databases are opened read-only and snapshotted consistently with SQLite before extraction.

The wizard chooses a source and destination, prevents profile edits during an import, and reports imported/skipped counts and affected sites. Plaintext and encrypted cookie records are handled separately; domain-bound records are validated. Partitioned cookies are skipped when their partition semantics cannot be preserved by Electron.

Validation includes synthetic decryption records, plaintext and legacy records, domain-binding failures, partitioned-cookie rejection, WAL snapshot consistency, interrupted writes, and wizard state transitions, plus scoped typechecks/lint. Earlier Helium imports were verified in the desktop app; this audit did not request another live Keychain read.

Original implementation: Claude Code. Review fixes: GPT-5.6 Sol agents, coordinated through Codex.

<!-- Macroscope's pull request summary starts here -->
<!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. -->
<!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. -->
> [!NOTE]
> ### Add browser cookie import into profiles via `BrowserImport` service
> - Adds `BrowserImport` service, contracts, and IPC methods to list browser sources and import cookies into a target partition.
> - Implements macOS-only Chromium cookie extraction via keychain lookup, SQLite database snapshots, and AES-128-CBC decryption.
> - Introduces `BrowserImportWizard` and redesigns browser profile settings to support profile management and cookie imports.
> - Fixes client-settings persistence by adding a serialized queue in `useSettings` to prevent race conditions and ensure correct publish order.
> - Risk: `persistClientSettingsUpdate` in [useSettings.ts](https://github.com/pingdotgg/t3code/pull/7255/files#diff-e989c3ad63c7359b2af1c2873a7ffbfea1639454ea1053c98da7f68d6946fbda) now rejects on persistence failure and recomputes concurrent writes, changing publish timing.
>
> <!-- Macroscope's review summary starts here -->
>
> <sup><a href="https://app.macroscope.com">Macroscope</a> summarized c5dbc20.</sup>
> <!-- Macroscope's review summary ends here -->
>
<!-- Macroscope's pull request summary ends here -->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches macOS Keychain reads and cross-browser cookie data with new IPC surface area, plus a behavior change to how client settings are persisted and published.
> 
> **Overview**
> Adds **cookie import from installed Chromium-family browsers** (initially Helium on macOS) into T3 Code preview browser profiles, wired end-to-end from contracts through desktop main, preload, and Integrations settings.
> 
> The desktop app introduces a **`BrowserImport` Effect service** that lists sources, blocks imports while the source browser holds `SingletonLock`, validates profile directories against listed profiles (path traversal hardening), snapshots the SQLite cookie DB via `VACUUM INTO`, reads the encryption key through **`@napi-rs/keyring`** (in-process Keychain, no CLI bypass), decrypts Chromium cookies, and writes them into the **same Electron partition** as the target profile via new IPC channels `listBrowserImportSources` / `importBrowserCookies`.
> 
> **Integrations → Browser profiles** is reworked: an **Add profile** menu offers blank profiles or **Import from** detected browsers, a **`BrowserImportWizard`** handles quit-browser / configure / success / blocked flows, per-profile actions include **Set as default**, **Clear cookies and cache**, and remove; the standalone default-profile row is folded into the list. New profiles are **persisted only after a successful import** (with partition cleanup on save failures or profile cap).
> 
> **`persistClientSettingsUpdate`** plus a serialized persistence queue ensures awaited settings writes (e.g. registering an imported profile) don’t race optimistic patches. Desktop artifact builds **stage keyring native binaries** like other nested native deps.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c5dbc20c4cea1b3bfb72777150544105a198c10b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
