fix: hide your own empty user space with the hide empty folders option (#12345)

* fix: hide your own empty user space with the hide empty folders option

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: gate hiding your own empty space on the option being offered

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Guilhem
2026-11-11 11:52:58 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent d1e97ef020
commit d37dcca4c6
2 changed files with 15 additions and 7 deletions
@@ -963,6 +963,9 @@
!flatList && !searching && ownerFilter == undefined && labelFilter == undefined
)
// Only the unfiltered tree lists folders it holds no rows of.
let hideEmptyFoldersOffered = $derived(treeLazyMode && !archived && keepEmptyFolders)
let listSettingsItems: MenuItem[] = $derived([
{
displayName: 'Flat list',
@@ -973,10 +976,9 @@
{
displayName: 'Hide empty folders',
description:
'Folders with no scripts, flows, apps, agents or data pipelines. They may still hold resources, variables or schedules.',
'Folders and your user space with no scripts, flows, apps, agents or data pipelines. They may still hold resources, variables or schedules.',
toggle: hideEmptyFolders,
// Only the unfiltered tree lists folders it holds no rows of.
hide: !treeLazyMode || archived || !keepEmptyFolders,
hide: !hideEmptyFoldersOffered,
action: () => setHideEmptyFolders(!hideEmptyFolders)
},
{
@@ -2462,6 +2464,7 @@
: undefined}
keepEmptyFolders={keepEmptyFolders && !hideEmptyFolders}
{keptFolders}
hideEmptySelf={hideEmptyFoldersOffered && hideEmptyFolders}
/>
{/key}
{/if}
@@ -34,7 +34,7 @@
// when it doesn't apply, in which case every owner is injected as before.
ownerCounts?: Record<string, number>
// The viewer's own username: their personal space is a fixture of the tree and
// stays even when empty, so they have somewhere to create into.
// stays even when empty, so they have somewhere to create into, unless `hideEmptySelf`.
selfUsername?: string
ownerLoad?: Record<
string,
@@ -64,6 +64,8 @@
keepEmptyFolders?: boolean
// Folders injected even when empty and `keepEmptyFolders` is off.
keptFolders?: string[]
// Drop `selfUsername`'s space too when it holds nothing, instead of keeping it as "0 items".
hideEmptySelf?: boolean
}
let {
@@ -92,7 +94,8 @@
ownerLead,
ownerDetail,
keepEmptyFolders = false,
keptFolders
keptFolders,
hideEmptySelf = false
}: Props = $props()
const unruled = inUnruledList()
@@ -121,6 +124,7 @@
selfUsername
keepEmptyFolders
keptFolders
hideEmptySelf
untrack(() => {
// While searching, `items` is already relevance-ranked and the sort
// selector is disabled, so keep that order: a no-op leaf comparator
@@ -170,8 +174,9 @@
for (const username of allUsers) {
if (presentUsers.has(username)) continue
// Your own space is exempt from the drop: it's where you create, so it
// stays visible (as "0 items") when empty rather than disappearing.
if (username !== selfUsername && isEmptyOwner(`u/${username}`)) continue
// stays visible (as "0 items") when empty rather than disappearing, unless `hideEmptySelf`.
if ((hideEmptySelf || username !== selfUsername) && isEmptyOwner(`u/${username}`))
continue
presentUsers.add(username)
missingUsers.push({ username, items: [] })
}