feat: move the home tree's owner menu to the row's right side (#12359)

Folder and user rows keep the ellipsis menu beside the +@ button, before
the chevron, so badges line up across rows. User rows get the menu too,
with Add to AI session context.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Guilhem
2026-11-12 16:40:25 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 2994e06643
commit 67cfa4630f
2 changed files with 50 additions and 51 deletions
@@ -18,8 +18,6 @@
toggleLabel?: string
/** The line under the name, usually its item count. */
detail: Snippet
/** Controls rendered next to the name. Clicks on them do not toggle the row. */
actions?: Snippet
/** Always-visible control before the icon (e.g. a checkbox). Clicks on it do not
* toggle the row. */
lead?: Snippet
@@ -37,7 +35,6 @@
indent = 0,
toggleLabel,
detail,
actions,
lead,
trailing,
expandable = true
@@ -65,22 +62,7 @@
{/if}
<Icon size={16} class="text-secondary shrink-0" />
<div>
<div class="flex flex-row items-center gap-1">
<span class="whitespace-nowrap text-xs text-emphasis font-semibold">{name}</span>
{#if actions}
<!-- Shown for the hovered row, a tabbed-into one, or one whose menu is open.
`-my-0.5` keeps the 20px trigger from making this line taller than the
name alone, so rows with and without actions line up. -->
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div
class="-my-0.5 opacity-0 transition-opacity duration-100 group-hover/row:opacity-100 group-has-[:focus-visible]/row:opacity-100 has-[[aria-expanded=true]]:opacity-100"
onclick={(e) => e.stopPropagation()}
>
{@render actions()}
</div>
{/if}
</div>
<span class="whitespace-nowrap text-xs text-emphasis font-semibold">{name}</span>
<div class="text-2xs font-normal text-secondary whitespace-nowrap">
{@render detail()}
</div>
@@ -104,5 +86,8 @@
<ChevronDown size={16} />
{/if}
</button>
{:else if trailing}
<!-- The chevron's width, so trailing controls line up with those of expandable rows. -->
<span class="w-4 shrink-0" aria-hidden="true"></span>
{/if}
</div>
@@ -19,7 +19,7 @@
type ItemType,
type UserItem
} from './treeViewUtils'
import { pluralize } from '$lib/utils'
import { pluralize, type Item as MenuItem } from '$lib/utils'
import { Button } from '$lib/components/common'
import { inUnruledList, rowRule } from '../common/table/unruledList'
import type { TreeOpenMemory } from './treeViewState.svelte'
@@ -124,6 +124,33 @@
)
const mentionRoot = $derived(homeComposerContext.available ? badgeRoot : undefined)
const ownerMenuItems = $derived.by(() => {
const items: MenuItem[] = []
if (mentionRoot) {
const path = mentionRoot
items.push({
displayName: 'Add to AI session context',
icon: AtSign,
type: 'ai',
action: () => homeComposerContext.attach(folderContextElement(path))
})
}
if (onManageFolder && isFolder(item) && depth === 0) {
const folderName = item.folderName
// The Folders page's write rule. A non-owner's drawer opens read-only.
const canWrite =
$userStore?.is_admin ||
$userStore?.is_super_admin ||
$userStore?.folders_owners.includes(folderName)
items.push({
displayName: canWrite ? 'Manage folder' : 'View folder',
icon: canWrite ? Pen : Eye,
action: () => onManageFolder?.(folderName)
})
}
return items
})
// Hidden while searching: pipelines aren't part of the text filter (the list
// view hides their rows on a query too), so a folder matching the search
// shouldn't surface an unrelated Pipeline row.
@@ -344,39 +371,27 @@
</Button>
</span>
{/if}
{#if badgeRoot}
<!-- Every owner row keeps this place, menu or not, so the badges line up down the tree.
The menu shows on the hovered or tabbed-into row, or the one whose menu is open. -->
{#if ownerMenuItems.length > 0}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
<span
class="inline-flex opacity-0 transition-opacity duration-100 group-hover/row:opacity-100 group-has-[:focus-visible]/row:opacity-100 has-[[aria-expanded=true]]:opacity-100"
onclick={(e) => e.stopPropagation()}
>
<Dropdown size="sm" fixedHeight={false} placement="bottom-end" items={ownerMenuItems} />
</span>
{:else}
<span class="invisible inline-flex" aria-hidden="true" inert>
<Dropdown size="sm" fixedHeight={false} items={[]} />
</span>
{/if}
{/if}
</span>
{/snippet}
{#snippet manageFolderMenu()}
{#if isFolder(item)}
{@const folderName = item.folderName}
<!-- The Folders page's write rule. A non-owner's drawer opens read-only. -->
{@const canWrite =
$userStore?.is_admin ||
$userStore?.is_super_admin ||
$userStore?.folders_owners.includes(folderName)}
<Dropdown
size="xs"
fixedHeight={false}
placement="bottom-start"
items={[
{
displayName: 'Add to AI session context',
icon: AtSign,
type: 'ai',
action: () => homeComposerContext.attach(folderContextElement(`f/${folderName}`)),
hide: !homeComposerContext.available
},
{
displayName: canWrite ? 'Manage folder' : 'View folder',
icon: canWrite ? Pen : Eye,
action: () => onManageFolder?.(folderName)
}
]}
/>
{/if}
{/snippet}
{#snippet ownerLeadForNode()}
{#if nodePrefix != undefined}
{@render ownerLead?.(nodePrefix)}
@@ -392,7 +407,6 @@
onToggle={toggleOwner}
expandable={!empty || opened}
indent={visualDepth * 16}
actions={onManageFolder && depth === 0 && isFolder(item) ? manageFolderMenu : undefined}
lead={ownerLead && nodePrefix != undefined ? ownerLeadForNode : undefined}
trailing={badgeRoot ? folderTrailing : undefined}
>