mirror of
https://github.com/stablyai/orca.git
synced 2026-10-17 16:02:55 +00:00
fix: address pr-bug-scan validated finding from #6958
deleteBrowserSessionProfile now resets sessionProfileId/sessionPartition on referencing tabs, so a deleted profile's tab falls back to the allowlisted default partition instead of the de-allowlisted o
This commit is contained in:
@@ -658,6 +658,28 @@ describe('createBrowserSlice runtime guard', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('clears the deleted profile partition from referencing tabs so they fall back to the default partition', async () => {
|
||||
// Regression for #6923 follow-up: deleting a profile de-allowlists its
|
||||
// partition in main. A tab still pointing at it would be denied attachment
|
||||
// by will-attach-webview and render blank after restart/remount. The tab
|
||||
// must reset to the allowlisted default partition instead.
|
||||
const store = createTestStore()
|
||||
mockApi.browser.sessionDeleteProfile.mockResolvedValueOnce(true)
|
||||
store.setState({ browserSessionProfiles: [] })
|
||||
const tab = store.getState().createBrowserTab('wt-1', 'https://example.com', {
|
||||
sessionProfileId: 'profile-isolated',
|
||||
sessionPartition: 'persist:orca-browser-session-profile-isolated'
|
||||
})
|
||||
|
||||
await store.getState().deleteBrowserSessionProfile('profile-isolated')
|
||||
|
||||
const updated = store
|
||||
.getState()
|
||||
.browserTabsByWorktree['wt-1']?.find((t) => t.id === tab.id)
|
||||
expect(updated?.sessionProfileId).toBeNull()
|
||||
expect(updated?.sessionPartition).toBeNull()
|
||||
})
|
||||
|
||||
it('creates new browser tabs through the owning runtime for desktop remote worktrees', async () => {
|
||||
const store = createTestStore()
|
||||
store.setState({
|
||||
|
||||
@@ -349,6 +349,33 @@ function buildWorkspaceFromPage(
|
||||
}
|
||||
}
|
||||
|
||||
// Why: when a session profile is deleted its per-profile partition is removed
|
||||
// from the main-process allowlist, so any tab still pointing at it would be
|
||||
// denied attachment by will-attach-webview and render blank after a restart or
|
||||
// remount (#6923 follow-up). Reset the persisted profile id/partition on those
|
||||
// tabs so the webview falls back to the allowlisted default partition, matching
|
||||
// the pre-sessionPartition behavior.
|
||||
function clearDeletedProfileFromBrowserTabs(
|
||||
browserTabsByWorktree: Record<string, BrowserWorkspace[]>,
|
||||
profileId: string
|
||||
): Record<string, BrowserWorkspace[]> {
|
||||
let changed = false
|
||||
const next: Record<string, BrowserWorkspace[]> = {}
|
||||
for (const [worktreeId, tabs] of Object.entries(browserTabsByWorktree)) {
|
||||
let tabsChanged = false
|
||||
const updatedTabs = tabs.map((tab) => {
|
||||
if (tab.sessionProfileId !== profileId) {
|
||||
return tab
|
||||
}
|
||||
tabsChanged = true
|
||||
return { ...tab, sessionProfileId: null, sessionPartition: null }
|
||||
})
|
||||
next[worktreeId] = tabsChanged ? updatedTabs : tabs
|
||||
changed = changed || tabsChanged
|
||||
}
|
||||
return changed ? next : browserTabsByWorktree
|
||||
}
|
||||
|
||||
function mirrorWorkspaceFromActivePage(
|
||||
workspace: BrowserWorkspace,
|
||||
pages: BrowserPage[]
|
||||
@@ -1791,6 +1818,10 @@ export const createBrowserSlice: StateCreator<AppState, [], [], BrowserSlice> =
|
||||
s,
|
||||
s.browserSessionProfiles.filter((p) => p.id !== profileId)
|
||||
),
|
||||
browserTabsByWorktree: clearDeletedProfileFromBrowserTabs(
|
||||
s.browserTabsByWorktree,
|
||||
profileId
|
||||
),
|
||||
...(s.defaultBrowserSessionProfileId === profileId
|
||||
? {
|
||||
defaultBrowserSessionProfileId: null,
|
||||
@@ -1815,6 +1846,10 @@ export const createBrowserSlice: StateCreator<AppState, [], [], BrowserSlice> =
|
||||
s,
|
||||
s.browserSessionProfiles.filter((p) => p.id !== profileId)
|
||||
),
|
||||
browserTabsByWorktree: clearDeletedProfileFromBrowserTabs(
|
||||
s.browserTabsByWorktree,
|
||||
profileId
|
||||
),
|
||||
...(s.defaultBrowserSessionProfileId === profileId
|
||||
? {
|
||||
defaultBrowserSessionProfileId: null,
|
||||
|
||||
Reference in New Issue
Block a user