Skip to content

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

TypeScript

fix(desktop): keep checking drag hovers landable so drop-time adjudication runs

Md5b667f02bda
diff --git a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/__tests__/FileExplorerTree.test.tsx b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/__tests__/FileExplorerTree.test.tsx
index 39a2b5bba..eec41854b 100644
--- a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/__tests__/FileExplorerTree.test.tsx
+++ b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/__tests__/FileExplorerTree.test.tsx
@@ -867,6 +867,54 @@ describe('FileExplorerTree — drag-and-drop moves', () => {
expect(screen.queryByRole('dialog')).toBeNull()
})
+ it('keeps a checking hover landable (dropEffect move) and only a deny refuses the drop', async () => {
+ // Regression: mapping every non-'allowed' verdict to dropEffect 'none'
+ // made Chromium CANCEL the drag at release — the drop event never fired,
+ // so the drop-time priority check could not run and any hover whose
+ // affordances had not resolved yet silently swallowed the gesture.
+ const moveResource = vi.fn()
+ const affordances = vi.fn(() => new Promise<{ held: string[] }>(() => {}))
+ installDndClerum({
+ listAccessible: vi.fn(async () =>
+ listAccessiblePage([
+ accessibleResource('folder-a', 'A', 'directory'),
+ accessibleResource('folder-b', 'B', 'directory'),
+ ])
+ ),
+ listChildren: vi.fn(async () =>
+ listChildrenPage([childView('child-c', 'C', 'directory', { parentResourceId: 'folder-a' })])
+ ),
+ affordances,
+ moveResource,
+ })
+ renderTreeWithSession()
+
+ const rowA = await screen.findByRole('button', { name: 'A' })
+ const rowB = await screen.findByRole('button', { name: 'B' })
+ const bRow = rowB.closest('[role="treeitem"]')!.querySelector('.da-file-explorer__row')!
+ const dataTransfer = dragTypes()
+
+ // Authority unresolved (affordances never settle): the hover must stay
+ // LANDABLE so the drop-time priority adjudication can decide.
+ fireEvent.dragStart(rowA, { dataTransfer })
+ fireEvent.dragOver(bRow, { dataTransfer })
+ expect(dataTransfer.dropEffect).toBe('move')
+
+ // Expand A to reveal its child C; a drop into the source's own descendant
+ // is structurally denied and must keep the no-drop cursor.
+ await act(async () => {
+ fireEvent.click(rowA)
+ })
+ await waitFor(() => {
+ expect(screen.getByRole('button', { name: 'C' })).toBeTruthy()
+ })
+ const rowC = screen.getByRole('button', { name: 'C' })
+ const cRow = rowC.closest('[role="treeitem"]')!.querySelector('.da-file-explorer__row')!
+ fireEvent.dragOver(cRow, { dataTransfer })
+ expect(cRow.getAttribute('data-drop-state')).toBe('denied')
+ expect(dataTransfer.dropEffect).toBe('none')
+ })
+
it('refuses a same-parent drop before any request or confirmation', async () => {
const moveResource = vi.fn()
const affordances = vi.fn(async () => ({ held: ['read', 'write', 'delete'] }))
diff --git a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx
index f8c948985..8f412a107 100644
--- a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx
+++ b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx
@@ -563,7 +563,11 @@ export function FileExplorerTree({
? previous
: { ...previous, [node.resourceId]: verdict.state }
)
- event.dataTransfer.dropEffect = verdict.state === 'allowed' ? 'move' : 'none'
+ // 'checking' must keep the drop LANDABLE (rev-2 §4.1): dropEffect 'none'
+ // makes Chromium cancel the drag at release, so the drop-time priority
+ // adjudication could never run and unresolved authority checks silently
+ // swallowed the gesture. Only an observed deny refuses the drop.
+ event.dataTransfer.dropEffect = verdict.state === 'denied' ? 'none' : 'move'
if (verdict.state === 'checking') {
adjudication.scheduleColdCheck(
{ resourceId: node.resourceId, name: node.name, kind: node.kind, ancestorIds },
diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsx
index e4cbafef8..8db7dc3c9 100644
--- a/desktop-app/ui/src/pages/FilesPage.tsx
+++ b/desktop-app/ui/src/pages/FilesPage.tsx
@@ -55,9 +55,6 @@ import {
} from '@lib/gfsGrantErrors'
import { isGfsPreviewFile, resolveGfsPreview } from '@lib/gfsPreview'
import { formatSharedFileSize } from '@lib/sharedFiles'
-import { useGfsDragAdjudication } from '@/gfs/dragAdjudication'
-import type { GfsDragSource, GfsDropRejection, GfsDropVerdict } from '@/gfs/dragSession'
-import { useGfsDragSession } from '@/gfs/dragSession'
import { GfsGrantList } from '@/gfs/GfsGrantList'
import type { GfsAccessRole } from '@/gfs/GfsGrantList'
import type { GfsMergedAccessRow } from '@/gfs/GfsGrantList/types'
@@ -70,11 +67,14 @@ import {
type GfsGrantListItem,
} from '@/gfs/delegation'
import type { GfsInheritedAccessSource } from '@/gfs/delegation.types'
+import { useGfsDragAdjudication } from '@/gfs/dragAdjudication'
+import type { GfsDragSource, GfsDropRejection, GfsDropVerdict } from '@/gfs/dragSession'
+import { useGfsDragSession } from '@/gfs/dragSession'
import { GfsFilePicker } from '@/gfs/filePicker'
import { planInheritedRoleChange } from '@/gfs/inheritedAccess'
-import { GfsMoveConfirmDialog } from '@/gfs/moveConfirmDialog'
import { commitGfsMove, suggestNumberedMoveName } from '@/gfs/moveCommit'
import type { MoveCommitOutcome } from '@/gfs/moveCommit'
+import { GfsMoveConfirmDialog } from '@/gfs/moveConfirmDialog'
import { GfsMoveDialog } from '@/gfs/moveDialog'
import type { TeamDirectoryResult } from '../../../src/types'
import type { FilesPageProps, GfsDriveResource, MyAgentEntry } from './FilesPage.types'
@@ -332,10 +332,7 @@ export function FilesPage({
const adjudication = useGfsDragAdjudication({
scope: sessionScope,
drive: GFS_DRIVE_MAIN,
- resolve: useCallback(
- (uri: string) => window.clerum.gfs.resolve(uri),
- []
- ),
+ resolve: useCallback((uri: string) => window.clerum.gfs.resolve(uri), []),
})
const lastRemoteGfsChangeEpochRef = useRef(remoteGfsChangeEpoch)
@@ -985,9 +982,7 @@ export function FilesPage({
/** Ancestor chain of rows in the current listing, nearest-first: the open
* folder and its breadcrumb ancestors (an observation, never a guess). */
const rowTargetAncestorIds = (): (string | null)[] =>
- currentIsFolder && current
- ? [...crumbs].map(crumb => crumb.resourceId).reverse()
- : []
+ currentIsFolder && current ? [...crumbs].map(crumb => crumb.resourceId).reverse() : []
/** Build the cross-surface drag descriptor for a row of this surface. */
const dragSourceFrom = (resource: GfsDriveResource): Omit<GfsDragSource, 'generation'> => {
@@ -1003,9 +998,8 @@ export function FilesPage({
...(Number.isSafeInteger(resource.version) ? { version: resource.version } : {}),
parentKnown,
parentResourceId,
- knownAncestorIds: currentIsFolder && current
- ? [...crumbs].map(crumb => crumb.resourceId).reverse()
- : [],
+ knownAncestorIds:
+ currentIsFolder && current ? [...crumbs].map(crumb => crumb.resourceId).reverse() : [],
origin: 'files',
scope: sessionScope ?? 'anonymous',
}
@@ -1032,9 +1026,7 @@ export function FilesPage({
setDragOverFolderId(null)
}
setDropStatesById(previous =>
- previous[folderId] === verdict.state
- ? previous
- : { ...previous, [folderId]: verdict.state }
+ previous[folderId] === verdict.state ? previous : { ...previous, [folderId]: verdict.state }
)
return verdict
}
@@ -1083,20 +1075,23 @@ export function FilesPage({
kind: folder.kind,
ancestorIds: rowTargetAncestorIds(),
} as const
- const verdict = applyHoverVerdict(
- folder.resourceId,
- adjudication.hoverVerdict(source, target)
- )
- event.dataTransfer.dropEffect = verdict.state === 'allowed' ? 'move' : 'none'
+ const verdict = applyHoverVerdict(folder.resourceId, adjudication.hoverVerdict(source, target))
+ // 'checking' must keep the drop LANDABLE: with dropEffect 'none' Chromium
+ // cancels the drag at release, so the drop-time priority adjudication
+ // (rev-2 §4.1 — "priority check on drop instead of a false deny") could
+ // never run and every authority check that had not finished resolving
+ // silently swallowed the gesture. Only an observed deny refuses the drop.
+ event.dataTransfer.dropEffect = verdict.state === 'denied' ? 'none' : 'move'
if (verdict.state === 'checking') {
adjudication.scheduleColdCheck(
target,
source.parentKnown ? source.parentResourceId : null,
() => {
- if (hoveredFolderRef.current !== folder.resourceId) return
- const fresh = adjudication.hoverVerdict(source, target)
- applyHoverVerdict(folder.resourceId, fresh)
- })
+ if (hoveredFolderRef.current !== folder.resourceId) return
+ const fresh = adjudication.hoverVerdict(source, target)
+ applyHoverVerdict(folder.resourceId, fresh)
+ }
+ )
}
}
@@ -1919,26 +1914,24 @@ export function FilesPage({
const isDragging =
draggingResourceId === resource.resourceId ||
movingResourceId === resource.resourceId
- const isDropTarget = dragOverFolderId === resource.resourceId
- const dropState =
- resource.kind === 'directory' ? dropStatesById[resource.resourceId] : undefined
- const canDragResource =
- resource.readable !== false &&
- movingResourceId === null &&
- !ctrl.mutating
- return (
- <div
- className="da-grid__row da-grid__row--clickable da-grid__row--compact"
- key={resource.resourceId}
- draggable={canDragResource}
- title={
- canDragResource
- ? `Drag ${resource.name} into a folder to move it`
- : undefined
- }
- data-dragging={isDragging ? 'true' : undefined}
- data-drop-target={isDropTarget ? 'true' : undefined}
- data-drop-state={dropState}
+ const isDropTarget = dragOverFolderId === resource.resourceId
+ const dropState =
+ resource.kind === 'directory' ? dropStatesById[resource.resourceId] : undefined
+ const canDragResource =
+ resource.readable !== false && movingResourceId === null && !ctrl.mutating
+ return (
+ <div
+ className="da-grid__row da-grid__row--clickable da-grid__row--compact"
+ key={resource.resourceId}
+ draggable={canDragResource}
+ title={
+ canDragResource
+ ? `Drag ${resource.name} into a folder to move it`
+ : undefined
+ }
+ data-dragging={isDragging ? 'true' : undefined}
+ data-drop-target={isDropTarget ? 'true' : undefined}
+ data-drop-state={dropState}
role="button"
tabIndex={0}
aria-label={
diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
index 7d0646dd1..34ce6496d 100644
--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
@@ -3732,7 +3732,12 @@ describe('FilesPage', () => {
await waitFor(() => expect(affordances).toHaveBeenCalledWith('private-1', 'main'))
expect(destinationRow.getAttribute('data-drop-target')).toBeNull()
+ // The initial hover stays landable while authority is unresolved (the
+ // drop-time priority check must be reachable); once the cold check
+ // observes the missing write, a further hover refuses the drop.
+ fireEvent.dragOver(destinationRow, { dataTransfer })
expect(dataTransfer.dropEffect).toBe('none')
+ expect(destinationRow.getAttribute('data-drop-state')).toBe('denied')
fireEvent.drop(destinationRow, { dataTransfer })
await waitFor(() => {
@@ -5109,28 +5114,27 @@ describe('FilesPage — folder drag-and-drop', () => {
vi.restoreAllMocks()
})
- function folderDragHarness(options: {
- destinationHeld?: string[]
- sourceParentHeld?: string[]
- sourceResourceHeld?: string[]
- resolveParent?: string | null
- resolveVersion?: number
- moveResult?: () => Promise<{ resourceId: string; version: number }>
- conflictOnce?: boolean
- } = {}) {
+ function folderDragHarness(
+ options: {
+ destinationHeld?: string[]
+ sourceParentHeld?: string[]
+ sourceResourceHeld?: string[]
+ resolveParent?: string | null
+ resolveVersion?: number
+ moveResult?: () => Promise<{ resourceId: string; version: number }>
+ conflictOnce?: boolean
+ } = {}
+ ) {
const pushToast = vi.fn()
const moveResource = vi.fn(
- options.moveResult ??
- (async () => ({ resourceId: 'folder-src', version: 5 }))
+ options.moveResult ?? (async () => ({ resourceId: 'folder-src', version: 5 }))
)
if (options.conflictOnce) {
let conflicted = false
moveResource.mockImplementation(async () => {
if (!conflicted) {
conflicted = true
- throw new Error(
- '409 Conflict: a resource with this name already exists httpStatus=409'
- )
+ throw new Error('409 Conflict: a resource with this name already exists httpStatus=409')
}
return { resourceId: 'folder-src', version: 5 }
})
@@ -5229,7 +5233,9 @@ describe('FilesPage — folder drag-and-drop', () => {
const dialog = await screen.findByRole('dialog', { name: 'Move folder Projects to Archive' })
expect(
- within(dialog).getByText(/Inherited access to this folder and its contents follows the new location/)
+ within(dialog).getByText(
+ /Inherited access to this folder and its contents follows the new location/
+ )
).toBeTruthy()
expect(moveResource).not.toHaveBeenCalled()
@@ -5267,10 +5273,7 @@ describe('FilesPage — folder drag-and-drop', () => {
const dialog = await screen.findByRole('dialog', { name: 'Move folder Projects to Archive' })
fireEvent.click(within(dialog).getByRole('button', { name: 'Cancel' }))
expect(moveResource).not.toHaveBeenCalled()
- expect(pushToast).not.toHaveBeenCalledWith(
- expect.stringContaining('Moved'),
- expect.anything()
- )
+ expect(pushToast).not.toHaveBeenCalledWith(expect.stringContaining('Moved'), expect.anything())
expect(screen.queryByRole('dialog')).toBeNull()
})
@@ -5308,9 +5311,7 @@ describe('FilesPage — folder drag-and-drop', () => {
const moveResource = vi.fn(async (_id: string, _dest: string, _v: number, newName?: string) => {
if (newName === undefined && !conflicted) {
conflicted = true
- throw new Error(
- '409 Conflict: a resource with this name already exists httpStatus=409'
- )
+ throw new Error('409 Conflict: a resource with this name already exists httpStatus=409')
}
return { resourceId: 'file-1', version: 6 }
})