Revert "Fix hide sleeping lineage restoration (#4543)"
This reverts commit 195f3e94f9.
This commit is contained in:
@@ -233,7 +233,7 @@ describe('computeVisibleWorktreeIds', () => {
|
||||
expect(result).toEqual([feature2.id])
|
||||
})
|
||||
|
||||
it('does not include slept lineage parents when sleeping workspaces are hidden', () => {
|
||||
it('includes valid lineage parents even when another filter would hide the parent', () => {
|
||||
const parent = makeWorktree('parent')
|
||||
const child = makeWorktree('child')
|
||||
const lineage = makeWorktreeLineage(child, parent)
|
||||
@@ -248,31 +248,7 @@ describe('computeVisibleWorktreeIds', () => {
|
||||
})
|
||||
)
|
||||
|
||||
expect(result).toEqual([child.id])
|
||||
})
|
||||
|
||||
it('stops lineage restoration at a slept ancestor when sleeping workspaces are hidden', () => {
|
||||
const grandparent = makeWorktree('grandparent', 'repo1')
|
||||
const parent = makeWorktree('parent', 'repo1')
|
||||
const child = makeWorktree('child', 'repo2')
|
||||
const parentLineage = makeWorktreeLineage(parent, grandparent)
|
||||
const childLineage = makeWorktreeLineage(child, parent)
|
||||
|
||||
const result = computeVisibleWorktreeIds(
|
||||
{ repo1: [grandparent, parent], repo2: [child] },
|
||||
[child.id, parent.id, grandparent.id],
|
||||
visibleOptions({
|
||||
filterRepoIds: ['repo2'],
|
||||
showSleepingWorkspaces: false,
|
||||
sleptWorktreeIds: { [parent.id]: true },
|
||||
worktreeLineageById: {
|
||||
[parent.id]: parentLineage,
|
||||
[child.id]: childLineage
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
expect(result).toEqual([child.id])
|
||||
expect(result).toEqual([parent.id, child.id])
|
||||
})
|
||||
|
||||
it('does not resurrect stale lineage parents', () => {
|
||||
|
||||
@@ -129,21 +129,14 @@ export function computeVisibleWorktreeIds(
|
||||
return addVisibleLineageAncestors(
|
||||
all.map((w) => w.id),
|
||||
lineageAncestorById,
|
||||
opts.worktreeLineageById,
|
||||
{
|
||||
canRestoreAncestor: (worktree) =>
|
||||
opts.showSleepingWorkspaces || !isSleptWorkspace(worktree.id, opts.sleptWorktreeIds)
|
||||
}
|
||||
opts.worktreeLineageById
|
||||
)
|
||||
}
|
||||
|
||||
function addVisibleLineageAncestors(
|
||||
ids: string[],
|
||||
worktreeById: Map<string, Worktree>,
|
||||
lineageById: Record<string, WorktreeLineage>,
|
||||
opts: {
|
||||
canRestoreAncestor: (worktree: Worktree) => boolean
|
||||
}
|
||||
lineageById: Record<string, WorktreeLineage>
|
||||
): string[] {
|
||||
const result: string[] = []
|
||||
const included = new Set<string>()
|
||||
@@ -163,11 +156,10 @@ function addVisibleLineageAncestors(
|
||||
if (
|
||||
parent &&
|
||||
worktree.instanceId === lineage.worktreeInstanceId &&
|
||||
parent.instanceId === lineage.parentWorktreeInstanceId &&
|
||||
opts.canRestoreAncestor(parent)
|
||||
parent.instanceId === lineage.parentWorktreeInstanceId
|
||||
) {
|
||||
// Why: lineage can restore structural parents, but the explicit sleep
|
||||
// filter is a user request to keep slept workspaces out of navigation.
|
||||
// Why: sidebar lineage is structural. If a filtered child is visible,
|
||||
// its valid parent must be rendered too so the hierarchy remains legible.
|
||||
addWithAncestors(parent.id)
|
||||
}
|
||||
visiting.delete(id)
|
||||
|
||||
Reference in New Issue
Block a user