Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): rp-027 tell a vanished source apart from a vanished destination
Md72638e3017b
diff --git a/desktop-app/ui/src/gfs/__tests__/moveCommit.test.ts b/desktop-app/ui/src/gfs/__tests__/moveCommit.test.tsindex 3ea52515b..b0277c2ce 100644--- a/desktop-app/ui/src/gfs/__tests__/moveCommit.test.ts+++ b/desktop-app/ui/src/gfs/__tests__/moveCommit.test.ts@@ -178,7 +178,7 @@ describe('commitGfsMove — server verdicts', () => {expect(moveResource).toHaveBeenCalledTimes(1)})- it('404 maps to target-unavailable', async () => {+ it('a 404 PATCH with a resolvable source maps to target-unavailable', async () => {const outcome = await commitGfsMove(deps({moveResource: vi.fn(async () => {@@ -190,6 +190,54 @@ describe('commitGfsMove — server verdicts', () => {expect(outcome.status).toBe('target-unavailable')})+ // RP-027 — the PATCH answers 404 for a vanished source AND for a vanished+ // destination. Telling a user that "this folder is no longer available"+ // when their item was deleted sends them looking in the wrong place.+ it('a 404 PATCH with a vanished source maps to source-unavailable', async () => {+ // The commit-time resolve succeeds; the re-read after the 404 fails.+ let reads = 0+ const resolveSource = vi.fn(async (_gfsUri: string) => {+ reads += 1+ if (reads > 1) throw new Error('404 Not Found: httpStatus=404')+ return resolved()+ })+ const outcome = await commitGfsMove(+ deps({+ resolveSource,+ moveResource: vi.fn(async () => {+ throw new Error('404 Not Found: httpStatus=404')+ }),+ }),+ plan()+ )+ expect(outcome.status).toBe('source-unavailable')+ // The source is re-read once to tell the two sides apart.+ expect(resolveSource).toHaveBeenCalledTimes(2)+ })++ it('a 404 PATCH that already landed in the destination commits', async () => {+ let reads = 0+ const resolveSource = vi.fn(async (_gfsUri: string) => {+ reads += 1+ if (reads > 1) return resolved({ parentResourceId: 'dest-1', version: 9 })+ return resolved()+ })+ const outcome = await commitGfsMove(+ deps({+ resolveSource,+ moveResource: vi.fn(async () => {+ throw new Error('404 Not Found: httpStatus=404')+ }),+ }),+ plan()+ )+ expect(outcome).toEqual({+ status: 'committed',+ version: 9,+ previousParentId: 'old-parent',+ })+ })+it('429 maps to rate-limited with the parsed window', async () => {const outcome = await commitGfsMove(deps({diff --git a/desktop-app/ui/src/gfs/moveCommit.ts b/desktop-app/ui/src/gfs/moveCommit.tsindex e28e6a4ad..69c5ee670 100644--- a/desktop-app/ui/src/gfs/moveCommit.ts+++ b/desktop-app/ui/src/gfs/moveCommit.ts@@ -198,7 +198,42 @@ export async function commitGfsMove(}}if (status === 404) {- return { status: 'target-unavailable', message: 'This folder is no longer available.' }+ // The PATCH answers 404 for a vanished SOURCE and for a vanished+ // DESTINATION alike, and the two need different copy: telling a user+ // that "this folder is no longer available" when their item was+ // deleted sends them looking in the wrong place. One read tells them+ // apart — the source still resolves when only the destination is gone+ // (RP-027).+ try {+ const resolvedSource = await deps.resolveSource(plan.source.gfsUri)+ if (resolvedSource.parentResourceId === plan.destination.resourceId) {+ // The move landed after all; the 404 answered about something else.+ return {+ status: 'committed',+ version: resolvedSource.version,+ previousParentId: snapshot.parentResourceId,+ ...(resolvedSource.name !== snapshot.name ? { renamedTo: resolvedSource.name } : {}),+ }+ }+ return {+ status: 'target-unavailable',+ message: 'This folder is no longer available.',+ }+ } catch (resolveError) {+ const resolveStatus = parseHttpStatus(messageOf(resolveError))+ if (resolveStatus === 404 || resolveStatus === 410) {+ return {+ status: 'source-unavailable',+ message: 'EvenDrive cannot verify this item’s current location. Refresh and try again.',+ }+ }+ // The side that is gone could not be established: say so instead of+ // naming a side that may still be there.+ return {+ status: 'unconfirmed',+ message: 'Couldn’t confirm the move. Refresh before trying again.',+ }+ }}if (status === 403) {// Generic unless a successful permission recheck proves the missing bit;