Skip to content

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

TypeScript

fix(evendrive): skip empty file-alignment grant after a successful parent update (N2)

M61818072c5eb
diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsx
index 9703cf683..c1845ba4f 100644
--- a/desktop-app/ui/src/pages/FilesPage.tsx
+++ b/desktop-app/ui/src/pages/FilesPage.tsx
@@ -740,7 +740,15 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:
const fileBits = rolePermissionRequest(subject.type, request.nextRole).filter(bit =>
affordances?.grantableBits.includes(bit)
)
- await ctrl.grant([subjectKey], fileBits, request.row.grant?.inherit ?? false)
+ // N2: an empty bit set means the file's affordances are
+ // unavailable (or grant nothing) — sending it would be rejected
+ // after the parent update already succeeded, turning a successful
+ // action into a confusing partial-failure toast. Skip the
+ // alignment grant; the parent outcome stands and the still-revoked
+ // direct shares cannot mask it.
+ if (fileBits.length > 0) {
+ await ctrl.grant([subjectKey], fileBits, request.row.grant?.inherit ?? false)
+ }
for (const share of request.row.shares) await ctrl.revokeShare(share.id)
} catch (updateError) {
await failPartially(
diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
index 003ce4ed7..f1a6f5df9 100644
--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
@@ -2312,6 +2312,68 @@ describe('FilesPage', () => {
)
})
+ // N2 — when the file's affordances are unavailable (empty grantable
+ // bits), the file-alignment grant must be skipped, not sent empty and
+ // rejected after the parent update already succeeded.
+ it('skips the file-alignment grant when the file affordances yield no bits', async () => {
+ installInheritedDirectoryMocks()
+ const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant
+ const fileGrant = vi.fn(async () => undefined)
+ const pushToast = vi.fn()
+ // File affordances failed: grantableBits came back empty while the
+ // merged row still shows Editor (direct grant + inherited editor).
+ hookMock.useGfsBrowserController.mockReturnValue(
+ inheritedFileController({
+ affordances: {
+ held: ['read', 'manage_acl'],
+ canDelegate: true,
+ grantableBits: [],
+ canCreateShare: false,
+ },
+ grant: fileGrant,
+ })
+ )
+
+ renderFilesPage(pushToast)
+ await openManageDialog('report.txt')
+ const manageDialog = await screen.findByRole('dialog', { name: 'Share file report.txt' })
+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user')
+
+ await act(async () => {
+ fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))
+ })
+ await act(async () => {
+ fireEvent.click(screen.getByRole('option', { name: 'Read' }))
+ })
+ const confirmDialog = await screen.findByRole('alertdialog')
+ await act(async () => {
+ fireEvent.click(within(confirmDialog).getByRole('button', { name: 'Update role' }))
+ })
+
+ // The parent update succeeded with its pre-validated folder bits…
+ await waitFor(() =>
+ expect(parentGrant).toHaveBeenCalledWith(
+ 'folder-1',
+ ['user:user-2'],
+ ['read', 'share'],
+ 'main',
+ true
+ )
+ )
+ // …and no empty-bits grant was sent to the file — the parent outcome
+ // stays a clean success, not a confusing partial failure.
+ expect(fileGrant).not.toHaveBeenCalled()
+ await waitFor(() =>
+ expect(pushToast).toHaveBeenCalledWith(
+ 'Test Two is now Read-only on Team folder and everything inside it',
+ 'success'
+ )
+ )
+ pushToast.mock.calls.forEach(([message, tone]) => {
+ expect(tone).not.toBe('error')
+ })
+ })
+
it('states the true partial outcome when a folder removal fails mid-run', async () => {
installInheritedDirectoryMocks()
const revokeGrant = vi.fn(async (grantId: string) => {