Skip to content

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

TypeScript

feat(control-ui): move resources by dropping rows onto breadcrumb crumbs

M6c57b19b084b
diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsx
index 3fc496e4c..a0149f27a 100644
--- a/control-ui/components/GfsBrowser.tsx
+++ b/control-ui/components/GfsBrowser.tsx
@@ -11,7 +11,10 @@ import {
gfsUploadNameRetryDecision,
isGfsNameConflict,
nextAvailableGfsResourceName,
+ normalizeCanonicalPath,
normalizeGfsResourceName,
+ parentPathOf,
+ planMoveConvergence,
} from '@clerum/gfs-interaction-policy'
import { FileUploadModal } from '@components/FileUploadModal'
import { GfsImagePreview } from '@components/GfsImagePreview'
@@ -53,6 +56,18 @@ import {
} from '@lib/entityChangeStream'
import { watchEntityChangeStreamLiveness } from '@lib/entityChangeStreamLiveness'
import { isGfsDocumentFile } from '@lib/gfsDocumentFile'
+import {
+ GfsMoveRefusalError,
+ computeGfsDropHoverVerdict,
+ gfsDropHoverAnnouncement,
+ gfsDropRefusalMessage,
+ gfsDropRefusalTone,
+} from '@lib/gfsDragFeedback'
+import type {
+ GfsDropHoverVerdict,
+ GfsDropRefusalReason,
+ GfsMoveDestination,
+} from '@lib/gfsDragFeedback.types'
import {
GfsUploadCapabilityError,
type GfsUploadJob,
@@ -170,6 +185,14 @@ interface GfsResolvedLocation {
version: number
}
+/** The slice of a resolve response the drag admission/commit reads. */
+interface GfsResolvedEndpointView {
+ resourceId: string
+ kind: string
+ path: string | null
+ version?: number
+}
+
/** Project every response-backed folder source through one version-preserving
* breadcrumb adapter. An incomplete runtime payload remains browseable but
* never gains a fabricated mutation precondition. */
@@ -401,14 +424,19 @@ export function GfsBrowser(): React.JSX.Element {
const [droppedUploadCount, setDroppedUploadCount] = useState(0)
const [draggingResourceId, setDraggingResourceId] = useState<string | null>(null)
const [dragOverFolderId, setDragOverFolderId] = useState<string | null>(null)
+ const [dragOverCrumbIndex, setDragOverCrumbIndex] = useState<number | null>(null)
const [movingResourceId, setMovingResourceId] = useState<string | null>(null)
const [moveTarget, setMoveTarget] = useState<GfsChild | null>(null)
- // rev-2 §1: a folder DROP stops at ONE confirmation (impact + naming
- // policy); files move directly; the Move dialog is its own confirmation.
+ // rev-2 §1 + breadcrumb plan §3.2: a drag DROP stops at ONE confirmation
+ // (impact + naming policy) for folders AND for breadcrumb drops of either
+ // kind; row file drops keep moving directly; the Move dialog is its own
+ // confirmation. The destination is captured IMMUTABLY at drop so a later
+ // trail rebuild can never re-anchor the commit (R7-M1).
const [confirmMoveTarget, setConfirmMoveTarget] = useState<{
source: GfsChild
- destination: GfsChild
+ destination: GfsMoveDestination
suggestedName?: string
+ epoch: number
} | null>(null)
const moveTargetRef = useRef(moveTarget)
moveTargetRef.current = moveTarget
@@ -437,6 +465,28 @@ export function GfsBrowser(): React.JSX.Element {
const trailReconstructionEpochRef = useRef(0)
const draggingResourceRef = useRef<GfsChild | null>(null)
const movingResourceRef = useRef<string | null>(null)
+ // Monotonic drag-gesture epoch (breadcrumb plan §3.4). A newer dragstart
+ // bumps it and thereby supersedes every pending admission read, the open
+ // confirmation, and any commit read that has not dispatched its PATCH yet.
+ // Dragend does NOT bump it: it only clears presentation, so a drop the
+ // browser already accepted keeps its async admission/commit. Unmount bumps
+ // it as well, so no stale closure can dispatch after the surface is gone.
+ const dragGestureEpochRef = useRef(0)
+ const mountedRef = useRef(true)
+ useEffect(() => {
+ mountedRef.current = true
+ return () => {
+ mountedRef.current = false
+ dragGestureEpochRef.current += 1
+ }
+ }, [])
+ // The physical source-parent ID observed at dragstart (null = the synthetic
+ // drive root). Active-crumb and own-parent drops resolve to same-parent
+ // from this observation without any network round-trip.
+ const dragSourceParentIdRef = useRef<string | null>(null)
+ const isGestureEpochCurrent = useCallback((epoch: number): boolean => {
+ return mountedRef.current && epoch === dragGestureEpochRef.current
+ }, [])
const [imagePreview, setImagePreview] = useState<Extract<
OpenPreviewState,
{ kind: 'image' }
@@ -1307,6 +1357,11 @@ export function GfsBrowser(): React.JSX.Element {
event.preventDefault()
return
}
+ // A newer gesture supersedes every pending admission read and any
+ // confirmation still open from an older one (plan §3.4).
+ dragGestureEpochRef.current += 1
+ setConfirmMoveTarget(null)
+ dragSourceParentIdRef.current = currentCrumbRef.current?.id ?? null
event.dataTransfer.effectAllowed = 'move'
event.dataTransfer.setData(GFS_RESOURCE_DRAG_TYPE, child.resourceId)
event.dataTransfer.setData('text/plain', child.name)
@@ -1315,18 +1370,108 @@ export function GfsBrowser(): React.JSX.Element {
}
function handleResourceDragEnd(): void {
+ // Presentation-only: an accepted drop's async admission/commit keeps
+ // running under the same gesture epoch (plan §3.4 — dragend must not
+ // cancel its own accepted drop).
draggingResourceRef.current = null
setDraggingResourceId(null)
setDragOverFolderId(null)
+ setDragOverCrumbIndex(null)
}
- function handleFolderDragOver(event: React.DragEvent<HTMLLIElement>, folder: GfsChild): void {
- if (!hasDraggedGfsResource(event)) return
- const source = draggingResourceRef.current
- if (!source || source.resourceId === folder.resourceId || folder.kind !== 'directory') return
+ /** Trail observed ancestors of the SOURCE: the physical parent (the
+ * current folder) plus every crumb above it. */
+ function knownSourceAncestorIdsForCurrentTrail(): Set<string> {
+ const ids = new Set<string>()
+ for (const crumb of crumbsRef.current) {
+ if (crumb.id) ids.add(crumb.id)
+ }
+ return ids
+ }
+
+ /** Nearest-first ancestor chain of a breadcrumb target, observed through
+ * the live trail. The trailing null marks the chain walked to the
+ * physical drive root (the trail always starts there, hydrated or not). */
+ function crumbTargetAncestorIds(index: number): (string | null)[] {
+ const chain: (string | null)[] = []
+ for (let cursor = index - 1; cursor >= 0; cursor -= 1) {
+ const crumb = crumbsRef.current[cursor]
+ chain.push(crumb?.id ?? null)
+ }
+ chain.push(null)
+ return chain
+ }
+
+ /** Nearest-first ancestor chain of a listing ROW target: its parent (the
+ * current folder) plus the trail above, observed to the physical root. */
+ function rowTargetAncestorIds(): (string | null)[] {
+ const chain: (string | null)[] = [currentCrumbRef.current?.id ?? null]
+ for (let cursor = crumbsRef.current.length - 2; cursor >= 0; cursor -= 1) {
+ const crumb = crumbsRef.current[cursor]
+ chain.push(crumb?.id ?? null)
+ }
+ chain.push(null)
+ return chain
+ }
+
+ function rowHoverVerdict(source: GfsChild, folder: GfsChild): GfsDropHoverVerdict | null {
+ if (folder.kind !== 'directory' && folder.resourceId !== source.resourceId) return null
+ return computeGfsDropHoverVerdict({
+ drive: DRIVE,
+ sourceResourceId: source.resourceId,
+ sourceKind: source.kind === 'file' ? 'file' : 'directory',
+ sourceParentKnown: (currentCrumbRef.current?.id ?? null) !== null,
+ sourceParentResourceId: currentCrumbRef.current?.id ?? null,
+ targetResourceId: folder.resourceId,
+ targetName: folder.name,
+ targetIsActiveLocation: false,
+ targetIsSourceParent: false,
+ targetAncestorIds: rowTargetAncestorIds(),
+ knownSourceAncestorIds: knownSourceAncestorIdsForCurrentTrail(),
+ })
+ }
+
+ function crumbHoverVerdict(source: GfsChild, index: number): GfsDropHoverVerdict | null {
+ const crumb = crumbsRef.current[index]
+ if (!crumb) return null
+ const parentId = dragSourceParentIdRef.current
+ return computeGfsDropHoverVerdict({
+ drive: DRIVE,
+ sourceResourceId: source.resourceId,
+ sourceKind: source.kind === 'file' ? 'file' : 'directory',
+ sourceParentKnown: parentId !== null,
+ sourceParentResourceId: parentId,
+ targetResourceId: crumb.id,
+ targetName: isDriveRootCrumb(crumb) ? DRIVE : crumb.name,
+ targetIsActiveLocation: index === crumbsRef.current.length - 1,
+ targetIsSourceParent:
+ parentId !== null
+ ? crumb.id === parentId
+ : isDriveRootCrumb(crumb) && dragSourceParentIdRef.current === null,
+ targetAncestorIds: crumbTargetAncestorIds(index),
+ knownSourceAncestorIds: knownSourceAncestorIdsForCurrentTrail(),
+ })
+ }
+
+ /** Internal directory drops stay DELIVERABLE even for an observed refusal,
+ * so release can present the reason (UX matrix §5.3). Admission still
+ * refuses the mutation. */
+ function deliverInternalMoveDrag(event: React.DragEvent<HTMLElement>): boolean {
+ if (!hasDraggedGfsResource(event)) return false
+ if (!draggingResourceRef.current) return false
event.preventDefault()
event.stopPropagation()
event.dataTransfer.dropEffect = 'move'
+ return true
+ }
+
+ function handleFolderDragOver(event: React.DragEvent<HTMLLIElement>, folder: GfsChild): void {
+ const source = draggingResourceRef.current
+ if (!hasDraggedGfsResource(event) || !source) return
+ // Self and directory targets stay deliverable and painted; a plain file
+ // row is not a move destination and keeps today's pass-through.
+ if (folder.kind !== 'directory' && folder.resourceId !== source.resourceId) return
+ deliverInternalMoveDrag(event)
setDragOverFolderId(folder.resourceId)
}
@@ -1343,9 +1488,305 @@ export function GfsBrowser(): React.JSX.Element {
}
}
+ function handleCrumbDragOver(event: React.DragEvent<HTMLButtonElement>, index: number): void {
+ const source = draggingResourceRef.current
+ if (!hasDraggedGfsResource(event) || !source) return
+ deliverInternalMoveDrag(event)
+ setDragOverCrumbIndex(index)
+ }
+
+ function handleCrumbDragEnter(event: React.DragEvent<HTMLButtonElement>, index: number): void {
+ handleCrumbDragOver(event, index)
+ }
+
+ function handleCrumbDragLeave(event: React.DragEvent<HTMLButtonElement>, index: number): void {
+ if (!hasDraggedGfsResource(event)) return
+ event.preventDefault()
+ event.stopPropagation()
+ if (
+ dragOverCrumbIndex === index &&
+ !event.currentTarget.contains(event.relatedTarget as Node | null)
+ ) {
+ setDragOverCrumbIndex(null)
+ }
+ }
+
+ function handleCrumbDrop(
+ event: React.DragEvent<HTMLButtonElement>,
+ crumb: Crumb,
+ index: number
+ ): void {
+ if (!hasDraggedGfsResource(event)) return
+ // Stop propagation/default FIRST so the upload container can never
+ // process an internal crumb drop (plan §3.4).
+ event.preventDefault()
+ event.stopPropagation()
+ setDragOverCrumbIndex(null)
+ const source = draggingResourceRef.current
+ if (!source) return
+ const epoch = dragGestureEpochRef.current
+ void admitCrumbDropMove(source, crumb, index, epoch)
+ }
+
+ /** Refuse a drop honestly: matrix wording, reason tone, no mutation. */
+ function refuseDropMove(
+ reason: GfsDropRefusalReason,
+ names: { sourceName?: string; targetName?: string }
+ ): void {
+ showToast(gfsDropRefusalMessage(reason, names), {
+ tone: gfsDropRefusalTone(reason),
+ })
+ }
+
+ /** One bounded read to (re)hydrate the drive root's resource identity. */
+ async function hydrateDriveRootIdentity(epoch: number): Promise<string | null> {
+ try {
+ const page = (await apiGet('/api/v1/gfs/tree', { drive: DRIVE })) as TreePage
+ if (!page.rootResourceId || !isGestureEpochCurrent(epoch)) return null
+ const rootRid = ridOfResourceId(page.rootResourceId)
+ setCrumbs(prev => {
+ const root = prev[0]
+ if (!isDriveRootCrumb(root)) return prev
+ if (root.id === page.rootResourceId && root.rid === rootRid) return prev
+ return [{ ...root, id: page.rootResourceId, rid: rootRid }, ...prev.slice(1)]
+ })
+ return page.rootResourceId
+ } catch {
+ return null
+ }
+ }
+
+ /** Immutable destination capture for a breadcrumb target, synchronously
+ * derivable from the crumb. Null for the not-yet-hydrated root. */
+ function crumbToMoveDestination(crumb: Crumb): GfsMoveDestination | null {
+ if (isDriveRootCrumb(crumb)) {
+ if (!crumb.id || !crumb.rid) return null
+ return {
+ resourceId: crumb.id,
+ rid: crumb.rid,
+ name: DRIVE,
+ kind: 'directory',
+ gfsUri: `gfs://${DRIVE}/${crumb.rid}`,
+ path: '/',
+ origin: 'crumb',
+ }
+ }
+ if (!crumb.id) return null
+ const gfsUri = crumb.gfsUri ?? (crumb.rid ? `gfs://${DRIVE}/${crumb.rid}` : null)
+ return {
+ resourceId: crumb.id,
+ rid: crumb.rid,
+ name: crumb.name,
+ kind: 'directory',
+ gfsUri,
+ path: null,
+ ...(crumb.version !== undefined ? { version: crumb.version } : {}),
+ origin: 'crumb',
+ }
+ }
+
+ function rowToMoveDestination(folder: GfsChild): GfsMoveDestination {
+ return {
+ resourceId: folder.resourceId,
+ rid: folder.rid,
+ name: folder.name,
+ kind: 'directory',
+ gfsUri: folder.gfsUri,
+ path: folder.path,
+ ...(folder.version !== undefined ? { version: folder.version } : {}),
+ origin: 'row',
+ }
+ }
+
+ async function admitCrumbDropMove(
+ source: GfsChild,
+ crumb: Crumb,
+ index: number,
+ epoch: number
+ ): Promise<void> {
+ // 1. Destination identity. The unhydrated root retries resolution here
+ // (plan §3.1); a failed retry warns honestly and dispatches nothing.
+ let destination = crumbToMoveDestination(crumb)
+ if (!destination) {
+ const rootId = await hydrateDriveRootIdentity(epoch)
+ if (!isGestureEpochCurrent(epoch)) return
+ if (!rootId) {
+ refuseDropMove('unavailable', { targetName: DRIVE })
+ return
+ }
+ destination = {
+ resourceId: rootId,
+ rid: ridOfResourceId(rootId),
+ name: DRIVE,
+ kind: 'directory',
+ gfsUri: `gfs://${DRIVE}/${ridOfResourceId(rootId)}`,
+ path: '/',
+ origin: 'crumb',
+ }
+ }
+ // 2. Synchronous identity/no-op checks from the dragstart observation.
+ if (destination.resourceId === source.resourceId) {
+ refuseDropMove('self', { sourceName: source.name, targetName: destination.name })
+ return
+ }
+ const parentId = dragSourceParentIdRef.current
+ const isSourceParent =
+ index === crumbsRef.current.length - 1 ||
+ (parentId !== null
+ ? destination.resourceId === parentId
+ : isDriveRootCrumb(crumb) && parentId === null)
+ if (isSourceParent) {
+ refuseDropMove('same-parent', {
+ sourceName: source.name,
+ targetName: destination.name,
+ })
+ return
+ }
+ // 3. Fresh-path structural admission: both endpoints re-resolved by
+ // immutable URI; failed resolution prevents dispatch with honest
+ // feedback, a missing path defers to the atomic server guard.
+ const admitted = await admitMoveEndpoints(source, destination, epoch)
+ if (!admitted.ok) {
+ if (admitted.refusal) {
+ refuseDropMove(admitted.refusal.reason, {
+ sourceName: source.name,
+ targetName: destination.name,
+ })
+ }
+ return
+ }
+ // 4. ONE confirmation for both files and folders (plan §3.2).
+ openMoveConfirmation(source, destination, epoch)
+ }
+
+ /** Fresh endpoint resolution + structural check shared by row and crumb
+ * admissions. `refusal` is set for every honest refusal; ok=true means
+ * the move is structurally admissible (observed or deferred to the server
+ * guard). */
+ async function admitMoveEndpoints(
+ source: GfsChild,
+ destination: GfsMoveDestination,
+ epoch: number
+ ): Promise<{ ok: boolean; refusal?: { reason: GfsDropRefusalReason } }> {
+ if (!destination.gfsUri) return { ok: false, refusal: { reason: 'unavailable' } }
+ const [sourceRead, targetRead] = await Promise.all([
+ resolveEndpointView(source.gfsUri, source.resourceId),
+ resolveEndpointView(destination.gfsUri!, destination.resourceId),
+ ])
+ if (!isGestureEpochCurrent(epoch)) return { ok: false }
+ if (sourceRead.status === 'missing' || sourceRead.status === 'mismatched') {
+ return { ok: false, refusal: { reason: 'source-location-unknown' } }
+ }
+ if (sourceRead.status === 'failed') return { ok: false, refusal: { reason: 'unavailable' } }
+ if (targetRead.status === 'missing' || targetRead.status === 'mismatched') {
+ return { ok: false, refusal: { reason: 'target-unavailable' } }
+ }
+ if (targetRead.status === 'failed') return { ok: false, refusal: { reason: 'unavailable' } }
+ if (targetRead.view.kind !== 'directory') {
+ return { ok: false, refusal: { reason: 'target-unavailable' } }
+ }
+ const targetPath = destination.path === '/' ? '/' : targetRead.view.path
+ const structure = decideDragPathStructure({
+ sourcePath: sourceRead.view.path,
+ targetPath,
+ })
+ if (structure.kind === 'deny') {
+ return { ok: false, refusal: { reason: structure.reason } }
+ }
+ return { ok: true }
+ }
+
+ /** Seed the confirmation dialog exactly like the row path: the same cache
+ * the numbered-name ladder will consult. */
+ function openMoveConfirmation(
+ source: GfsChild,
+ destination: GfsMoveDestination,
+ epoch: number
+ ): void {
+ const occupiedNames = new Set<string>(
+ (childCacheRef.current.get(destination.resourceId)?.items ?? []).map(item => item.name)
+ )
+ const suggested =
+ occupiedNames.size > 0 && occupiedNames.has(source.name)
+ ? nextAvailableGfsResourceName(source.name, occupiedNames)
+ : undefined
+ setConfirmMoveTarget({
+ source,
+ destination,
+ ...(suggested !== undefined ? { suggestedName: suggested } : {}),
+ epoch,
+ })
+ }
+
+ /** GET /gfs/resolve by immutable URI, classified for admission/commit.
+ * `expectedResourceId` turns an identity drift (the immutable URI now
+ * resolves to a different resource id) into an explicit mismatch. */
+ async function resolveEndpointView(
+ uri: string,
+ expectedResourceId?: string
+ ): Promise<
+ | { status: 'resolved'; view: GfsResolvedEndpointView }
+ | { status: 'missing' }
+ | { status: 'mismatched' }
+ | { status: 'failed' }
+ > {
+ try {
+ const view = (await apiGet('/api/v1/gfs/resolve', { uri })) as GfsResolvedEndpointView
+ if (expectedResourceId && view.resourceId !== expectedResourceId) {
+ return { status: 'mismatched' }
+ }
+ return { status: 'resolved', view }
+ } catch (error) {
+ if (entityChangeErrorStatus(error) === 404) return { status: 'missing' }
+ return { status: 'failed' }
+ }
+ }
+
+ async function handleFolderDrop(
+ event: React.DragEvent<HTMLLIElement>,
+ folder: GfsChild
+ ): Promise<void> {
+ if (!hasDraggedGfsResource(event)) return
+ event.preventDefault()
+ event.stopPropagation()
+ setDragOverFolderId(null)
+ const source = draggingResourceRef.current
+ if (!source) return
+ const epoch = dragGestureEpochRef.current
+ if (source.resourceId === folder.resourceId) {
+ refuseDropMove('self', { sourceName: source.name, targetName: folder.name })
+ return
+ }
+ const destination = rowToMoveDestination(folder)
+ if (source.kind === 'file') {
+ // Files cannot be ancestors: no structural risk; move directly — the
+ // commit runner still re-resolves both endpoints before dispatch.
+ await moveResource(source, destination, {
+ revalidate: { epoch },
+ })
+ return
+ }
+ // Folder drops stop at ONE confirmation (rev-2 §1) after the fresh-path
+ // structural guard — the impact dialog also records the naming policy.
+ const admitted = await admitMoveEndpoints(source, destination, epoch)
+ if (!admitted.ok) {
+ if (admitted.refusal) {
+ refuseDropMove(admitted.refusal.reason, {
+ sourceName: source.name,
+ targetName: destination.name,
+ })
+ }
+ return
+ }
+ openMoveConfirmation(source, destination, epoch)
+ }
+
async function moveResource(
source: GfsChild,
- destination: Pick<GfsChild, 'resourceId' | 'name' | 'kind'>,
+ destination: Pick<GfsChild, 'resourceId' | 'name' | 'kind'> & {
+ gfsUri?: string
+ path?: string | null
+ },
options: {
bubbleError?: boolean
allowNumberedRename?: boolean
@@ -1357,6 +1798,14 @@ export function GfsBrowser(): React.JSX.Element {
* are already taken (RP-003).
*/
occupiedNames?: readonly string[]
+ /**
+ * Drag commits re-resolve BOTH endpoints by immutable URI immediately
+ * before dispatch (plan §3.4): validate returned identity and
+ * destination kind, use the fresh source version, and stop without
+ * dispatching when the gesture epoch was superseded. The keyboard Move
+ * dialog keeps its established single-read behavior.
+ */
+ revalidate?: { epoch: number }
} = {}
): Promise<void> {
const { bubbleError = false, allowNumberedRename = true } = options
@@ -1371,6 +1820,63 @@ export function GfsBrowser(): React.JSX.Element {
movingResourceRef.current = source.resourceId
setMovingResourceId(source.resourceId)
try {
+ let ifMatchVersion = source.version
+ let verifiedDestinationPath: string | null = destination.path ?? null
+ if (options.revalidate) {
+ const epoch = options.revalidate.epoch
+ if (!isGestureEpochCurrent(epoch)) return
+ const sourceRead = await resolveEndpointView(source.gfsUri, source.resourceId)
+ if (!isGestureEpochCurrent(epoch)) return
+ if (sourceRead.status === 'missing' || sourceRead.status === 'mismatched') {
+ throw new GfsMoveRefusalError(
+ 'source-location-unknown',
+ gfsDropRefusalMessage('source-location-unknown', { sourceName: source.name })
+ )
+ }
+ if (sourceRead.status === 'failed') {
+ throw new GfsMoveRefusalError('unavailable', gfsDropRefusalMessage('unavailable'))
+ }
+ ifMatchVersion = Number.isSafeInteger(sourceRead.view.version)
+ ? (sourceRead.view.version as number)
+ : source.version
+ if (destination.gfsUri) {
+ const targetRead = await resolveEndpointView(destination.gfsUri, destination.resourceId)
+ if (!isGestureEpochCurrent(epoch)) return
+ if (targetRead.status === 'missing' || targetRead.status === 'mismatched') {
+ throw new GfsMoveRefusalError(
+ 'target-unavailable',
+ gfsDropRefusalMessage('target-unavailable')
+ )
+ }
+ if (targetRead.status === 'failed') {
+ throw new GfsMoveRefusalError('unavailable', gfsDropRefusalMessage('unavailable'))
+ }
+ if (targetRead.view.kind !== 'directory') {
+ throw new GfsMoveRefusalError(
+ 'target-unavailable',
+ gfsDropRefusalMessage('target-unavailable')
+ )
+ }
+ verifiedDestinationPath = destination.path === '/' ? '/' : targetRead.view.path
+ const structure = decideDragPathStructure({
+ sourcePath: sourceRead.view.path,
+ targetPath: verifiedDestinationPath,
+ })
+ if (structure.kind === 'deny') {
+ throw new GfsMoveRefusalError(
+ structure.reason,
+ gfsDropRefusalMessage(structure.reason, {
+ sourceName: source.name,
+ targetName: destination.name,
+ })
+ )
+ }
+ } else if (verifiedDestinationPath === null) {
+ // No immutable key and no path observation: the destination cannot
+ // be validated or verified — refuse honestly instead of guessing.
+ throw new GfsMoveRefusalError('unavailable', gfsDropRefusalMessage('unavailable'))
+ }
+ }
// Seed the ladder with the destination's known children (the same cache
// the confirmation suggestion came from, plus whatever the caller
// observed) so the first 409 skips every already-taken numbered name
@@ -1386,6 +1892,9 @@ export function GfsBrowser(): React.JSX.Element {
// approved numbered-name policy; a single attempt otherwise.
const maxAttempts = allowNumberedRename ? GFS_MOVE_MAX_NETWORK_ATTEMPTS : 1
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
+ // The gesture must still own the dispatch the instant the PATCH
+ // leaves (plan §3.4); an already-dispatched request is never recalled.
+ if (options.revalidate && !isGestureEpochCurrent(options.revalidate.epoch)) return
try {
moveResult = await apiSend(
'PATCH',
@@ -1393,7 +1902,7 @@ export function GfsBrowser(): React.JSX.Element {
{
drive: DRIVE,
newParentId: destination.resourceId,
- ifMatch: source.version,
+ ifMatch: ifMatchVersion,
...(moveName === source.name ? {} : { newName: moveName }),
},
{ drive: DRIVE }
@@ -1401,7 +1910,39 @@ export function GfsBrowser(): React.JSX.Element {
moved = true
break
} catch (error) {
- if (!isGfsNameConflict(error)) throw error
+ if (!isGfsNameConflict(error)) {
+ if (
+ options.revalidate &&
+ entityChangeErrorStatus(error) === undefined &&
+ movingResourceRef.current === source.resourceId
+ ) {
+ // Transport loss with the request possibly dispatched: the
+ // outcome is UNKNOWN. Never claim the move failed and never
+ // repeat the PATCH — verify once by identity (matrix B7/B8).
+ const settled = await settleUnknownTransportMove(
+ source,
+ verifiedDestinationPath,
+ options.revalidate.epoch
+ )
+ if (!isGestureEpochCurrent(options.revalidate.epoch)) return
+ if (settled === 'moved') {
+ moved = true
+ moveResult = undefined
+ break
+ }
+ if (settled === 'not-moved') {
+ throw new GfsMoveRefusalError(
+ 'move-not-completed',
+ gfsDropRefusalMessage('move-not-completed')
+ )
+ }
+ throw new GfsMoveRefusalError(
+ 'unknown-outcome',
+ gfsDropRefusalMessage('unknown-outcome')
+ )
+ }
+ throw error
+ }
if (!allowNumberedRename) {
throw new Error(
'An item with this name already exists. Choose another folder, or use Move to change its name.'
@@ -1423,10 +1964,26 @@ export function GfsBrowser(): React.JSX.Element {
movedResource?.resourceId && movedResource.resourceId !== source.resourceId
? undefined
: movedResource?.version
- // The destination may have been prefetched while it was visible. Its
- // cached listing is stale after a move and must be revalidated before it
- // is opened.
- childCacheRef.current.delete(destination.resourceId)
+ // plan §3.4 convergence: invalidate the observed OLD and NEW parent
+ // listings through the shared pure planner. The old parent is the
+ // observed folder whose listing held the source — the trail parent for
+ // a trail folder, otherwise the folder currently on screen.
+ const movedCrumbIndex = crumbs.findIndex(crumb => crumb.id === source.resourceId)
+ const oldParentId =
+ movedCrumbIndex > 0
+ ? (crumbs[movedCrumbIndex - 1]?.id ?? null)
+ : (currentCrumbRef.current?.id ?? null)
+ const childParentByResourceId = new Map<string, string | null>()
+ for (const [folderId, page] of childCacheRef.current.entries()) {
+ for (const item of page.items) childParentByResourceId.set(item.resourceId, folderId)
+ }
+ const convergence = planMoveConvergence(
+ { resourceId: source.resourceId, oldParentId, newParentId: destination.resourceId },
+ { childParentByResourceId }
+ )
+ for (const staleFolderId of convergence.refetchChildIds) {
+ childCacheRef.current.delete(staleFolderId)
+ }
showToast(
moveName === source.name
? `Moved "${source.name}" to "${destination.name}".`
@@ -1443,14 +2000,9 @@ export function GfsBrowser(): React.JSX.Element {
// is part of the open breadcrumb trail, patching only its own crumb
// would leave every crumb above it describing the OLD location (R5-M1):
// with /org open and /org moved under /archive, the trail must become
- // main / archive / org — not stay main / org.
- const movedCrumbIndex = crumbs.findIndex(crumb => crumb.id === source.resourceId)
+ // main / archive / org — not stay main / org. (The old parent's cache
+ // entry was already invalidated through the convergence plan above.)
if (movedCrumbIndex >= 0) {
- // The listing the moved folder left behind (its old parent, an
- // ancestor of the old trail) still contains its row; drop it so a
- // later navigation revalidates instead of serving the stale page.
- const oldParent = crumbs[movedCrumbIndex - 1]
- if (oldParent?.id) childCacheRef.current.delete(oldParent.id)
// The crumb adopts the receipt metadata FIRST — this is the
// resource's truthful post-move state. The ancestry rebuild below
// (and any later retry of it) preserves this metadata from LIVE
@@ -1482,18 +2034,47 @@ export function GfsBrowser(): React.JSX.Element {
}
return
}
+ // Refresh the live current location — the user stays where they are;
+ // a drag move never auto-navigates to the destination (plan §3.4).
await refreshCurrent()
} catch (err) {
if (bubbleError) throw err
- showToast(err instanceof Error ? err.message : 'Could not move resource.', {
- tone: 'error',
- })
+ if (err instanceof GfsMoveRefusalError) {
+ showToast(err.message, { tone: err.tone })
+ } else {
+ showToast(err instanceof Error ? err.message : 'Could not move resource.', {
+ tone: 'error',
+ })
+ }
} finally {
movingResourceRef.current = null
setMovingResourceId(null)
}
}
+ /** Resolve the moved source ONCE by immutable URI after a transport loss
+ * on the move PATCH (matrix B7/B8): a fresh path whose parent IS the
+ * destination proves the move landed; an unchanged path proves it did
+ * not; a failed verification keeps the outcome honestly unknown. */
+ async function settleUnknownTransportMove(
+ source: GfsChild,
+ destinationPath: string | null,
+ epoch: number
+ ): Promise<'moved' | 'not-moved' | 'unknown'> {
+ if (destinationPath === null) return 'unknown'
+ const read = await resolveEndpointView(source.gfsUri, source.resourceId)
+ if (!isGestureEpochCurrent(epoch)) return 'unknown'
+ if (read.status !== 'resolved' || typeof read.view.path !== 'string') return 'unknown'
+ const destinationCanonical = normalizeCanonicalPath(destinationPath)
+ if (destinationCanonical === null) return 'unknown'
+ const parent = parentPathOf(read.view.path)
+ // null → the resolved path IS the root itself (parent is root by
+ // definition); undefined → the path could not be classified.
+ if (parent === undefined) return 'unknown'
+ const landedParent = parent ?? '/'
+ return landedParent === destinationCanonical ? 'moved' : 'not-moved'
+ }
+
/** Rebuild the breadcrumb trail ANCESTRY for a moved trail-folder. The
* resolve contract answers with the folder's new `path`; every ancestor
* prefix is then resolved by-path so the trail reflects the new ancestor
@@ -1581,78 +2162,6 @@ export function GfsBrowser(): React.JSX.Element {
await rebuildTrailFromNewLocation(recovery.resourceId, recovery.gfsUri)
}
- /** Resolve a resource's canonical path from a current authorized view
- * (rev-2 §3.2): the operator resolve contract returns `path`; a null or
- * absent path NEVER certifies structure — callers fall back to the atomic
- * server check. */
- async function canonicalPathOf(child: Pick<GfsChild, 'gfsUri' | 'path'>): Promise<string | null> {
- if (typeof child.path === 'string' && child.path.length > 0) return child.path
- try {
- const view = (await apiGet('/api/v1/gfs/resolve', { uri: child.gfsUri })) as {
- path?: string | null
- }
- return typeof view.path === 'string' && view.path.length > 0 ? view.path : null
- } catch {
- return null
- }
- }
-
- function structureDenialMessage(
- reason: 'self' | 'descendant' | 'same-parent' | 'root-source' | 'cross-drive'
- ): string {
- switch (reason) {
- case 'same-parent':
- return 'This item is already in this folder.'
- case 'descendant':
- case 'self':
- return 'A folder cannot be moved into itself or one of its subfolders.'
- case 'root-source':
- return 'The top-level folder cannot be moved.'
- default:
- return 'Items can’t be moved between drives.'
- }
- }
-
- async function handleFolderDrop(
- event: React.DragEvent<HTMLLIElement>,
- folder: GfsChild
- ): Promise<void> {
- if (!hasDraggedGfsResource(event)) return
- event.preventDefault()
- event.stopPropagation()
- setDragOverFolderId(null)
- const source = draggingResourceRef.current
- if (!source) return
- if (source.kind === 'file') {
- // Files cannot be ancestors: no structural risk; move directly.
- await moveResource(source, folder)
- return
- }
- // Folder drops stop at ONE confirmation (rev-2 §1) after the fresh-path
- // structural guard — the impact dialog also records the naming policy.
- const [sourcePath, targetPath] = await Promise.all([
- canonicalPathOf(source),
- canonicalPathOf(folder),
- ])
- const structure = decideDragPathStructure({ sourcePath, targetPath })
- if (structure.kind === 'deny') {
- showToast(structureDenialMessage(structure.reason), { tone: 'error' })
- return
- }
- const occupiedNames = new Set<string>(
- (childCacheRef.current.get(folder.resourceId)?.items ?? []).map(item => item.name)
- )
- const suggested =
- occupiedNames.size > 0 && occupiedNames.has(source.name)
- ? nextAvailableGfsResourceName(source.name, occupiedNames)
- : undefined
- setConfirmMoveTarget({
- source,
- destination: folder,
- ...(suggested !== undefined ? { suggestedName: suggested } : {}),
- })
- }
-
async function uploadWithCompatibility(
input: GfsUploadJobInput
): Promise<'completed' | 'paused'> {
@@ -2203,12 +2712,42 @@ export function GfsBrowser(): React.JSX.Element {
const moveDialogCrumbs =
moveTargetCrumbIndex >= 0 ? crumbs.slice(0, moveTargetCrumbIndex) : crumbs
+ // Hover verdict announcement (RP-026 shape, plan §3.3): the live region
+ // carries the hovered target's verdict sentence. Text CHANGES announce;
+ // repeated identical text stays silent, so repeated dragover events never
+ // spam. Refused drops additionally use the toast stack, which is itself a
+ // live region.
+ const draggedSourceNow = draggingResourceId !== null ? draggingResourceRef.current : null
+ let dropHoverAnnouncement = ''
+ if (draggedSourceNow && dragOverCrumbIndex !== null) {
+ const hoveredCrumb = crumbs[dragOverCrumbIndex]
+ const verdict = crumbHoverVerdict(draggedSourceNow, dragOverCrumbIndex)
+ if (verdict && hoveredCrumb) {
+ dropHoverAnnouncement = gfsDropHoverAnnouncement(verdict, {
+ sourceName: draggedSourceNow.name,
+ targetName: isDriveRootCrumb(hoveredCrumb) ? DRIVE : hoveredCrumb.name,
+ })
+ }
+ } else if (draggedSourceNow && dragOverFolderId !== null) {
+ const hoveredRow = items.find(item => item.resourceId === dragOverFolderId)
+ const verdict = hoveredRow ? rowHoverVerdict(draggedSourceNow, hoveredRow) : null
+ if (verdict && hoveredRow) {
+ dropHoverAnnouncement = gfsDropHoverAnnouncement(verdict, {
+ sourceName: draggedSourceNow.name,
+ targetName: hoveredRow.name,
+ })
+ }
+ }
+
return (
<section
className="cu-gfs"
aria-label="EvenDrive browser"
aria-busy={loading || droppedUploadCount > 0 || movingResourceId !== null}
>
+ <div aria-live="polite" className="cu-gfs-drop-announce" data-testid="gfs-drop-announce">
+ {dropHoverAnnouncement}
+ </div>
<div
className="cu-card cu-card--viewport-fill cu-gfs-card"
onDragEnter={handleGfsDragEnter}
@@ -2275,6 +2814,15 @@ export function GfsBrowser(): React.JSX.Element {
// the right of its name, mirroring the Desktop Files pattern.
// The synthetic drive root and ancestor crumbs stay plain.
const activeFolder = index === crumbs.length - 1 ? crumbToChild(crumb) : null
+ // Every crumb is a drop target (plan §3.1): the drop-state
+ // verdict is painted token-driven alongside the reason; click
+ // and keyboard navigation stay untouched.
+ const draggedSource =
+ draggingResourceId !== null ? draggingResourceRef.current : null
+ const crumbVerdict =
+ draggedSource && dragOverCrumbIndex === index
+ ? crumbHoverVerdict(draggedSource, index)
+ : null
return (
<span
className="cu-gfs-breadcrumb__item"
@@ -2287,7 +2835,17 @@ export function GfsBrowser(): React.JSX.Element {
}`}
type="button"
onClick={() => goToCrumb(index)}
+ onDragEnter={event => handleCrumbDragEnter(event, index)}
+ onDragOver={event => handleCrumbDragOver(event, index)}
+ onDragLeave={event => handleCrumbDragLeave(event, index)}
+ onDrop={event => handleCrumbDrop(event, crumb, index)}
aria-current={index === crumbs.length - 1 ? 'page' : undefined}
+ data-drop-state={crumbVerdict ? crumbVerdict.state : undefined}
+ data-drop-reason={
+ crumbVerdict && crumbVerdict.state === 'denied'
+ ? crumbVerdict.reason
+ : undefined
+ }
>
{crumb.name === '/' ? (
<>
@@ -2357,8 +2915,20 @@ export function GfsBrowser(): React.JSX.Element {
{items.map(child => {
const rowOpenable = child.kind === 'directory' || isGfsPreviewFile(child.name)
const isDragging = draggingResourceId === child.resourceId
- const isDropTarget = dragOverFolderId === child.resourceId
const canDragResource = movingResourceId === null
+ // Directory rows and the dragged row itself stay hoverable
+ // drop zones so a refused drop can explain its reason
+ // (matrix A1/§5.3); plain file rows are not move targets.
+ const rowIsDropZone =
+ canDragResource &&
+ (child.kind === 'directory' ||
+ (isDragging && draggingResourceId === child.resourceId))
+ const draggedSource =
+ draggingResourceId !== null ? draggingResourceRef.current : null
+ const rowVerdict =
+ draggedSource && dragOverFolderId === child.resourceId
+ ? rowHoverVerdict(draggedSource, child)
+ : null
const openRow = () => {
if (child.kind === 'directory') openDirectory(child)
else openFilePreview(child)
@@ -2369,30 +2939,30 @@ export function GfsBrowser(): React.JSX.Element {
key={child.resourceId}
draggable={canDragResource}
title={
- canDragResource ? `Drag ${child.name} into a folder to move it` : undefined
+ canDragResource
+ ? `Drag ${child.name} into a folder or breadcrumb to move it`
+ : undefined
}
onDragStart={
canDragResource ? event => handleResourceDragStart(event, child) : undefined
}
onDragEnd={canDragResource ? handleResourceDragEnd : undefined}
onDragEnter={
- child.kind === 'directory'
- ? event => handleFolderDragEnter(event, child)
- : undefined
+ rowIsDropZone ? event => handleFolderDragEnter(event, child) : undefined
}
onDragOver={
- child.kind === 'directory'
- ? event => handleFolderDragOver(event, child)
- : undefined
+ rowIsDropZone ? event => handleFolderDragOver(event, child) : undefined
}
- onDragLeave={child.kind === 'directory' ? handleFolderDragLeave : undefined}
+ onDragLeave={rowIsDropZone ? handleFolderDragLeave : undefined}
onDrop={
- child.kind === 'directory'
- ? event => void handleFolderDrop(event, child)
- : undefined
+ rowIsDropZone ? event => void handleFolderDrop(event, child) : undefined
}
data-dragging={isDragging ? 'true' : undefined}
- data-drop-target={isDropTarget ? 'true' : undefined}
+ data-drop-target={rowVerdict?.state === 'allowed' ? 'true' : undefined}
+ data-drop-state={rowVerdict ? rowVerdict.state : undefined}
+ data-drop-reason={
+ rowVerdict && rowVerdict.state === 'denied' ? rowVerdict.reason : undefined
+ }
role={rowOpenable ? 'button' : undefined}
tabIndex={rowOpenable ? 0 : undefined}
aria-label={rowOpenable ? `Open ${child.name}` : undefined}
@@ -2729,11 +3299,15 @@ export function GfsBrowser(): React.JSX.Element {
const pending = confirmMoveTarget
setConfirmMoveTarget(null)
if (pending) {
- void moveResource(pending.source, pending.destination, { allowNumberedRename })
+ void moveResource(pending.source, pending.destination, {
+ allowNumberedRename,
+ revalidate: { epoch: pending.epoch },
+ })
}
}}
request={{
sourceName: confirmMoveTarget.source.name,
+ sourceKind: confirmMoveTarget.source.kind === 'directory' ? 'directory' : 'file',
destinationName: confirmMoveTarget.destination.name,
canRename: true,
...(confirmMoveTarget.suggestedName !== undefined
diff --git a/control-ui/components/GfsMoveConfirmDialog/index.tsx b/control-ui/components/GfsMoveConfirmDialog/index.tsx
index a67aad786..02935dd37 100644
--- a/control-ui/components/GfsMoveConfirmDialog/index.tsx
+++ b/control-ui/components/GfsMoveConfirmDialog/index.tsx
@@ -5,6 +5,8 @@ import { Button } from '@components/ui'
export interface GfsMoveConfirmRequest {
sourceName: string
+ /** Accurate impact copy and accessible naming per source kind. */
+ sourceKind: 'file' | 'directory'
destinationName: string
/** Suggested numbered-name candidate, when destination names are known. */
suggestedName?: string
@@ -20,12 +22,12 @@ export interface GfsMoveConfirmDialogProps {
}
/**
- * The ONE confirmation for folder drag moves (rev-2 §1): explains the
+ * The ONE confirmation for drag moves (rev-2 §1): explains the
* inherited-access impact and records the conflict naming policy in the same
* dialog, so no second automatic prompt follows the drop. Cancel ends the
* admission before dispatch; once the PATCH is dispatched it cannot be
- * recalled. Files move without confirmation; the Move dialog is its own
- * explicit confirmation surface.
+ * recalled. Files dropped onto breadcrumbs stop here too (source-kind-aware
+ * copy); the Move dialog is its own explicit confirmation surface.
*/
export function GfsMoveConfirmDialog({
request,
@@ -35,6 +37,7 @@ export function GfsMoveConfirmDialog({
}: GfsMoveConfirmDialogProps): React.JSX.Element {
const [allowNumberedRename, setAllowNumberedRename] = useState(false)
const dialogRef = useRef<HTMLElement | null>(null)
+ const sourceLabel = request.sourceKind === 'file' ? 'file' : 'folder'
// The element that had focus before the dialog opened. It is captured during
// the FIRST render — before the dialog moves focus into itself — so the
// restore can hand the keyboard back where it came from (RP-020).
@@ -112,7 +115,7 @@ export function GfsMoveConfirmDialog({
}}
>
<section
- aria-label={`Move folder ${request.sourceName} to ${request.destinationName}`}
+ aria-label={`Move ${sourceLabel} ${request.sourceName} to ${request.destinationName}`}
aria-modal="true"
className="cu-modal-panel cu-gfs-move-confirm"
onKeyDown={handleDialogKeyDown}
@@ -126,11 +129,18 @@ export function GfsMoveConfirmDialog({
</h3>
</header>
<div className="cu-gfs-move-confirm__body">
- <p className="cu-gfs-move-confirm__impact">
- Inherited access to this folder and its contents follows the new location. Direct
- sharing entries stay with their items — including any access they grant — and grantees
- may lose access.
- </p>
+ {request.sourceKind === 'file' ? (
+ <p className="cu-gfs-move-confirm__impact">
+ Inherited access to this file follows the new location. Direct sharing entries stay
+ with it — including any access they grant.
+ </p>
+ ) : (
+ <p className="cu-gfs-move-confirm__impact">
+ Inherited access to this folder and its contents follows the new location. Direct
+ sharing entries stay with their items — including any access they grant — and grantees
+ may lose access.
+ </p>
+ )}
{request.canRename ? (
<label className="cu-gfs-move-confirm__rename-toggle">
<input
diff --git a/control-ui/components/__tests__/GfsBrowser.test.tsx b/control-ui/components/__tests__/GfsBrowser.test.tsx
index 825d29a75..e38042069 100644
--- a/control-ui/components/__tests__/GfsBrowser.test.tsx
+++ b/control-ui/components/__tests__/GfsBrowser.test.tsx
@@ -1831,11 +1831,35 @@ describe('GfsBrowser', () => {
it('moves a dragged file into a visible folder without treating it as an upload', async () => {
const folder = child('archive', 'directory', 1)
const file = child('report.md', 'file', 2)
- mockApiGet
- .mockResolvedValueOnce({ items: [folder, file], nextCursor: null })
- .mockResolvedValueOnce({ items: [], nextCursor: null })
- .mockResolvedValueOnce({ items: [folder], nextCursor: null })
- mockApiSend.mockResolvedValueOnce({ ok: true })
+ let moved = false
+ mockApiGet.mockImplementation(async (path: string, query?: Record<string, string>) => {
+ if (path === '/api/v1/gfs/resolve' && query?.uri === file.gfsUri) {
+ // The pre-dispatch re-resolve answers with a FRESH source version —
+ // the PATCH must carry it, not the stale row version.
+ return {
+ resourceId: file.resourceId,
+ kind: 'file',
+ path: '/report.md',
+ version: 3,
+ }
+ }
+ if (path === '/api/v1/gfs/resolve' && query?.uri === folder.gfsUri) {
+ return {
+ resourceId: folder.resourceId,
+ kind: 'directory',
+ path: '/archive',
+ version: 0,
+ }
+ }
+ if (path === '/api/v1/gfs/tree') {
+ return { items: moved ? [folder] : [folder, file], nextCursor: null }
+ }
+ return { items: [], nextCursor: null }
+ })
+ mockApiSend.mockImplementationOnce(async () => {
+ moved = true
+ return { ok: true }
+ })
renderBrowser()
const resources = await screen.findByRole('list', { name: 'Current folder resources' })
@@ -1865,7 +1889,7 @@ describe('GfsBrowser', () => {
expect(mockApiSend).toHaveBeenCalledWith(
'PATCH',
'/api/v1/gfs/resources/id-2',
- { drive: 'main', newParentId: 'id-1', ifMatch: 0 },
+ { drive: 'main', newParentId: 'id-1', ifMatch: 3 },
{ drive: 'main' }
)
)
@@ -3928,7 +3952,31 @@ describe('GfsBrowser — folder drag-and-drop', () => {
function folderPage(archiveChildren: ReturnType<typeof child>[] = []) {
const archive = child('archive', 'directory', 1)
const projects = child('projects', 'directory', 2)
- mockApiGet.mockImplementation(async (path: string) => {
+ const resolveViewFor = (uri: string) => {
+ if (uri === archive.gfsUri) {
+ return {
+ resourceId: archive.resourceId,
+ kind: 'directory',
+ path: '/archive',
+ version: 0,
+ }
+ }
+ if (uri === projects.gfsUri) {
+ return {
+ resourceId: projects.resourceId,
+ kind: 'directory',
+ path: '/projects',
+ version: 0,
+ }
+ }
+ return null
+ }
+ mockApiGet.mockImplementation(async (path: string, query?: Record<string, string>) => {
+ if (path === '/api/v1/gfs/resolve' && query?.uri) {
+ const view = resolveViewFor(query.uri)
+ if (view) return view
+ throw Object.assign(new Error('404 Not Found'), { status: 404 })
+ }
if (
path === '/api/v1/gfs/tree' ||
path === '/api/v1/gfs/resources/11111111-1111-1111-1111-111111111111/children'
@@ -3944,7 +3992,7 @@ describe('GfsBrowser — folder drag-and-drop', () => {
}
return { items: [], nextCursor: null }
})
- return { archive, projects }
+ return { archive, projects, resolveViewFor }
}
function dragAndDrop(sourceRow: HTMLElement, destinationRow: HTMLElement) {
@@ -4028,11 +4076,28 @@ describe('GfsBrowser — folder drag-and-drop', () => {
it('refuses a folder drop into its own descendant using canonical paths', async () => {
// projects lives at /projects; archive lives at /projects/archive — a
- // child of the source. The listing rows carry those paths.
+ // child of the source. The listing rows carry those paths and the
+ // admission re-resolves both endpoints by immutable URI.
const projects = child('projects', 'directory', 2)
const nestedArchive = child('archive', 'directory', 1)
nestedArchive.path = '/projects/archive'
- mockApiGet.mockImplementation(async (path: string) => {
+ mockApiGet.mockImplementation(async (path: string, query?: Record<string, string>) => {
+ if (path === '/api/v1/gfs/resolve' && query?.uri === projects.gfsUri) {
+ return {
+ resourceId: projects.resourceId,
+ kind: 'directory',
+ path: '/projects',
+ version: 0,
+ }
+ }
+ if (path === '/api/v1/gfs/resolve' && query?.uri === nestedArchive.gfsUri) {
+ return {
+ resourceId: nestedArchive.resourceId,
+ kind: 'directory',
+ path: '/projects/archive',
+ version: 0,
+ }
+ }
if (
path === '/api/v1/gfs/tree' ||
path === '/api/v1/gfs/resources/11111111-1111-1111-1111-111111111111/children'
@@ -4055,7 +4120,7 @@ describe('GfsBrowser — folder drag-and-drop', () => {
dragAndDrop(projectsRow, archiveRow)
expect(
- await screen.findByText('A folder cannot be moved into itself or one of its subfolders.')
+ await screen.findByText(/You can't move projects into a folder inside itself/)
).toBeTruthy()
expect(mockApiSend).not.toHaveBeenCalled()
expect(screen.queryByRole('dialog')).toBeNull()
@@ -4190,3 +4255,725 @@ describe('GfsBrowser — folder drag-and-drop', () => {
expect(await screen.findByText('Moved "projects" to "archive" as "projects (3)".')).toBeTruthy()
})
})
+
+describe('GfsBrowser — breadcrumb drop moves', () => {
+ // The file's shared mock reset lives inside the sibling describe('GfsBrowser')
+ // block; this block resets the same API mocks for itself.
+ beforeEach(() => {
+ mockApiGet.mockReset()
+ mockApiSend.mockReset()
+ })
+
+ // Drive fixture: main › Product › live tests, browsing `live tests` with
+ // the file abac.md and the folder specs. Resolve answers carry FRESH
+ // versions so the pre-dispatch re-resolve is observable in ifMatch.
+ const rootId = '11111111-1111-1111-1111-111111111111'
+ const rootRid = '11111111111111111111111111111111'
+
+ interface EndpointView {
+ resourceId: string
+ kind: string
+ path: string
+ version: number
+ }
+
+ function breadcrumbTrailFixture(options?: { hydrateRoot?: boolean }) {
+ const product = child('Product', 'directory', 1)
+ product.path = '/Product'
+ const liveTests = child('live tests', 'directory', 3)
+ liveTests.path = '/Product/live tests'
+ const abac = child('abac.md', 'file', 2)
+ abac.path = '/Product/live tests/abac.md'
+ const specs = child('specs', 'directory', 4)
+ specs.path = '/Product/live tests/specs'
+ const views: Record<string, EndpointView> = {
+ // The root is keyed by its RID (dashes stripped): that is the form
+ // gfs:// URIs resolve with.
+ [rootRid]: { resourceId: rootId, kind: 'directory', path: '/', version: 1 },
+ r1: { resourceId: 'id-1', kind: 'directory', path: '/Product', version: 2 },
+ r2: { resourceId: 'id-2', kind: 'file', path: '/Product/live tests/abac.md', version: 5 },
+ r3: {
+ resourceId: 'id-3',
+ kind: 'directory',
+ path: '/Product/live tests',
+ version: 3,
+ },
+ r4: {
+ resourceId: 'id-4',
+ kind: 'directory',
+ path: '/Product/live tests/specs',
+ version: 7,
+ },
+ }
+ let moved = false
+ let treeReads = 0
+ let sourceResolveReads = 0
+ const parkedSourceReads: Array<(view: EndpointView) => void> = []
+ const hydrateRoot = options?.hydrateRoot !== false
+ // Test-side knobs that do not clobber the base listing mocks.
+ const policy = {
+ /** Tree reads (1-based) at and after this index throw transport errors. */
+ treeErrorFromRead: 0,
+ /** Per-read (1-based) overrides for the SOURCE resolve: a view, or 'failed'. */
+ sourceReadResults: new Map<number, EndpointView | 'failed'>(),
+ /** Park source reads at/after this index until released. */
+ parkSourceReadFrom: 0,
+ }
+ const resolveOverride: { uri?: string; result?: 'missing' | 'failed' | EndpointView } = {}
+ mockApiGet.mockImplementation(async (path: string, query?: Record<string, string>) => {
+ if (path === '/api/v1/gfs/resolve' && query?.uri) {
+ if (resolveOverride.uri === query.uri) {
+ if (resolveOverride.result === 'missing') {
+ throw Object.assign(new Error('404 Not Found'), { status: 404 })
+ }
+ if (resolveOverride.result === 'failed') {
+ throw new TypeError('fetch failed')
+ }
+ if (resolveOverride.result) return resolveOverride.result
+ }
+ if (query.uri === 'gfs://main/r2') {
+ sourceResolveReads += 1
+ const readResult = policy.sourceReadResults.get(sourceResolveReads)
+ if (readResult === 'failed') throw new TypeError('fetch failed')
+ if (readResult) return readResult
+ if (policy.parkSourceReadFrom > 0 && sourceResolveReads >= policy.parkSourceReadFrom) {
+ return new Promise<EndpointView>(resolve => {
+ parkedSourceReads.push(resolve)
+ })
+ }
+ }
+ const rid = query.uri.replace('gfs://main/', '')
+ const view = views[rid]
+ if (!view) throw Object.assign(new Error('404 Not Found'), { status: 404 })
+ return view
+ }
+ if (path === '/api/v1/gfs/tree') {
+ treeReads += 1
+ if (policy.treeErrorFromRead > 0 && treeReads >= policy.treeErrorFromRead) {
+ throw new TypeError('fetch failed')
+ }
+ // First load leaves the root synthetic when hydration is disabled;
+ // the drop-time retry then hydrates on the next tree read.
+ const includeRoot = hydrateRoot || treeReads > 1
+ return {
+ ...(includeRoot ? { rootResourceId: rootId } : {}),
+ items: [product],
+ nextCursor: null,
+ }
+ }
+ if (path === '/api/v1/gfs/by-path' && query?.path === '/live tests') {
+ return { ...views['r3']!, path: '/live tests' }
+ }
+ if (path === `/api/v1/gfs/resources/${rootId}/children`) {
+ return { items: [product], nextCursor: null }
+ }
+ if (path === '/api/v1/gfs/resources/id-1/children') {
+ return { items: moved ? [liveTests, abac] : [liveTests], nextCursor: null }
+ }
+ if (path === '/api/v1/gfs/resources/id-3/children') {
+ return { items: moved ? [specs] : [abac, specs], nextCursor: null }
+ }
+ return { items: [], nextCursor: null }
+ })
+ mockApiSend.mockImplementation(async () => {
+ moved = true
+ return { ok: true, data: { resourceId: 'id-2', version: 6 } }
+ })
+ return {
+ product,
+ liveTests,
+ abac,
+ specs,
+ views,
+ resolveOverride,
+ policy,
+ releaseParkedSourceReads(view: EndpointView) {
+ for (const release of parkedSourceReads.splice(0)) release(view)
+ },
+ }
+ }
+
+ function dataTransfer() {
+ return {
+ dropEffect: 'none',
+ effectAllowed: 'uninitialized',
+ files: [],
+ types: ['application/x-evenfire-gfs-resource'],
+ setData: vi.fn(),
+ getData: vi.fn(),
+ }
+ }
+
+ function breadcrumbNav() {
+ return screen.getByRole('navigation', { name: 'Breadcrumb' })
+ }
+
+ function crumbButton(name: string) {
+ return within(breadcrumbNav()).getByRole('button', { name, exact: true })
+ }
+
+ async function browseToLiveTests(productName = 'Product') {
+ renderBrowser()
+ await waitFor(() => expect(screen.queryByRole('status', { name: 'Loading files' })).toBeNull())
+ fireEvent.click((await screen.findAllByRole('button', { name: productName }))[0]!)
+ let list = screen.getByRole('list', { name: 'Current folder resources' })
+ fireEvent.click(await within(list).findByRole('button', { name: 'live tests', exact: true }))
+ await waitFor(() => expect(crumbButton('live tests')).toHaveAttribute('aria-current', 'page'))
+ list = screen.getByRole('list', { name: 'Current folder resources' })
+ await within(list).findByText('abac.md')
+ return list
+ }
+
+ function rowOf(list: HTMLElement, name: string) {
+ return within(list).getByText(name).closest('li')!
+ }
+
+ function dragRowOverCrumb(row: HTMLElement, crumb: HTMLElement) {
+ const transfer = dataTransfer()
+ fireEvent.dragStart(row, { dataTransfer: transfer })
+ fireEvent.dragEnter(crumb, { dataTransfer: transfer })
+ fireEvent.dragOver(crumb, { dataTransfer: transfer })
+ return transfer
+ }
+
+ it('moves a dropped file onto an ancestor crumb after one file-kind confirmation', async () => {
+ breadcrumbTrailFixture()
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+ const productCrumb = crumbButton('Product')
+
+ const transfer = dragRowOverCrumb(abacRow, productCrumb)
+ expect(productCrumb).toHaveAttribute('data-drop-state', 'allowed')
+ expect(screen.getByTestId('gfs-drop-announce')).toHaveTextContent('You can move into Product.')
+ fireEvent.drop(productCrumb, { dataTransfer: transfer })
+ fireEvent.dragEnd(abacRow, { dataTransfer: transfer })
+
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ expect(within(dialog).getByRole('heading', { level: 3 })).toHaveTextContent(
+ 'Move “abac.md” to “Product”?'
+ )
+ expect(
+ within(dialog).getByText(/Inherited access to this file follows the new location/)
+ ).toBeTruthy()
+ expect(
+ within(dialog).queryByText(/Inherited access to this folder and its contents/)
+ ).toBeNull()
+ expect(mockApiSend).not.toHaveBeenCalled()
+
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ // The commit re-resolved BOTH endpoints and used the FRESH source
+ // version (5), not the stale row version (0).
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenCalledWith(
+ 'PATCH',
+ '/api/v1/gfs/resources/id-2',
+ { drive: 'main', newParentId: 'id-1', ifMatch: 5 },
+ { drive: 'main' }
+ )
+ )
+ expect(await screen.findByText('Moved "abac.md" to "Product".')).toBeTruthy()
+ await waitFor(() => expect(screen.queryByText('abac.md')).toBeNull())
+ })
+
+ it('moves a dropped folder onto an ancestor crumb after one folder confirmation', async () => {
+ breadcrumbTrailFixture()
+ const list = await browseToLiveTests()
+ const specsRow = rowOf(list, 'specs')
+ const productCrumb = crumbButton('Product')
+
+ const transfer = dragRowOverCrumb(specsRow, productCrumb)
+ expect(productCrumb).toHaveAttribute('data-drop-state', 'allowed')
+ fireEvent.drop(productCrumb, { dataTransfer: transfer })
+ fireEvent.dragEnd(specsRow, { dataTransfer: transfer })
+
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move folder specs to Product',
+ })
+ expect(
+ within(dialog).getByText(/Inherited access to this folder and its contents/)
+ ).toBeTruthy()
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenCalledWith(
+ 'PATCH',
+ '/api/v1/gfs/resources/id-4',
+ { drive: 'main', newParentId: 'id-1', ifMatch: 7 },
+ { drive: 'main' }
+ )
+ )
+ expect(await screen.findByText('Moved "specs" to "Product".')).toBeTruthy()
+ expect(await screen.findByText(/access now follows the new location/)).toBeTruthy()
+ })
+
+ it('admits a drop onto the hydrated drive-root crumb as an intrinsic-authority move', async () => {
+ breadcrumbTrailFixture()
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+ const rootCrumb = crumbButton('main')
+
+ const transfer = dragRowOverCrumb(abacRow, rootCrumb)
+ expect(rootCrumb).toHaveAttribute('data-drop-state', 'allowed')
+ fireEvent.drop(rootCrumb, { dataTransfer: transfer })
+ fireEvent.dragEnd(abacRow, { dataTransfer: transfer })
+
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to main',
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenCalledWith(
+ 'PATCH',
+ '/api/v1/gfs/resources/id-2',
+ { drive: 'main', newParentId: rootId, ifMatch: 5 },
+ { drive: 'main' }
+ )
+ )
+ expect(await screen.findByText('Moved "abac.md" to "main".')).toBeTruthy()
+ })
+
+ it('hydrates an unhydrated root on drop and completes the move', async () => {
+ const { resolveOverride } = breadcrumbTrailFixture({ hydrateRoot: false })
+ void resolveOverride
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+ const rootCrumb = crumbButton('main')
+
+ const transfer = dragRowOverCrumb(abacRow, rootCrumb)
+ // Identity not available yet: warning paint, never a fake denial.
+ expect(rootCrumb).toHaveAttribute('data-drop-state', 'unavailable')
+ expect(screen.getByTestId('gfs-drop-announce')).toHaveTextContent(
+ 'EvenDrive could not confirm whether you can move into main.'
+ )
+ fireEvent.drop(rootCrumb, { dataTransfer: transfer })
+ fireEvent.dragEnd(abacRow, { dataTransfer: transfer })
+
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to main',
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenCalledWith(
+ 'PATCH',
+ '/api/v1/gfs/resources/id-2',
+ { drive: 'main', newParentId: rootId, ifMatch: 5 },
+ { drive: 'main' }
+ )
+ )
+ })
+
+ it('warns honestly when the drop-time root hydration read fails, without any PATCH', async () => {
+ // The first load stays rootless and every later tree read fails, so the
+ // drop-time hydration retry cannot answer.
+ const fixture = breadcrumbTrailFixture({ hydrateRoot: false })
+ fixture.policy.treeErrorFromRead = 2
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+ const rootCrumb = crumbButton('main')
+
+ const transfer = dragRowOverCrumb(abacRow, rootCrumb)
+ fireEvent.drop(rootCrumb, { dataTransfer: transfer })
+ fireEvent.dragEnd(abacRow, { dataTransfer: transfer })
+
+ expect(
+ await screen.findByText(
+ 'EvenDrive couldn’t verify this move. Check your connection and try again.'
+ )
+ ).toBeTruthy()
+ expect(
+ screen.getByText(/EvenDrive couldn’t verify this move/).closest('.cu-toast')
+ ).toHaveClass('cu-toast--warning')
+ expect(mockApiSend).not.toHaveBeenCalled()
+ expect(screen.queryByRole('dialog')).toBeNull()
+ })
+
+ it('reports the active crumb as already-here info without a dialog or PATCH', async () => {
+ breadcrumbTrailFixture()
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+ const activeCrumb = crumbButton('live tests')
+
+ const transfer = dragRowOverCrumb(abacRow, activeCrumb)
+ expect(activeCrumb).toHaveAttribute('data-drop-state', 'same-parent')
+ expect(screen.getByTestId('gfs-drop-announce')).toHaveTextContent(
+ 'abac.md is already in live tests.'
+ )
+ fireEvent.drop(activeCrumb, { dataTransfer: transfer })
+ fireEvent.dragEnd(abacRow, { dataTransfer: transfer })
+
+ expect(await screen.findByText('abac.md is already in live tests.')).toBeTruthy()
+ expect(screen.getByText('abac.md is already in live tests.').closest('.cu-toast')).toHaveClass(
+ 'cu-toast--info'
+ )
+ expect(mockApiSend).not.toHaveBeenCalled()
+ expect(screen.queryByRole('dialog')).toBeNull()
+ expect(within(list).getByText('abac.md')).toBeTruthy()
+ })
+
+ it('cancelling the crumb confirmation sends no PATCH and claims no move', async () => {
+ breadcrumbTrailFixture()
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+ const productCrumb = crumbButton('Product')
+
+ const transfer = dragRowOverCrumb(abacRow, productCrumb)
+ fireEvent.drop(productCrumb, { dataTransfer: transfer })
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Cancel' }))
+
+ expect(mockApiSend).not.toHaveBeenCalled()
+ expect(screen.queryByText(/Moved/)).toBeNull()
+ expect(screen.queryByRole('dialog')).toBeNull()
+ expect(within(list).getByText('abac.md')).toBeTruthy()
+ })
+
+ it('refuses admission when the destination crumb vanished (404), without a PATCH', async () => {
+ const { resolveOverride } = breadcrumbTrailFixture()
+ resolveOverride.uri = 'gfs://main/r1'
+ resolveOverride.result = 'missing'
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+ const productCrumb = crumbButton('Product')
+
+ const transfer = dragRowOverCrumb(abacRow, productCrumb)
+ fireEvent.drop(productCrumb, { dataTransfer: transfer })
+ fireEvent.dragEnd(abacRow, { dataTransfer: transfer })
+
+ expect(await screen.findByText('This folder is no longer available.')).toBeTruthy()
+ expect(mockApiSend).not.toHaveBeenCalled()
+ expect(screen.queryByRole('dialog')).toBeNull()
+ })
+
+ it('refuses admission when the source can no longer be located (404)', async () => {
+ const { resolveOverride } = breadcrumbTrailFixture()
+ resolveOverride.uri = 'gfs://main/r2'
+ resolveOverride.result = 'missing'
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+
+ expect(
+ await screen.findByText(
+ 'EvenDrive cannot verify this item’s current location. Refresh and try again.'
+ )
+ ).toBeTruthy()
+ expect(mockApiSend).not.toHaveBeenCalled()
+ expect(screen.queryByRole('dialog')).toBeNull()
+ })
+
+ it('refuses admission with a warning when endpoint resolution itself fails', async () => {
+ const { resolveOverride } = breadcrumbTrailFixture()
+ resolveOverride.uri = 'gfs://main/r1'
+ resolveOverride.result = 'failed'
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+
+ expect(
+ await screen.findByText(
+ 'EvenDrive couldn’t verify this move. Check your connection and try again.'
+ )
+ ).toBeTruthy()
+ expect(mockApiSend).not.toHaveBeenCalled()
+ expect(screen.queryByRole('dialog')).toBeNull()
+ })
+
+ it('re-checks the destination at commit: vanished target refuses without a PATCH', async () => {
+ const { resolveOverride } = breadcrumbTrailFixture()
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ // The destination disappears between the confirmation and the commit.
+ resolveOverride.uri = 'gfs://main/r1'
+ resolveOverride.result = 'missing'
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ expect(await screen.findByText('This folder is no longer available.')).toBeTruthy()
+ expect(mockApiSend).not.toHaveBeenCalled()
+ })
+
+ it('re-checks the destination at commit: a target that is no longer a folder refuses', async () => {
+ const { resolveOverride, views } = breadcrumbTrailFixture()
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ resolveOverride.uri = 'gfs://main/r1'
+ resolveOverride.result = { ...views['r1']!, kind: 'file' }
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ expect(await screen.findByText('This folder is no longer available.')).toBeTruthy()
+ expect(mockApiSend).not.toHaveBeenCalled()
+ })
+
+ it('re-checks structure at commit: a remote same-parent move becomes info, not a PATCH', async () => {
+ const { resolveOverride, views } = breadcrumbTrailFixture()
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ // The source was moved into Product by someone else while the dialog
+ // was open: the fresh commit read sees the new parent.
+ resolveOverride.uri = 'gfs://main/r2'
+ resolveOverride.result = { ...views['r2']!, path: '/Product/abac.md' }
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ expect(await screen.findByText('abac.md is already in Product.')).toBeTruthy()
+ expect(screen.getByText('abac.md is already in Product.').closest('.cu-toast')).toHaveClass(
+ 'cu-toast--info'
+ )
+ expect(mockApiSend).not.toHaveBeenCalled()
+ })
+
+ it('keeps the commit anchored to the captured crumb identity when the trail rebuilds mid-gesture', async () => {
+ const streamControllers: ReadableStreamDefaultController<Uint8Array>[] = []
+ const { views, resolveOverride } = breadcrumbTrailFixture()
+ // `live tests` was moved to the drive root by the remote change the
+ // frame announces: the rebuilt trail drops the Product crumb while the
+ // confirmation is still open.
+ resolveOverride.uri = 'gfs://main/r3'
+ resolveOverride.result = { ...views['r3']!, path: '/live tests' }
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn(async (_input: RequestInfo | URL, init?: RequestInit) => {
+ const body = new ReadableStream<Uint8Array>({
+ start(controller) {
+ streamControllers.push(controller)
+ init?.signal?.addEventListener('abort', () => controller.close(), { once: true })
+ },
+ })
+ return new Response(body, {
+ status: 200,
+ headers: { 'content-type': 'application/x-ndjson' },
+ })
+ })
+ )
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+
+ const frame = await controlApiProducerFrame()
+ await act(async () => {
+ streamControllers[0]!.enqueue(new TextEncoder().encode(`${frame}\n`))
+ })
+ await waitFor(() =>
+ expect(within(breadcrumbNav()).queryByRole('button', { name: 'Product' })).toBeNull()
+ )
+ expect(dialog).toBeVisible()
+
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ // The commit still targets the CAPTURED immutable destination identity,
+ // never a crumb re-read from the rebuilt trail (R7-M1).
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenCalledWith(
+ 'PATCH',
+ '/api/v1/gfs/resources/id-2',
+ { drive: 'main', newParentId: 'id-1', ifMatch: 5 },
+ { drive: 'main' }
+ )
+ )
+ })
+
+ it('a newer drag gesture supersedes the open confirmation', async () => {
+ breadcrumbTrailFixture()
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+ const specsRow = rowOf(list, 'specs')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ await screen.findByRole('dialog', { name: 'Move file abac.md to Product' })
+
+ // Starting a new drag invalidates the pending confirmation.
+ const secondTransfer = dataTransfer()
+ fireEvent.dragStart(specsRow, { dataTransfer: secondTransfer })
+
+ await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull())
+ expect(mockApiSend).not.toHaveBeenCalled()
+ })
+
+ it('dragend after an accepted drop does not cancel its admission', async () => {
+ breadcrumbTrailFixture()
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dataTransfer()
+ fireEvent.dragStart(abacRow, { dataTransfer: transfer })
+ fireEvent.dragEnter(crumbButton('Product'), { dataTransfer: transfer })
+ fireEvent.dragOver(crumbButton('Product'), { dataTransfer: transfer })
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ // The drop was accepted; dragend only clears presentation.
+ fireEvent.dragEnd(abacRow, { dataTransfer: transfer })
+
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+ await waitFor(() => expect(mockApiSend).toHaveBeenCalledTimes(1))
+ })
+
+ it('unmount supersedes a commit that has not dispatched yet', async () => {
+ const fixture = breadcrumbTrailFixture()
+ // Park the commit-time SOURCE read (read #2) until the surface is gone.
+ fixture.policy.parkSourceReadFrom = 2
+ const { unmount } = renderBrowser()
+ await waitFor(() => expect(screen.queryByRole('status', { name: 'Loading files' })).toBeNull())
+ fireEvent.click((await screen.findAllByRole('button', { name: 'Product' }))[0]!)
+ let list = screen.getByRole('list', { name: 'Current folder resources' })
+ fireEvent.click(await within(list).findByRole('button', { name: 'live tests', exact: true }))
+ await waitFor(() => expect(crumbButton('live tests')).toHaveAttribute('aria-current', 'page'))
+ list = screen.getByRole('list', { name: 'Current folder resources' })
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ // The surface unmounts while the commit read is still in flight: the
+ // epoch is superseded, so the PATCH must never dispatch.
+ unmount()
+ fixture.releaseParkedSourceReads(fixture.views['r2']!)
+ await act(async () => {
+ await Promise.resolve()
+ })
+ expect(mockApiSend).not.toHaveBeenCalled()
+ })
+
+ it('verifies a transport-lost PATCH by identity once and reports the move it proved', async () => {
+ const fixture = breadcrumbTrailFixture()
+ // Source resolve read #3 is the post-transport verification: the move
+ // actually landed in Product.
+ fixture.policy.sourceReadResults.set(3, {
+ ...fixture.views['r2']!,
+ path: '/Product/abac.md',
+ })
+ let patched = false
+ mockApiSend.mockImplementation(async () => {
+ if (patched) throw new Error('PATCH repeated after an unknown transport outcome')
+ patched = true
+ // Transport loss AFTER dispatch: no HTTP status, outcome unknown.
+ throw new TypeError('fetch failed')
+ })
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ expect(await screen.findByText('Moved "abac.md" to "Product".')).toBeTruthy()
+ // Exactly one PATCH — the ambiguous outcome was resolved by reading,
+ // never by repeating the dispatch.
+ await waitFor(() => expect(mockApiSend).toHaveBeenCalledTimes(1))
+ expect(mockApiSend).toHaveBeenCalledTimes(1)
+ })
+
+ it('reports a transport-lost PATCH as not-completed when verification proves no move', async () => {
+ breadcrumbTrailFixture()
+ mockApiSend.mockImplementation(async () => {
+ throw new TypeError('fetch failed')
+ })
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ expect(
+ await screen.findByText(
+ 'EvenDrive couldn’t complete this move. Check your connection and try again.'
+ )
+ ).toBeTruthy()
+ expect(mockApiSend).toHaveBeenCalledTimes(1)
+ })
+
+ it('keeps a transport-lost PATCH honestly unknown when verification cannot answer', async () => {
+ const fixture = breadcrumbTrailFixture()
+ // Source resolve read #3 is the post-transport verification and fails.
+ fixture.policy.sourceReadResults.set(3, 'failed')
+ mockApiSend.mockImplementation(async () => {
+ throw new TypeError('fetch failed')
+ })
+ const list = await browseToLiveTests()
+ const abacRow = rowOf(list, 'abac.md')
+
+ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))
+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })
+ const dialog = await screen.findByRole('dialog', {
+ name: 'Move file abac.md to Product',
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))
+
+ expect(
+ await screen.findByText(/Couldn.t confirm the move\. Refresh before trying again\./)
+ ).toBeTruthy()
+ expect(screen.getByText(/confirm the move/).closest('.cu-toast')).toHaveClass(
+ 'cu-toast--warning'
+ )
+ expect(mockApiSend).toHaveBeenCalledTimes(1)
+ })
+
+ it('explains a row dropped onto itself instead of silently ignoring it', async () => {
+ breadcrumbTrailFixture()
+ const list = await browseToLiveTests()
+ const specsRow = rowOf(list, 'specs')
+
+ const transfer = dataTransfer()
+ fireEvent.dragStart(specsRow, { dataTransfer: transfer })
+ fireEvent.dragEnter(specsRow, { dataTransfer: transfer })
+ fireEvent.dragOver(specsRow, { dataTransfer: transfer })
+ expect(specsRow).toHaveAttribute('data-drop-state', 'denied')
+ expect(specsRow).toHaveAttribute('data-drop-reason', 'self')
+ expect(screen.getByTestId('gfs-drop-announce')).toHaveTextContent(
+ 'You dropped specs onto itself. Pick a destination folder.'
+ )
+ fireEvent.drop(specsRow, { dataTransfer: transfer })
+ fireEvent.dragEnd(specsRow, { dataTransfer: transfer })
+
+ expect(
+ await screen.findByText('You dropped specs onto itself. Pick a destination folder.')
+ ).toBeTruthy()
+ expect(mockApiSend).not.toHaveBeenCalled()
+ expect(within(list).getByText('specs')).toBeTruthy()
+ })
+})
diff --git a/control-ui/e2e/gfs-drag-and-drop.spec.ts b/control-ui/e2e/gfs-drag-and-drop.spec.ts
index af5cd9b48..57758dbb8 100644
--- a/control-ui/e2e/gfs-drag-and-drop.spec.ts
+++ b/control-ui/e2e/gfs-drag-and-drop.spec.ts
@@ -327,6 +327,37 @@ async function dragRowToRow(page: Page, sourceRow: Locator, targetRow: Locator):
await page.mouse.up()
}
+/**
+ * Drag a resource row onto a breadcrumb crumb button. Same mouse sequence as
+ * dragRowToRow, but the release waits for the crumb to advertise its
+ * `data-drop-state` verdict — the breadcrumb drop targets paint a tokenized
+ * state (allowed/checking/denied/unavailable/same-parent) instead of the row
+ * affordance.
+ */
+async function dragRowToCrumb(
+ page: Page,
+ sourceRow: Locator,
+ crumb: Locator,
+ expectedState: 'allowed' | 'checking' | 'same-parent' | 'unavailable' = 'allowed'
+): Promise<void> {
+ await sourceRow.scrollIntoViewIfNeeded()
+ const iconBox = await sourceRow.locator('.cu-gfs-list__icon').boundingBox()
+ const crumbBox = await crumb.boundingBox()
+ if (!iconBox || !crumbBox) {
+ throw new Error(
+ 'drag source row or breadcrumb crumb is not visible; cannot compute drag coordinates'
+ )
+ }
+ const start = { x: iconBox.x + iconBox.width / 2, y: iconBox.y + iconBox.height / 2 }
+ const end = { x: crumbBox.x + crumbBox.width / 2, y: crumbBox.y + crumbBox.height / 2 }
+ await page.mouse.move(start.x, start.y)
+ await page.mouse.down()
+ await page.mouse.move((start.x + end.x) / 2, (start.y + end.y) / 2, { steps: 6 })
+ await page.mouse.move(end.x, end.y, { steps: 6 })
+ await expect(crumb).toHaveAttribute('data-drop-state', expectedState, { timeout: 10_000 })
+ await page.mouse.up()
+}
+
test.describe('EvenDrive drag and drop', () => {
test.describe.configure({ mode: 'serial' })
test.skip(
@@ -546,6 +577,195 @@ test.describe('EvenDrive drag and drop', () => {
}
})
+ test('file drag onto a breadcrumb crumb moves it up after one confirmation', async ({
+ page,
+ }, testInfo) => {
+ const parentName = fixtureName('parent')
+ const childName = fixtureName('kid')
+ const fileName = `${fixtureName('doc')}.txt`
+ let tempFile: Awaited<ReturnType<typeof createSecureTempFile>> | undefined
+
+ await beginJourney(page)
+ try {
+ await createFolderViaUi(page, parentName)
+ await openFolderViaUi(page, parentName)
+ await createFolderViaUi(page, childName)
+ await openFolderViaUi(page, childName)
+ tempFile = await createSecureTempFile(fileName, 'even-drive breadcrumb drop fixture\n')
+ await uploadFileViaUi(page, tempFile.filePath, fileName)
+
+ // The file lands on the PARENT crumb while browsing the child folder.
+ await dragRowToCrumb(page, resourceRow(page, fileName), breadcrumbButton(page, parentName))
+
+ // Both files and folders dropped onto a crumb stop at ONE
+ // confirmation with source-kind-accurate copy.
+ const dialog = page.getByRole('dialog', {
+ name: `Move file ${fileName} to ${parentName}`,
+ exact: true,
+ })
+ await expect(dialog).toBeVisible({ timeout: 20_000 })
+ await expect(dialog.getByRole('heading', { level: 3 })).toHaveText(
+ `Move “${fileName}” to “${parentName}”?`
+ )
+ await expect(
+ dialog.getByText(/Inherited access to this file follows the new location/)
+ ).toBeVisible()
+ await dialog.getByRole('button', { name: 'Move', exact: true }).click()
+
+ await expect(toast(page, `Moved "${fileName}" to "${parentName}".`)).toBeVisible()
+ await expect(resourceRow(page, fileName)).toHaveCount(0)
+ // Business signal: the file is now a child of the parent folder.
+ const rootId = await driveRootId(page)
+ const parentId = await findChildByName(page, rootId, parentName)
+ expect(parentId).not.toBeNull()
+ await expect
+ .poll(async () => (await childNames(page, parentId as string)).includes(fileName), {
+ timeout: 30_000,
+ intervals: [250, 1_000],
+ })
+ .toBe(true)
+ await screenshotAndLog(page, testInfo, 'gfs-dnd-breadcrumb-file-move')
+ } finally {
+ await tempFile?.cleanup().catch(() => {})
+ await cleanupGfsDragDropFixtures(page, new Set([parentName, childName, fileName]))
+ }
+ })
+
+ test('file drag onto the main drive-root crumb moves it to the root', async ({ page }) => {
+ const parentName = fixtureName('parent')
+ const childName = fixtureName('kid')
+ const fileName = `${fixtureName('doc')}.txt`
+ let tempFile: Awaited<ReturnType<typeof createSecureTempFile>> | undefined
+
+ await beginJourney(page)
+ try {
+ await createFolderViaUi(page, parentName)
+ await openFolderViaUi(page, parentName)
+ await createFolderViaUi(page, childName)
+ await openFolderViaUi(page, childName)
+ tempFile = await createSecureTempFile(fileName, 'even-drive root crumb fixture\n')
+ await uploadFileViaUi(page, tempFile.filePath, fileName)
+
+ // The root crumb is an admin-plane destination with intrinsic
+ // authority: the drop is admitted, never a fabricated permission deny.
+ await dragRowToCrumb(page, resourceRow(page, fileName), breadcrumbButton(page, 'main'))
+
+ const dialog = page.getByRole('dialog', {
+ name: `Move file ${fileName} to main`,
+ exact: true,
+ })
+ await expect(dialog).toBeVisible({ timeout: 20_000 })
+ await dialog.getByRole('button', { name: 'Move', exact: true }).click()
+
+ await expect(toast(page, `Moved "${fileName}" to "main".`)).toBeVisible()
+ await expect(resourceRow(page, fileName)).toHaveCount(0)
+ const rootId = await driveRootId(page)
+ await expect
+ .poll(async () => (await childNames(page, rootId)).includes(fileName), {
+ timeout: 30_000,
+ intervals: [250, 1_000],
+ })
+ .toBe(true)
+ } finally {
+ await tempFile?.cleanup().catch(() => {})
+ await cleanupGfsDragDropFixtures(page, new Set([parentName, childName, fileName]))
+ }
+ })
+
+ test('drop onto the active breadcrumb crumb explains it is already there', async ({
+ page,
+ }, testInfo) => {
+ const parentName = fixtureName('parent')
+ const childName = fixtureName('kid')
+ const fileName = `${fixtureName('doc')}.txt`
+ let tempFile: Awaited<ReturnType<typeof createSecureTempFile>> | undefined
+
+ await beginJourney(page)
+ try {
+ await createFolderViaUi(page, parentName)
+ await openFolderViaUi(page, parentName)
+ await createFolderViaUi(page, childName)
+ await openFolderViaUi(page, childName)
+ tempFile = await createSecureTempFile(fileName, 'even-drive active crumb fixture\n')
+ await uploadFileViaUi(page, tempFile.filePath, fileName)
+
+ const rootId = await driveRootId(page)
+ const parentId = await findChildByName(page, rootId, parentName)
+ const childId = await findChildByName(page, parentId as string, childName)
+ const namesBefore = await childNames(page, childId as string)
+
+ // The ACTIVE crumb is the listing's physical parent: an info no-op,
+ // never an error and never a PATCH.
+ await dragRowToCrumb(
+ page,
+ resourceRow(page, fileName),
+ breadcrumbButton(page, childName),
+ 'same-parent'
+ )
+
+ await expect(toast(page, `${fileName} is already in ${childName}.`)).toBeVisible()
+ await expect(toast(page, `${fileName} is already in ${childName}.`)).toHaveClass(
+ /cu-toast--info/
+ )
+ await expect(page.getByRole('dialog')).toHaveCount(0)
+ await expect(resourceRow(page, fileName)).toBeVisible()
+ const namesAfter = await childNames(page, childId as string)
+ expect(namesAfter).toEqual(namesBefore)
+ await screenshotAndLog(page, testInfo, 'gfs-dnd-breadcrumb-same-parent')
+ } finally {
+ await tempFile?.cleanup().catch(() => {})
+ await cleanupGfsDragDropFixtures(page, new Set([parentName, childName, fileName]))
+ }
+ })
+
+ test('folder drag onto an ancestor crumb above its parent commits after confirmation', async ({
+ page,
+ }) => {
+ const outerName = fixtureName('outer')
+ const midName = fixtureName('mid')
+ const leafName = fixtureName('leaf')
+ const folderName = fixtureName('arch')
+
+ await beginJourney(page)
+ try {
+ await createFolderViaUi(page, outerName)
+ await openFolderViaUi(page, outerName)
+ await createFolderViaUi(page, midName)
+ await openFolderViaUi(page, midName)
+ await createFolderViaUi(page, leafName)
+ await openFolderViaUi(page, leafName)
+ await createFolderViaUi(page, folderName)
+
+ // Drag the folder TWO levels up, onto a crumb above its own parent.
+ await dragRowToCrumb(page, resourceRow(page, folderName), breadcrumbButton(page, outerName))
+
+ const dialog = page.getByRole('dialog', {
+ name: `Move folder ${folderName} to ${outerName}`,
+ exact: true,
+ })
+ await expect(dialog).toBeVisible({ timeout: 20_000 })
+ await expect(
+ dialog.getByText(/Inherited access to this folder and its contents/)
+ ).toBeVisible()
+ await dialog.getByRole('button', { name: 'Move', exact: true }).click()
+
+ await expect(toast(page, `Moved "${folderName}" to "${outerName}".`)).toBeVisible()
+ await expect(toast(page, 'access now follows the new location')).toBeVisible()
+ await expect(resourceRow(page, folderName)).toHaveCount(0)
+ // Business signal: the folder is now a direct child of OUTER.
+ const rootId = await driveRootId(page)
+ const outerId = await findChildByName(page, rootId, outerName)
+ await expect
+ .poll(async () => (await childNames(page, outerId as string)).includes(folderName), {
+ timeout: 30_000,
+ intervals: [250, 1_000],
+ })
+ .toBe(true)
+ } finally {
+ await cleanupGfsDragDropFixtures(page, new Set([outerName, midName, leafName, folderName]))
+ }
+ })
+
test('OS-file drop uploads into the open folder', async ({ page }, testInfo) => {
const parentName = fixtureName('parent')
const fileName = `${fixtureName('osfile')}.txt`
diff --git a/control-ui/e2e/run-gfs-drag-and-drop.mjs b/control-ui/e2e/run-gfs-drag-and-drop.mjs
index 1057b9af0..920f2ec89 100644
--- a/control-ui/e2e/run-gfs-drag-and-drop.mjs
+++ b/control-ui/e2e/run-gfs-drag-and-drop.mjs
@@ -64,7 +64,35 @@ const PLAYWRIGHT_ARGS = [
'--workers=1',
]
-/** First non-empty value among the candidate env names (never logged). */
+/**
+ * The journey lanes this gate REQUIRES in the selected inventory. The
+ * breadcrumb drop-move feature (docs/design/gfs-breadcrumb-drop-move.md §7)
+ * owns live journeys; a spec file that silently loses them would still
+ * report green for the remaining journeys, so their absence from the
+ * inventory is a gate failure, not a smaller pass.
+ */
+export const REQUIRED_JOURNEY_INVENTORY = [
+ { label: 'a breadcrumb file-move journey', pattern: /breadcrumb crumb|drive-root crumb/i },
+ { label: 'an active-crumb same-parent journey', pattern: /active breadcrumb crumb/i },
+ { label: 'an ancestor folder-move journey', pattern: /ancestor crumb/i },
+]
+
+/**
+ * Required lanes missing from a journey inventory (selection or report).
+ * Returns the missing lane labels; empty means the inventory is complete.
+ */
+export function missingRequiredJourneyInventories(journeys) {
+ const titles = journeys.map(journey => journey.title)
+ const missing = []
+ for (const lane of REQUIRED_JOURNEY_INVENTORY) {
+ if (!titles.some(title => lane.pattern.test(title))) missing.push(lane.label)
+ }
+ return missing
+}
+
+/**
+ * First non-empty value among the candidate env names (never logged).
+ */
export function firstConfiguredValue(env, keys) {
for (const key of keys) {
const value = env[key]
@@ -476,6 +504,17 @@ async function main() {
)
return 1
}
+ // The inventory must carry every required lane BEFORE anything runs: a
+ // selection that lost the breadcrumb journeys cannot certify the feature.
+ const missingLanes = missingRequiredJourneyInventories(selectedJourneys)
+ if (missingLanes.length > 0) {
+ process.stderr.write('[E2E-GATE] The selected journey inventory is missing required lanes:\n')
+ for (const lane of missingLanes) process.stderr.write(` - ${lane}\n`)
+ process.stderr.write(
+ '[E2E-GATE] Nothing was executed. This is a FAILURE, not a smaller pass.\n'
+ )
+ return 1
+ }
process.stdout.write(
`[E2E-GATE] ${selectedJourneys.length} journey(s) selected: ${selectedJourneys
.map(journey => journey.title)
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 8fea81289..99dd39c39 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.745",
+ "version": "0.1.746",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.745",
+ "version": "0.1.746",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/control-ui/package.json b/control-ui/package.json
index 7e91021e3..b868a6196 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.745",
+ "version": "0.1.746",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/control-ui/test/__tests__/gfsDragAndDropGate.test.ts b/control-ui/test/__tests__/gfsDragAndDropGate.test.ts
index 5ca7157bd..b34cf4466 100644
--- a/control-ui/test/__tests__/gfsDragAndDropGate.test.ts
+++ b/control-ui/test/__tests__/gfsDragAndDropGate.test.ts
@@ -6,10 +6,12 @@ import {
ADMIN_PASSWORD_KEYS,
ADMIN_USER_KEYS,
CONFIRM_MUTATIONS_FLAG,
+ REQUIRED_JOURNEY_INVENTORY,
collectGateProblems,
collectReportJourneys,
evaluateGateReport,
invalidatePreviousAttemptArtifacts,
+ missingRequiredJourneyInventories,
tallyReportJourneys,
writeSanitizedRunSummary,
} from '../../e2e/run-gfs-drag-and-drop.mjs'
@@ -378,4 +380,54 @@ describe('EvenDrive drag-and-drop E2E gate', () => {
})
})
})
+
+ describe('required breadcrumb journey inventory', () => {
+ const breadcrumbJourneys = [
+ { title: 'file drag onto a breadcrumb crumb moves it up after one confirmation' },
+ { title: 'file drag onto the main drive-root crumb moves it to the root' },
+ { title: 'drop onto the active breadcrumb crumb explains it is already there' },
+ { title: 'folder drag onto an ancestor crumb above its parent commits after confirmation' },
+ ]
+
+ it('accepts an inventory that carries every required lane', () => {
+ const journeys = collectReportJourneys(
+ journeyReport([...breadcrumbJourneys, { title: 'file drag into folder moves it' }])
+ )
+ expect(missingRequiredJourneyInventories(journeys)).toEqual([])
+ })
+
+ it('fails an inventory that lost the breadcrumb journeys entirely', () => {
+ // The pre-breadcrumb spec: still a valid Playwright inventory, but it
+ // can no longer certify the breadcrumb drop-move feature.
+ const journeys = collectReportJourneys(
+ journeyReport([
+ { title: 'file drag into folder moves it' },
+ { title: 'folder drag opens the one confirmation and Cancel changes nothing' },
+ ])
+ )
+ const missing = missingRequiredJourneyInventories(journeys)
+ expect(missing).toEqual(REQUIRED_JOURNEY_INVENTORY.map(lane => lane.label))
+ })
+
+ it('names the exact lane a partial inventory is missing', () => {
+ const journeys = collectReportJourneys(
+ journeyReport([breadcrumbJourneys[0]!, breadcrumbJourneys[1]!, breadcrumbJourneys[3]!])
+ )
+ expect(missingRequiredJourneyInventories(journeys)).toEqual([
+ 'an active-crumb same-parent journey',
+ ])
+ })
+
+ it('requires the same-parent lane through the active-crumb wording, not any crumb title', () => {
+ const journeys = collectReportJourneys(
+ journeyReport([breadcrumbJourneys[0]!, breadcrumbJourneys[1]!, breadcrumbJourneys[3]!])
+ )
+ expect(
+ REQUIRED_JOURNEY_INVENTORY.find(lane => lane.label.includes('active-crumb'))?.pattern.test(
+ 'file drag onto a breadcrumb crumb moves it up'
+ )
+ ).toBe(false)
+ void journeys
+ })
+ })
})