Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): med-convergence-fresh-parent converge against the commit-time parent
M71cf26f952b7
diff --git a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsxindex bad166f4f..5763d6acd 100644--- a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx+++ b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx@@ -725,13 +725,13 @@ export function FileExplorerTree({parentResourceId: resolved.parentResourceId,}},- moveResource: async (resourceId, destinationId, ifMatch, newName) => {+ moveResource: async (resourceId, destinationId, ifMatch, newName, oldParentId) => {const receipt = await ctrl.moveResource(resourceId,destinationId,ifMatch,newName,- source.parentKnown ? source.parentResourceId : null+ oldParentId)dispatchConfirmed = truereturn receiptdiff --git a/desktop-app/ui/src/gfs/__tests__/dragOwnership.test.tsx b/desktop-app/ui/src/gfs/__tests__/dragOwnership.test.tsxindex 3c145af98..8f4068388 100644--- a/desktop-app/ui/src/gfs/__tests__/dragOwnership.test.tsx+++ b/desktop-app/ui/src/gfs/__tests__/dragOwnership.test.tsx@@ -461,6 +461,29 @@ for (const surface of ['sidebar', 'files'] as const) {expect(h.api().activeSource()?.resourceId).toBe('external')})+ it('dispatches the commit-time parent, not the drag-start parent', async () => {+ // The item was moved elsewhere since the gesture started: the+ // commit-time resolve sees a DIFFERENT parent than the drag did. The+ // convergence must drop the item from the folder it really left, so the+ // PATCH carries the resolved parent — the drag-start parent would+ // leave a ghost row in the real old folder.+ const h = await setup('file')+ h.resolve.mockImplementation(async (uri: string) => {+ const id = uri.split('/').pop()!+ return resolvedFile(id, 'Source', { parentResourceId: 'other-parent' })+ })+ h.start()+ h.drop()+ await waitFor(() => expect(h.moveResource).toHaveBeenCalled())+ expect(h.moveResource).toHaveBeenCalledWith(+ 'source',+ 'target',+ expect.any(Number),+ undefined,+ 'other-parent'+ )+ })+it('revokes the session when a drag probe answers 401', async () => {// A probe 401 is a session failure: the drop is refused AND the session// must be revoked, not left active over a dead session.diff --git a/desktop-app/ui/src/gfs/__tests__/moveCommit.test.ts b/desktop-app/ui/src/gfs/__tests__/moveCommit.test.tsindex e82386a26..43c860de2 100644--- a/desktop-app/ui/src/gfs/__tests__/moveCommit.test.ts+++ b/desktop-app/ui/src/gfs/__tests__/moveCommit.test.ts@@ -39,7 +39,7 @@ describe('commitGfsMove — commit-time source refresh', () => {const outcome = await commitGfsMove(deps({ moveResource }), plan())expect(outcome).toEqual({ status: 'committed', version: 8, previousParentId: 'old-parent' })expect(moveResource).toHaveBeenCalledTimes(1)- expect(moveResource).toHaveBeenCalledWith('r-1', 'dest-1', 7, undefined)+ expect(moveResource).toHaveBeenCalledWith('r-1', 'dest-1', 7, undefined, 'old-parent')})it('refuses without a request when the fresh parent already IS the destination (no-op)', async () => {@@ -116,7 +116,7 @@ describe('commitGfsMove — conflict policy (rev-2 §5)', () => {previousParentId: 'old-parent',})expect(moveResource).toHaveBeenCalledTimes(2)- expect(moveResource).toHaveBeenLastCalledWith('r-1', 'dest-1', 7, 'report (1).md')+ expect(moveResource).toHaveBeenLastCalledWith('r-1', 'dest-1', 7, 'report (1).md', 'old-parent')})it('seeds the ladder from plan.occupiedDestinationNames so known-taken names are skipped', async () => {@@ -150,7 +150,7 @@ describe('commitGfsMove — conflict policy (rev-2 §5)', () => {previousParentId: 'old-parent',})expect(moveResource).toHaveBeenCalledTimes(2)- expect(moveResource).toHaveBeenLastCalledWith('r-1', 'dest-1', 7, 'report (3).md')+ expect(moveResource).toHaveBeenLastCalledWith('r-1', 'dest-1', 7, 'report (3).md', 'old-parent')})it('a concurrent-name storm stops after the attempt cap with the destination-changed copy', async () => {@@ -264,6 +264,50 @@ describe('commitGfsMove — gesture ownership (rev-2 §4.1)', () => {expect(moveResource).toHaveBeenCalledTimes(1)})+ it('dispatches the commit-time parent, never the gesture parent', async () => {+ // The convergence has to drop the item from the folder it REALLY left.+ // The drag-start parent can be stale (or unknown), and an unknown parent+ // is not the physical root.+ const moveResource = vi.fn(async () => ({ resourceId: 'r-1', version: 8 }))+ await commitGfsMove(+ deps({+ moveResource,+ resolveSource: vi.fn(async () => resolved({ parentResourceId: 'fresh-parent' })),+ }),+ plan()+ )+ expect(moveResource).toHaveBeenCalledWith('r-1', 'dest-1', 7, undefined, 'fresh-parent')+ })++ it('dispatches every retry with the commit-time parent', async () => {+ const moveResource = vi+ .fn()+ .mockImplementation(async (_id: string, _dest: string, _v: number, newName?: string) => {+ if (newName === undefined) {+ throw new Error(+ 'Error invoking remote method: Error: 409 Conflict: a resource with this name already exists httpStatus=409'+ )+ }+ return { resourceId: 'r-1', version: 9 }+ })+ await commitGfsMove(+ deps({+ moveResource,+ resolveSource: vi.fn(async () => resolved({ parentResourceId: 'fresh-parent' })),+ }),+ plan({ allowNumberedRename: true })+ )+ expect(moveResource).toHaveBeenNthCalledWith(1, 'r-1', 'dest-1', 7, undefined, 'fresh-parent')+ expect(moveResource).toHaveBeenNthCalledWith(+ 2,+ 'r-1',+ 'dest-1',+ 7,+ 'report (1).md',+ 'fresh-parent'+ )+ })+it('dispatches when the gesture is still current', async () => {const moveResource = vi.fn(async () => ({ resourceId: 'r-1', version: 8 }))const outcome = await commitGfsMove(deps({ moveResource, isCurrent: () => true }), plan())diff --git a/desktop-app/ui/src/gfs/moveCommit.ts b/desktop-app/ui/src/gfs/moveCommit.tsindex 3e6ca8646..bb8994d0e 100644--- a/desktop-app/ui/src/gfs/moveCommit.ts+++ b/desktop-app/ui/src/gfs/moveCommit.ts@@ -55,12 +55,18 @@ export type MoveCommitOutcome =export interface MoveCommitDeps {/** Resolve by stable URI; throws on 403/404/transport like the read plane. */resolveSource: (gfsUri: string) => Promise<MoveCommitSourceSnapshot>- /** One move PATCH attempt; ifMatch is mandatory client policy. */+ /**+ * One move PATCH attempt; ifMatch is mandatory client policy. The+ * `oldParentId` is the parent the COMMIT-TIME resolve observed — never the+ * gesture's drag-start guess — because the convergence has to drop the item+ * from the folder it really left. `null` means the physical root.+ */moveResource: (resourceId: string,destinationId: string,ifMatch: number,- newName?: string+ newName?: string,+ oldParentId?: string | null) => Promise<{ resourceId: string; version: number }>/** Central fail-closed classifier; returns true when the session died. */isSessionAuthorityFailure: (error: unknown) => boolean@@ -136,7 +142,11 @@ export async function commitGfsMove(snapshot.resourceId,plan.destination.resourceId,snapshot.version,- moveName === snapshot.name ? undefined : moveName+ moveName === snapshot.name ? undefined : moveName,+ // The commit-time parent, so the convergence drops the item from the+ // folder it really left (the drag-start parent can be stale, or+ // unknown — and an unknown parent is not the physical root).+ snapshot.parentResourceId)return {status: 'committed',diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsxindex 636816cb5..f05289ff0 100644--- a/desktop-app/ui/src/pages/FilesPage.tsx+++ b/desktop-app/ui/src/pages/FilesPage.tsx@@ -1356,13 +1356,13 @@ export function FilesPage({parentResourceId: resolved.parentResourceId,}},- moveResource: async (resourceId, destinationId, ifMatch, newName) => {+ moveResource: async (resourceId, destinationId, ifMatch, newName, oldParentId) => {const receipt = await ctrl.moveResource(resourceId,destinationId,ifMatch,newName,- source.parentKnown ? source.parentResourceId : null+ oldParentId)dispatchConfirmed = truereturn receipt