Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): dragend no longer cancels its own in-flight drop adjudication
Ma5242de7d208
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.tsxindex eec41854b..ce65fce8c 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@@ -795,6 +795,65 @@ function renderTreeWithSession(props: Partial<Parameters<typeof FileExplorerTree}describe('FileExplorerTree — drag-and-drop moves', () => {+ it('still opens the confirmation when adjudication resolves after the gesture’s dragend', async () => {+ // Regression: the browser fires dragend ~immediately after drop.+ // clearDragState used to bump the gesture epoch on that dragend, so the+ // drop's own decision — resuming after its async affordances probes — saw+ // a stale epoch and returned silently: no confirmation, no move, no toast.+ // Cache-cold drops (the common case for fresh folders) lost every time.+ const moveResource = vi.fn(async () => ({ resourceId: 'foldera', version: 9 }))+ const delayed = <T,>(value: T) =>+ new Promise<T>(resolve => setTimeout(() => resolve(value), 25))+ const affordances = vi.fn((resourceId: string) =>+ delayed(+ resourceId === 'folderb'+ ? { held: ['read', 'write'] }+ : { held: ['read', 'write', 'delete'] }+ )+ )+ const resolve = vi.fn(async (uri: string) => {+ const id = uri.split('/').pop()+ const parent = id === 'grand' ? null : 'grand'+ const name = id === 'foldera' ? 'A' : id === 'folderb' ? 'B' : 'Grand'+ const resourceId = id === 'grand' ? 'grand' : id+ return {+ drive: 'main',+ resourceId,+ parentResourceId: parent,+ name,+ kind: 'directory',+ version: id === 'foldera' ? 4 : 1,+ }+ })+ installDndClerum({+ listAccessible: vi.fn(async () =>+ listAccessiblePage([+ accessibleResource('foldera', 'A', 'directory', { version: 4 }),+ accessibleResource('folderb', 'B', 'directory'),+ ])+ ),+ affordances,+ resolve,+ moveResource,+ })+ renderTreeWithSession()++ const rowA = await screen.findByRole('button', { name: 'A' })+ const rowB = await screen.findByRole('button', { name: 'B' })+ const dataTransfer = dragTypes()+ const aRow = rowA.closest('[role="treeitem"]')!.querySelector('.da-file-explorer__row')!+ const bRow = rowB.closest('[role="treeitem"]')!.querySelector('.da-file-explorer__row')!++ fireEvent.dragStart(rowA, { dataTransfer })+ fireEvent.dragOver(bRow, { dataTransfer })+ fireEvent.drop(bRow, { dataTransfer })+ // The browser ends the gesture right after the drop — before the delayed+ // probes resolve. This used to invalidate the drop's own decision.+ fireEvent.dragEnd(aRow, { dataTransfer })++ await screen.findByRole('dialog', { name: 'Move folder A to B' })+ })+it('moves a dragged folder into an unrelated folder through the one confirmation', async () => {// Two directly-shared folders under one unshared common parent 'grand':// the drop must walk B's (bounded) ancestry, find the common anchor viadiff --git a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsxindex 8f412a107..630524d86 100644--- a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx+++ b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx@@ -468,7 +468,13 @@ export function FileExplorerTree({}, [])const clearDragState = useCallback(() => {- dragSessionEpochRef.current += 1+ // NOTE: deliberately does NOT bump dragSessionEpochRef. The epoch marks+ // GESTURES (dragstart); the drop handler compares its captured epoch after+ // the async drop adjudication. dragend fires ~immediately after drop —+ // bumping here invalidated the drop's OWN commit once adjudication+ // resolved (cache-cold drops lost that race and died silently, so the+ // folder confirmation never appeared). A new dragstart still invalidates+ // in-flight decisions.draggingSourceRef.current = nulldragSession?.endDrag()adjudication.endDragSession()diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsxindex 8db7dc3c9..720924538 100644--- a/desktop-app/ui/src/pages/FilesPage.tsx+++ b/desktop-app/ui/src/pages/FilesPage.tsx@@ -968,7 +968,12 @@ export function FilesPage({}const clearResourceDrag = () => {- dragSessionRef.current += 1+ // NOTE: deliberately does NOT bump dragSessionRef. The counter marks+ // GESTURES (dragstart); the drop handler compares its captured generation+ // after its async adjudication. The browser fires dragend ~immediately+ // after drop — bumping here invalidated the drop's OWN commit once the+ // adjudication resolved (cache-cold drops lost that race every time and+ // died silently). A new dragstart still invalidates in-flight decisions.draggingResourceRef.current = nulldraggingSourceRef.current = nullhoveredFolderRef.current = nulldiff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsxindex 34ce6496d..ee87b817a 100644--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx@@ -3749,6 +3749,109 @@ describe('FilesPage', () => {})})+ it('commits a file drop whose adjudication resolves after the gesture’s dragend', async () => {+ // Regression: the browser fires dragend ~immediately after drop.+ // clearResourceDrag used to bump the gesture counter on that dragend, so+ // the drop's own commit — resuming after its async affordances probes —+ // saw a stale generation and returned silently. Cache-cold drops lost+ // that race every time: no move, no dialog, no toast.+ const pushToast = vi.fn()+ const moveResource = vi.fn(async (_resourceId: string, _destinationId: string) => ({}))+ const affordances = vi.fn(+ () =>+ new Promise(resolve =>+ setTimeout(+ () =>+ resolve({+ held: ['read', 'write', 'delete'],+ canDelegate: false,+ grantableBits: [],+ canCreateShare: false,+ }),+ 25+ )+ )+ )+ Object.defineProperty(window, 'clerum', {+ configurable: true,+ value: {+ gfs: {+ affordances,+ resolve: vi.fn(async () => ({+ resourceId: 'file-1',+ gfsUri: 'gfs://main/file-1',+ kind: 'file',+ name: 'notes.txt',+ version: 3,+ parentResourceId: 'folder-1',+ })),+ },+ },+ })+ hookMock.useGfsBrowserController.mockReturnValue({+ ...baseController(),+ current: {+ resourceId: 'folder-1',+ gfsUri: 'gfs://main/folder-1',+ name: 'Product',+ kind: 'directory',+ version: 1,+ },+ items: [+ {+ resourceId: 'file-1',+ rid: 'file-1',+ gfsUri: 'gfs://main/file-1',+ drive: 'main',+ parentResourceId: 'folder-1',+ name: 'notes.txt',+ kind: 'file',+ path: '/Product/notes.txt',+ version: 3,+ bytes: 12,+ },+ {+ resourceId: 'dest-1',+ rid: 'dest-1',+ gfsUri: 'gfs://main/dest-1',+ drive: 'main',+ parentResourceId: 'folder-1',+ name: 'Dest',+ kind: 'directory',+ path: '/Product/Dest',+ version: 2,+ bytes: 0,+ },+ ],+ moveResource,+ })+ renderFilesPage(pushToast)++ const sourceRow = screen.getByRole('button', { name: 'Open notes.txt' })+ const destinationRow = screen.getByRole('button', { name: 'Open Dest' })+ const dataTransfer = {+ types: ['application/x-evenfire-gfs-resource'],+ files: [],+ effectAllowed: 'none',+ dropEffect: 'none',+ setData: vi.fn(),+ }++ fireEvent.dragStart(sourceRow, { dataTransfer })+ fireEvent.dragOver(destinationRow, { dataTransfer })+ fireEvent.drop(destinationRow, { dataTransfer })+ // The browser ends the gesture right after the drop — before the delayed+ // probes resolve. This used to invalidate the drop's own commit.+ fireEvent.dragEnd(sourceRow, { dataTransfer })++ await waitFor(() => expect(moveResource).toHaveBeenCalled())+ expect(moveResource.mock.calls[0]![0]).toBe('file-1')+ expect(moveResource.mock.calls[0]![1]).toBe('dest-1')+ await waitFor(() =>+ expect(pushToast).toHaveBeenCalledWith('Moved notes.txt to Dest', 'success')+ )+ })+it('presents a rate-limited drop check in the shared read-plane words', async () => {// The affordances check is one of the nine methods `surfaceGfsGrantError`// wraps, so its rejection reaches the renderer as the IPC wrapper plus the