Skip to content

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

TypeScript

feat(desktop): carry drop-verdict reasons through tree and Files grid

Mcb5877121904
diff --git a/desktop-app/ui/src/components/Common/ToastStack/index.tsx b/desktop-app/ui/src/components/Common/ToastStack/index.tsx
index 5828476bf..dfd5699ad 100644
--- a/desktop-app/ui/src/components/Common/ToastStack/index.tsx
+++ b/desktop-app/ui/src/components/Common/ToastStack/index.tsx
@@ -17,7 +17,11 @@ export function ToastStack({ items }: ToastStackProps) {
className={`toast tone-${item.tone}`}
>
<span aria-hidden className="toast-icon">
- {item.tone === 'success' ? '●' : item.tone === 'error' ? '!' : 'i'}
+ {item.tone === 'success'
+ ? '●'
+ : item.tone === 'error' || item.tone === 'warn'
+ ? '!'
+ : 'i'}
</span>
<span>{item.text}</span>
</div>
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 a7a9be89b..aa1a9bcba 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
@@ -1282,7 +1282,9 @@ describe('FileExplorerTree — drag-and-drop moves', () => {
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.
+ // is structurally denied. The refusal must stay DELIVERABLE (dropEffect
+ // 'move', UX matrix §5.3) so the release can present the reason — the
+ // tone-keyed tint, not the cursor, carries the denial.
await act(async () => {
fireEvent.click(rowA)
})
@@ -1293,7 +1295,8 @@ describe('FileExplorerTree — drag-and-drop moves', () => {
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')
+ expect(cRow.getAttribute('data-drop-reason')).toBe('descendant')
+ expect(dataTransfer.dropEffect).toBe('move')
})
it('refuses a same-parent drop before any request or confirmation', async () => {
@@ -1328,10 +1331,13 @@ describe('FileExplorerTree — drag-and-drop moves', () => {
fireEvent.dragStart(rowA, { dataTransfer })
const pRow = rowP.closest('[role="treeitem"]')!.querySelector('.da-file-explorer__row')!
fireEvent.dragOver(pRow, { dataTransfer })
+ expect(pRow.getAttribute('data-drop-state')).toBe('denied')
+ expect(pRow.getAttribute('data-drop-reason')).toBe('same-parent')
fireEvent.drop(pRow, { dataTransfer })
+ // A4: the no-op is INFO ("already in"), never an error "cannot".
await waitFor(() => {
- expect(pushToast).toHaveBeenCalledWith('This item is already in this folder.', 'error')
+ expect(pushToast).toHaveBeenCalledWith('A is already in P.', 'info')
})
expect(moveResource).not.toHaveBeenCalled()
expect(screen.queryByRole('dialog')).toBeNull()
@@ -1365,17 +1371,293 @@ describe('FileExplorerTree — drag-and-drop moves', () => {
const cRow = rowC.closest('[role="treeitem"]')!.querySelector('.da-file-explorer__row')!
fireEvent.dragOver(cRow, { dataTransfer })
expect(cRow.getAttribute('data-drop-state')).toBe('denied')
+ expect(cRow.getAttribute('data-drop-reason')).toBe('descendant')
fireEvent.drop(cRow, { dataTransfer })
await waitFor(() => {
expect(pushToast).toHaveBeenCalledWith(
- 'A folder cannot be moved into itself or one of its subfolders.',
+ 'You can’t move A into a folder inside itself.',
+ 'error'
+ )
+ })
+ expect(moveResource).not.toHaveBeenCalled()
+ })
+
+ it('paints and explains a drop of an item onto itself (A1)', async () => {
+ // Self-hover used to be skipped entirely, so dropping an item onto itself
+ // looked dead: no verdict, no cursor story, no words. The verdict now
+ // paints with its `self` reason and the release explains itself, while
+ // admission still refuses the mutation.
+ const moveResource = vi.fn()
+ installDndClerum({
+ listAccessible: vi.fn(async () =>
+ listAccessiblePage([accessibleResource('folder-a', 'A', 'directory')])
+ ),
+ affordances: vi.fn(async () => ({ held: ['read', 'write', 'delete'] })),
+ moveResource,
+ })
+ const { pushToast } = renderTreeWithSession()
+
+ const rowA = await screen.findByRole('button', { name: 'A' })
+ const aRow = rowA.closest('[role="treeitem"]')!.querySelector('.da-file-explorer__row')!
+ const dataTransfer = dragTypes()
+ fireEvent.dragStart(rowA, { dataTransfer })
+ fireEvent.dragOver(aRow, { dataTransfer })
+ expect(aRow.getAttribute('data-drop-state')).toBe('denied')
+ expect(aRow.getAttribute('data-drop-reason')).toBe('self')
+ // The denied hover stays deliverable so the refused drop can fire (§5.3).
+ expect(dataTransfer.dropEffect).toBe('move')
+ fireEvent.drop(aRow, { dataTransfer })
+
+ await waitFor(() => {
+ expect(pushToast).toHaveBeenCalledWith(
+ 'You dropped A onto itself. Pick a destination folder.',
+ 'error'
+ )
+ })
+ expect(moveResource).not.toHaveBeenCalled()
+ // The refused drop announces its full reason to the screen reader.
+ expect(screen.getByText('You dropped A onto itself. Pick a destination folder.')).toBeTruthy()
+ })
+
+ it('updates the reason when a newer gesture denies the same row differently', async () => {
+ // The stored verdict must not collapse to its state: gesture 1 denies a
+ // row as same-parent; a lost dragend leaves that verdict painted, and
+ // gesture 2 denies the SAME row as self. A state-only guard would skip
+ // the repaint and leave the stale reason on the row.
+ installDndClerum({
+ listAccessible: vi.fn(async () =>
+ listAccessiblePage([accessibleResource('folder-a', 'A', 'directory')])
+ ),
+ listChildren: vi.fn(async () =>
+ listChildrenPage([childView('file-1', 'f.md', 'file', { parentResourceId: 'folder-a' })])
+ ),
+ affordances: vi.fn(async () => ({ held: ['read', 'write', 'delete'] })),
+ moveResource: vi.fn(),
+ })
+ renderTreeWithSession()
+
+ await act(async () => {
+ fireEvent.click(await screen.findByRole('button', { name: 'A' }))
+ })
+ const rowA = await screen.findByRole('button', { name: 'A' })
+ const rowF = await screen.findByRole('button', { name: 'f.md' })
+ const aRow = rowA.closest('[role="treeitem"]')!.querySelector('.da-file-explorer__row')!
+ const dataTransfer = dragTypes()
+
+ // Gesture 1: the file already lives in A → same-parent.
+ fireEvent.dragStart(rowF, { dataTransfer })
+ fireEvent.dragOver(aRow, { dataTransfer })
+ expect(aRow.getAttribute('data-drop-state')).toBe('denied')
+ expect(aRow.getAttribute('data-drop-reason')).toBe('same-parent')
+ expect(aRow.getAttribute('title')).toBe('f.md is already in A.')
+
+ // The browser lost gesture 1's dragend (R1-H2); gesture 2 supersedes it
+ // and denies the same row as self — the reason must repaint.
+ fireEvent.dragStart(rowA, { dataTransfer })
+ fireEvent.dragOver(aRow, { dataTransfer })
+ expect(aRow.getAttribute('data-drop-state')).toBe('denied')
+ expect(aRow.getAttribute('data-drop-reason')).toBe('self')
+ expect(aRow.getAttribute('title')).toBe('You cannot move A into itself.')
+ })
+
+ it('refuses a drop whose source parent lacks write, naming the folder that contains it (A7)', async () => {
+ const moveResource = vi.fn()
+ const affordances = vi.fn(async (resourceId: string) => {
+ // The physical source parent holds no write bit; everything else is full.
+ if (resourceId === 'parent-1') return { held: ['read'] }
+ return { held: ['read', 'write', 'delete'] }
+ })
+ installDndClerum({
+ listAccessible: vi.fn(async () =>
+ listAccessiblePage([accessibleResource('parent-1', 'P', 'directory')])
+ ),
+ listChildren: vi.fn(async () =>
+ listChildrenPage([
+ childView('folder-a', 'A', 'directory', { parentResourceId: 'parent-1' }),
+ childView('folder-b', 'B', 'directory', { parentResourceId: 'parent-1' }),
+ ])
+ ),
+ affordances,
+ moveResource,
+ })
+ const { pushToast } = renderTreeWithSession()
+
+ await act(async () => {
+ fireEvent.click(await screen.findByRole('button', { name: 'P' }))
+ })
+ 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()
+
+ fireEvent.dragStart(rowA, { dataTransfer })
+ fireEvent.dragOver(bRow, { dataTransfer })
+ fireEvent.drop(bRow, { dataTransfer })
+
+ await waitFor(() => {
+ expect(pushToast).toHaveBeenCalledWith(
+ 'You can’t move A out of its current folder because you don’t have edit access to the folder that contains it.',
+ 'error'
+ )
+ })
+ expect(moveResource).not.toHaveBeenCalled()
+ expect(screen.queryByRole('dialog')).toBeNull()
+ })
+
+ it('refuses a drop whose source parent lacks delete, naming the folder that contains it (A8)', async () => {
+ const moveResource = vi.fn()
+ const affordances = vi.fn(async (resourceId: string) => {
+ // Write but no delete on the physical source parent.
+ if (resourceId === 'parent-1') return { held: ['read', 'write'] }
+ return { held: ['read', 'write', 'delete'] }
+ })
+ installDndClerum({
+ listAccessible: vi.fn(async () =>
+ listAccessiblePage([accessibleResource('parent-1', 'P', 'directory')])
+ ),
+ listChildren: vi.fn(async () =>
+ listChildrenPage([
+ childView('folder-a', 'A', 'directory', { parentResourceId: 'parent-1' }),
+ childView('folder-b', 'B', 'directory', { parentResourceId: 'parent-1' }),
+ ])
+ ),
+ affordances,
+ moveResource,
+ })
+ const { pushToast } = renderTreeWithSession()
+
+ await act(async () => {
+ fireEvent.click(await screen.findByRole('button', { name: 'P' }))
+ })
+ 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()
+
+ fireEvent.dragStart(rowA, { dataTransfer })
+ fireEvent.dragOver(bRow, { dataTransfer })
+ fireEvent.drop(bRow, { dataTransfer })
+
+ await waitFor(() => {
+ expect(pushToast).toHaveBeenCalledWith(
+ 'You can’t move A out of its current folder because you don’t have delete access to the folder that contains it.',
+ 'error'
+ )
+ })
+ expect(moveResource).not.toHaveBeenCalled()
+ })
+
+ it('refuses a move of an observed physical root with the top-level copy (A3)', async () => {
+ const moveResource = vi.fn()
+ installDndClerum({
+ listAccessible: vi.fn(async () =>
+ listAccessiblePage([
+ accessibleResource('root-1', 'R', 'directory'),
+ accessibleResource('folder-b', 'B', 'directory'),
+ ])
+ ),
+ affordances: vi.fn(async () => ({ held: ['read', 'write', 'delete'] })),
+ resolve: vi.fn(async () => ({ parentResourceId: null, kind: 'directory', version: 1 })),
+ moveResource,
+ })
+ const { pushToast } = renderTreeWithSession()
+
+ const rowR = await screen.findByRole('button', { name: 'R' })
+ const rowB = await screen.findByRole('button', { name: 'B' })
+ const bRow = rowB.closest('[role="treeitem"]')!.querySelector('.da-file-explorer__row')!
+ const dataTransfer = dragTypes()
+
+ fireEvent.dragStart(rowR, { dataTransfer })
+ fireEvent.dragOver(bRow, { dataTransfer })
+ fireEvent.drop(bRow, { dataTransfer })
+
+ await waitFor(() => {
+ expect(pushToast).toHaveBeenCalledWith(
+ 'This location is the top level — it can’t be moved.',
'error'
)
})
expect(moveResource).not.toHaveBeenCalled()
})
+ it('presents an unverifiable drop as a warning, never as a refusal (A10)', async () => {
+ const moveResource = vi.fn()
+ const affordances = vi.fn(async () => {
+ throw new Error('500 Internal Server Error httpStatus=500')
+ })
+ installDndClerum({
+ listAccessible: vi.fn(async () =>
+ listAccessiblePage([
+ accessibleResource('folder-a', 'A', 'directory'),
+ accessibleResource('folder-b', 'B', 'directory'),
+ ])
+ ),
+ affordances,
+ resolve: vi.fn(async () => ({ parentResourceId: 'grand', kind: 'directory', version: 1 })),
+ moveResource,
+ })
+ const { pushToast } = 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()
+
+ fireEvent.dragStart(rowA, { dataTransfer })
+ fireEvent.dragOver(bRow, { dataTransfer })
+ fireEvent.drop(bRow, { dataTransfer })
+
+ await waitFor(() => {
+ expect(pushToast).toHaveBeenCalledWith('500 Internal Server Error', 'warn')
+ })
+ expect(moveResource).not.toHaveBeenCalled()
+ })
+
+ it('keeps a session-lost drop persistently visible after revocation invalidates the gesture (A11)', async () => {
+ // The probe 401 both refuses the drop AND revokes the session; the
+ // revocation invalidates the gesture's ownership before the drop
+ // continuation resumes. The refused drop must still explain itself — as a
+ // persistent banner, not a toast — and stay visible next to the revoked
+ // surface.
+ const moveResource = vi.fn()
+ const affordances = vi.fn(async () => {
+ throw new Error(
+ "Error invoking remote method 'gfs:affordances': Error: 401 Unauthorized httpStatus=401"
+ )
+ })
+ installDndClerum({
+ listAccessible: vi.fn(async () =>
+ listAccessiblePage([
+ accessibleResource('folder-a', 'A', 'directory'),
+ accessibleResource('folder-b', 'B', 'directory'),
+ ])
+ ),
+ affordances,
+ resolve: vi.fn(async () => ({ parentResourceId: 'grand', kind: 'directory', version: 1 })),
+ moveResource,
+ })
+ const { pushToast } = 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()
+
+ fireEvent.dragStart(rowA, { dataTransfer })
+ fireEvent.dragOver(bRow, { dataTransfer })
+ fireEvent.drop(bRow, { dataTransfer })
+
+ expect(
+ await screen.findByText('Your session ended. Sign in again to continue moving files.')
+ ).toBeTruthy()
+ // The revoked surface stays visible alongside the refusal banner.
+ expect(await screen.findByText('File access is not authorized')).toBeTruthy()
+ // A dead session is not a one-shot toast.
+ expect(pushToast).not.toHaveBeenCalled()
+ expect(moveResource).not.toHaveBeenCalled()
+ })
+
it('dragstart cancels the deferred folder toggle (no expansion after a drag)', async () => {
installDndClerum({
listAccessible: vi.fn(async () =>
diff --git a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx
index e3615b9c8..b8541b29f 100644
--- a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx
+++ b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx
@@ -19,15 +19,21 @@ import { sanitizeAppTabTitle } from '@lib/sanitizeAppTabTitle'
import { isGfsChildrenDenied, purgeDeniedGfsChildren } from '@/gfs/deniedChildren'
import { useGfsDragAdjudication } from '@/gfs/dragAdjudication'
import { ownsGfsDrop } from '@/gfs/dragOwnership'
-import type { GfsDragSource } from '@/gfs/dragSession'
+import type { GfsDragSource, GfsDropVerdict } from '@/gfs/dragSession'
import { useGfsDragSession } from '@/gfs/dragSession'
-import { gfsDropVerdictAnnouncement } from '@/gfs/dropVerdict'
-import { moveDenialMessage, suggestNumberedMoveName } from '@/gfs/moveCommit'
+import {
+ GFS_DROP_SESSION_LOST_MESSAGE,
+ gfsDropVerdictLiveAnnouncement,
+ gfsDropVerdictReason,
+ presentGfsDropRefusal,
+ sameGfsDropVerdict,
+} from '@/gfs/dropVerdict'
+import { suggestNumberedMoveName } from '@/gfs/moveCommit'
import { runGfsMoveCommit } from '@/gfs/moveCommitRunner'
import { GfsMoveConfirmDialog } from '@/gfs/moveConfirmDialog'
import { GfsMoveDialog } from '@/gfs/moveDialog'
import { IconChevronRight, IconContexts } from '../icons'
-import type { FileExplorerDropState, FileExplorerNodeProps, FileExplorerTreeProps } from './types'
+import type { FileExplorerNodeProps, FileExplorerTreeProps } from './types'
// A folder's single-click (toggle) must not act before we know a double-click
// (open its files tab) is not coming, so it is deferred by this window to let a
@@ -81,6 +87,7 @@ function FileExplorerNode({
ancestorCrumbs,
dropState,
dropStatesByResourceId,
+ dragSourceName,
onToggle,
onActivateFolder,
onActivateFile,
@@ -256,10 +263,11 @@ function FileExplorerNode({
const handleRowDragEnterOrOver = useCallback(
(event: React.DragEvent<HTMLDivElement>) => {
handleRowDragOver(event)
+ const hoverState = dropState?.state
if (
isDirectoryRow &&
!isExpanded &&
- (dropState === undefined || dropState === 'allowed' || dropState === 'checking')
+ (hoverState === undefined || hoverState === 'allowed' || hoverState === 'checking')
) {
if (hoverExpandTimerRef.current === null) {
hoverExpandTimerRef.current = window.setTimeout(() => {
@@ -302,6 +310,15 @@ function FileExplorerNode({
[ancestorCrumbs, node]
)
+ const dropStateName = isDirectory ? dropState?.state : undefined
+ const dropReason = isDirectory ? gfsDropVerdictReason(dropState) : undefined
+ // The deny/no-op/unknown tint carries no reason of its own; the tooltip
+ // speaks the full sentence for it (one wording per reason, every surface).
+ const dropReasonTooltip =
+ dropState && dropReason !== undefined
+ ? gfsDropVerdictLiveAnnouncement(dropState, node.name, dragSourceName ?? undefined)
+ : undefined
+
return (
<div
aria-expanded={isDirectory ? isExpanded : undefined}
@@ -311,8 +328,10 @@ function FileExplorerNode({
role="treeitem"
>
<div
- className={`da-file-explorer__row${dropState ? ` is-drop-${dropState}` : ''}`}
- data-drop-state={isDirectory ? dropState : undefined}
+ className={`da-file-explorer__row${dropStateName ? ` is-drop-${dropStateName}` : ''}`}
+ data-drop-state={dropStateName}
+ data-drop-reason={dropReason}
+ title={dropReasonTooltip}
onDragEnter={isDirectory ? handleRowDragEnterOrOver : undefined}
onDragOver={isDirectory ? handleRowDragEnterOrOver : undefined}
onDragLeave={isDirectory ? handleRowDragLeave : undefined}
@@ -374,6 +393,7 @@ function FileExplorerNode({
accessActive={accessActive}
ancestorCrumbs={nextAncestorCrumbs}
ancestorIds={nextAncestorIds}
+ dragSourceName={dragSourceName}
dropState={dropStatesByResourceId[child.resourceId]}
dropStatesByResourceId={dropStatesByResourceId}
expandedIds={expandedIds}
@@ -450,12 +470,18 @@ export function FileExplorerTree({
const [expandedIds, setExpandedIds] = useState<Set<string>>(() => new Set())
const [selectedId, setSelectedId] = useState<string | null>(null)
const [dropStatesByResourceId, setDropStatesByResourceId] = useState<
- Record<string, FileExplorerDropState>
+ Record<string, GfsDropVerdict>
>({})
// The drop verdict is painted on the target row, which assistive technology
// never announces. The spoken form lives here so the verdict reaches a
// screen reader as well (RP-026).
const [dropVerdictAnnouncement, setDropVerdictAnnouncement] = useState('')
+ // A drop refused by a dead session must stay visible AFTER the revocation
+ // has already invalidated the gesture's ownership (UX matrix A11): the
+ // banner outlives the drop callback, until the next gesture or scope.
+ const [dropSessionLost, setDropSessionLost] = useState(false)
+ // Display name of the live gesture's source, for reason copy that names it.
+ const [dragSourceName, setDragSourceName] = useState<string | null>(null)
const [movingResourceId, setMovingResourceId] = useState<string | null>(null)
const movingResourceIdRef = useRef<string | null>(null)
const draggingSourceRef = useRef<GfsDragSource | null>(null)
@@ -496,6 +522,8 @@ export function FileExplorerTree({
adjudication.endDragSession()
setPendingFolderMove(null)
setDropStatesByResourceId({})
+ setDropSessionLost(false)
+ setDragSourceName(null)
}, [adjudication.endDragSession, liveDragScope])
const ownsDrop = useCallback(
@@ -555,6 +583,7 @@ export function FileExplorerTree({
adjudication.endDragSession()
setDropStatesByResourceId({})
setDropVerdictAnnouncement('')
+ setDragSourceName(null)
}, [adjudication, dragSession])
/** Release only the source and hover work owned by the admitted gesture. */
@@ -629,6 +658,9 @@ export function FileExplorerTree({
event.dataTransfer.setData(GFS_RESOURCE_DRAG_TYPE, node.resourceId)
event.dataTransfer.setData('text/plain', node.name)
draggingSourceRef.current = source
+ setDragSourceName(node.name)
+ // A new gesture clears the previous gesture's persistent surfaces.
+ setDropSessionLost(false)
},
[adjudication, dragSession, treeDragSourceFrom]
)
@@ -651,7 +683,11 @@ export function FileExplorerTree({
) => {
if (!Array.from(event.dataTransfer.types || []).includes(GFS_RESOURCE_DRAG_TYPE)) return
const source = resolveActiveSource()
- if (!source || node.kind !== 'directory' || source.resourceId === node.resourceId) return
+ // Self-hover is NO longer skipped: dropping an item onto itself paints
+ // the denied verdict with its `self` reason, so the release can explain
+ // itself instead of looking dead (UX matrix §5.3). Admission still
+ // refuses the mutation.
+ if (!source || node.kind !== 'directory') return
event.preventDefault()
event.stopPropagation()
hoverOwnerRef.current = source
@@ -662,16 +698,17 @@ export function FileExplorerTree({
ancestorIds,
})
setDropStatesByResourceId(previous =>
- previous[node.resourceId] === verdict.state
+ sameGfsDropVerdict(previous[node.resourceId], verdict)
? previous
- : { ...previous, [node.resourceId]: verdict.state }
+ : { ...previous, [node.resourceId]: verdict }
)
- setDropVerdictAnnouncement(gfsDropVerdictAnnouncement(verdict.state, node.name))
- // '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'
+ setDropVerdictAnnouncement(gfsDropVerdictLiveAnnouncement(verdict, node.name, source.name))
+ // An OBSERVED deny must stay DELIVERABLE: dropEffect 'none' makes
+ // Chromium cancel the drag at release, so the refused drop event never
+ // fires and the reason could never be presented (UX matrix §5.3). The
+ // tone-keyed row tint carries the denial; the drop-time adjudication
+ // still refuses the mutation.
+ event.dataTransfer.dropEffect = 'move'
if (verdict.state === 'checking') {
adjudication.scheduleColdCheck(
{ resourceId: node.resourceId, name: node.name, kind: node.kind, ancestorIds },
@@ -685,11 +722,13 @@ export function FileExplorerTree({
ancestorIds,
})
setDropStatesByResourceId(previous =>
- previous[node.resourceId] === fresh.state
+ sameGfsDropVerdict(previous[node.resourceId], fresh)
? previous
- : { ...previous, [node.resourceId]: fresh.state }
+ : { ...previous, [node.resourceId]: fresh }
+ )
+ setDropVerdictAnnouncement(
+ gfsDropVerdictLiveAnnouncement(fresh, node.name, source.name)
)
- setDropVerdictAnnouncement(gfsDropVerdictAnnouncement(fresh.state, node.name))
}
)
}
@@ -769,10 +808,23 @@ export function FileExplorerTree({
kind: node.kind,
ancestorIds,
})
+ if (!decision.allowed && decision.reason === 'session-lost') {
+ // Presented BEFORE the ownership guard, and as a persistent banner:
+ // the revocation that caused this refusal has already invalidated
+ // the gesture's ownership, so the normal callback path would return
+ // silently — the session's death must stay explained (A11).
+ setDropSessionLost(true)
+ setDropVerdictAnnouncement(GFS_DROP_SESSION_LOST_MESSAGE)
+ return
+ }
if (!ownsDrop(source, epoch, sessionGeneration)) return
if (!decision.allowed) {
- const message = moveDenialMessage(decision, node.name)
- if (message) pushToast(message, 'error')
+ const { message, tone } = presentGfsDropRefusal(decision, {
+ source: source.name,
+ target: node.name,
+ })
+ setDropVerdictAnnouncement(message)
+ pushToast(message, tone)
return
}
if (source.kind === 'directory') {
@@ -889,6 +941,11 @@ export function FileExplorerTree({
<p aria-live="polite" className="visually-hidden">
{dropVerdictAnnouncement}
</p>
+ {dropSessionLost ? (
+ // Persistent (A11): the refusal outlives the dead gesture and the
+ // revoked tree surface below — it is not a one-shot toast.
+ <StatusBanner tone="error" text={GFS_DROP_SESSION_LOST_MESSAGE} compact />
+ ) : null}
{ctrl.accessState === 'revoked' ? (
// Mirror the Files page's revoked surface, adapted to the sidebar's
// compact chrome. Without this branch a revoked drive falls through to
@@ -921,6 +978,7 @@ export function FileExplorerTree({
accessActive={ctrl.accessState === 'active'}
ancestorCrumbs={[]}
ancestorIds={node.parentResourceId != null ? [node.parentResourceId] : []}
+ dragSourceName={dragSourceName}
// The forest roots are drop targets like any other row: their
// verdict belongs to them, so the root row receives its own
// state instead of only the map its children read (RP-019).
diff --git a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/types.ts b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/types.ts
index 5ddd5dcd4..b64e6f9be 100644
--- a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/types.ts
+++ b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/types.ts
@@ -1,6 +1,7 @@
import type { DragEvent as ReactDragEvent } from 'react'
import type { GfsBrowserChild, GfsCrumb } from '@hooks/domain/useGfsBrowserController'
import type { GfsPreviewResource } from '@lib/gfsPreview'
+import type { GfsDropVerdict } from '@/gfs/dragSession'
import type { Tone } from '@/uiTypes'
/**
@@ -17,8 +18,6 @@ export interface FileExplorerTreeProps {
pushToast: (message: string, tone: Tone) => void
}
-export type FileExplorerDropState = 'checking' | 'allowed' | 'denied' | 'unavailable'
-
export interface FileExplorerNodeProps {
node: GfsBrowserChild
/** 1-based ARIA depth (`aria-level`). */
@@ -26,22 +25,26 @@ export interface FileExplorerNodeProps {
/** Cache-scope key shared with the Files page's TanStack queries. */
scope: string
/** Session access is live: gates the per-node children fetch the same way the
- * controller gates its own children query — a revoked session fetches nothing. */
+ * controller gates its own children query — a revoked session fetches nothing. */
accessActive: boolean
expandedIds: ReadonlySet<string>
selectedId: string | null
/** Resource id currently being moved (freezes drag starts), when a move the
- * tree itself initiated is in flight. */
+ * tree itself initiated is in flight. */
movingResourceId?: string | null
/** Loaded ancestors of this node, NEAREST-FIRST; drives the drag structure
- * facts (common-anchor / descendant observations). */
+ * facts (common-anchor / descendant observations). */
ancestorIds: readonly (string | null)[]
/** Same ancestors as crumbs, ROOT-FIRST, for the Move dialog's initial path. */
ancestorCrumbs: readonly GfsCrumb[]
- /** Live hover verdict for directory nodes (drop feedback). */
- dropState?: FileExplorerDropState
+ /** Live hover verdict for directory nodes (drop feedback). The FULL verdict
+ * is carried — not just its state — so the deny reason reaches the row
+ * (`data-drop-reason`), the tooltip and the announcements (UX matrix §5.1). */
+ dropState?: GfsDropVerdict
/** Verdict map shared with descendant nodes (render feedback only). */
- dropStatesByResourceId: Readonly<Record<string, FileExplorerDropState>>
+ dropStatesByResourceId: Readonly<Record<string, GfsDropVerdict>>
+ /** Display name of the active drag's source, for reason copy that names it. */
+ dragSourceName?: string | null
onToggle: (resourceId: string) => void
onActivateFolder: (node: GfsBrowserChild) => void
onActivateFile: (node: GfsBrowserChild) => void
diff --git a/desktop-app/ui/src/gfs/moveCommit.ts b/desktop-app/ui/src/gfs/moveCommit.ts
index 69c5ee670..bb6120943 100644
--- a/desktop-app/ui/src/gfs/moveCommit.ts
+++ b/desktop-app/ui/src/gfs/moveCommit.ts
@@ -5,7 +5,6 @@ import {
nextAvailableGfsResourceName,
} from '@clerum/gfs-interaction-policy'
import { describeGfsReadError, parseHttpStatus, parseRetryAfterSeconds } from '@lib/gfsGrantErrors'
-import type { GfsDropRejection } from './dragSession.types'
/** Server truth from a commit-time resolve of the source. */
export interface MoveCommitSourceSnapshot {
@@ -355,31 +354,3 @@ export function toastMoveOutcome(
pushToast?.(outcome.message, 'error')
}
}
-
-/** Exact-reason denial copy (rev-2 §8). Null = stay silent (session-lost). */
-export function moveDenialMessage(
- rejection: GfsDropRejection,
- destinationName: string
-): string | null {
- switch (rejection.reason) {
- case 'destination-write':
- return `You can’t move files to ${destinationName} because you don’t have write permission for this folder.`
- case 'source-write':
- return 'You cannot move this item out of its current folder without write access there.'
- case 'source-delete':
- return 'You do not have permission to remove this item from its current folder.'
- case 'same-parent':
- return 'This item is already in this folder.'
- case 'self':
- case 'descendant':
- return 'A folder cannot be moved into itself or one of its subfolders.'
- case 'root-source':
- return 'The top-level folder cannot be moved.'
- case 'cross-drive':
- return 'Items can’t be moved between drives.'
- case 'session-lost':
- return null
- default:
- return rejection.message ?? 'This move is not available right now. Try again in a moment.'
- }
-}
diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsx
index c4e70f871..084f88bd8 100644
--- a/desktop-app/ui/src/pages/FilesPage.tsx
+++ b/desktop-app/ui/src/pages/FilesPage.tsx
@@ -68,9 +68,15 @@ import { useGfsDragAdjudication } from '@/gfs/dragAdjudication'
import { ownsGfsDrop } from '@/gfs/dragOwnership'
import type { GfsDragSource, GfsDropVerdict } from '@/gfs/dragSession'
import { useGfsDragSession } from '@/gfs/dragSession'
-import { gfsDropVerdictAnnouncement } from '@/gfs/dropVerdict'
+import {
+ GFS_DROP_SESSION_LOST_MESSAGE,
+ gfsDropVerdictLiveAnnouncement,
+ gfsDropVerdictReason,
+ presentGfsDropRefusal,
+ sameGfsDropVerdict,
+} from '@/gfs/dropVerdict'
import { GfsFilePicker } from '@/gfs/filePicker'
-import { moveDenialMessage, suggestNumberedMoveName } from '@/gfs/moveCommit'
+import { suggestNumberedMoveName } from '@/gfs/moveCommit'
import type { MoveCommitOutcome } from '@/gfs/moveCommit'
import { runGfsMoveCommit } from '@/gfs/moveCommitRunner'
import { GfsMoveConfirmDialog } from '@/gfs/moveConfirmDialog'
@@ -344,11 +350,19 @@ export function FilesPage({
const [draggingResourceId, setDraggingResourceId] = useState<string | null>(null)
const [dragOverFolderId, setDragOverFolderId] = useState<string | null>(null)
const [movingResourceId, setMovingResourceId] = useState<string | null>(null)
- const [dropStatesById, setDropStatesById] = useState<Record<string, GfsDropVerdict['state']>>({})
+ // The FULL verdict is stored — not just its state — so the deny reason
+ // reaches the row (`data-drop-reason`), the tooltip and the announcements
+ // (UX matrix §5.1); a same-state reason change must still repaint.
+ const [dropStatesById, setDropStatesById] = useState<Record<string, GfsDropVerdict>>({})
// The drop verdict is painted on the target row; this live region is its
// spoken form, so a screen reader learns whether the folder under the
// pointer accepts the move (RP-026).
const [dropVerdictAnnouncement, setDropVerdictAnnouncement] = useState('')
+ // A drop refused by a dead session must stay visible AFTER the revocation
+ // has already invalidated the gesture's ownership (UX matrix A11).
+ const [dropSessionLost, setDropSessionLost] = useState(false)
+ // Display name of the live gesture's source, for reason copy that names it.
+ const [dragSourceName, setDragSourceName] = useState<string | null>(null)
// Folder drops stop at ONE confirmation (impact + naming policy) before the
// shared dispatch; files commit directly on an allowed admission.
const [pendingFolderMove, setPendingFolderMove] = useState<{
@@ -434,6 +448,8 @@ export function FilesPage({
setDragOverFolderId(null)
setDropStatesById({})
setDropVerdictAnnouncement('')
+ setDropSessionLost(false)
+ setDragSourceName(null)
}, [adjudication.endDragSession, liveDragScope])
const ownsDrop = (source: GfsDragSource, epoch: number, sharedGeneration: number | null) =>
@@ -1210,6 +1226,7 @@ export function FilesPage({
setDraggingResourceId(null)
setDragOverFolderId(null)
setDropStatesById({})
+ setDragSourceName(null)
}
/** Release only the source and hover work owned by the admitted gesture. */
@@ -1222,6 +1239,7 @@ export function FilesPage({
draggingResourceRef.current = null
draggingSourceRef.current = null
setDraggingResourceId(null)
+ setDragSourceName(null)
if (hoverOwnerRef.current === null || hoverOwnerRef.current === source) {
hoverOwnerRef.current = null
hoveredFolderRef.current = null
@@ -1274,17 +1292,21 @@ export function FilesPage({
const applyHoverVerdict = (
folderId: string,
verdict: GfsDropVerdict,
- folderName = ''
+ folderName = '',
+ sourceName = ''
): GfsDropVerdict => {
+ // Only observed-allowed paints the blue highlight (UX matrix §5.5).
if (verdict.state === 'allowed') {
setDragOverFolderId(folderId)
} else if (hoveredFolderRef.current === folderId) {
setDragOverFolderId(null)
}
setDropStatesById(previous =>
- previous[folderId] === verdict.state ? previous : { ...previous, [folderId]: verdict.state }
+ sameGfsDropVerdict(previous[folderId], verdict)
+ ? previous
+ : { ...previous, [folderId]: verdict }
)
- setDropVerdictAnnouncement(gfsDropVerdictAnnouncement(verdict.state, folderName))
+ setDropVerdictAnnouncement(gfsDropVerdictLiveAnnouncement(verdict, folderName, sourceName))
return verdict
}
@@ -1317,6 +1339,9 @@ export function FilesPage({
draggingResourceRef.current = resource
draggingSourceRef.current = source
setDraggingResourceId(resource.resourceId)
+ setDragSourceName(resource.name)
+ // A new gesture clears the previous gesture's persistent surfaces.
+ setDropSessionLost(false)
}
const handleResourceDragEnd = () => {
@@ -1326,7 +1351,10 @@ export function FilesPage({
const handleFolderDragOver = (event: ReactDragEvent<HTMLElement>, folder: GfsDriveResource) => {
if (!hasDraggedGfsResource(event)) return
const source = resolveActiveSource()
- if (!source || folder.kind !== 'directory' || source.resourceId === folder.resourceId) return
+ // Self-hover is NO longer skipped: dropping an item onto itself paints the
+ // denied verdict with its `self` reason, so the release can explain itself
+ // instead of looking dead (UX matrix §5.3). Admission still refuses.
+ if (!source || folder.kind !== 'directory') return
event.preventDefault()
event.stopPropagation()
@@ -1341,14 +1369,16 @@ export function FilesPage({
const verdict = applyHoverVerdict(
folder.resourceId,
adjudication.hoverVerdict(source, target),
- folder.name
+ folder.name,
+ source.name
)
- // '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'
+ // An OBSERVED deny must stay DELIVERABLE: dropEffect 'none' makes Chromium
+ // cancel the drag at release, so the refused drop event never fires and
+ // the reason could never be presented (UX matrix §5.3) — and 'checking'
+ // must stay landable so the drop-time priority adjudication (rev-2 §4.1)
+ // can decide. The tone-keyed row tint carries the denial; admission still
+ // refuses the mutation.
+ event.dataTransfer.dropEffect = 'move'
if (verdict.state === 'checking') {
adjudication.scheduleColdCheck(
target,
@@ -1357,7 +1387,7 @@ export function FilesPage({
if (hoverOwnerRef.current !== source || hoveredFolderRef.current !== folder.resourceId)
return
const fresh = adjudication.hoverVerdict(source, target)
- applyHoverVerdict(folder.resourceId, fresh, folder.name)
+ applyHoverVerdict(folder.resourceId, fresh, folder.name, source.name)
}
)
}
@@ -1443,10 +1473,23 @@ export function FilesPage({
kind: destination.kind,
ancestorIds: rowTargetAncestorIds(),
})
+ if (!decision.allowed && decision.reason === 'session-lost') {
+ // Presented BEFORE the ownership guard, and as a persistent banner:
+ // the revocation that caused this refusal has already invalidated
+ // the gesture's ownership, so the normal callback path would return
+ // silently — the session's death must stay explained (A11).
+ setDropSessionLost(true)
+ setDropVerdictAnnouncement(GFS_DROP_SESSION_LOST_MESSAGE)
+ return
+ }
if (!ownsDrop(source, dragGeneration, sessionGeneration)) return
if (!decision.allowed) {
- const message = moveDenialMessage(decision, destination.name)
- if (message) pushToast?.(message, 'error')
+ const { message, tone } = presentGfsDropRefusal(decision, {
+ source: source.name,
+ target: destination.name,
+ })
+ setDropVerdictAnnouncement(message)
+ pushToast?.(message, tone)
return
}
if (source.kind === 'directory') {
@@ -1984,6 +2027,11 @@ export function FilesPage({
</div>
) : null}
+ {dropSessionLost ? (
+ // Persistent (A11): the refusal outlives the dead gesture and the
+ // revoked surface below — it is not a one-shot toast.
+ <StatusBanner tone="error" text={GFS_DROP_SESSION_LOST_MESSAGE} />
+ ) : null}
{accessibleNotice ? <StatusBanner tone="info" text={accessibleNotice} /> : null}
{unavailableLocation ? (
<StatusBanner tone="error" text={GFS_UNAVAILABLE_LOCATION_MESSAGE} />
@@ -2133,6 +2181,18 @@ export function FilesPage({
const isDropTarget = dragOverFolderId === resource.resourceId
const dropState =
resource.kind === 'directory' ? dropStatesById[resource.resourceId] : undefined
+ const dropReason = gfsDropVerdictReason(dropState)
+ // The deny/no-op/unknown tint carries no reason of its own;
+ // the tooltip speaks the full sentence (one wording per
+ // reason, every surface).
+ const dropReasonTooltip =
+ dropState && dropReason !== undefined
+ ? gfsDropVerdictLiveAnnouncement(
+ dropState,
+ resource.name,
+ dragSourceName ?? undefined
+ )
+ : undefined
const canDragResource =
resource.readable !== false && movingResourceId === null && !ctrl.mutating
return (
@@ -2141,13 +2201,15 @@ export function FilesPage({
key={resource.resourceId}
draggable={canDragResource}
title={
- canDragResource
+ dropReasonTooltip ??
+ (canDragResource
? `Drag ${resource.name} into a folder to move it`
- : undefined
+ : undefined)
}
data-dragging={isDragging ? 'true' : undefined}
data-drop-target={isDropTarget ? 'true' : undefined}
- data-drop-state={dropState}
+ data-drop-state={dropState?.state}
+ data-drop-reason={dropReason}
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 b5dd6cb02..3f7224a6b 100644
--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
@@ -4008,19 +4008,28 @@ describe('FilesPage', () => {
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.
+ // observes the missing write, a further hover paints the denied verdict
+ // with its reason. The denied hover stays DELIVERABLE (UX matrix §5.3) —
+ // the tint, not the cursor, carries the denial.
fireEvent.dragOver(destinationRow, { dataTransfer })
- expect(dataTransfer.dropEffect).toBe('none')
+ expect(dataTransfer.dropEffect).toBe('move')
expect(destinationRow.getAttribute('data-drop-state')).toBe('denied')
+ expect(destinationRow.getAttribute('data-drop-reason')).toBe('destination-write')
fireEvent.drop(destinationRow, { dataTransfer })
await waitFor(() => {
expect(moveResource).not.toHaveBeenCalled()
expect(pushToast).toHaveBeenCalledWith(
- 'You can’t move files to Private because you don’t have write permission for this folder.',
+ 'You don’t have permission to move items into Private. You need edit access to the destination folder.',
'error'
)
})
+ // The refused drop announces its full reason to the screen reader.
+ expect(
+ screen.getByText(
+ 'You don’t have permission to move items into Private. You need edit access to the destination folder.'
+ )
+ ).toBeTruthy()
})
it('commits a file drop whose adjudication resolves after the gesture’s dragend', async () => {
@@ -4350,7 +4359,8 @@ describe('FilesPage', () => {
await waitFor(() => {
expect(moveResource).not.toHaveBeenCalled()
- expect(pushToast).toHaveBeenCalledWith('Too many file requests — try again in 7s.', 'error')
+ // A rate-limited check is unverifiable, not forbidden: warning tone.
+ expect(pushToast).toHaveBeenCalledWith('Too many file requests — try again in 7s.', 'warn')
})
const toasted = pushToast.mock.calls.map(([text]) => String(text)).join('\n')
expect(toasted).not.toContain('httpStatus=')
@@ -4358,6 +4368,323 @@ describe('FilesPage', () => {
expect(toasted).not.toContain('Error invoking remote method')
})
+ it('paints and explains a drop of a folder onto itself (A1)', async () => {
+ // Self-hover used to be skipped entirely, so dropping an item onto itself
+ // looked dead. The verdict now paints with its `self` reason, the denied
+ // hover stays deliverable, and the release explains itself while
+ // admission still refuses the mutation.
+ const pushToast = vi.fn()
+ const moveResource = vi.fn(async () => ({}))
+ const affordances = vi.fn(async () => ({
+ held: ['read', 'write', 'delete'],
+ canDelegate: false,
+ grantableBits: [],
+ canCreateShare: false,
+ }))
+ Object.defineProperty(window, 'clerum', {
+ configurable: true,
+ value: { gfs: { affordances } },
+ })
+ hookMock.useGfsBrowserController.mockReturnValue({
+ ...baseController(),
+ current: {
+ resourceId: 'folder-1',
+ gfsUri: 'gfs://main/folder-1',
+ name: 'Product',
+ kind: 'directory',
+ version: 1,
+ },
+ items: [
+ {
+ resourceId: 'archive-1',
+ rid: 'archive-1',
+ gfsUri: 'gfs://main/archive-1',
+ drive: 'main',
+ parentResourceId: 'folder-1',
+ name: 'Archive',
+ kind: 'directory',
+ path: '/Product/Archive',
+ version: 2,
+ bytes: 0,
+ },
+ ],
+ moveResource,
+ })
+ renderFilesPage(pushToast)
+
+ const archiveRow = screen.getByRole('button', { name: 'Open Archive' })
+ const dataTransfer = {
+ types: ['application/x-evenfire-gfs-resource'],
+ files: [],
+ effectAllowed: 'none',
+ dropEffect: 'none',
+ setData: vi.fn(),
+ }
+
+ fireEvent.dragStart(archiveRow, { dataTransfer })
+ fireEvent.dragOver(archiveRow, { dataTransfer })
+ expect(archiveRow.getAttribute('data-drop-state')).toBe('denied')
+ expect(archiveRow.getAttribute('data-drop-reason')).toBe('self')
+ // The denied hover stays deliverable so the refused drop can fire (§5.3).
+ expect(dataTransfer.dropEffect).toBe('move')
+ fireEvent.drop(archiveRow, { dataTransfer })
+
+ await waitFor(() => {
+ expect(moveResource).not.toHaveBeenCalled()
+ expect(pushToast).toHaveBeenCalledWith(
+ 'You dropped Archive onto itself. Pick a destination folder.',
+ 'error'
+ )
+ })
+ // The refused drop announces its full reason to the screen reader.
+ expect(
+ screen.getByText('You dropped Archive onto itself. Pick a destination folder.')
+ ).toBeTruthy()
+ })
+
+ it('updates the deny reason on a row when a newer gesture denies it differently', async () => {
+ // The stored verdict must not collapse to its state: gesture 1 denies a
+ // row as destination-write; its dragend is lost, and gesture 2 denies the
+ // SAME row as self. A state-only guard would skip the repaint and leave
+ // the stale reason on the row.
+ const pushToast = vi.fn()
+ const moveResource = vi.fn(async () => ({}))
+ const affordances = vi.fn(async (resourceId: string) => {
+ if (resourceId === 'folder-1') {
+ return {
+ held: ['read', 'write', 'delete'],
+ canDelegate: false,
+ grantableBits: [],
+ canCreateShare: false,
+ }
+ }
+ return {
+ held: ['read'],
+ canDelegate: false,
+ grantableBits: [],
+ canCreateShare: false,
+ }
+ })
+ Object.defineProperty(window, 'clerum', {
+ configurable: true,
+ value: { gfs: { affordances } },
+ })
+ 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: 'private-1',
+ rid: 'private-1',
+ gfsUri: 'gfs://main/private-1',
+ drive: 'main',
+ parentResourceId: 'folder-1',
+ name: 'Private',
+ kind: 'directory',
+ path: '/Product/Private',
+ version: 2,
+ bytes: 0,
+ },
+ ],
+ moveResource,
+ })
+ renderFilesPage(pushToast)
+
+ const sourceRow = screen.getByRole('button', { name: 'Open notes.txt' })
+ const destinationRow = screen.getByRole('button', { name: 'Open Private' })
+ const dataTransfer = {
+ types: ['application/x-evenfire-gfs-resource'],
+ files: [],
+ effectAllowed: 'none',
+ dropEffect: 'none',
+ setData: vi.fn(),
+ }
+
+ // Gesture 1: the destination lacks write once the cold check answers.
+ fireEvent.dragStart(sourceRow, { dataTransfer })
+ fireEvent.dragEnter(destinationRow, { dataTransfer })
+ await waitFor(() => expect(affordances).toHaveBeenCalledWith('private-1', 'main'))
+ fireEvent.dragOver(destinationRow, { dataTransfer })
+ expect(destinationRow.getAttribute('data-drop-state')).toBe('denied')
+ expect(destinationRow.getAttribute('data-drop-reason')).toBe('destination-write')
+
+ // The browser lost gesture 1's dragend; gesture 2 drags the row onto
+ // itself and must repaint the reason, not skip the same state.
+ fireEvent.dragStart(destinationRow, { dataTransfer })
+ fireEvent.dragOver(destinationRow, { dataTransfer })
+ expect(destinationRow.getAttribute('data-drop-state')).toBe('denied')
+ expect(destinationRow.getAttribute('data-drop-reason')).toBe('self')
+ expect(moveResource).not.toHaveBeenCalled()
+ })
+
+ it('presents an unverifiable drop check as a warning, never as a refusal (A10)', async () => {
+ const pushToast = vi.fn()
+ const moveResource = vi.fn(async () => ({}))
+ const affordances = vi.fn(async () => {
+ throw new Error('500 Internal Server Error httpStatus=500')
+ })
+ Object.defineProperty(window, 'clerum', {
+ configurable: true,
+ value: { gfs: { affordances } },
+ })
+ 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: 'private-1',
+ rid: 'private-1',
+ gfsUri: 'gfs://main/private-1',
+ drive: 'main',
+ parentResourceId: 'folder-1',
+ name: 'Private',
+ kind: 'directory',
+ path: '/Product/Private',
+ version: 2,
+ bytes: 0,
+ },
+ ],
+ moveResource,
+ })
+ renderFilesPage(pushToast)
+
+ const sourceRow = screen.getByRole('button', { name: 'Open notes.txt' })
+ const destinationRow = screen.getByRole('button', { name: 'Open Private' })
+ const dataTransfer = {
+ types: ['application/x-evenfire-gfs-resource'],
+ files: [],
+ effectAllowed: 'none',
+ dropEffect: 'none',
+ setData: vi.fn(),
+ }
+
+ fireEvent.dragStart(sourceRow, { dataTransfer })
+ fireEvent.dragEnter(destinationRow, { dataTransfer })
+ await waitFor(() => expect(affordances).toHaveBeenCalledWith('private-1', 'main'))
+ fireEvent.drop(destinationRow, { dataTransfer })
+
+ await waitFor(() => {
+ expect(moveResource).not.toHaveBeenCalled()
+ expect(pushToast).toHaveBeenCalledWith('500 Internal Server Error', 'warn')
+ })
+ })
+
+ it('keeps a session-lost drop persistently visible after the probe revoked the session (A11)', async () => {
+ // The probe 401 refuses the drop AND revokes the session; the revocation
+ // invalidates the gesture's ownership before the drop continuation
+ // resumes. The refused drop must still explain itself — as a persistent
+ // banner, not a one-shot toast.
+ const pushToast = vi.fn()
+ const moveResource = vi.fn(async () => ({}))
+ const affordances = vi.fn(async () => {
+ throw new Error('401 Unauthorized httpStatus=401')
+ })
+ Object.defineProperty(window, 'clerum', {
+ configurable: true,
+ value: { gfs: { affordances } },
+ })
+ 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: 'private-1',
+ rid: 'private-1',
+ gfsUri: 'gfs://main/private-1',
+ drive: 'main',
+ parentResourceId: 'folder-1',
+ name: 'Private',
+ kind: 'directory',
+ path: '/Product/Private',
+ version: 2,
+ bytes: 0,
+ },
+ ],
+ moveResource,
+ })
+ renderFilesPage(pushToast)
+
+ const sourceRow = screen.getByRole('button', { name: 'Open notes.txt' })
+ const destinationRow = screen.getByRole('button', { name: 'Open Private' })
+ const dataTransfer = {
+ types: ['application/x-evenfire-gfs-resource'],
+ files: [],
+ effectAllowed: 'none',
+ dropEffect: 'none',
+ setData: vi.fn(),
+ }
+
+ fireEvent.dragStart(sourceRow, { dataTransfer })
+ fireEvent.dragEnter(destinationRow, { dataTransfer })
+ await waitFor(() => expect(affordances).toHaveBeenCalledWith('private-1', 'main'))
+ fireEvent.drop(destinationRow, { dataTransfer })
+
+ // Both refusal surfaces carry it: the persistent banner AND the SR live
+ // region (the spoken refusal). A one-shot toast was NOT used.
+ const sessionLostSurfaces = await screen.findAllByText(
+ 'Your session ended. Sign in again to continue moving files.'
+ )
+ expect(sessionLostSurfaces.some(element => element.closest('.status-banner') !== null)).toBe(
+ true
+ )
+ expect(pushToast).not.toHaveBeenCalled()
+ expect(moveResource).not.toHaveBeenCalled()
+ })
+
it('renames a folder child from its row menu once write affordances resolve', async () => {
const pushToast = vi.fn()
const renameResource = vi.fn(async () => ({}))
diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.css
index 1ba926694..1de5ed149 100644
--- a/desktop-app/ui/src/styles.css
+++ b/desktop-app/ui/src/styles.css
@@ -1978,14 +1978,17 @@ h3 {
flex: 0 0 auto;
}
-/* ── Drag-and-drop states (rev-2 D1) ──────────────────────────────────────
- Existing tokens only; no motion. `checking` reads as neutral-active so the
- row is visibly being adjudicated without implying a verdict; `allowed`
- reuses the selected-row accent; `denied` keeps the error border tone. The
- row-level attribute also styles Files-page rows which reuse the same
- attribute names on their grid rows. */
+/* ── Drag-and-drop states (rev-2 D1; refusal UX matrix §5) ────────────────
+ Tone-keyed by REASON, existing tokens only, no motion. Only `allowed`
+ paints the accent (blue); `checking` is neutral; a deny paints the error
+ inset unless its reason re-maps the tone — `same-parent` is the no-op
+ (info, edge tokens) and the unknown family is a warning, never a deny
+ look. Labels stay readable: the tint + inset carry the verdict, not label
+ dimming (the old dim-only treatment was the invisible one). The row-level
+ attribute also styles Files-page rows which reuse the same attribute
+ names on their grid rows. */
.da-file-explorer__row[data-drop-state='checking'] {
- background: rgba(var(--accent-rgb), 0.06);
+ background: rgba(var(--edge-rgb), 0.08);
}
.da-file-explorer__row[data-drop-state='allowed'] {
@@ -1996,14 +1999,36 @@ h3 {
background: transparent;
}
-.da-file-explorer__row[data-drop-state='denied'] .da-file-explorer__label.ui-button,
-.da-file-explorer__row[data-drop-state='unavailable'] .da-file-explorer__label.ui-button {
- color: var(--text-dim);
+/* Deny = error inset + tint (UX matrix A1–A8). */
+.da-file-explorer__row[data-drop-state='denied'],
+.da-grid__row--compact[data-drop-state='denied'] {
+ background: rgba(var(--danger-rgb), 0.1);
+ box-shadow: inset 2px 0 0 rgba(var(--danger-rgb), 0.72);
+}
+
+/* A4 no-op: informational, never error-red. */
+.da-file-explorer__row[data-drop-state='denied'][data-drop-reason='same-parent'],
+.da-grid__row--compact[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);
+}
+
+/* A10 unknown/unverifiable: warning, must not look denied. */
+.da-file-explorer__row[data-drop-state='denied'][data-drop-reason='unavailable'],
+.da-file-explorer__row[data-drop-state='denied'][data-drop-reason='target-unavailable'],
+.da-file-explorer__row[data-drop-state='denied'][data-drop-reason='source-location-unknown'],
+.da-file-explorer__row[data-drop-state='unavailable'],
+.da-grid__row--compact[data-drop-state='denied'][data-drop-reason='unavailable'],
+.da-grid__row--compact[data-drop-state='denied'][data-drop-reason='target-unavailable'],
+.da-grid__row--compact[data-drop-state='denied'][data-drop-reason='source-location-unknown'],
+.da-grid__row--compact[data-drop-state='unavailable'] {
+ background: rgba(var(--warning-rgb), 0.1);
+ box-shadow: inset 2px 0 0 rgba(var(--warning-rgb), 0.72);
}
/* Files-page grid rows use the same attribute vocabulary. */
.da-grid__row--compact[data-drop-state='checking'] {
- background: rgba(var(--accent-rgb), 0.06);
+ background: rgba(var(--edge-rgb), 0.08);
}
.da-grid__row--compact[data-drop-state='allowed'] {
@@ -10666,6 +10691,12 @@ button.page-breadcrumb-link--plain-action:hover:enabled {
border-color: rgba(var(--danger-rgb), 0.52);
}
+/* Unverifiable-but-not-forbidden outcomes (refusal UX matrix A10): the
+ warning border pairs with the warn toast tone. */
+.toast.tone-warn {
+ border-color: rgba(var(--warning-rgb), 0.52);
+}
+
.auth-page {
min-height: calc(100vh - var(--window-titlebar-height));
padding: var(--space-5);