Skip to content

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

TypeScript

Merge remote-tracking branch 'origin/dev' into feat/evendrive-improvements

Ma69f601b3249
diff --cc control-ui/components/GfsBrowser.tsx
index 567f4daf9,fc90488e7..275fbfa24
--- a/control-ui/components/GfsBrowser.tsx
+++ b/control-ui/components/GfsBrowser.tsx
@@@ -24,18 -24,9 +25,15 @@@ import
IconVideo,
} from '@components/Sidebar/icons'
import { useToast } from '@components/Toast'
-import { IconChevronRight, IconPaperclip, IconUpload, IconX } from '@components/icons'
+import {
+ IconChevronRight,
- IconDownload,
+ IconHardDrive,
+ IconPaperclip,
- IconPencil,
- IconShare,
+ IconUpload,
+ IconX,
+} from '@components/icons'
- import { Button } from '@components/ui'
+ import { Button, Field, TextInput } from '@components/ui'
-import { apiGet, apiSend, gfsDownload, isSilentApiError } from '@lib/api'
+import { apiGet, apiSend, getGfsResourceByPath, gfsDownload, isSilentApiError } from '@lib/api'
import { isGfsDocumentFile } from '@lib/gfsDocumentFile'
import {
GfsUploadCapabilityError,
@@@ -230,14 -208,10 +227,14 @@@ export function GfsBrowser(): React.JSX
// Operator selects a resource to delegate access on (grant panel).
const [selected, setSelected] = useState<GfsChild | null>(null)
const [renameTarget, setRenameTarget] = useState<GfsChild | null>(null)
- const [renameOpen, setRenameOpen] = useState(false)
- const [renameName, setRenameName] = useState('')
const [renaming, setRenaming] = useState(false)
+ const [renameError, setRenameError] = useState('')
+ const [renameValid, setRenameValid] = useState(true)
const [deleteOpen, setDeleteOpen] = useState(false)
+ // "Open EvenDrive link" dialog launched from the folder ⋯ menus.
+ const [openLinkOpen, setOpenLinkOpen] = useState(false)
+ const [openLinkResolving, setOpenLinkResolving] = useState(false)
+ const [openLinkError, setOpenLinkError] = useState<string | null>(null)
// New-folder dialog (replaces the native window.prompt flow).
const [newFolderOpen, setNewFolderOpen] = useState(false)
const [creatingFolder, setCreatingFolder] = useState(false)
@@@ -1182,104 -964,12 +1176,103 @@@
function openRowRename(child: GfsChild): void {
setSelected(null)
- setRenameOpen(false)
setDeleteOpen(false)
+ setRenameError('')
+ setRenameValid(true)
setRenameTarget(child)
- setRenameName(child.name)
}
+ /** Adapt a folder crumb for the row-action handlers (share, rename, move,
+ * delete) so a breadcrumb menu acts on exactly the same shape a
+ * parent-view row does. Returns null for the synthetic root. */
+ function crumbToChild(crumb: Crumb): GfsChild | null {
+ if (!crumb.id || !crumb.rid || crumb.kind !== 'directory' || crumb.version === undefined)
+ return null
+ return {
+ resourceId: crumb.id,
+ rid: crumb.rid,
+ gfsUri: crumb.gfsUri ?? `gfs://${DRIVE}/${crumb.rid}`,
+ name: crumb.name,
+ kind: crumb.kind,
+ path: null,
+ bytes: 0,
+ version: crumb.version,
+ }
+ }
+
+ /** Single construction path for a FOLDER's ⋯ menu. Parent-view rows and
+ * breadcrumb crumb menus both build their props here, so their option
+ * lists cannot drift apart. File-only actions stay on the file rows. */
+ function folderMenuProps(folder: GfsChild) {
+ return {
+ resourceName: folder.name,
+ resourceUri: folder.gfsUri,
+ onManage: () => openManage(folder),
+ onCopyLink: () => void copyGfsUri(folder.gfsUri),
+ onOpenLink: () => setOpenLinkOpen(true),
+ onRename: () => openRowRename(folder),
+ onMove: () => openMove(folder),
+ onDelete: () => openManage(folder, 'delete'),
+ }
+ }
+
+ /** "Open EvenDrive link": resolve a pasted gfs:// URI through control-api
+ * and navigate the breadcrumb straight to that folder, mirroring the
+ * Desktop Files flow.
+ *
+ * DEFERRAL (R1-M5 / R2-M2): the real resolve producer (control-api
+ * `toResolveView`) returns resourceId, rid, gfsUri, drive, name, kind,
+ * path, and updatedAt — and NO mutation version. Until that contract
+ * supplies a version (backend issue #774), a link-opened active crumb
+ * carries no version, so `crumbToChild` returns null and the crumb gets
+ * NO mutating ⋯ menu — breadcrumb mutations on link-opened folders stay
+ * deferred rather than running against an invented ifMatch. */
+ async function openEvenDriveLink(uri: string): Promise<void> {
+ setOpenLinkError(null)
+ setOpenLinkResolving(true)
+ try {
+ const view = (await apiGet('/api/v1/gfs/resolve', { uri })) as {
+ resourceId: string
+ rid: string
+ gfsUri: string
+ name: string
+ kind: string
+ /** Absent from the real resolve contract; kept so a future producer
+ * that supplies it lights the mutating menu up without another UI
+ * change (see the deferral note above). */
+ version?: number
+ }
+ if (view.kind !== 'directory') {
+ setOpenLinkError('Only folder links can be opened here.')
+ return
+ }
+ setRenameTarget(null)
+ setSelected(null)
- setRenameOpen(false)
+ setDeleteOpen(false)
+ // Replacing the whole trail supersedes any in-flight breadcrumb
+ // reconstruction (R7-M1): its late response must not re-anchor the
+ // trail this link-open just replaced.
+ trailReconstructionEpochRef.current += 1
+ setCrumbs([
+ { id: null, rid: null, name: '/' },
+ {
+ id: view.resourceId,
+ rid: view.rid,
+ name: view.name,
+ kind: 'directory',
+ gfsUri: view.gfsUri,
+ ...(view.version === undefined ? {} : { version: view.version }),
+ },
+ ])
+ setLoading(true)
+ setOpenLinkOpen(false)
+ } catch (err) {
+ setOpenLinkError(err instanceof Error ? err.message : 'Could not open the EvenDrive link.')
+ } finally {
+ setOpenLinkResolving(false)
+ }
+ }
+
async function renameResource(child: GfsChild, requestedName: string): Promise<void> {
if (!requestedName.trim() || renaming) return
setRenaming(true)
@@@ -1296,30 -986,12 +1289,29 @@@
{ drive: DRIVE, newName: name, ifMatch: child.version },
{ drive: DRIVE }
)
+ const nextVersion = (
+ patchResult as { data?: { resourceId?: string; version?: number } } | undefined
+ )?.data?.version
showToast('Resource renamed.', { tone: 'success' })
+ // A crumb rename must retitle the breadcrumb segment too, not just the
+ // listing rows refreshed below. It also supersedes any in-flight
+ // breadcrumb reconstruction (R7-M1): a stale retry response must not
+ // land over a trail the rename just advanced.
+ trailReconstructionEpochRef.current += 1
+ setCrumbs(prev =>
+ prev.map(crumb =>
+ crumb.id === child.resourceId
+ ? { ...crumb, name, ...(nextVersion === undefined ? {} : { version: nextVersion }) }
+ : crumb
+ )
+ )
- setRenameOpen(false)
setRenameTarget(null)
setSelected(null)
await refreshCurrent()
} catch (err) {
- showToast(err instanceof Error ? err.message : 'Could not rename resource.', {
- tone: 'error',
- })
++ // The rename dialog stays open with the draft and the failure reason —
++ // a toast alone gave the operator no retry path.
+ setRenameError(err instanceof Error ? err.message : 'Could not rename resource.')
} finally {
setRenaming(false)
}
@@@ -1507,49 -1148,30 +1499,37 @@@
<div className="cu-gfs-panel">
<div className="cu-gfs-panel__toolbar">
<nav aria-label="Breadcrumb" className="cu-gfs-breadcrumb">
- {crumbs.map((crumb, index) => (
- <span className="cu-gfs-breadcrumb__item" key={`${crumb.id ?? 'root'}-${index}`}>
- {index > 0 ? <IconChevronRight width={14} height={14} /> : null}
- <button
- className={`cu-gfs-breadcrumb__button${
- crumb.name === '/' ? ' cu-gfs-breadcrumb__button--root' : ''
- }`}
- type="button"
- onClick={() => goToCrumb(index)}
- aria-current={index === crumbs.length - 1 ? 'page' : undefined}
- >
- {crumb.name === '/' ? (
- <>
- <span className="cu-gfs-breadcrumb__drive-icon" aria-hidden="true">
- <IconFolder />
- </span>
- <span>{DRIVE}</span>
- </>
- ) : (
- crumb.name
- )}
- </button>
- </span>
- ))}
+ {crumbs.map((crumb, index) => {
+ // Only the ACTIVE folder segment carries a ⋯ menu — mounted to
+ // 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
+ return (
+ <span className="cu-gfs-breadcrumb__item" key={`${crumb.id ?? 'root'}-${index}`}>
+ {index > 0 ? <IconChevronRight width={14} height={14} /> : null}
- {activeFolder && renameTarget?.resourceId === activeFolder.resourceId ? (
- <GfsInlineRename
- onCancel={() => setRenameTarget(null)}
- onChange={setRenameName}
- onSubmit={() => void renameResource(activeFolder, renameName)}
- value={renameName}
- busy={renaming}
- />
- ) : (
- <button
- className={`cu-gfs-breadcrumb__button${
- crumb.name === '/' ? ' cu-gfs-breadcrumb__button--root' : ''
- }`}
- type="button"
- onClick={() => goToCrumb(index)}
- aria-current={index === crumbs.length - 1 ? 'page' : undefined}
- >
- {crumb.name === '/' ? (
- <>
- <span className="cu-gfs-breadcrumb__drive-icon" aria-hidden="true">
- <IconFolder />
- </span>
- <span>{DRIVE}</span>
- </>
- ) : (
- crumb.name
- )}
- </button>
- )}
- {activeFolder && renameTarget?.resourceId !== activeFolder.resourceId ? (
- <GfsResourceMenu {...folderMenuProps(activeFolder)} />
- ) : null}
++ <button
++ className={`cu-gfs-breadcrumb__button${
++ crumb.name === '/' ? ' cu-gfs-breadcrumb__button--root' : ''
++ }`}
++ type="button"
++ onClick={() => goToCrumb(index)}
++ aria-current={index === crumbs.length - 1 ? 'page' : undefined}
++ >
++ {crumb.name === '/' ? (
++ <>
++ <span className="cu-gfs-breadcrumb__drive-icon" aria-hidden="true">
++ <IconFolder />
++ </span>
++ <span>{DRIVE}</span>
++ </>
++ ) : (
++ crumb.name
++ )}
++ </button>
++ {activeFolder ? <GfsResourceMenu {...folderMenuProps(activeFolder)} /> : null}
+ </span>
+ )
+ })}
</nav>
<div className="cu-gfs-panel__actions">
<Button
@@@ -1713,64 -1326,44 +1684,49 @@@
<span className="cu-gfs-list__value">
{child.kind === 'directory' ? '—' : formatBytes(child.bytes)}
</span>
- <span className="cu-gfs-list__actions">
- <Button
- className="cu-gfs-list__row-action"
- icon
- size="sm"
- variant="ghost"
- title={`Share ${child.name}`}
- aria-label={`Share ${child.name}`}
- onClick={() => openManage(child)}
- >
- <IconShare width={16} height={16} />
- </Button>
- {child.kind !== 'directory' ? (
- <Button
- className="cu-gfs-list__download cu-gfs-list__row-action"
- icon
- size="sm"
- variant="ghost"
- title={`Download ${child.name}`}
- aria-label={`Download ${child.name}`}
- disabled={downloadingIds.has(child.resourceId)}
- onClick={() => void downloadFile(child)}
- >
- <IconDownload width={18} height={18} />
- </Button>
- ) : null}
- <Button
- className="cu-gfs-list__row-action"
- icon
- size="sm"
- variant="ghost"
- title={`Rename ${child.name}`}
- aria-label={`Rename ${child.name}`}
- onClick={() => openRowRename(child)}
- >
- <IconPencil width={16} height={16} />
- </Button>
- {child.kind === 'directory' ? (
- <GfsResourceMenu {...folderMenuProps(child)} />
- ) : (
- <GfsResourceMenu
- resourceName={child.name}
- resourceUri={child.gfsUri}
- downloading={downloadingIds.has(child.resourceId)}
- onManage={() => openManage(child)}
- onPreview={
- isGfsPreviewFile(child.name)
- ? () => openFilePreview(child)
- : undefined
- }
- onDownload={() => void downloadFile(child)}
- onReplace={file => void replaceFile(child, file)}
- onCopyLink={() => void copyGfsUri(child.gfsUri)}
- onRename={() => openRowRename(child)}
- onMove={() => openMove(child)}
- onDelete={() => openManage(child, 'delete')}
- />
- )}
+ <span
+ className="cu-gfs-list__actions"
+ onClick={event => {
+ const target = event.target
+ if (target instanceof Element) {
+ const interactive = target.closest(
+ 'button, a, input, select, textarea, [tabindex]'
+ )
+ if (interactive && event.currentTarget.contains(interactive)) return
+ }
+ event.preventDefault()
+ event.stopPropagation()
+ event.currentTarget
+ .querySelector<HTMLButtonElement>('button[aria-haspopup="menu"]')
+ ?.click()
+ }}
+ >
+ <GfsResourceMenu
+ resourceName={child.name}
+ resourceUri={child.gfsUri}
+ downloading={downloadingIds.has(child.resourceId)}
+ onManage={() => openManage(child)}
+ onPreview={
+ isGfsPreviewFile(child.name) ? () => openFilePreview(child) : undefined
+ }
+ onDownload={
+ child.kind !== 'directory' ? () => void downloadFile(child) : undefined
+ }
+ onReplace={
+ child.kind !== 'directory'
+ ? file => void replaceFile(child, file)
+ : undefined
+ }
+ onCopyLink={() => void copyGfsUri(child.gfsUri)}
++ // Folders keep the EvenDrive link flow reachable from
++ // their row menu, matching the breadcrumb crumb menu.
++ onOpenLink={
++ child.kind === 'directory' ? () => setOpenLinkOpen(true) : undefined
++ }
+ onRename={() => openRowRename(child)}
+ onMove={() => openMove(child)}
+ onDelete={() => openManage(child, 'delete')}
+ />
</span>
</li>
)
diff --cc control-ui/components/__tests__/GfsBrowser.test.tsx
index 374123f60,6f8721e80..32498ae00
--- a/control-ui/components/__tests__/GfsBrowser.test.tsx
+++ b/control-ui/components/__tests__/GfsBrowser.test.tsx
@@@ -1097,56 -1093,34 +1096,82 @@@ describe('GfsBrowser', () =>
)
})
+ it('keeps a directory rename draft open on failure and discards it on cancel', async () => {
+ mockApiGet.mockResolvedValueOnce({
+ items: [child('archive', 'directory', 1)],
+ nextCursor: null,
+ })
+ mockApiSend.mockRejectedValueOnce(new Error('stale resource version'))
+ renderBrowser()
+
+ await openResourceMenu('archive')
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))
+ const renameDialog = await screen.findByRole('dialog', { name: 'Rename folder' })
+ fireEvent.change(within(renameDialog).getByLabelText('New name'), {
+ target: { value: 'renamed-archive' },
+ })
+ fireEvent.click(within(renameDialog).getByRole('button', { name: 'Rename' }))
+
+ expect(await within(renameDialog).findByRole('alert')).toHaveTextContent(
+ 'stale resource version'
+ )
+ expect(within(renameDialog).getByLabelText('New name')).toHaveValue('renamed-archive')
+ fireEvent.click(within(renameDialog).getByRole('button', { name: 'Cancel' }))
+ expect(screen.queryByRole('dialog', { name: 'Rename folder' })).toBeNull()
+
+ await openResourceMenu('archive')
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))
+ expect(await screen.findByLabelText('New name')).toHaveValue('archive')
+ })
+
+ it('carries the server version through consecutive renames', async () => {
+ const first = child('report.txt', 'file', 1, 7)
+ const second = { ...first, name: 'report-renamed.txt', version: 8 }
+ const third = { ...second, name: 'report-final.txt', version: 9 }
+ mockApiGet
+ .mockResolvedValueOnce({ items: [first], nextCursor: null })
+ .mockResolvedValueOnce({ items: [second], nextCursor: null })
+ .mockResolvedValueOnce({ items: [third], nextCursor: null })
+ mockApiSend
+ .mockResolvedValueOnce({ ok: true, data: { resourceId: 'id-1', version: 8 } })
+ .mockResolvedValueOnce({ ok: true, data: { resourceId: 'id-1', version: 9 } })
+ renderBrowser()
+
+ await screen.findByText('report.txt')
- const firstRow = screen.getByText('report.txt').closest('li')!
+ await openResourceMenu('report.txt')
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))
- const firstForm = within(firstRow).getByRole('form', { name: 'Rename resource' })
- fireEvent.change(within(firstForm).getByLabelText('New name'), {
++ let renameDialog = await screen.findByRole('dialog', { name: 'Rename file' })
++ fireEvent.change(within(renameDialog).getByLabelText('New name'), {
+ target: { value: 'report-renamed.txt' },
+ })
- fireEvent.click(within(firstForm).getByRole('button', { name: 'Save name' }))
++ fireEvent.click(within(renameDialog).getByRole('button', { name: 'Rename' }))
+
+ await screen.findByText('report-renamed.txt')
+ expect(mockApiSend).toHaveBeenNthCalledWith(
+ 1,
+ 'PATCH',
+ '/api/v1/gfs/resources/id-1',
+ { drive: 'main', newName: 'report-renamed.txt', ifMatch: 7 },
+ { drive: 'main' }
+ )
- const secondRow = screen.getByText('report-renamed.txt').closest('li')!
+ await openResourceMenu('report-renamed.txt')
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))
- const secondForm = within(secondRow).getByRole('form', { name: 'Rename resource' })
- fireEvent.change(within(secondForm).getByLabelText('New name'), {
++ renameDialog = await screen.findByRole('dialog', { name: 'Rename file' })
++ fireEvent.change(within(renameDialog).getByLabelText('New name'), {
+ target: { value: 'report-final.txt' },
+ })
- fireEvent.click(within(secondForm).getByRole('button', { name: 'Save name' }))
++ fireEvent.click(within(renameDialog).getByRole('button', { name: 'Rename' }))
+
+ await waitFor(() => expect(screen.getByText('report-final.txt')).toBeTruthy())
+ expect(mockApiSend).toHaveBeenNthCalledWith(
+ 2,
+ 'PATCH',
+ '/api/v1/gfs/resources/id-1',
+ { drive: 'main', newName: 'report-final.txt', ifMatch: 8 },
+ { drive: 'main' }
+ )
+ })
+
it('keeps the share dialog focused on sharing without resource actions', async () => {
mockApiGet.mockResolvedValueOnce({
items: [child('report.txt', 'file', 2)],
@@@ -1217,13 -1193,12 +1244,12 @@@
expect(folderRow).not.toBeNull()
expect(fileRow).not.toBeNull()
- expect(within(folderRow!).getByRole('button', { name: 'Share archive' })).toBeTruthy()
- expect(within(folderRow!).getByRole('button', { name: 'Rename archive' })).toBeTruthy()
+ expect(within(folderRow!).getAllByRole('button')).toHaveLength(2)
+ expect(within(folderRow!).getByRole('button', { name: 'Actions for archive' })).toBeTruthy()
expect(within(folderRow!).queryByRole('button', { name: 'Download archive' })).toBeNull()
- expect(within(fileRow!).getByRole('button', { name: 'Share report.md' })).toBeTruthy()
- expect(within(fileRow!).getByRole('button', { name: 'Download report.md' })).toBeTruthy()
- expect(within(fileRow!).getByRole('button', { name: 'Rename report.md' })).toBeTruthy()
- expect(within(fileRow!).getAllByRole('button')).toHaveLength(2)
+ expect(within(fileRow!).getByRole('button', { name: 'Actions for report.md' })).toBeTruthy()
++ expect(within(fileRow!).queryByRole('button', { name: 'Share report.md' })).toBeNull()
})
it('surfaces download failures through the toast stack', async () => {
@@@ -1480,684 -1456,6 +1507,684 @@@
)
})
+ it('shows the ⋯ menu only on the active breadcrumb folder and opens pasted EvenDrive links', async () => {
+ const orgFolder = child('org', 'directory', 1)
+ const nestedFolder = child('nested', 'directory', 3)
+ mockApiGet.mockImplementation(async (path: string) => {
+ if (path === '/api/v1/gfs/tree') {
+ return { items: [orgFolder], nextCursor: null }
+ }
+ if (path === '/api/v1/gfs/resources/id-1/children') {
+ return { items: [nestedFolder], nextCursor: null }
+ }
+ if (path === '/api/v1/gfs/resolve') {
+ // Real control-api resolve contract (toResolveView): no version.
+ return {
+ resourceId: 'id-3',
+ rid: 'r3',
+ gfsUri: 'gfs://main/r3',
+ drive: 'main',
+ name: 'nested',
+ kind: 'directory',
+ path: '/nested',
+ updatedAt: '2026-09-24T00:00:00.000Z',
+ }
+ }
+ return { items: [], nextCursor: null }
+ })
+ renderBrowser()
+
+ fireEvent.click(await screen.findByRole('button', { name: 'org' }))
+ await screen.findByText('nested')
+
+ const breadcrumb = screen.getByRole('navigation', { name: 'Breadcrumb' })
+ // Only the ACTIVE folder (org) carries a menu. The synthetic drive root
+ // and non-active segments — and the nested ROW, which lives in the listing
+ // rather than the breadcrumb — do not render breadcrumb menus.
+ expect(within(breadcrumb).queryByRole('button', { name: 'Actions for main' })).toBeNull()
+ expect(within(breadcrumb).queryByRole('button', { name: 'Actions for nested' })).toBeNull()
+ const activeTrigger = within(breadcrumb).getByRole('button', { name: 'Actions for org' })
+ // The menu sits to the RIGHT of the active folder's name: its wrapper is
+ // the breadcrumb label button's next sibling within the segment.
+ const activeWrapper = activeTrigger.closest('.cu-gfs-resource-menu')
+ expect(activeWrapper?.previousElementSibling).toBe(
+ within(breadcrumb).getByRole('button', { name: 'org' })
+ )
+
+ // The active folder menu lists the same options as that folder's row menu
+ // in its parent view.
+ await openResourceMenu('nested')
+ const rowOptions = screen.getAllByRole('menuitem').map(item => item.textContent)
+ fireEvent.keyDown(document, { key: 'Escape' })
+ await openResourceMenu('org')
+ expect(screen.getAllByRole('menuitem').map(item => item.textContent)).toEqual(rowOptions)
+ expect(rowOptions).toEqual(['Share', 'Open EvenDrive link', 'Rename', 'Move to…', 'Delete'])
+
+ // "Open EvenDrive link" resolves the pasted URI and navigates to it. The
+ // current resolve contract does not return a mutation version, so the
+ // active breadcrumb deliberately has no mutating menu until the backend
+ // version contract is delivered.
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Open EvenDrive link' }))
+ const dialog = await screen.findByRole('dialog', { name: 'Open EvenDrive link' })
+ fireEvent.change(within(dialog).getByLabelText('EvenDrive link'), {
+ target: { value: 'gfs://main/r3' },
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Open' }))
+
+ await waitFor(() =>
+ expect(mockApiGet).toHaveBeenCalledWith('/api/v1/gfs/resolve', { uri: 'gfs://main/r3' })
+ )
+ await waitFor(() =>
+ expect(within(breadcrumb).getByRole('button', { name: 'nested' })).toBeTruthy()
+ )
+ expect(within(breadcrumb).queryByRole('button', { name: 'Actions for nested' })).toBeNull()
+ expect(within(breadcrumb).queryByRole('button', { name: 'Actions for org' })).toBeNull()
+ expect(screen.queryByRole('dialog', { name: 'Open EvenDrive link' })).toBeNull()
+ })
+
+ // R5-M1: moving the folder the breadcrumb is INSIDE changes its ancestry, so
+ // patching the moved crumb in place would leave the trail pointing at the
+ // old location. The trail must be rebuilt from the folder's new location.
+ it('rebuilds the breadcrumb trail after moving the open folder to another parent', async () => {
+ const rootId = '11111111-1111-1111-1111-111111111111'
+ const folder = child('org', 'directory', 1, 7)
+ const archive = child('archive', 'directory', 2, 5)
+ // The resolve and by-path fixtures carry exactly the real control-api
+ // contract shape (toResolveView): no version field anywhere.
+ const resolveView = (resourceId: string, rid: string, name: string, path: string) => ({
+ resourceId,
+ rid,
+ gfsUri: `gfs://main/${rid}`,
+ drive: 'main',
+ name,
+ kind: 'directory',
+ path,
+ updatedAt: '2026-09-24T00:00:00.000Z',
+ })
+ mockApiGet.mockImplementation(async (path: string) => {
+ if (path === '/api/v1/gfs/tree' || path === `/api/v1/gfs/resources/${rootId}/children`) {
+ return { rootResourceId: rootId, items: [folder, archive], nextCursor: null }
+ }
+ if (path === '/api/v1/gfs/resolve') {
+ return resolveView(folder.resourceId, folder.rid, folder.name, '/archive/org')
+ }
+ if (path === '/api/v1/gfs/by-path') {
+ return resolveView(archive.resourceId, archive.rid, archive.name, '/archive')
+ }
+ return { items: [], nextCursor: null }
+ })
+ mockGetGfsResourceByPath.mockReset()
+ mockGetGfsResourceByPath.mockImplementation(async (_drive: string, path: string) =>
+ resolveView(archive.resourceId, archive.rid, archive.name, path)
+ )
+ mockApiSend
+ .mockResolvedValueOnce({
+ ok: true,
+ data: { resourceId: folder.resourceId, version: 8 },
+ })
+ .mockResolvedValueOnce({
+ ok: true,
+ data: { resourceId: folder.resourceId, version: 9 },
+ })
+ renderBrowser()
+
+ await waitFor(() =>
+ expect(mockApiGet).toHaveBeenCalledWith('/api/v1/gfs/tree', { drive: 'main' })
+ )
+ // Open /org by navigation, so its crumb carries the listed version (7).
+ fireEvent.click(await screen.findByRole('button', { name: 'org' }))
+ await screen.findByText('No resources are visible in this folder.')
+
+ const breadcrumb = screen.getByRole('navigation', { name: 'Breadcrumb' })
+ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Move to…' }))
+ const moveDialog = await screen.findByRole('dialog', { name: 'Move folder org' })
+ fireEvent.click(await within(moveDialog).findByRole('button', { name: 'archive' }))
+ fireEvent.click(within(moveDialog).getByRole('button', { name: 'Move here (archive)' }))
+
+ // The move runs with the pre-move version from the listing.
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenNthCalledWith(
+ 1,
+ 'PATCH',
+ `/api/v1/gfs/resources/${folder.resourceId}`,
+ { drive: 'main', newParentId: archive.resourceId, ifMatch: 7 },
+ { drive: 'main' }
+ )
+ )
+ // The trail is rebuilt from the folder's new location: the moved folder
+ // resolves at /archive/org, and each ancestor prefix resolves by-path.
+ await waitFor(() =>
+ expect(mockApiGet).toHaveBeenCalledWith('/api/v1/gfs/resolve', { uri: folder.gfsUri })
+ )
+ await waitFor(() => expect(mockGetGfsResourceByPath).toHaveBeenCalledWith('main', '/archive'))
+ await waitFor(() => {
+ const labels = within(breadcrumb)
+ .getAllByRole('button')
+ .map(button => button.getAttribute('aria-label') ?? button.textContent)
+ expect(labels).toEqual(['main', 'archive', 'org', 'Actions for org'])
+ })
+
+ // The rebuilt active crumb kept the move receipt's version: a follow-up
+ // breadcrumb rename runs with the post-move version, not the pre-move one.
+ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))
- const renameForm = await within(breadcrumb).findByRole('form', { name: 'Rename resource' })
- fireEvent.change(within(renameForm).getByLabelText('New name'), {
++ const renameDialog = await screen.findByRole('dialog', { name: 'Rename folder' })
++ fireEvent.change(within(renameDialog).getByLabelText('New name'), {
+ target: { value: 'org-renamed' },
+ })
- fireEvent.click(within(renameForm).getByRole('button', { name: 'Save name' }))
++ fireEvent.click(within(renameDialog).getByRole('button', { name: 'Rename' }))
+
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenNthCalledWith(
+ 2,
+ 'PATCH',
+ `/api/v1/gfs/resources/${folder.resourceId}`,
+ { drive: 'main', newName: 'org-renamed', ifMatch: 8 },
+ { drive: 'main' }
+ )
+ )
+ await waitFor(() =>
+ expect(within(breadcrumb).getByRole('button', { name: 'org-renamed' })).toBeTruthy()
+ )
+ })
+
+ // R1-M5 / R2-M2: the real resolve producer (control-api toResolveView)
+ // returns NO mutation version, so link-opened breadcrumb mutations stay
+ // explicitly deferred — no synthetic version fixture may imply otherwise.
+ // Production resolve version support remains owned by backend issue #774.
+ it('keeps breadcrumb mutations deferred for a link-opened folder while resolve provides no version', async () => {
+ const orgFolder = child('org', 'directory', 1)
+ // Fixture derived field-for-field from the real resolve contract
+ // (control-api/src/routes/gfs/resolve.ts toResolveView): no version.
+ const linkedView = {
+ resourceId: 'id-9',
+ rid: 'r9',
+ gfsUri: 'gfs://main/r9',
+ drive: 'main',
+ name: 'nested',
+ kind: 'directory',
+ path: '/nested',
+ updatedAt: '2026-09-24T00:00:00.000Z',
+ }
+ mockApiGet.mockImplementation(async (path: string) => {
+ if (path === '/api/v1/gfs/tree') {
+ return { items: [orgFolder], nextCursor: null }
+ }
+ if (path === '/api/v1/gfs/resolve') {
+ return linkedView
+ }
+ return { items: [], nextCursor: null }
+ })
+ renderBrowser()
+
+ await openResourceMenu('org')
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Open EvenDrive link' }))
+ const dialog = await screen.findByRole('dialog', { name: 'Open EvenDrive link' })
+ fireEvent.change(within(dialog).getByLabelText('EvenDrive link'), {
+ target: { value: 'gfs://main/r9' },
+ })
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Open' }))
+
+ await waitFor(() =>
+ expect(mockApiGet).toHaveBeenCalledWith('/api/v1/gfs/resolve', { uri: 'gfs://main/r9' })
+ )
+ const breadcrumb = screen.getByRole('navigation', { name: 'Breadcrumb' })
+ await waitFor(() =>
+ expect(within(breadcrumb).getByRole('button', { name: 'nested' })).toBeTruthy()
+ )
+ // Browsing the linked folder still works…
+ await waitFor(() =>
+ expect(mockApiGet).toHaveBeenCalledWith('/api/v1/gfs/resources/id-9/children', {
+ drive: 'main',
+ })
+ )
+ // …but with no real version from resolve, the active crumb carries no
+ // mutating ⋯ menu and no mutation request is issued against an
+ // invented ifMatch.
+ expect(within(breadcrumb).queryByRole('button', { name: 'Actions for nested' })).toBeNull()
+ expect(within(breadcrumb).queryByRole('button', { name: 'Actions for org' })).toBeNull()
+ expect(mockApiSend).not.toHaveBeenCalled()
+ })
+
+ // R5-M1 failure path (leaf resolve fails): after a successful Move PATCH,
+ // the breadcrumb must NOT be replaced by a shortened trail presented as
+ // authoritative. The stale trail stays on screen, a visible notice says
+ // the path could not be refreshed, and Retry rebuilds the trail once
+ // resolve recovers.
+ it('keeps the stale trail with a retry notice when the post-move resolve fails', async () => {
+ const rootId = '11111111-1111-1111-1111-111111111111'
+ const work = child('work', 'directory', 1, 3)
+ const org = child('org', 'directory', 2, 7)
+ const archive = child('archive', 'directory', 3, 5)
+ const resolveView = (resourceId: string, rid: string, name: string, path: string) => ({
+ resourceId,
+ rid,
+ gfsUri: `gfs://main/${rid}`,
+ drive: 'main',
+ name,
+ kind: 'directory',
+ path,
+ updatedAt: '2026-09-24T00:00:00.000Z',
+ })
+ let resolveCalls = 0
+ mockApiGet.mockImplementation(async (path: string) => {
+ if (path === '/api/v1/gfs/tree' || path === `/api/v1/gfs/resources/${rootId}/children`) {
+ return { rootResourceId: rootId, items: [work, archive], nextCursor: null }
+ }
+ if (path === `/api/v1/gfs/resources/${work.resourceId}/children`) {
+ return { items: [org], nextCursor: null }
+ }
+ if (path === '/api/v1/gfs/resolve') {
+ resolveCalls += 1
+ if (resolveCalls === 1) throw new Error('resolve unavailable')
+ return resolveView(org.resourceId, org.rid, 'org', '/archive/org')
+ }
+ return { items: [], nextCursor: null }
+ })
+ mockGetGfsResourceByPath.mockReset()
+ mockGetGfsResourceByPath.mockImplementation(async (_drive: string, path: string) =>
+ resolveView(archive.resourceId, archive.rid, archive.name, path)
+ )
+ mockApiSend.mockResolvedValueOnce({
+ ok: true,
+ data: { resourceId: org.resourceId, version: 8 },
+ })
+ renderBrowser()
+
+ // Open /work/org so the pre-move trail is deep enough to prove the
+ // stale trail is PRESERVED (work stays in it), not truncated.
+ fireEvent.click(await screen.findByRole('button', { name: 'work' }))
+ fireEvent.click(await screen.findByRole('button', { name: 'org' }))
+ await screen.findByText('No resources are visible in this folder.')
+
+ const breadcrumb = screen.getByRole('navigation', { name: 'Breadcrumb' })
+ const labels = () =>
+ within(breadcrumb)
+ .getAllByRole('button')
+ .map(button => button.getAttribute('aria-label') ?? button.textContent)
+ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Move to…' }))
+ const moveDialog = await screen.findByRole('dialog', { name: 'Move folder org' })
+ fireEvent.click(await within(moveDialog).findByRole('button', { name: 'archive' }))
+ fireEvent.click(within(moveDialog).getByRole('button', { name: 'Move here (archive)' }))
+
+ // The Move PATCH succeeded with the pre-move version.
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenCalledWith(
+ 'PATCH',
+ `/api/v1/gfs/resources/${org.resourceId}`,
+ { drive: 'main', newParentId: archive.resourceId, ifMatch: 7 },
+ { drive: 'main' }
+ )
+ )
+
+ // Reconstruction failed: the OLD trail is preserved and explicitly
+ // labeled — never shortened to main / org as if reconstruction
+ // succeeded.
+ const notice = await screen.findByRole('alert')
+ expect(notice.textContent).toMatch(/folder path could not be refreshed/)
+ expect(within(notice).getByRole('button', { name: 'Retry' })).toBeTruthy()
+ expect(labels()).toEqual(['main', 'work', 'org', 'Actions for org'])
+
+ // Retry: resolve now answers, the trail rebuilds from the new location,
+ // and the notice clears.
+ fireEvent.click(within(notice).getByRole('button', { name: 'Retry' }))
+ await waitFor(() => expect(labels()).toEqual(['main', 'archive', 'org', 'Actions for org']))
+ await waitFor(() => expect(screen.queryByRole('alert')).toBeNull())
+ })
+
+ // R5-M1 failure path (ancestor by-path fails): resolve names the new
+ // location, but an ancestor by-path lookup fails. Same contract — the
+ // stale trail is preserved and labeled, never partially applied, and
+ // Retry rebuilds it once by-path recovers.
+ it('keeps the stale trail with a retry notice when a post-move ancestor by-path lookup fails', async () => {
+ const rootId = '11111111-1111-1111-1111-111111111111'
+ const work = child('work', 'directory', 1, 3)
+ const org = child('org', 'directory', 2, 7)
+ const archive = child('archive', 'directory', 3, 5)
+ const resolveView = (resourceId: string, rid: string, name: string, path: string) => ({
+ resourceId,
+ rid,
+ gfsUri: `gfs://main/${rid}`,
+ drive: 'main',
+ name,
+ kind: 'directory',
+ path,
+ updatedAt: '2026-09-24T00:00:00.000Z',
+ })
+ mockApiGet.mockImplementation(async (path: string) => {
+ if (path === '/api/v1/gfs/tree' || path === `/api/v1/gfs/resources/${rootId}/children`) {
+ return { rootResourceId: rootId, items: [work, archive], nextCursor: null }
+ }
+ if (path === `/api/v1/gfs/resources/${work.resourceId}/children`) {
+ return { items: [org], nextCursor: null }
+ }
+ if (path === '/api/v1/gfs/resolve') {
+ return resolveView(org.resourceId, org.rid, 'org', '/archive/org')
+ }
+ return { items: [], nextCursor: null }
+ })
+ let byPathCalls = 0
+ mockGetGfsResourceByPath.mockReset()
+ mockGetGfsResourceByPath.mockImplementation(async (_drive: string, path: string) => {
+ byPathCalls += 1
+ if (byPathCalls === 1) throw new Error('by-path unavailable')
+ return resolveView(archive.resourceId, archive.rid, archive.name, path)
+ })
+ mockApiSend.mockResolvedValueOnce({
+ ok: true,
+ data: { resourceId: org.resourceId, version: 8 },
+ })
+ renderBrowser()
+
+ fireEvent.click(await screen.findByRole('button', { name: 'work' }))
+ fireEvent.click(await screen.findByRole('button', { name: 'org' }))
+ await screen.findByText('No resources are visible in this folder.')
+
+ const breadcrumb = screen.getByRole('navigation', { name: 'Breadcrumb' })
+ const labels = () =>
+ within(breadcrumb)
+ .getAllByRole('button')
+ .map(button => button.getAttribute('aria-label') ?? button.textContent)
+ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Move to…' }))
+ const moveDialog = await screen.findByRole('dialog', { name: 'Move folder org' })
+ fireEvent.click(await within(moveDialog).findByRole('button', { name: 'archive' }))
+ fireEvent.click(within(moveDialog).getByRole('button', { name: 'Move here (archive)' }))
+
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenCalledWith(
+ 'PATCH',
+ `/api/v1/gfs/resources/${org.resourceId}`,
+ { drive: 'main', newParentId: archive.resourceId, ifMatch: 7 },
+ { drive: 'main' }
+ )
+ )
+ // Resolve DID name the new location; only the ancestor lookup failed —
+ // still no partial trail.
+ await waitFor(() =>
+ expect(mockApiGet).toHaveBeenCalledWith('/api/v1/gfs/resolve', { uri: org.gfsUri })
+ )
+ expect(byPathCalls).toBe(1)
+ const notice = await screen.findByRole('alert')
+ expect(notice.textContent).toMatch(/folder path could not be refreshed/)
+ expect(within(notice).getByRole('button', { name: 'Retry' })).toBeTruthy()
+ expect(labels()).toEqual(['main', 'work', 'org', 'Actions for org'])
+
+ fireEvent.click(within(notice).getByRole('button', { name: 'Retry' }))
+ await waitFor(() => expect(labels()).toEqual(['main', 'archive', 'org', 'Actions for org']))
+ await waitFor(() => expect(screen.queryByRole('alert')).toBeNull())
+ })
+
+ // R7-M1: the recovery snapshot must carry IDENTITY only. A rename that
+ // lands between the failed post-move reconstruction and Retry keeps its
+ // newer name/version — Retry rebuilds the ancestry from the server and the
+ // crumb metadata from LIVE state, never replaying the move-time snapshot.
+ it('retry preserves a rename that landed while move recovery was pending', async () => {
+ const rootId = '11111111-1111-1111-1111-111111111111'
+ const work = child('work', 'directory', 1, 3)
+ const org = child('org', 'directory', 2, 7)
+ const archive = child('archive', 'directory', 3, 5)
+ const resolveView = (resourceId: string, rid: string, name: string, path: string) => ({
+ resourceId,
+ rid,
+ gfsUri: `gfs://main/${rid}`,
+ drive: 'main',
+ name,
+ kind: 'directory',
+ path,
+ updatedAt: '2026-09-24T00:00:00.000Z',
+ })
+ let resolveCalls = 0
+ mockApiGet.mockImplementation(async (path: string) => {
+ if (path === '/api/v1/gfs/tree' || path === `/api/v1/gfs/resources/${rootId}/children`) {
+ return { rootResourceId: rootId, items: [work, archive], nextCursor: null }
+ }
+ if (path === `/api/v1/gfs/resources/${work.resourceId}/children`) {
+ return { items: [org], nextCursor: null }
+ }
+ if (path === '/api/v1/gfs/resolve') {
+ resolveCalls += 1
+ if (resolveCalls === 1) throw new Error('resolve unavailable')
+ // Retry resolves the RENAMED folder at its real new location.
+ return resolveView(org.resourceId, org.rid, 'org-renamed', '/archive/org-renamed')
+ }
+ return { items: [], nextCursor: null }
+ })
+ mockGetGfsResourceByPath.mockReset()
+ mockGetGfsResourceByPath.mockImplementation(async (_drive: string, path: string) =>
+ resolveView(archive.resourceId, archive.rid, archive.name, path)
+ )
+ mockApiSend
+ .mockResolvedValueOnce({
+ ok: true,
+ data: { resourceId: org.resourceId, version: 8 },
+ })
+ .mockResolvedValueOnce({
+ ok: true,
+ data: { resourceId: org.resourceId, version: 9 },
+ })
+ .mockResolvedValueOnce({
+ ok: true,
+ data: { resourceId: org.resourceId, version: 10 },
+ })
+ renderBrowser()
+
+ fireEvent.click(await screen.findByRole('button', { name: 'work' }))
+ fireEvent.click(await screen.findByRole('button', { name: 'org' }))
+ await screen.findByText('No resources are visible in this folder.')
+
+ const breadcrumb = screen.getByRole('navigation', { name: 'Breadcrumb' })
+ const labels = () =>
+ within(breadcrumb)
+ .getAllByRole('button')
+ .map(button => button.getAttribute('aria-label') ?? button.textContent)
+ // Move /work/org under /archive — the PATCH succeeds (version 7 → 8)…
+ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Move to…' }))
+ const moveDialog = await screen.findByRole('dialog', { name: 'Move folder org' })
+ fireEvent.click(await within(moveDialog).findByRole('button', { name: 'archive' }))
+ fireEvent.click(within(moveDialog).getByRole('button', { name: 'Move here (archive)' }))
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenNthCalledWith(
+ 1,
+ 'PATCH',
+ `/api/v1/gfs/resources/${org.resourceId}`,
+ { drive: 'main', newParentId: archive.resourceId, ifMatch: 7 },
+ { drive: 'main' }
+ )
+ )
+ // …but reconstruction fails: stale trail kept, warning + Retry shown.
+ const notice = await screen.findByRole('alert')
+ expect(within(notice).getByRole('button', { name: 'Retry' })).toBeTruthy()
+ expect(labels()).toEqual(['main', 'work', 'org', 'Actions for org'])
+
+ // BEFORE Retry: rename the active crumb. It succeeds and advances the
+ // name/version (8 → 9, 'org' → 'org-renamed').
+ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))
- const renameForm = await within(breadcrumb).findByRole('form', { name: 'Rename resource' })
++ const renameForm = await screen.findByRole('dialog', { name: 'Rename folder' })
+ fireEvent.change(within(renameForm).getByLabelText('New name'), {
+ target: { value: 'org-renamed' },
+ })
- fireEvent.click(within(renameForm).getByRole('button', { name: 'Save name' }))
++ fireEvent.click(within(renameForm).getByRole('button', { name: 'Rename' }))
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenNthCalledWith(
+ 2,
+ 'PATCH',
+ `/api/v1/gfs/resources/${org.resourceId}`,
+ { drive: 'main', newName: 'org-renamed', ifMatch: 8 },
+ { drive: 'main' }
+ )
+ )
+ await waitFor(() =>
+ expect(within(breadcrumb).getByRole('button', { name: 'org-renamed' })).toBeTruthy()
+ )
+ // The notice reads the LIVE crumb name, not a move-time snapshot.
+ expect(screen.getByRole('alert').textContent).toContain('org-renamed')
+
+ // Retry now succeeds: the ancestry rebuilds from the server while the
+ // crumb keeps the renamed identity and version 9.
+ fireEvent.click(within(screen.getByRole('alert')).getByRole('button', { name: 'Retry' }))
+ await waitFor(() =>
+ expect(labels()).toEqual(['main', 'archive', 'org-renamed', 'Actions for org-renamed'])
+ )
+ await waitFor(() => expect(screen.queryByRole('alert')).toBeNull())
+
+ // The next breadcrumb mutation uses the LATEST version (9), not the
+ // earlier Move version (8) — a stale ifMatch here would 409.
+ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org-renamed' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))
- const finalRenameForm = await within(breadcrumb).findByRole('form', { name: 'Rename resource' })
++ const finalRenameForm = await screen.findByRole('dialog', { name: 'Rename folder' })
+ fireEvent.change(within(finalRenameForm).getByLabelText('New name'), {
+ target: { value: 'org-final' },
+ })
- fireEvent.click(within(finalRenameForm).getByRole('button', { name: 'Save name' }))
++ fireEvent.click(within(finalRenameForm).getByRole('button', { name: 'Rename' }))
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenNthCalledWith(
+ 3,
+ 'PATCH',
+ `/api/v1/gfs/resources/${org.resourceId}`,
+ { drive: 'main', newName: 'org-final', ifMatch: 9 },
+ { drive: 'main' }
+ )
+ )
+ await waitFor(() =>
+ expect(within(breadcrumb).getByRole('button', { name: 'org-final' })).toBeTruthy()
+ )
+ })
+
+ // R7-M1 (in-flight race): a Retry whose resolve/by-path responses land
+ // AFTER a newer Move completed must be discarded whole — the stale response
+ // can neither overwrite the newer ancestry nor clear the newer operation's
+ // recovery state.
+ it('discards a superseded Retry response that lands after a newer Move', async () => {
+ const rootId = '11111111-1111-1111-1111-111111111111'
+ const work = child('work', 'directory', 1, 3)
+ const org = child('org', 'directory', 2, 7)
+ const archive = child('archive', 'directory', 3, 5)
+ const dept = child('dept', 'directory', 4, 6)
+ const resolveView = (resourceId: string, rid: string, name: string, path: string) => ({
+ resourceId,
+ rid,
+ gfsUri: `gfs://main/${rid}`,
+ drive: 'main',
+ name,
+ kind: 'directory',
+ path,
+ updatedAt: '2026-09-24T00:00:00.000Z',
+ })
+ // resolve call order: 1 = Move A reconstruction (fails), 2 = Retry A
+ // (HELD pending), 3 = Move B reconstruction (succeeds → /dept/org).
+ let resolveCalls = 0
+ let releaseRetryResolve: ((view: unknown) => void) | null = null
+ mockApiGet.mockImplementation(async (path: string) => {
+ if (path === '/api/v1/gfs/tree' || path === `/api/v1/gfs/resources/${rootId}/children`) {
+ return { rootResourceId: rootId, items: [work, archive, dept], nextCursor: null }
+ }
+ if (path === `/api/v1/gfs/resources/${work.resourceId}/children`) {
+ return { items: [org], nextCursor: null }
+ }
+ if (path === '/api/v1/gfs/resolve') {
+ resolveCalls += 1
+ if (resolveCalls === 1) throw new Error('resolve unavailable')
+ if (resolveCalls === 2) {
+ return new Promise<unknown>(resolve => {
+ releaseRetryResolve = resolve
+ })
+ }
+ return resolveView(org.resourceId, org.rid, 'org', '/dept/org')
+ }
+ return { items: [], nextCursor: null }
+ })
+ mockGetGfsResourceByPath.mockReset()
+ mockGetGfsResourceByPath.mockImplementation(async (_drive: string, path: string) => {
+ if (path === '/dept') {
+ return resolveView(dept.resourceId, dept.rid, dept.name, '/dept')
+ }
+ // Retry A's ancestor lookup (after its release) answers with the OLD
+ // Move A ancestry — exactly the stale data that must be discarded.
+ return resolveView(archive.resourceId, archive.rid, archive.name, path)
+ })
+ mockApiSend
+ .mockResolvedValueOnce({
+ ok: true,
+ data: { resourceId: org.resourceId, version: 8 },
+ })
+ .mockResolvedValueOnce({
+ ok: true,
+ data: { resourceId: org.resourceId, version: 9 },
+ })
+ renderBrowser()
+
+ fireEvent.click(await screen.findByRole('button', { name: 'work' }))
+ fireEvent.click(await screen.findByRole('button', { name: 'org' }))
+ await screen.findByText('No resources are visible in this folder.')
+
+ const breadcrumb = screen.getByRole('navigation', { name: 'Breadcrumb' })
+ const labels = () =>
+ within(breadcrumb)
+ .getAllByRole('button')
+ .map(button => button.getAttribute('aria-label') ?? button.textContent)
+
+ // Move A: /work/org → /archive. Succeeds, reconstruction FAILS.
+ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Move to…' }))
+ let moveDialog = await screen.findByRole('dialog', { name: 'Move folder org' })
+ fireEvent.click(await within(moveDialog).findByRole('button', { name: 'archive' }))
+ fireEvent.click(within(moveDialog).getByRole('button', { name: 'Move here (archive)' }))
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenNthCalledWith(
+ 1,
+ 'PATCH',
+ `/api/v1/gfs/resources/${org.resourceId}`,
+ { drive: 'main', newParentId: archive.resourceId, ifMatch: 7 },
+ { drive: 'main' }
+ )
+ )
+ const notice = await screen.findByRole('alert')
+ expect(within(notice).getByRole('button', { name: 'Retry' })).toBeTruthy()
+ expect(labels()).toEqual(['main', 'work', 'org', 'Actions for org'])
+
+ // Start Retry A and HOLD its resolve response pending.
+ fireEvent.click(within(notice).getByRole('button', { name: 'Retry' }))
+ await waitFor(() => expect(resolveCalls).toBe(2))
+ expect(releaseRetryResolve).toBeTruthy()
+
+ // While Retry A is held: Move B moves the same folder under /dept and
+ // completes — its reconstruction succeeds and refreshes the trail.
+ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Move to…' }))
+ moveDialog = await screen.findByRole('dialog', { name: 'Move folder org' })
+ fireEvent.click(await within(moveDialog).findByRole('button', { name: 'dept' }))
+ fireEvent.click(within(moveDialog).getByRole('button', { name: 'Move here (dept)' }))
+ await waitFor(() =>
+ expect(mockApiSend).toHaveBeenNthCalledWith(
+ 2,
+ 'PATCH',
+ `/api/v1/gfs/resources/${org.resourceId}`,
+ { drive: 'main', newParentId: dept.resourceId, ifMatch: 8 },
+ { drive: 'main' }
+ )
+ )
+ await waitFor(() => expect(labels()).toEqual(['main', 'dept', 'org', 'Actions for org']))
+ // Move B's successful reconstruction retires Move A's stale notice.
+ await waitFor(() => expect(screen.queryByRole('alert')).toBeNull())
+
+ // Release Retry A's OLD response (Move A-era /archive ancestry) and let
+ // its full walk settle.
+ await act(async () => {
+ releaseRetryResolve!(resolveView(org.resourceId, org.rid, 'org', '/archive/org'))
+ await new Promise(resolve => setTimeout(resolve, 0))
+ })
+
+ // The superseded response was discarded: the breadcrumb still reflects
+ // Move B's ancestry, and no recovery state was resurrected or cleared.
+ expect(labels()).toEqual(['main', 'dept', 'org', 'Actions for org'])
+ expect(screen.queryByRole('alert')).toBeNull()
+ })
+
it('does not fall back to legacy when replacing a persisted resumable session', async () => {
const lastModified = 1_725_000_000_000
const uploadId = '66666666-6666-4666-8666-666666666666'
diff --cc control-ui/e2e/qa-recorder-secret-connector.spec.ts
index d892dd1ff,6b4fb44bc..d45cc394f
--- a/control-ui/e2e/qa-recorder-secret-connector.spec.ts
+++ b/control-ui/e2e/qa-recorder-secret-connector.spec.ts
@@@ -9,6 -9,7 +9,7 @@@
// creation + the connector shell; the secret is removed via the Control API in
// `finally` (DELETE /api/v1/admin/mcp-secrets/<name>).
import { expect, test } from '@playwright/test'
-import { requireSecretIdentity, type SecretIdentity } from '../test-utils/secretIdentity'
++import { type SecretIdentity, requireSecretIdentity } from '../test-utils/secretIdentity'
import {
CONTROL_API_URL,
CONTROL_UI_URL,
diff --cc control-ui/e2e/qa-recorder-secret-recipe.spec.ts
index d2610364e,7d975c046..994c5f1d5
--- a/control-ui/e2e/qa-recorder-secret-recipe.spec.ts
+++ b/control-ui/e2e/qa-recorder-secret-recipe.spec.ts
@@@ -4,6 -4,7 +4,7 @@@
// shared recipe secret (dummy values) through the Control UI. Run with
// QA_RECORDER_CONFIRM_MUTATIONS=1.
import { expect, test } from '@playwright/test'
-import { requireSecretIdentity, type SecretIdentity } from '../test-utils/secretIdentity'
++import { type SecretIdentity, requireSecretIdentity } from '../test-utils/secretIdentity'
import {
CONTROL_API_URL,
CONTROL_UI_URL,