Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat(desktop): move resources by dropping rows onto breadcrumb crumbs

M44ab91f63244
diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsx
index b8cb0b242..3d0d5ae93 100644
--- a/desktop-app/ui/src/pages/FilesPage.tsx
+++ b/desktop-app/ui/src/pages/FilesPage.tsx
@@ -225,8 +225,14 @@ function mergeErrorMessages(...errors: unknown[]): string | null {
return messages.length > 0 ? messages.join(' · ') : null
}
+/** A drop destination the drag pipeline can move INTO: a grid folder row or a
+ * breadcrumb crumb. Only the identity fields admission and the commit need. */
+type GfsFolderDropTarget = Pick<GfsDriveResource, 'resourceId' | 'name'> & {
+ kind: 'directory'
+}
+
/** Any row/header action target — a listing row (GfsDriveResource) or the
- * current breadcrumb (GfsCrumb); both carry the identity fields the delete /
+ * current breadcrumb (GfsCrumb); both carry the identity fields the delete /
* rename / move calls need (kind also powers dialog titles + the move cycle
* guard). */
type GfsActionTarget = Pick<GfsDriveResource, 'resourceId' | 'name' | 'version'> & {
@@ -1512,6 +1518,66 @@ export function FilesPage({
}
}
+ /** Nearest-first ancestor chain of a breadcrumb target, observed through the
+ * live trail (the crumbs above the hovered one). Crumbs are ancestors of
+ * the current folder, so a crumb can never be inside a dragged row — the
+ * descendant case is unreachable here and the policy sees an honest chain. */
+ const crumbTargetAncestorIds = (index: number): string[] =>
+ crumbs
+ .slice(0, index)
+ .map(trailCrumb => trailCrumb.resourceId)
+ .reverse()
+
+ /** Breadcrumb hover (drop-move parity with Control UI): paint the verdict on
+ * the crumb, keep internal drops deliverable even when denied (§5.3), and
+ * cold-check through the same budgeted adjudication the grid rows use. The
+ * dragged source is the shared drag-session source captured at dragstart —
+ * its parent identity is frozen, so the same-parent verdict can never be
+ * flipped by a trail reconstruction landing mid-gesture (Control UI R7). */
+ const handleCrumbDragOver = (
+ event: ReactDragEvent<HTMLElement>,
+ crumb: GfsCrumb,
+ index: number
+ ) => {
+ if (!hasDraggedGfsResource(event)) return
+ const source = resolveActiveSource()
+ if (!source) return
+ event.preventDefault()
+ event.stopPropagation()
+ hoveredFolderRef.current = crumb.resourceId
+ hoverOwnerRef.current = source
+ setDragSourceName(previous => (previous === source.name ? previous : source.name))
+ const target = {
+ resourceId: crumb.resourceId,
+ name: crumb.name,
+ kind: 'directory',
+ ancestorIds: crumbTargetAncestorIds(index),
+ } as const
+ const verdict = applyHoverVerdict(
+ crumb.resourceId,
+ adjudication.hoverVerdict(source, target),
+ crumb.name,
+ source.name
+ )
+ event.dataTransfer.dropEffect = 'move'
+ if (verdict.state === 'checking') {
+ adjudication.scheduleColdCheck(
+ target,
+ source.parentKnown ? source.parentResourceId : null,
+ () => {
+ if (hoverOwnerRef.current !== source || hoveredFolderRef.current !== crumb.resourceId)
+ return
+ applyHoverVerdict(
+ crumb.resourceId,
+ adjudication.hoverVerdict(source, target),
+ crumb.name,
+ source.name
+ )
+ }
+ )
+ }
+ }
+
/** Cached destination names for the suggested numbered-name candidate. */
const cachedDestinationNames = (destinationId: string): Set<string> => {
const cached = queryClient.getQueryData<{ pages?: Array<{ items?: GfsDriveResource[] }> }>(
@@ -1560,7 +1626,7 @@ export function FilesPage({
const handleFolderDrop = async (
event: ReactDragEvent<HTMLElement>,
- destination: GfsDriveResource
+ destination: GfsFolderDropTarget
) => {
if (!hasDraggedGfsResource(event)) return
event.preventDefault()
@@ -2079,10 +2145,38 @@ export function FilesPage({
/>
) : (
<Button
- className="da-gfs-drive__breadcrumb"
+ className={`da-gfs-drive__breadcrumb${
+ dragOverFolderId === crumb.resourceId
+ ? ' da-gfs-drive__breadcrumb--allowed'
+ : ''
+ }`}
color="neutral"
disabled={index === crumbs.length - 1}
+ title={
+ gfsDropVerdictReason(dropStatesById[crumb.resourceId]) !== undefined
+ ? gfsDropVerdictLiveAnnouncement(
+ dropStatesById[crumb.resourceId]!,
+ crumb.name,
+ dragSourceName ?? undefined
+ )
+ : undefined
+ }
+ data-drop-state={dropStatesById[crumb.resourceId]?.state}
+ data-drop-reason={gfsDropVerdictReason(dropStatesById[crumb.resourceId])}
onClick={() => ctrl.goToCrumb(index)}
+ onDragEnter={event => handleCrumbDragOver(event, crumb, index)}
+ onDragOver={event => handleCrumbDragOver(event, crumb, index)}
+ onDragLeave={handleFolderDragLeave}
+ onDrop={
+ index === crumbs.length - 1
+ ? undefined
+ : event =>
+ void handleFolderDrop(event, {
+ resourceId: crumb.resourceId,
+ name: crumb.name,
+ kind: 'directory',
+ })
+ }
variant="text"
>
{crumb.name}
@@ -2402,7 +2496,12 @@ export function FilesPage({
}
onDrop={
resource.kind === 'directory'
- ? event => void handleFolderDrop(event, resource)
+ ? event =>
+ void handleFolderDrop(event, {
+ resourceId: resource.resourceId,
+ name: resource.name,
+ kind: 'directory',
+ })
: undefined
}
>
diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
index c1bbd1158..8d717d3ba 100644
--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
@@ -6905,6 +6905,189 @@ describe('FilesPage — folder drag-and-drop', () => {
expect(moveResource).toHaveBeenCalledTimes(1)
})
+ // Breadcrumb crumb drop targets (Control UI parity): the trail inside a
+ // nested folder — folder-0 "Product" is an enabled ancestor crumb, folder-1
+ // "Child" is the active (disabled) crumb and the rows' parent.
+ function crumbDragHarness(
+ options: {
+ destinationHeld?: string[]
+ sourceParentHeld?: string[]
+ sourceResourceHeld?: string[]
+ } = {}
+ ) {
+ const pushToast = vi.fn()
+ const moveResource = vi.fn(async () => ({ resourceId: 'folder-src', version: 5 }))
+ const affordances = vi.fn(async (resourceId: string) => {
+ if (resourceId === 'folder-0') {
+ return { held: options.destinationHeld ?? ['read', 'write', 'delete'] }
+ }
+ if (resourceId === 'folder-1') {
+ return { held: options.sourceParentHeld ?? ['read', 'write', 'delete'] }
+ }
+ return { held: options.sourceResourceHeld ?? ['read', 'write'] }
+ })
+ const resolve = vi.fn(async () => ({
+ drive: 'main',
+ resourceId: 'folder-src',
+ parentResourceId: 'folder-1',
+ rid: 'foldersrc',
+ gfsUri: 'gfs://main/foldersrc',
+ name: 'Projects',
+ kind: 'directory',
+ pathCache: '/Product/Child/Projects',
+ version: 4,
+ }))
+ Object.defineProperty(window, 'clerum', {
+ configurable: true,
+ value: { gfs: { affordances, resolve } },
+ })
+ hookMock.useGfsBrowserController.mockReturnValue({
+ ...baseController(),
+ current: {
+ resourceId: 'folder-1',
+ gfsUri: 'gfs://main/folder-1',
+ name: 'Child',
+ kind: 'directory',
+ version: 1,
+ },
+ crumbs: [
+ {
+ resourceId: 'folder-0',
+ gfsUri: 'gfs://main/folder-0',
+ name: 'Product',
+ kind: 'directory',
+ version: 1,
+ bytes: 0,
+ },
+ {
+ resourceId: 'folder-1',
+ gfsUri: 'gfs://main/folder-1',
+ name: 'Child',
+ kind: 'directory',
+ version: 1,
+ bytes: 0,
+ },
+ ],
+ items: [
+ {
+ resourceId: 'folder-src',
+ rid: 'folder-src',
+ gfsUri: 'gfs://main/folder-src',
+ drive: 'main',
+ parentResourceId: 'folder-1',
+ name: 'Projects',
+ kind: 'directory',
+ path: '/Product/Child/Projects',
+ version: 4,
+ bytes: 0,
+ },
+ {
+ resourceId: 'archive-1',
+ rid: 'archive-1',
+ gfsUri: 'gfs://main/archive-1',
+ drive: 'main',
+ parentResourceId: 'folder-1',
+ name: 'Archive',
+ kind: 'directory',
+ path: '/Product/Child/Archive',
+ version: 2,
+ bytes: 0,
+ },
+ ],
+ moveResource,
+ })
+ renderFilesPage(pushToast)
+ return { pushToast, moveResource }
+ }
+
+ function crumbDragDataTransfer() {
+ return {
+ types: ['application/x-evenfire-gfs-resource'],
+ files: [],
+ effectAllowed: 'none',
+ dropEffect: 'none',
+ setData: vi.fn(),
+ }
+ }
+
+ it('drops a dragged folder onto an ancestor crumb after the one confirmation', async () => {
+ const { pushToast, moveResource } = crumbDragHarness()
+ const sourceRow = screen.getByRole('button', { name: 'Open Projects' })
+ const ancestorCrumb = screen.getByRole('button', { name: 'Product' })
+ const dataTransfer = crumbDragDataTransfer()
+
+ fireEvent.dragStart(sourceRow, { dataTransfer })
+ fireEvent.dragEnter(ancestorCrumb, { dataTransfer })
+ fireEvent.dragOver(ancestorCrumb, { dataTransfer })
+ fireEvent.drop(ancestorCrumb, { dataTransfer })
+
+ const dialog = await screen.findByRole('dialog', { name: 'Move folder Projects to Product' })
+ expect(
+ within(dialog).getByText(
+ /Inherited access to this folder and its contents follows the new location/
+ )
+ ).toBeTruthy()
+ expect(moveResource).not.toHaveBeenCalled()
+
+ await act(async () => {
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move' }))
+ })
+ await waitFor(() => {
+ expect(moveResource).toHaveBeenCalledWith('folder-src', 'folder-0', 4, undefined, 'folder-1')
+ })
+ await waitFor(() =>
+ expect(pushToast).toHaveBeenCalledWith('Moved Projects to Product', 'success')
+ )
+ expect(pushToast).toHaveBeenCalledWith(
+ 'Moving a folder changes who can access its contents — access now follows the new location.',
+ 'info'
+ )
+ expect(screen.queryByRole('dialog')).toBeNull()
+ })
+
+ it('cancelling a crumb-drop confirmation sends nothing', async () => {
+ const { pushToast, moveResource } = crumbDragHarness()
+ const sourceRow = screen.getByRole('button', { name: 'Open Projects' })
+ const ancestorCrumb = screen.getByRole('button', { name: 'Product' })
+ const dataTransfer = crumbDragDataTransfer()
+
+ fireEvent.dragStart(sourceRow, { dataTransfer })
+ fireEvent.drop(ancestorCrumb, { dataTransfer })
+
+ const dialog = await screen.findByRole('dialog', { name: 'Move folder Projects to Product' })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Cancel' }))
+ expect(moveResource).not.toHaveBeenCalled()
+ expect(pushToast).not.toHaveBeenCalledWith(expect.stringContaining('Moved'), expect.anything())
+ expect(screen.queryByRole('dialog')).toBeNull()
+ })
+
+ it('a crumb drop without source-parent delete access refuses with the source-delete reason', async () => {
+ const { pushToast, moveResource } = crumbDragHarness({
+ sourceParentHeld: ['read', 'write'],
+ })
+ const sourceRow = screen.getByRole('button', { name: 'Open Projects' })
+ const ancestorCrumb = screen.getByRole('button', { name: 'Product' })
+ const dataTransfer = crumbDragDataTransfer()
+
+ fireEvent.dragStart(sourceRow, { dataTransfer })
+ // Hover paints the deny on the crumb itself once the cold check lands.
+ fireEvent.dragOver(ancestorCrumb, { dataTransfer })
+ await waitFor(() => {
+ expect(ancestorCrumb.getAttribute('data-drop-state')).toBe('denied')
+ })
+ expect(ancestorCrumb.getAttribute('data-drop-reason')).toBe('source-delete')
+
+ fireEvent.drop(ancestorCrumb, { dataTransfer })
+ await waitFor(() =>
+ expect(pushToast).toHaveBeenCalledWith(
+ 'You can’t move Projects out of its current folder because you don’t have delete access to the folder that contains it.',
+ 'error'
+ )
+ )
+ expect(moveResource).not.toHaveBeenCalled()
+ expect(screen.queryByRole('dialog')).toBeNull()
+ })
+
it('a file conflict resolves with a numbered whole-resource rename (CU parity)', async () => {
const pushToast = vi.fn()
let conflicted = false
diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.css
index 98859c5a4..bc4712a51 100644
--- a/desktop-app/ui/src/styles.css
+++ b/desktop-app/ui/src/styles.css
@@ -15378,6 +15378,38 @@ pre {
opacity: 1;
}
+/* Breadcrumb drop-move verdict tints (drop-move parity, refusal UX matrix):
+ same tone contract as the tree rows and grid rows — only observed-allowed
+ paints the accent, checking is neutral, the unknown family warns, and a
+ deny carries the danger inset. The active (disabled) crumb is never a
+ target, so these only ever render on ancestor crumbs. */
+.da-gfs-drive__breadcrumb.ui-button[data-drop-state='checking'] {
+ background: rgba(var(--edge-rgb), 0.08);
+}
+
+.da-gfs-drive__breadcrumb.ui-button[data-drop-state='allowed'],
+.da-gfs-drive__breadcrumb.ui-button.da-gfs-drive__breadcrumb--allowed {
+ background: rgba(var(--accent-rgb), 0.12);
+}
+
+.da-gfs-drive__breadcrumb.ui-button[data-drop-state='denied'] {
+ background: rgba(var(--danger-rgb), 0.1);
+ box-shadow: inset 2px 0 0 rgba(var(--danger-rgb), 0.72);
+}
+
+.da-gfs-drive__breadcrumb.ui-button[data-drop-state='denied'][data-drop-reason='same-parent'] {
+ background: rgba(var(--edge-rgb), 0.12);
+ box-shadow: inset 2px 0 0 rgba(var(--edge-rgb), 0.6);
+}
+
+.da-gfs-drive__breadcrumb.ui-button[data-drop-state='denied'][data-drop-reason='unavailable'],
+.da-gfs-drive__breadcrumb.ui-button[data-drop-state='denied'][data-drop-reason='target-unavailable'],
+.da-gfs-drive__breadcrumb.ui-button[data-drop-state='denied'][data-drop-reason='source-location-unknown'],
+.da-gfs-drive__breadcrumb.ui-button[data-drop-state='unavailable'] {
+ background: rgba(var(--warning-rgb), 0.1);
+ box-shadow: inset 2px 0 0 rgba(var(--warning-rgb), 0.72);
+}
+
.da-gfs-drive__header-actions {
display: flex;
align-items: center;