Skip to content

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

TypeScript

fix(desktop): gate unreadable file-explorer rows against activation (R1-H1)

Diego Zacarias72cdaf730ab4
diff --git a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/__tests__/FileExplorerTree.test.tsx b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/__tests__/FileExplorerTree.test.tsx
index a79c40ef6..395c27e9d 100644
--- a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/__tests__/FileExplorerTree.test.tsx
+++ b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/__tests__/FileExplorerTree.test.tsx
@@ -469,3 +469,67 @@ describe('FileExplorerTree — folder activation focuses an existing files tab',
expect(screen.getByTestId('tab-count').textContent).toBe('3')
})
})
+
+describe('FileExplorerTree — unreadable rows refuse activation (R1-H1)', () => {
+ // A `readable: false` child (a folder grant without inheritance; a file whose
+ // parent does not inherit) is listed but cannot be opened. The tree must
+ // refuse to open its preview / download / files tab and mark it, the same way
+ // FilesPage.openResource already does — not fire an activation that 403s.
+ // `readable` is carried by the REAL producer (GfsChildView.readable) through
+ // GfsClient + the IPC clone, so the fixture emits it via childView overrides.
+ async function renderExpandedVault(props: Partial<Parameters<typeof FileExplorerTree>[0]> = {}) {
+ const listChildren = vi.fn(async () =>
+ listChildrenPage([
+ childView('locked', 'Locked', 'directory', { readable: false }),
+ childView('secret', 'secret.pdf', 'file', { readable: false }),
+ ])
+ )
+ const download = vi.fn(async () => downloadResult(resolvedFile('secret', 'secret.pdf')))
+ installClerum({
+ listAccessible: vi.fn(async () =>
+ listAccessiblePage([accessibleResource('vault', 'Vault', 'directory')])
+ ),
+ listChildren,
+ download,
+ })
+ const handles = renderTree(props)
+ fireEvent.click(await screen.findByRole('button', { name: 'Expand Vault' }))
+ // Wait for the unreadable children to render (marked "No access"). The label
+ // button's accessible name carries the file name plus the "No access" badge.
+ await screen.findByRole('button', { name: /secret\.pdf.*No access/ })
+ return { ...handles, download }
+ }
+
+ it('file: single-click and Enter on an unreadable file toast and never preview or download', async () => {
+ const { onOpenPreview, pushToast, download } = await renderExpandedVault()
+
+ const fileButton = screen.getByRole('button', { name: /secret\.pdf.*No access/ })
+
+ fireEvent.click(fileButton)
+ fireEvent.keyDown(fileButton, { key: 'Enter' })
+
+ // The observable outcome: no preview descriptor, no download — only the
+ // access toast, once per activation attempt.
+ expect(onOpenPreview).not.toHaveBeenCalled()
+ expect(download).not.toHaveBeenCalled()
+ expect(pushToast).toHaveBeenCalledWith('You do not have read access to secret.pdf', 'error')
+ expect(pushToast).toHaveBeenCalledTimes(2)
+ // The row is marked non-actionable.
+ expect(within(fileButton).getByText('No access')).toBeTruthy()
+ })
+
+ it('folder: double-click and Enter on an unreadable folder toast and never open a files tab', async () => {
+ const { onOpenFolder, pushToast } = await renderExpandedVault()
+
+ const folderButton = screen.getByRole('button', { name: /^Locked.*No access/ })
+
+ fireEvent.doubleClick(folderButton)
+ fireEvent.keyDown(folderButton, { key: 'Enter' })
+
+ // The observable outcome: no files tab opened — only the access toast.
+ expect(onOpenFolder).not.toHaveBeenCalled()
+ expect(pushToast).toHaveBeenCalledWith('You do not have read access to Locked', 'error')
+ expect(pushToast).toHaveBeenCalledTimes(2)
+ expect(within(folderButton).getByText('No access')).toBeTruthy()
+ })
+})
diff --git a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx
index 4c31da828..34f848c97 100644
--- a/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx
+++ b/desktop-app/ui/src/components/SidebarNav/FileExplorerTree/index.tsx
@@ -1,6 +1,6 @@
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useInfiniteQuery } from '@tanstack/react-query'
-import { Button, IconButton, StatusBanner } from '@components/Common'
+import { Badge, Button, IconButton, StatusBanner } from '@components/Common'
import { GfsFileIcon } from '@components/GfsFileIcon'
import { GFS_DRIVE_MAIN } from '@constants/gfsBrowser'
import { desktopQueryKeys } from '@hooks/domain/queryKeys'
@@ -68,6 +68,12 @@ function FileExplorerNode({
const isExpanded = isDirectory && expandedIds.has(node.resourceId)
const isSelected = selectedId === node.resourceId
const label = displayName(node.name)
+ // Server-computed: the row is visible but the session cannot read it (a
+ // folder grant without inheritance; a file whose parent does not inherit).
+ // Mark it so it does not look actionable, and let the activate handlers
+ // refuse it with a toast instead of a later download/preview 403. Absent
+ // (older servers) is treated as unknown, not unreadable.
+ const isUnreadable = node.readable === false
const childQuery = useInfiniteQuery({
queryKey: desktopQueryKeys.gfsChildren(scope, node.resourceId, GFS_DRIVE_MAIN),
@@ -170,7 +176,9 @@ function FileExplorerNode({
<Button
align="start"
block
- className={`da-file-explorer__label${isSelected ? ' is-selected' : ''}`}
+ className={`da-file-explorer__label${isSelected ? ' is-selected' : ''}${
+ isUnreadable ? ' da-file-explorer__label--no-access' : ''
+ }`}
color="neutral"
onClick={handleRowClick}
onDoubleClick={handleRowDoubleClick}
@@ -181,6 +189,13 @@ function FileExplorerNode({
{isDirectory ? <IconContexts /> : <GfsFileIcon name={node.name} />}
</span>
<span className="da-file-explorer__name">{label}</span>
+ {/* Rendered inside the label so "No access" joins the row's accessible
+ name, matching the Files page's row affordance. */}
+ {isUnreadable ? (
+ <Badge tone="neutral" className="da-file-explorer__no-access-badge">
+ No access
+ </Badge>
+ ) : null}
</Button>
</div>
{isExpanded ? (
@@ -258,9 +273,16 @@ export function FileExplorerTree({
const handleActivateFolder = useCallback(
(node: GfsBrowserChild) => {
+ // A folder grant without inheritance lists the folder but denies its
+ // contents: opening its files tab would 403 on every child. Refuse the
+ // activation with the same message the Files page uses on the row click.
+ if (node.readable === false) {
+ pushToast(`You do not have read access to ${displayName(node.name)}`, 'error')
+ return
+ }
onOpenFolder(node.gfsUri)
},
- [onOpenFolder]
+ [onOpenFolder, pushToast]
)
const authorityFailure = ctrl.handleAuthorityFailure
@@ -281,6 +303,13 @@ export function FileExplorerTree({
const handleActivateFile = useCallback(
(node: GfsBrowserChild) => {
+ // A file whose parent grant does not inherit is listed but unreadable:
+ // both the preview and the download fallback would 403. Refuse before
+ // either, matching the Files page's openResource guard and toast.
+ if (node.readable === false) {
+ pushToast(`You do not have read access to ${displayName(node.name)}`, 'error')
+ return
+ }
setSelectedId(node.resourceId)
const preview = resolveGfsPreview(node)
if (preview) {
diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsx
index d77b32e96..5ce81da4e 100644
--- a/desktop-app/ui/src/pages/FilesPage.tsx
+++ b/desktop-app/ui/src/pages/FilesPage.tsx
@@ -1436,12 +1436,12 @@ export function FilesPage({
}
onMove={() => setMoveTarget(resource)}
onPreview={
- isGfsPreviewFile(resource.name)
+ resource.readable !== false && isGfsPreviewFile(resource.name)
? () => void openFilePreview(resource)
: undefined
}
onDownload={
- resource.kind === 'file'
+ resource.readable !== false && resource.kind === 'file'
? () => void handleDownload(resource.gfsUri, resource.name)
: undefined
}
diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
index 113e69ee1..361e762ac 100644
--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
@@ -505,6 +505,66 @@ describe('FilesPage', () => {
expect(openChild).not.toHaveBeenCalled()
})
+ it('omits Preview and Download from the ⋯ menu of an unreadable file (R1-H1)', async () => {
+ hookMock.useGfsBrowserController.mockReturnValue({
+ ...baseController(),
+ current: {
+ resourceId: 'parent-1',
+ gfsUri: 'gfs://main/parent-1',
+ name: 'Workspace',
+ kind: 'directory',
+ version: 1,
+ },
+ items: [
+ {
+ resourceId: 'file-locked',
+ rid: 'file-locked',
+ gfsUri: 'gfs://main/file-locked',
+ drive: 'main',
+ parentResourceId: 'parent-1',
+ name: 'locked.md',
+ kind: 'file',
+ path: '/locked.md',
+ version: 1,
+ bytes: 8,
+ readable: false,
+ },
+ {
+ resourceId: 'file-open',
+ rid: 'file-open',
+ gfsUri: 'gfs://main/file-open',
+ drive: 'main',
+ parentResourceId: 'parent-1',
+ name: 'open.md',
+ kind: 'file',
+ path: '/open.md',
+ version: 1,
+ bytes: 4,
+ readable: true,
+ },
+ ],
+ })
+
+ renderFilesPage()
+
+ // The unreadable file's ⋯ menu offers no Preview and no Download — the same
+ // guard openResource already enforces — so no enabled action can 403.
+ await act(async () => {
+ fireEvent.click(screen.getByRole('button', { name: 'Options for locked.md' }))
+ })
+ const lockedMenu = screen.getByRole('menu', { name: 'Actions for locked.md' })
+ expect(within(lockedMenu).queryByRole('menuitem', { name: 'Preview' })).toBeNull()
+ expect(within(lockedMenu).queryByRole('menuitem', { name: 'Download' })).toBeNull()
+
+ // A readable, previewable file still offers both.
+ await act(async () => {
+ fireEvent.click(screen.getByRole('button', { name: 'Options for open.md' }))
+ })
+ const openMenu = screen.getByRole('menu', { name: 'Actions for open.md' })
+ expect(within(openMenu).getByRole('menuitem', { name: 'Preview' })).toBeTruthy()
+ expect(within(openMenu).getByRole('menuitem', { name: 'Download' })).toBeTruthy()
+ })
+
it('uses a size column and keeps folder rows focused on the icon and name', () => {
hookMock.useGfsBrowserController.mockReturnValue({
...baseController(),
diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.css
index 723a1bdd5..f2c8825fa 100644
--- a/desktop-app/ui/src/styles.css
+++ b/desktop-app/ui/src/styles.css
@@ -1930,6 +1930,24 @@ h3 {
color: var(--text);
}
+/* An unreadable row (folder grant without inheritance / non-inheriting parent)
+ stays focusable so its activation can toast, but reads as non-actionable:
+ muted text/icon even on hover and focus. The focus-visible frame/background
+ from the base rule is kept for keyboard accessibility. */
+.da-file-explorer__label--no-access.ui-button,
+.da-file-explorer__label--no-access.ui-button:hover:enabled,
+.da-file-explorer__label--no-access.ui-button:focus-visible {
+ color: var(--text-dim);
+}
+
+.da-file-explorer__label--no-access .da-file-explorer__icon {
+ color: var(--text-dim);
+}
+
+.da-file-explorer__no-access-badge {
+ flex: 0 0 auto;
+}
+
.da-file-explorer__icon {
display: inline-flex;
flex: 0 0 auto;