# feat\(desktop\): browser profiles for the preview browser · PR \#7254 · pingdotgg/t3code

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

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

Visibility: public

State: merged

Source repository: pingdotgg/t3code

Source branch: browser-profiles

Target branch: main

Head commit: 1a5aa8592169f1da2a1db4aaf9472887eb70b4a9

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

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

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

## Description

---

Adds profiles to the desktop preview browser so tabs can keep separate cookies and site data. This is the bottom of the remaining stack; the browser-access setting is already merged.

Default preserves existing login storage. Incognito uses an in-memory partition. Other profiles use a separate partition namespace with unambiguous environment/profile scoping. A tab keeps its chosen profile for its lifetime.

Settings supports creating, renaming, choosing a default, and removing profiles. Removal waits for cookie/cache cleanup across all known environments and retains the profile if cleanup fails. Existing tabs remain open after removal and are labeled “Removed profile.” The Browser menu supports opening a chosen profile, including touch input.

Validation: focused profile, preview, settings-hydration, and partition-isolation tests; web/desktop typechecks; scoped formatting and lint. Latest CI results are shown below. Earlier desktop behavior was verified by the maintainer; this audit did not run another GUI pass.

Compatibility: Default partitions are unchanged. Data created in custom profiles by an earlier unmerged version of this stack is not migrated from the collision-prone partition mapping.

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 profiles for the preview browser with per-profile partition isolation
> - Adds browser profile contracts in [browserProfile.ts](https://github.com/pingdotgg/t3code/pull/7254/files#diff-0253b59e871191bec4bcd7345d62f0d37f03f35065497282ceca92cdc7986634) with built-in `Default` and `Incognito` profiles, plus user-defined persistent profiles capped at a contract maximum
> - Extends `BrowserSession` partition derivation in [BrowserSession.ts](https://github.com/pingdotgg/t3code/pull/7254/files#diff-17a3bda9cc115ba14d32576e0f787fbd4488b05312afb31216156b1616efee0f) to support persistent, ephemeral, and profile-namespaced partitions, with escaping that prevents collisions from lone UTF-16 surrogates and backslash sequences
> - Adds profile management and default-profile selection UI in [IntegrationsSettings.tsx](https://github.com/pingdotgg/t3code/pull/7254/files#diff-8ecfd51e80236f708bcd5b2191dc1d30ac76dd2752851089b78353b9f86878f6); removing a user profile clears its cookies and cache across all environments first
> - Propagates `profileId` through preview open, navigate, and status snapshots in [Manager.ts](https://github.com/pingdotgg/t3code/pull/7254/files#diff-377ad24fc9187608a35f448399c3553c7eabe0fa9eef50a6510b96a3ab6e5a5b), through webview config caching keyed by environment+profile in [previewWebviewConfigState.ts](https://github.com/pingdotgg/t3code/pull/7254/files#diff-f926d059f47e3206cd9c0430037a9f79928940400c7c80e9a9b28d594741eb2e), and through all desktop IPC handlers in [preview.ts](https://github.com/pingdotgg/t3code/pull/7254/files#diff-8526df92d9957bd23a5f5ea2368417e8d6652ba67a1cdc59eed46edffaca82f8)
> - Surfaces a browser-profile submenu in [RightPanelTabs.tsx](https://github.com/pingdotgg/t3code/pull/7254/files#diff-1580fd0e52935869fd626dd71bcb2484b765e9b216e92c55d09960e870986b91) where mouse clicks open the default profile directly and touch opens the submenu for selection
> - Risk: `getPartition` in [BrowserSession.ts](https://github.com/pingdotgg/t3code/pull/7254/files#diff-17a3bda9cc115ba14d32576e0f787fbd4488b05312afb31216156b1616efee0f) changes partition format for non-default profiles using a JSON tuple scope; existing sessions opened before this change remain on the legacy bare-environment persistent partition, and default-profile partitions are kept compatible with that legacy format
>
> <!-- Macroscope's review summary starts here -->
>
> <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 1a5aa85.</sup>
> <!-- Macroscope's review summary ends here -->
>
<!-- Macroscope's pull request summary ends here -->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes Electron partition derivation and cookie/cache clearing semantics; default profile behavior is preserved, but wrong scoping could leak or wipe the wrong profile’s storage.
> 
> **Overview**
> Adds **browser profiles** so preview tabs can use separate Chromium session partitions (cookies, cache, logins). Built-in **Default** keeps the legacy bare-environment partition; **Incognito** uses a non-persistent partition; custom profiles get a namespaced partition with collision-safe scope encoding.
> 
> **Contracts & server:** New profile types and client settings (`browserProfiles`, `browserDefaultProfileId`). Preview open/snapshots carry optional `profileId` through navigate and status updates so a tab does not silently switch partitions.
> 
> **Desktop:** `resolvePartitionScope` maps environment + profile to partition scope; `getPreviewConfig` and clear-cookie/cache IPC take `environmentId` and optional `profileId`, with per-profile clears loading the session first so data is actually removed after restart.
> 
> **Web:** Settings to add/rename/remove profiles and pick a default (incognito excluded as default). New tabs and link/file opens send configured `profileId`; webview config is cached per environment+profile. UI: profile submenu on “Add browser,” profile badge in preview chrome, and profile-scoped clear actions in the more menu.
> 
> **Note:** Default partitions stay compatible; custom profiles from an earlier partition scheme are not migrated per the PR description.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1a5aa8592169f1da2a1db4aaf9472887eb70b4a9. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
