Repository navigation
fix(browser): keep isolated profile storage on its partition - #6958
Conversation
|
Ready to review this PR? Stage has broken it down into 7 individual chapters for you: Chapters generated by Stage for commit 0ef83cf on Jun 30, 2026 10:55pm UTC. |
📝 WalkthroughWalkthroughThis PR adds browser session partition handling tied to profile ids. The main process now resolves partitions from the browser session registry and includes them in runtime tab creation, profile switching, cloning, and preload IPC payloads. The renderer stores and forwards sessionPartition through browser state, duplication flows, browser pane rendering, and webview lifecycle management. Tests were added or updated across the affected registry, runtime, store, component, and IPC paths. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/renderer/src/store/slices/browser.ts (1)
1697-1718: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPass
sessionPartitiontoswitchBrowserTabProfileinsrc/renderer/src/components/browser-pane/BrowserToolbarMenu.tsx(both switch flows). Both calls omit the third arg, so the store coerces it tonulland can wipe the tab’s existing partition, breaking profile isolation.src/preload/api-types.ts (1)
2528-2545: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winMake the partition fields required in the preload contract.
Lines 2533-2545 still advertise
sessionProfileId/sessionPartitionas optional, butsrc/main/runtime/orca-runtime-browser.tsnow always sends them. Leaving them optional keeps the oldundefinedpath alive in renderer code, which is exactly the fallback that can put a tab back on the wrong storage partition. Please tighten this type, and mirror the same change insrc/preload/index.ts.Suggested type change
onRequestTabCreate: ( callback: (data: { requestId: string url: string worktreeId?: string - sessionProfileId?: string | null - sessionPartition?: string + sessionProfileId: string | null + sessionPartition: string activate?: boolean }) => void ) => () => void @@ onRequestTabSetProfile: ( callback: (data: { requestId: string browserPageId: string profileId: string - sessionPartition?: string + sessionPartition: string }) => void ) => () => void
🧹 Nitpick comments (4)
src/renderer/src/components/browser-pane/browser-page-webview.ts (1)
58-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a shared color token here.
#ffffffintroduces a new renderer color insrc/renderer/src, which bypasses the token/style-guide contract for UI surfaces. Please switch this background to a documented token/constant fromsrc/renderer/src/assets/main.cssinstead of a raw hex value.As per coding guidelines,
src/renderer/src/**/*.{ts,tsx,css}: "Never invent new color values, font sizes, or shadow tiers when a documented one in STYLEGUIDE.md already covers the role" andsrc/renderer/src/**/*.{ts,tsx}: "All UI work ... must follow docs/STYLEGUIDE.md and use tokens defined in src/renderer/src/assets/main.css".Source: Coding guidelines
src/renderer/src/components/browser-pane/BrowserPane.tsx (1)
2815-2818: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument why the resolved partition wins over the renderer profile mirror.
This precedence is carrying the storage-isolation invariant from the PR, but the line reads like a simple fallback chain. Please add a short
Why:comment so it stays clear thatsessionPartitionmust overridesessionProfile?.partitionwhen the renderer mirror is stale.As per coding guidelines,
**/*.{ts,tsx,js,jsx}: "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."Source: Coding guidelines
src/renderer/src/store/slices/browser.ts (1)
326-350: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider an options object for
buildWorkspaceFromPage.The helper now takes 6 positional parameters, two of which (
sessionProfileId,sessionPartition) were added in this PR: function buildWorkspaceFromPage(\n id: string,\n worktreeId: string,\n page: BrowserPage,\n pageIds: string[],\n sessionProfileId?: string | null,\n sessionPartition?: string | null\n): BrowserWorkspace { Its only caller (createBrowserTab) already has an options bag available; passing a{ sessionProfileId, sessionPartition }object instead of two more trailing optional positionals would reduce the risk of param-order mistakes as the field count grows further.♻️ Proposed refactor sketch
-function buildWorkspaceFromPage( - id: string, - worktreeId: string, - page: BrowserPage, - pageIds: string[], - sessionProfileId?: string | null, - sessionPartition?: string | null -): BrowserWorkspace { +function buildWorkspaceFromPage( + id: string, + worktreeId: string, + page: BrowserPage, + pageIds: string[], + session?: { sessionProfileId?: string | null; sessionPartition?: string | null } +): BrowserWorkspace { return { id, worktreeId, - sessionProfileId: sessionProfileId ?? null, - sessionPartition: sessionPartition ?? null, + sessionProfileId: session?.sessionProfileId ?? null, + sessionPartition: session?.sessionPartition ?? null,src/main/runtime/orca-runtime-browser.ts (1)
1338-1344: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a short why-comment for the strict profile rejection.
This branch intentionally changed from “fallback to default partition” to “hard-fail”. A one-line why note here would make the storage-isolation constraint obvious and reduce the chance of someone switching this back to
resolvePartition()later. As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 709dee0f-7656-464a-8bf4-4e1098495be5
📒 Files selected for processing (19)
src/main/browser/browser-session-registry.test.tssrc/main/browser/browser-session-registry.tssrc/main/runtime/orca-runtime-browser.test.tssrc/main/runtime/orca-runtime-browser.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/Terminal.tsxsrc/renderer/src/components/browser-pane/BrowserPane.tsxsrc/renderer/src/components/browser-pane/BrowserPane.webview-preferences.test.tssrc/renderer/src/components/browser-pane/browser-page-webview.tssrc/renderer/src/components/floating-terminal/FloatingTerminalPanel.test.tsxsrc/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsxsrc/renderer/src/components/tab-group/useTabGroupWorkspaceModel.focus.test.tssrc/renderer/src/components/tab-group/useTabGroupWorkspaceModel.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/lib/duplicate-browser-tab-options.tssrc/renderer/src/store/slices/browser.test.tssrc/renderer/src/store/slices/browser.tssrc/shared/types.ts
| resolveKnownPartition(profileId: string | null | undefined): string | null { | ||
| if (!profileId) { | ||
| return ORCA_BROWSER_PARTITION | ||
| } | ||
| return this.profiles.get(profileId)?.partition ?? null |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Don't treat '' as the default browser profile.
Line 330 uses a falsy check, so an explicit empty-string profile id resolves to the default partition instead of being rejected. That reopens the default-storage fallback this PR is trying to eliminate for invalid profile ids.
Suggested fix
resolveKnownPartition(profileId: string | null | undefined): string | null {
- if (!profileId) {
+ if (profileId == null) {
return ORCA_BROWSER_PARTITION
}
return this.profiles.get(profileId)?.partition ?? null
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| resolveKnownPartition(profileId: string | null | undefined): string | null { | |
| if (!profileId) { | |
| return ORCA_BROWSER_PARTITION | |
| } | |
| return this.profiles.get(profileId)?.partition ?? null | |
| resolveKnownPartition(profileId: string | null | undefined): string | null { | |
| if (profileId == null) { | |
| return ORCA_BROWSER_PARTITION | |
| } | |
| return this.profiles.get(profileId)?.partition ?? null | |
| } |
Keep the isolated-storage invariant universal: UI-initiated profile switch/create now persist the resolved partition alongside the profile id, matching the runtime path, so a tab stays on its partition even if the renderer profile mirror is later stale (issue stablyai#6923). Co-authored-by: Orca <[email protected]>
Add sessionPartition to the workspace-session zod schema so the resolved partition survives persist->load; without it zod strips the field and a restored isolated tab whose profile mirror is stale at startup falls back to the shared default partition, reopening the storage leak (stablyai#6923). Fold the webview teardown branches (parent drift or partition mismatch) into one and re-resolve the viewport container once, matching the pre-refactor null-guard behavior. Split the sleeping-agent parse tests into their own file to keep both under the 800-line cap. Co-authored-by: Orca <[email protected]>
browserTabCreate without an explicit profile was sending sessionProfileId: null, which the renderer store treats as 'no inheritance' (its guard is !== undefined). That forced CLI-created tabs onto the shared default partition even when the user had configured a default browser session profile, silently changing behavior a stablyai#6923 fix should not touch. Leave sessionProfileId/sessionPartition undefined when no profile is named so the renderer applies default-profile inheritance; thread the resolved partition only when a profile is explicitly chosen. Co-authored-by: Orca <[email protected]>
|
Picked this up for staff review and finishing. Summary of what I verified and added, plus one decision I'm deliberately leaving to a maintainer before merge. Security re-screen (hostile eye): clean. Partition names are Validity: confirmed. The leak is real and present on What I added on top of @rodboev's work:
Verification: affected suite green (160 tests), Not merging yet — one decision for a maintainer (data migration). Storage that leaked into the shared default partition while the bug was live is not migrated into the now-correctly-resolved isolated partition. Net effect: an isolated tab that had accumulated cookies/logins in the shared partition appears "logged out" once (its real isolated storage is now used). The leaked data is not deleted — it stays in the default partition, still visible to default tabs. There's no clean automatic migration (shared-bucket cookies can't be attributed to a profile; auto-copying would re-leak). My read is this is inherent and acceptable for an isolation fix, but I'd like a maintainer to decide whether to ship a user-facing heads-up before this merges. Details in the updated PR description's Trade-offs. Thanks @rodboev — the core approach is solid and well-tested; this is genuinely close. |
|
Merged — this passed our review bar. @rodboev thanks for the contribution! We validated the cross-profile storage leak against current main, confirmed the fix strengthens isolation (rejects unknown profiles instead of downgrading to the shared partition), persisted the resolved partition through the zod schema so it survives restart, and fixed a CLI regression where One migration note for users: storage that leaked into the shared default partition while this bug was live is not migrated into the now-correctly-resolved isolated partition. Net effect: an isolated tab that had accumulated logins in the shared partition will appear logged out once (the data is not deleted — it remains in the default partition, still visible to default tabs). This is inherent, one-time, and non-destructive; there is no clean automatic migration because shared-bucket cookies can't be attributed back to a specific profile without re-leaking them. |
|
Thank you, @rodboev — this is an important one. Quietly downgrading an invalid profile to the shared partition meant cookies and storage could bleed across profiles, and your fix makes isolation fail-closed instead. I genuinely appreciate you strengthening the privacy story here. Merged (with a heads-up in the notes about a one-time re-login for tabs that were affected while the bug was live). |
|
Rod, thank you again 🙏 This is a real privacy fix — profiles silently sharing storage is the kind of thing that erodes trust quietly. Strengthening isolation instead of papering over it was the right call. Seriously appreciate the care here. 🐋 |
…fix garbled comments (#7322) Quality pass on renderer/shared PRs merged 2026-07-03: - WorktreeTitleInlineRename: skip the truncation measure + ResizeObserver in `wrapTitle` mode, where wrapped titles never truncate — it could only churn unused state (#7307). - editor slice: reuse the `removeEditorStateForReplacedPreview` helper this PR added instead of a hand-rolled copy of the same six-field eviction (drops ~50 lines) (#6476). - useFileExplorerTree: extract `readWorktreeDirectory` so the connectionId/settings assembly for `readRuntimeDirectory` lives in one place, not three (#6321). - comment-markdown-github-attachment-media: extract a shared `AttachmentFallbackLink` for the image/video error-fallback link (#6759). - repository-icon-github: fold the two near-identical live resolvers into one parameterized `resolveRepositoryIdentityLive`; trim a 3-line comment to 2 (#6507). - resource-usage-open-slices: delete the `shouldReadPopoverSlices` identity wrapper and inline `open` at the four call sites (#7275). - BrowserPane: drop the pointerEvents assignment already applied inside `ensureBrowserPageWebview` for the reused-webview path (#6958). - github slice: fix two garbled "…a commit main confirmed…" comments (#7277). - runtime-file-client: trim the binary-file fallback comment to its whys (#6606). - composer-branch-selection: drop the inline comment that restated the JSDoc (#6748). - TabBarQuickCommandsButton: correct the stale "+ Command" comment (button shows no +). No behavior change (the editor-helper reuse is behavior-equivalent, only more conservative on an edge case); typecheck, oxlint, react-doctor, oxfmt, and touched unit suites all pass.
…i#6958) * fix(browser): keep isolated profile storage on its partition * fix(browser): keep cloned isolated tabs on their resolved partition * fix(browser): thread resolved partition through UI profile switches Keep the isolated-storage invariant universal: UI-initiated profile switch/create now persist the resolved partition alongside the profile id, matching the runtime path, so a tab stays on its partition even if the renderer profile mirror is later stale (issue stablyai#6923). Co-authored-by: Orca <[email protected]> * fix(browser): persist resolved partition through session restore Add sessionPartition to the workspace-session zod schema so the resolved partition survives persist->load; without it zod strips the field and a restored isolated tab whose profile mirror is stale at startup falls back to the shared default partition, reopening the storage leak (stablyai#6923). Fold the webview teardown branches (parent drift or partition mismatch) into one and re-resolve the viewport container once, matching the pre-refactor null-guard behavior. Split the sleeping-agent parse tests into their own file to keep both under the 800-line cap. Co-authored-by: Orca <[email protected]> * fix(browser): keep CLI-created tabs inheriting the default profile browserTabCreate without an explicit profile was sending sessionProfileId: null, which the renderer store treats as 'no inheritance' (its guard is !== undefined). That forced CLI-created tabs onto the shared default partition even when the user had configured a default browser session profile, silently changing behavior a stablyai#6923 fix should not touch. Leave sessionProfileId/sessionPartition undefined when no profile is named so the renderer applies default-profile inheritance; thread the resolved partition only when a profile is explicitly chosen. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Neil <[email protected]> Co-authored-by: Orca <[email protected]>
…fix garbled comments (stablyai#7322) Quality pass on renderer/shared PRs merged 2026-07-03: - WorktreeTitleInlineRename: skip the truncation measure + ResizeObserver in `wrapTitle` mode, where wrapped titles never truncate — it could only churn unused state (stablyai#7307). - editor slice: reuse the `removeEditorStateForReplacedPreview` helper this PR added instead of a hand-rolled copy of the same six-field eviction (drops ~50 lines) (stablyai#6476). - useFileExplorerTree: extract `readWorktreeDirectory` so the connectionId/settings assembly for `readRuntimeDirectory` lives in one place, not three (stablyai#6321). - comment-markdown-github-attachment-media: extract a shared `AttachmentFallbackLink` for the image/video error-fallback link (stablyai#6759). - repository-icon-github: fold the two near-identical live resolvers into one parameterized `resolveRepositoryIdentityLive`; trim a 3-line comment to 2 (stablyai#6507). - resource-usage-open-slices: delete the `shouldReadPopoverSlices` identity wrapper and inline `open` at the four call sites (stablyai#7275). - BrowserPane: drop the pointerEvents assignment already applied inside `ensureBrowserPageWebview` for the reused-webview path (stablyai#6958). - github slice: fix two garbled "…a commit main confirmed…" comments (stablyai#7277). - runtime-file-client: trim the binary-file fallback comment to its whys (stablyai#6606). - composer-branch-selection: drop the inline comment that restated the JSDoc (stablyai#6748). - TabBarQuickCommandsButton: correct the stale "+ Command" comment (button shows no +). No behavior change (the editor-helper reuse is behavior-equivalent, only more conservative on an edge case); typecheck, oxlint, react-doctor, oxfmt, and touched unit suites all pass.
Fixes #6923
Description
Isolated browser session profiles were not actually isolating web storage: cookies and
localStoragecould be shared with the default session because an unresolved/"invalid" profile silently downgraded into the shared default Electron partition (ORCA_BROWSER_PARTITION).Two independent paths caused the downgrade:
browserTabCreateresolved the partition through a lookup that fell back to the shared default for any unknownprofileId, so a stale or bad profile id produced a tab that silently wrote into shared storage.browserSessionProfilesmirror (sessionProfile?.partition ?? ORCA_BROWSER_PARTITION). At startup that mirror can be empty/stale, so a restored isolated tab attached to the default partition until (if ever) the mirror hydrated.This PR makes the resolved partition authoritative and durable:
browserSessionRegistry.resolveKnownPartition()which returnsnullfor an unknown profile instead of the shared default.browserTabCreatenow rejects an unknown explicitprofileId(invalid_argument) rather than downgrading it.sessionPartitionfrom main through tab creation, tab duplication, and profile switches, and persists it onBrowserWorkspace.sessionPartitionto the workspace-session zod schema so it survives persist→restore (zod strips unlisted keys — without this the persisted partition was dropped on load and the leak reopened across restarts).sessionPartitionas the primary source for the webview partition (sessionPartition ?? sessionProfile?.partition ?? ORCA_BROWSER_PARTITION), so a stale renderer profile mirror can no longer strand an isolated tab on the shared partition.buildDuplicatedBrowserTabOptionshelper so a duplicated isolated tab keeps its partition.The security boundary is unchanged:
will-attach-webviewstill fails closed viabrowserSessionRegistry.isAllowedPartition()(the registry is the sole authority), partition names remainpersist:orca-browser-session-<uuid>fromrandomUUID(), and the persisted-profile validator (PARTITION_RE) still gates deserialized partitions. A persistedsessionPartitionthat isn't in the registry allowlist cannot attach a guest.Evidence
origin/main(a CLI-created isolated tab whose renderer mirror is stale resolves topersist:orca-browser— the shared default) and passes on this branch (resolves to the profile's own partition). Evidence captured invalidation-evidence/pr6958-repro-{BEFORE-origin-main,AFTER-pr-branch}.txt.workspace-session-schematest asserts a persistedsessionPartitionsurvivesparseWorkspaceSessionhydration (guards the zod-strip regression).orca-runtime-browsertests assert the resolved isolated partition is sent on create, unknown explicit profile ids are rejected before a renderer request, and the resolved partition is sent on profile switch.pnpm run typecheckclean, lint clean.ELI5
Think of browser profiles as separate lockers. The bug was: if the app couldn't immediately find your named locker, it quietly dumped your stuff into the shared hallway locker that everyone uses — so your "private" cookies mixed with the shared session. This change makes the app remember exactly which locker each tab belongs to (and refuse to open a tab for a locker that doesn't exist), instead of silently falling back to the shared one.
Trade-offs
sessionPartitionis deterministically derivable fromsessionProfileId, so persisting it is technically redundant state that could drift. It is persisted deliberately because the renderer's profile mirror is async-hydrated and can be stale at exactly the moment a restored tab needs its partition. All write paths (create, duplicate, switch) set both fields together.browser tab createwithout--profilecontinues to inherit the user's configured default browser session profile (it leavessessionProfileId/sessionPartitionunset so the renderer applies inheritance); only an explicit--profilethreads an authoritative partition. This keeps the fix scoped to Browser profiles do not isolate web storage (localStorage + cookies shared across --scope isolated) #6923 and avoids changing unrelated CLI semantics.