Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(desktop): r7-m3 scope folder denial purge

Josuéaf9b7c0af090
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx
index 815519505..03d0c135a 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx
@@ -2011,6 +2011,7 @@ describe('useGfsBrowserController', () => {
const root = await resolveResource(
resolvedDirectory('root', 'Root', { gfsUri: 'gfs://main/root' })
)
+ const accessibleRoot = childView('other-root', 'Other folder', 'directory')
const child = childView('private-child', 'private.md', 'file', { parentResourceId: 'root' })
let denyRefresh!: (error: Error) => void
const deniedRefresh = new Promise<never>((_resolve, reject) => {
@@ -2024,7 +2025,7 @@ describe('useGfsBrowserController', () => {
configurable: true,
value: {
gfs: {
- listAccessible: vi.fn(async () => ({ items: [], nextCursor: null })),
+ listAccessible: vi.fn(async () => ({ items: [accessibleRoot], nextCursor: null })),
resolve: vi.fn(async () => root),
listChildren,
affordances: vi.fn(async () => ({
@@ -2053,6 +2054,11 @@ describe('useGfsBrowserController', () => {
)
await waitFor(() => expect(screen.getByTestId('current').textContent).toBe('none'))
expect(screen.getByTestId('items-count').textContent).toBe('0')
+ expect(screen.getByTestId('open-error').textContent).toBe(
+ 'This folder or file is no longer available.'
+ )
+ expect(screen.getByTestId('access-state').textContent).toBe('active')
+ expect(screen.getByTestId('accessible-count').textContent).toBe('1')
expect(lastHarnessQueryClient?.getQueryData(childrenKey)).toBeUndefined()
})
diff --git a/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts b/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts
index d2c44f9a0..3cc5423c2 100644
--- a/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts
+++ b/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts
@@ -579,6 +579,20 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {
setOpenError(null)
queryClient.removeQueries({ queryKey: desktopQueryKeys.gfsRoot })
}, [queryClient])
+ const clearInaccessibleGfsLocation = useCallback(() => {
+ const resourceId = currentCrumbRef.current?.resourceId
+ if (resourceId && sessionScope) {
+ queryClient.removeQueries({
+ exact: true,
+ queryKey: desktopQueryKeys.gfsChildren(sessionScope, resourceId, DRIVE),
+ })
+ }
+ // A resource-scoped denial is not loss of the authenticated session.
+ // Keep accessible roots and other GFS scopes intact, and avoid the
+ // foreground navigation setter so a background denial cannot advance it.
+ setCrumbsState([])
+ setOpenError('This folder or file is no longer available.')
+ }, [queryClient, sessionScope])
const revokeAccess = useCallback(() => {
setAccessState('revoked')
clearGfsState()
@@ -816,8 +830,8 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {
// A soft scope invalidation preserves rows while the authoritative read is
// pending. Once that read proves this open folder is denied or gone, none
// of its cached descendants may remain visible in this browser session.
- clearGfsState()
- }, [clearGfsState, currentFolderUnavailable])
+ clearInaccessibleGfsLocation()
+ }, [clearInaccessibleGfsLocation, currentFolderUnavailable])
const accessibleResources = useMemo<GfsAccessibleResource[]>(
() =>
authorityPending
@@ -986,9 +1000,7 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {
if (!handleAuthorityFailure(message, 'operation')) {
const status = parseHttpStatus(message)
if (options?.clearIfUnavailable && (status === 403 || status === 404)) {
- setCrumbsState([])
- setOpenError(null)
- void queryClient.removeQueries({ queryKey: desktopQueryKeys.gfsRoot })
+ clearInaccessibleGfsLocation()
} else {
setOpenError(toPresentedMessage(error))
}
@@ -998,7 +1010,7 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {
if (!background && openUriGenerationRef.current === generation) setResolving(false)
}
},
- [handleAuthorityFailure, queryClient]
+ [clearInaccessibleGfsLocation, handleAuthorityFailure]
)
const refreshCurrentLocation = useCallback(