Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): r7-m1 trust the vetted GFS HTTP status
Josuéf8c361a79316
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex 8b76e24c2..3b5e8e0ff 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -39,6 +39,7 @@ import { useWindowFocusBridge } from '@hooks/useWindowFocusBridge'import type { ChatLocalMatch } from '@lib/chatLocalSearch'import { buildLoadedChatSemanticModels } from '@lib/chatMessageSemantics'import { EntityChangeRegistry } from '@lib/entityChangeRegistry'+import { authoritativeGfsStatus } from '@lib/gfsEntityChangeState'import { resolveGfsPreview } from '@lib/gfsPreview'import { desktopQueryClient } from '@lib/queryClient'import {@@ -169,14 +170,6 @@ function errorCode(error: unknown): string {return String(record.code || record.cause?.code || '').toUpperCase()}-function resourceStatus(error: unknown): number | undefined {- if (!error || typeof error !== 'object') return undefined- const status = (error as { status?: unknown }).status- if (typeof status === 'number') return status- const match = errorMessage(error).match(/(?:^|\D)(403|404)(?:\D|$)/)- return match ? Number(match[1]) : undefined-}-function isTransientSandboxUiTeamContextError(error: unknown): boolean {const message = errorMessage(error).toLowerCase()if (@@ -1020,7 +1013,7 @@ export function App() {previewRetryAttemptRef.current.delete(gfsUri)} catch (error) {if (previewRefreshGenerationRef.current.get(gfsUri) !== generation) return- const status = resourceStatus(error)+ const status = authoritativeGfsStatus(error)if (status === 403 || status === 404) {setWorkspaceTabs(state =>refreshPreviewTab(state, gfsUri, {diff --git a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsxindex b1ecb4a55..55106f1dc 100644--- a/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx+++ b/desktop-app/ui/src/__tests__/App.chatDrawer.test.tsx@@ -1343,7 +1343,9 @@ describe('App live GFS preview revalidation', () => {})expect(initial()).toEqual(before)- resolve.mockRejectedValueOnce(Object.assign(new Error('403 Forbidden'), { status: 403 }))+ resolve.mockRejectedValueOnce(+ new Error('upstream dependency reported 404 while fetching httpStatus=500')+ )act(() =>dispatchEntityChange?.({type: 'scope.invalidated',@@ -1352,6 +1354,18 @@ describe('App live GFS preview revalidation', () => {scopes: ['authorization'],}))+ await waitFor(() => expect(resolve).toHaveBeenCalledTimes(2))+ expect(initial()).toEqual(before)++ resolve.mockRejectedValueOnce(new Error('resource denied httpStatus=403'))+ act(() =>+ dispatchEntityChange?.({+ type: 'scope.invalidated',+ schemaVersion: 1,+ cursor: 'cursor-3',+ scopes: ['authorization'],+ })+ )await waitFor(() =>expect(initial()?.kind === 'preview' && initial()?.preview?.unavailable).toBe(true))diff --git a/desktop-app/ui/src/lib/gfsEntityChangeState.ts b/desktop-app/ui/src/lib/gfsEntityChangeState.tsnew file mode 100644index 000000000..42d0c3eb4--- /dev/null+++ b/desktop-app/ui/src/lib/gfsEntityChangeState.ts@@ -0,0 +1,11 @@+import { parseHttpStatus } from './gfsGrantErrors'++/**+ * Return only a transport-vetted status attached by the main-process GFS client.+ * Error prose can contain arbitrary upstream status numbers and is not an+ * authorization or deletion signal.+ */+export function authoritativeGfsStatus(error: unknown): number | undefined {+ const message = error instanceof Error ? error.message : String(error ?? '')+ return parseHttpStatus(message) ?? undefined+}