fix(sidebar): reveal duplicate owner folder groups

This commit is contained in:
Brennan Benson
2026-08-10 20:17:43 -07:00
parent d87fc15f05
commit 8468f940c2
2 changed files with 28 additions and 3 deletions
@@ -162,6 +162,26 @@ describe('worktree list folder reveal', () => {
])
})
it('derives the owner when only project-group ids collide', () => {
const localGroup = makeProjectGroup({ id: 'group-child', executionHostId: 'local' })
const runtimeGroup = makeProjectGroup({
id: 'group-child',
executionHostId: 'runtime:env-1'
})
const runtimeFolder = makeFolderWorkspace({
id: 'runtime-folder',
executionHostId: 'runtime:env-1'
})
expect(
getFolderWorkspaceRevealGroupKeys(
folderWorkspaceKey(runtimeFolder.id),
[runtimeFolder],
[localGroup, runtimeGroup]
)
).toEqual([getProjectGroupHeaderKey(runtimeGroup.id, 'runtime:env-1')])
})
it('uses qualified DOM row keys only for collision-qualified folder rows', () => {
expect(
getFolderWorkspaceSidebarRowKey('folder-workspace-1', 'folder-workspace:folder-workspace-1')
@@ -107,16 +107,21 @@ export function getFolderWorkspaceRevealGroupKeys(
return []
}
const resolvedOwnerHostId =
ownerHostId ?? resolveFolderWorkspaceCatalogOwnerHostId(folderWorkspace, projectGroups)
if (!resolvedOwnerHostId) {
return []
}
const projectGroupIndex = buildProjectGroupSidebarIndex(projectGroups)
let group = findProjectGroupForSidebarOwner(
projectGroupIndex,
folderWorkspace.projectGroupId,
ownerHostId
resolvedOwnerHostId
)
const keys: string[] = []
const seen = new Set<string>()
while (group) {
const identity = JSON.stringify([ownerHostId, group.id])
const identity = JSON.stringify([resolvedOwnerHostId, group.id])
if (seen.has(identity)) {
break
}
@@ -124,7 +129,7 @@ export function getFolderWorkspaceRevealGroupKeys(
keys.unshift(
getProjectGroupHeaderKey(
group.id,
projectGroupIndex.ambiguousIds.has(group.id) ? ownerHostId : undefined
projectGroupIndex.ambiguousIds.has(group.id) ? resolvedOwnerHostId : undefined
)
)
group = findProjectGroupParentForSidebar(projectGroupIndex, group)