Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop-app): preserve foreground GFS error (r8-m2)
Josué6cfcb9910fb9
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsxindex f8b29bc17..f8c551852 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx@@ -150,6 +150,9 @@ function Probe() {<button type="button" onClick={() => swallow(ctrl.openUri('gfs://main/root'))}>open</button>+ <button type="button" onClick={() => swallow(ctrl.openUri('gfs://main/denied-link'))}>+ open denied link+ </button><button type="button" onClick={() => swallow(ctrl.refreshCurrentLocation())}>refresh current location</button>@@ -424,6 +427,50 @@ describe('useGfsBrowserController', () => {expect(lastHarnessQueryClient?.getQueryData(grantsKey)).toBeUndefined()})+ it('preserves a failed link error when a background refresh resolves the current folder', async () => {+ const root = await resolveResource(+ resolvedDirectory('root', 'Root', { gfsUri: 'gfs://main/root' })+ )+ const resolve = vi+ .fn()+ .mockResolvedValueOnce(root)+ .mockRejectedValueOnce(new Error(await resolveDeniedMessage('gfs://main/denied-link')))+ .mockResolvedValue(root)++ Object.defineProperty(window, 'clerum', {+ configurable: true,+ value: {+ gfs: {+ listAccessible: vi.fn(async () => ({ items: [], nextCursor: null })),+ resolve,+ listChildren: vi.fn(async () => ({ items: [], nextCursor: null })),+ affordances: vi.fn(async () => ({+ held: [],+ canDelegate: false,+ grantableBits: [],+ canCreateShare: false,+ })),+ },+ },+ })++ render(<Probe />, { wrapper: Harness })+ await act(async () => screen.getByRole('button', { name: 'open' }).click())+ await waitFor(() => expect(screen.getByTestId('current').textContent).toBe('root'))++ await act(async () => screen.getByRole('button', { name: 'open denied link' }).click())+ await waitFor(() => expect(screen.getByTestId('open-error').textContent).not.toBe('none'))+ const linkError = screen.getByTestId('open-error').textContent++ await act(async () =>+ screen.getByRole('button', { name: 'background refresh current location' }).click()+ )++ await waitFor(() => expect(resolve).toHaveBeenCalledTimes(3))+ expect(screen.getByTestId('current').textContent).toBe('root')+ expect(screen.getByTestId('open-error').textContent).toBe(linkError)+ })+it.each(['success', 'denial'] as const)('keeps a newly opened child folder when an older refresh completes with %s',async completion => {diff --git a/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts b/desktop-app/ui/src/hooks/domain/useGfsBrowserController.tsindex 26065831c..84ba98c3e 100644--- a/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts+++ b/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts@@ -306,6 +306,7 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {const openUriGenerationRef = useRef(0)const foregroundOpenUriPendingRef = useRef<number | null>(null)const backgroundOpenUriGenerationRef = useRef(0)+ const backgroundOpenErrorRef = useRef(false)const pendingDeniedResourceIdRef = useRef<string | null>(null)const backgroundLocationRetryRef = useRef<(uri: string) => void>(() => undefined)const backgroundLocationRetryTimerRef = useRef<number | null>(null)@@ -978,6 +979,7 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {}backgroundLocationRetryAttemptRef.current = 0foregroundOpenUriPendingRef.current = generation+ backgroundOpenErrorRef.current = falsesetOpenError(null)setResolving(true)}@@ -1019,6 +1021,7 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {parentResourceId = parent.parentResourceId} catch (error) {if (background) {+ backgroundOpenErrorRef.current = truesetOpenError(toPresentedMessage(error))scheduleBackgroundLocationRetry(uri, error)return false@@ -1030,7 +1033,13 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {}if (!isCurrent()) return false- setOpenError(null)+ // A background resolve may recover its own transient error, but it+ // must not erase a foreground link/navigation error being shown for a+ // separate user action.+ if (!background || backgroundOpenErrorRef.current) {+ backgroundOpenErrorRef.current = false+ setOpenError(null)+ }if (background) {if (backgroundLocationRetryTimerRef.current !== null) {window.clearTimeout(backgroundLocationRetryTimerRef.current)@@ -1054,6 +1063,7 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {if (options?.clearIfUnavailable && (status === 403 || status === 404)) {clearInaccessibleGfsLocation()} else {+ if (background) backgroundOpenErrorRef.current = truesetOpenError(toPresentedMessage(error))if (background) scheduleBackgroundLocationRetry(uri, error)}