Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): refresh accessible GFS resources on remount
Alfredo Lopez3671090d6749
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsxindex 82f3d6e25..754d9d57d 100644--- a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx+++ b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx@@ -186,6 +186,18 @@ function Harness({ children, queryClient }: { children: ReactNode; queryClient?:)}+function MountingProbe() {+ const [mounted, setMounted] = useState(true)+ return (+ <>+ {mounted ? <Probe /> : null}+ <button type="button" onClick={() => setMounted(value => !value)}>+ toggle files+ </button>+ </>+ )+}+describe('useGfsBrowserController', () => {afterEach(() => {cleanup()@@ -687,6 +699,62 @@ describe('useGfsBrowserController', () => {await waitFor(() => expect(screen.getByTestId('current').textContent).toBe('team-folder'))})+ it('refetches permission-derived resources when Files remounts', async () => {+ const resource = {+ resourceId: 'revoked-folder',+ rid: 'revokedfolder',+ gfsUri: 'gfs://main/revokedfolder',+ drive: 'main',+ parentResourceId: null,+ name: 'Revoked folder',+ kind: 'directory' as const,+ path: '/revoked-folder',+ version: 1,+ bytes: 0,+ sources: ['grant'],+ permissions: ['read'],+ coversDescendants: false,+ }+ let resources = [resource]+ const listAccessible = vi.fn(async () => ({ items: resources, nextCursor: null }))+ Object.defineProperty(window, 'clerum', {+ configurable: true,+ value: {+ gfs: {+ listAccessible,+ resolve: vi.fn(),+ listChildren: vi.fn(async () => ({ items: [], nextCursor: null })),+ affordances: vi.fn(async () => ({+ held: [],+ canDelegate: false,+ grantableBits: [],+ canCreateShare: false,+ })),+ },+ },+ })++ const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })+ render(<MountingProbe />, {+ wrapper: ({ children }) => <Harness queryClient={queryClient}>{children}</Harness>,+ })++ await waitFor(() => expect(screen.getByTestId('accessible-count').textContent).toBe('1'))+ resources = []++ await act(async () => {+ screen.getByRole('button', { name: 'toggle files' }).click()+ })+ expect(screen.queryByTestId('accessible-count')).toBeNull()++ await act(async () => {+ screen.getByRole('button', { name: 'toggle files' }).click()+ })++ await waitFor(() => expect(screen.getByTestId('accessible-count').textContent).toBe('0'))+ expect(listAccessible).toHaveBeenCalledTimes(2)+ })+it('hydrates readable parent folders for a directly opened file', async () => {const rootId = '00000000-0000-0000-0000-000000000001'const projectsId = '00000000-0000-0000-0000-000000000002'diff --git a/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts b/desktop-app/ui/src/hooks/domain/useGfsBrowserController.tsindex afc1e2dae..8da6467ab 100644--- a/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts+++ b/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts@@ -235,6 +235,11 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {return listAccessible(DRIVE, pageParam)},enabled: Boolean(sessionScope) && canListAccessibleResources && accessState === 'active',+ // Accessible resources are permission-derived state. The operator can+ // revoke a grant/share from another Desktop session while this user is+ // away from Files, so an Infinity-cached list must not survive a Files+ // remount without a server check.+ refetchOnMount: 'always',initialPageParam: undefined as string | undefined,getNextPageParam: lastPage => lastPage.nextCursor ?? undefined,})