Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix: resolve GFS access review regressions
M26810b18f0e7
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex a223c56f9..7accde0c0 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.550",+ "version": "0.1.551","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.550",+ "version": "0.1.551","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/image-policy": "file:../packages/image-policy",diff --git a/control-api/package.json b/control-api/package.jsonindex 05ea1f10b..b3b94222e 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.550",+ "version": "0.1.551","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/src/gfs/resolve.ts b/control-api/src/gfs/resolve.tsindex 5581c6a54..0f65f0948 100644--- a/control-api/src/gfs/resolve.ts+++ b/control-api/src/gfs/resolve.ts@@ -66,6 +66,7 @@ export interface ResolvedResource {name: stringkind: stringpathCache: string | null+ version: numberupdatedAt: string}@@ -99,7 +100,7 @@ export interface ResolveDb {query(text: string, values?: unknown[]): Promise<{ rows: unknown[] }>}-const SELECT_COLS = 'resource_id, drive, name, kind, path_cache, updated_at'+const SELECT_COLS = 'resource_id, drive, name, kind, path_cache, version, updated_at'function toIsoTimestamp(value: unknown): string {if (value instanceof Date) return value.toISOString()@@ -117,6 +118,7 @@ function rowToResource(row: unknown): ResolvedResource {name: unknownkind: unknownpath_cache: unknown+ version: unknownupdated_at: unknown}return {@@ -125,6 +127,7 @@ function rowToResource(row: unknown): ResolvedResource {name: String(r.name),kind: String(r.kind),pathCache: r.path_cache == null ? null : String(r.path_cache),+ version: Number(r.version),updatedAt: toIsoTimestamp(r.updated_at),}}diff --git a/control-api/src/routes/gfs/resolve.ts b/control-api/src/routes/gfs/resolve.tsindex eb7a44a2d..37d6fa06a 100644--- a/control-api/src/routes/gfs/resolve.ts+++ b/control-api/src/routes/gfs/resolve.ts@@ -19,6 +19,7 @@ export interface GfsResourceView {name: stringkind: stringpath: string | null+ version: numberupdatedAt: string}@@ -32,6 +33,7 @@ export function toResolveView(resource: ResolvedResource): GfsResourceView {name: resource.name,kind: resource.kind,path: resource.pathCache,+ version: resource.version,updatedAt: resource.updatedAt,}}diff --git a/control-api/src/routes/gfs/resources.ts b/control-api/src/routes/gfs/resources.tsindex 7e98337f4..e5a7f1d94 100644--- a/control-api/src/routes/gfs/resources.ts+++ b/control-api/src/routes/gfs/resources.ts@@ -12,6 +12,7 @@ import { requireAuthForControlUI } from '../../middleware/controlUIAuth.js'import {type GfsCaller,type GrantsDb,+ PERMISSIONS,UUID_RE,auditMutation,checkAccess,@@ -347,6 +348,32 @@ export async function applyResourcePatch(}export function registerGfsResourceRoutes(router: Router): void {+ router.get(+ '/gfs/resources/:id/affordances',+ requireAuthForControlUI,+ asyncHandler(async (req, res) => {+ const id = String(req.params.id)+ if (!UUID_RE.test(id)) {+ res.status(400).json({ error: 'path_invalid' })+ return+ }+ // Control UI is the authenticated operator plane. These are the same+ // concrete affordances the desktop preflight consumes; the operator's+ // intrinsic authority supplies every permission on visible resources.+ const caller = resolveCaller(req)+ if (!caller.isOperator) {+ res.status(403).json({ error: 'forbidden' })+ return+ }+ res.status(200).json({+ resourceId: id,+ held: [...PERMISSIONS],+ canDelegate: true,+ grantableBits: [...PERMISSIONS],+ canCreateShare: true,+ })+ })+ )router.patch('/gfs/resources/:id', requireAuthForControlUI, asyncHandler(handlePatch))}diff --git a/control-api/test/gfs.resolve.test.ts b/control-api/test/gfs.resolve.test.tsindex fb2951b64..586f7e533 100644--- a/control-api/test/gfs.resolve.test.ts+++ b/control-api/test/gfs.resolve.test.ts@@ -46,6 +46,7 @@ function res(partial: Partial<ResolvedResource> & { resourceId: string }): Resolname: 'n',kind: 'directory',pathCache: null,+ version: 1,updatedAt: '2026-01-01T00:00:00.000Z',...partial,}@@ -114,6 +115,7 @@ const row = (resourceId: string, name = 'n', kind = 'directory') => ({name,kind,path_cache: null,+ version: 1,updated_at: new Date('2026-01-01T00:00:00.000Z'),})diff --git a/control-api/test/gfs.resolveRoutes.test.ts b/control-api/test/gfs.resolveRoutes.test.tsindex 4377afdb5..f1223d841 100644--- a/control-api/test/gfs.resolveRoutes.test.ts+++ b/control-api/test/gfs.resolveRoutes.test.ts@@ -11,6 +11,7 @@ function res(partial: Partial<ResolvedResource> & { resourceId: string }): Resolname: 'n',kind: 'directory',pathCache: null,+ version: 1,updatedAt: '2026-01-01T00:00:00.000Z',...partial,}@@ -33,6 +34,7 @@ describe('toResolveView', () => {expect(view.rid).toBe(RID)expect(view.gfsUri).toBe(`gfs://main/${RID}`)expect(view.path).toBe('/org')+ expect(view.version).toBe(1)expect(view.updatedAt).toBe('2026-01-01T00:00:00.000Z')expect(view.updatedAt).toMatch(/^\d{4}-\d{2}-\d{2}T.*Z$/)})diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsxindex e69159f1b..16afa1b44 100644--- a/control-ui/components/GfsBrowser.tsx+++ b/control-ui/components/GfsBrowser.tsx@@ -1006,7 +1006,8 @@ export function GfsBrowser(): React.JSX.Element {* delete) so a breadcrumb menu acts on exactly the same shape a* parent-view row does. Returns null for the synthetic root. */function crumbToChild(crumb: Crumb): GfsChild | null {- if (!crumb.id || !crumb.rid || crumb.kind !== 'directory') return null+ if (!crumb.id || !crumb.rid || crumb.kind !== 'directory' || crumb.version === undefined)+ return nullreturn {resourceId: crumb.id,rid: crumb.rid,@@ -1015,7 +1016,7 @@ export function GfsBrowser(): React.JSX.Element {kind: crumb.kind,path: null,bytes: 0,- version: crumb.version ?? 0,+ version: crumb.version,}}@@ -1048,6 +1049,7 @@ export function GfsBrowser(): React.JSX.Element {gfsUri: stringname: stringkind: string+ version: number}if (view.kind !== 'directory') {setOpenLinkError('Only folder links can be opened here.')@@ -1065,6 +1067,7 @@ export function GfsBrowser(): React.JSX.Element {name: view.name,kind: 'directory',gfsUri: view.gfsUri,+ version: view.version,},])setLoading(true)@@ -1086,17 +1089,24 @@ export function GfsBrowser(): React.JSX.Element {setRenameTarget(null)return}- await apiSend(+ const patchResult = await apiSend('PATCH',- `/api/v1/gfs/resources/${encodeURIComponent(child.resourceId)}`,+ '/api/v1/gfs/resources/' + encodeURIComponent(child.resourceId),{ drive: DRIVE, newName: name, ifMatch: child.version },{ drive: DRIVE })+ const nextVersion = (+ patchResult as { data?: { resourceId?: string; version?: number } } | undefined+ )?.data?.versionshowToast('Resource renamed.', { tone: 'success' })// A crumb rename must retitle the breadcrumb segment too, not just the// listing rows refreshed below.setCrumbs(prev =>- prev.map(crumb => (crumb.id === child.resourceId ? { ...crumb, name } : crumb))+ prev.map(crumb =>+ crumb.id === child.resourceId+ ? { ...crumb, name, ...(nextVersion === undefined ? {} : { version: nextVersion }) }+ : crumb+ ))setRenameOpen(false)setRenameTarget(null)diff --git a/control-ui/components/GfsGrantPanel.tsx b/control-ui/components/GfsGrantPanel.tsxindex 6d9c72954..56135944f 100644--- a/control-ui/components/GfsGrantPanel.tsx+++ b/control-ui/components/GfsGrantPanel.tsx@@ -29,6 +29,7 @@ import {deleteGfsShare,getAdminTeams,getAdminUsers,+ getGfsAffordances,getGfsGrants,getGfsShares,getHosts,@@ -146,7 +147,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Elemerow: GfsFileAccessRowmode: 'change-role'nextRole: AccessRole- affected: GfsInheritedAccessSource[]+ affected: Array<{ source: GfsInheritedAccessSource; permissions: string[] }>}| { row: GfsFileAccessRow; mode: 'remove' }| null@@ -551,6 +552,54 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme)}+ /**+ * Control UI is the operator plane, but it still preflights every affected+ * ancestor independently. The server remains authoritative; this walk keeps+ * the confirmation dialog from promising a role that one folder cannot+ * express and makes the folder-level decision visible in the UI.+ */+ async function prepareParentRoleChange(row: GfsFileAccessRow, nextRole: AccessRole) {+ const inherited = row.inherited+ if (!inherited) return+ if (nextRole === roleForPermissions(row.permissions)) return+ const affected = planInheritedRoleChange(inherited, nextRole === 'editor')+ if (affected.length === 0 && !row.direct) return++ const updates: Array<{ source: GfsInheritedAccessSource; permissions: string[] }> = []+ for (const source of affected) {+ let folderAffordances+ try {+ folderAffordances = await getGfsAffordances(source.resourceId, DRIVE)+ } catch (caught) {+ if (!isAlreadyMissing(caught)) {+ setError(caught instanceof Error ? caught.message : 'Could not verify folder access')+ showToast('Could not verify access on the affected folder.', { tone: 'error' })+ }+ return+ }+ const permissions = rolePermissions(nextRole, hostOnlySubject(row.subject)).filter(+ permission => folderAffordances.grantableBits.includes(permission)+ )+ const expressesRole =+ nextRole === 'editor'+ ? permissions.includes('read') && permissions.includes('write')+ : permissions.includes('read')+ if (!folderAffordances.canDelegate || !expressesRole) {+ showToast(+ 'Access on ' ++ source.name ++ ' cannot make ' ++ subjectLabel(row) ++ (nextRole === 'editor' ? ' an Editor.' : ' Read-only.'),+ { tone: 'error' }+ )+ return+ }+ updates.push({ source, permissions })+ }+ setParentUpdate({ row, mode: 'change-role', nextRole, affected: updates })+ }+/*** Confirmed edit of an inherited row (R1-H1 semantics, verified against* Google Drive): a removal revokes the member's rows on EVERY contributing@@ -630,10 +679,9 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Elemereturn}const affected = request.affected- const permissions = rolePermissions(request.nextRole, hostOnlySubject(row.subject))- const affectedNames = affected.map(source => source.name)+ const affectedNames = affected.map(update => update.source.name)let updated = 0- for (const source of affected) {+ for (const { source, permissions } of affected) {try {await putGfsGrant({drive: DRIVE,@@ -658,6 +706,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme}if (row.direct) {try {+ const permissions = rolePermissions(request.nextRole, hostOnlySubject(row.subject))await putGfsGrant({drive: DRIVE,resourceId: resource.resourceId,@@ -798,7 +847,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Elemereturn (<RecordListRowclassName="cu-gfs-existing-access__item"- data-testid={`gfs-access-row-${row.subject.type}`}+ data-testid={`gfs-access-row-${subjectKey(row.subject)}`}data-access-id={row.direct?.grantId ?? row.direct?.shareIds[0]}data-inherited={inherited ? 'true' : undefined}key={`file:${subjectKey(row.subject)}`}@@ -828,27 +877,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Elemereturn}const nextRole = (next[0] ?? 'read') as AccessRole- // N1: the dropdown displays the MERGED- // effective role (direct ⊔ inherited).- // Re-selecting the already-displayed role is a- // no-op — comparing it against the- // inherited-only floor instead would open the- // parent-update modal and escalate the parent- // folder for a non-change.- if (nextRole === roleForPermissions(row.permissions)) return- const affected = planInheritedRoleChange(- row.inherited as GfsInheritedAccessItem,- nextRole === 'editor'- )- // Selecting the already-held role with only- // inherited access changes nothing: no modal.- if (affected.length === 0 && !row.direct) return- setParentUpdate({- row,- mode: 'change-role',- nextRole,- affected,- })+ void prepareParentRoleChange(row, nextRole)}}menuClassName="cu-gfs-existing-access__role-menu"options={ROLE_OPTIONS}@@ -883,9 +912,9 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Elemereturn (<RecordListRowclassName="cu-gfs-existing-access__item"- data-testid={`gfs-access-row-${item.subject.type}`}+ data-testid={`gfs-access-row-${subjectKey(item.subject)}`}data-access-id={item.grantId ?? item.shareIds[0]}- key={`${item.subject.type}:${item.grantId ?? item.shareIds[0]}`}+ key={`direct:${subjectKey(item.subject)}`}><spanaria-hidden="true"@@ -950,7 +979,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Elemename: source.name,currentRole: roleForPermissions(source.permissions),}))- : parentUpdate.affected.map(source => ({+ : parentUpdate.affected.map(({ source }) => ({name: source.name,currentRole: roleForPermissions(source.permissions),})),diff --git a/control-ui/components/__tests__/GfsBrowser.test.tsx b/control-ui/components/__tests__/GfsBrowser.test.tsxindex 133cb113f..3f12713c7 100644--- a/control-ui/components/__tests__/GfsBrowser.test.tsx+++ b/control-ui/components/__tests__/GfsBrowser.test.tsx@@ -113,7 +113,7 @@ async function openManage(resourceName: string) {)}-function child(name: string, kind: string, n: number) {+function child(name: string, kind: string, n: number, version = 0) {return {resourceId: `id-${n}`,rid: `r${n}`,@@ -122,7 +122,7 @@ function child(name: string, kind: string, n: number) {kind,path: `/${name}`,bytes: 0,- version: 0,+ version,}}@@ -1094,6 +1094,56 @@ describe('GfsBrowser', () => {)})+ it('carries the server version through consecutive renames', async () => {+ const first = child('report.txt', 'file', 1, 7)+ const second = { ...first, name: 'report-renamed.txt', version: 8 }+ const third = { ...second, name: 'report-final.txt', version: 9 }+ mockApiGet+ .mockResolvedValueOnce({ items: [first], nextCursor: null })+ .mockResolvedValueOnce({ items: [second], nextCursor: null })+ .mockResolvedValueOnce({ items: [third], nextCursor: null })+ mockApiSend+ .mockResolvedValueOnce({ ok: true, data: { resourceId: 'id-1', version: 8 } })+ .mockResolvedValueOnce({ ok: true, data: { resourceId: 'id-1', version: 9 } })+ renderBrowser()++ await screen.findByText('report.txt')+ const firstRow = screen.getByText('report.txt').closest('li')!+ await openResourceMenu('report.txt')+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))+ const firstForm = within(firstRow).getByRole('form', { name: 'Rename resource' })+ fireEvent.change(within(firstForm).getByLabelText('New name'), {+ target: { value: 'report-renamed.txt' },+ })+ fireEvent.click(within(firstForm).getByRole('button', { name: 'Save name' }))++ await screen.findByText('report-renamed.txt')+ expect(mockApiSend).toHaveBeenNthCalledWith(+ 1,+ 'PATCH',+ '/api/v1/gfs/resources/id-1',+ { drive: 'main', newName: 'report-renamed.txt', ifMatch: 7 },+ { drive: 'main' }+ )+ const secondRow = screen.getByText('report-renamed.txt').closest('li')!+ await openResourceMenu('report-renamed.txt')+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))+ const secondForm = within(secondRow).getByRole('form', { name: 'Rename resource' })+ fireEvent.change(within(secondForm).getByLabelText('New name'), {+ target: { value: 'report-final.txt' },+ })+ fireEvent.click(within(secondForm).getByRole('button', { name: 'Save name' }))++ await waitFor(() => expect(screen.getByText('report-final.txt')).toBeTruthy())+ expect(mockApiSend).toHaveBeenNthCalledWith(+ 2,+ 'PATCH',+ '/api/v1/gfs/resources/id-1',+ { drive: 'main', newName: 'report-final.txt', ifMatch: 8 },+ { drive: 'main' }+ )+ })+it('keeps the share dialog focused on sharing without resource actions', async () => {mockApiGet.mockResolvedValueOnce({items: [child('report.txt', 'file', 2)],@@ -1444,6 +1494,7 @@ describe('GfsBrowser', () => {gfsUri: 'gfs://main/r3',name: 'nested',kind: 'directory',+ version: 7,}}return { items: [], nextCursor: null }diff --git a/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx b/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsxindex d8c9cbafa..7d0f88932 100644--- a/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx+++ b/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx@@ -7,6 +7,7 @@ import {deleteGfsShare,getAdminTeams,getAdminUsers,+ getGfsAffordances,getGfsGrants,getGfsShares,getHosts,@@ -23,6 +24,7 @@ vi.mock('@lib/api', () => ({getRecipes: vi.fn(),getGfsGrants: vi.fn(),getGfsShares: vi.fn(),+ getGfsAffordances: vi.fn(),deleteGfsGrant: vi.fn(),deleteGfsShare: vi.fn(),putGfsGrant: vi.fn(),@@ -46,6 +48,7 @@ const resource = {}const userSubject = { type: 'user', id: '11111111-1111-1111-1111-111111111111' } as const+const userRowTestId = `gfs-access-row-user:${userSubject.id}`const teamSubject = { type: 'team', id: '22222222-2222-2222-2222-222222222222' } as constconst statefulHostSubject = { type: 'host', id: '1st:mcp-host/chatllm' } as constconst statelessHostSubject = { type: 'host', id: '1st:mcp-host/chatllm-stateless' } as const@@ -145,7 +148,7 @@ describe('GfsGrantPanel bulk access', () => {const existing = await screen.findByRole('region', { name: 'People with access' })expect(within(existing).getByText('Ada Lovelace')).toBeTruthy()- const userRow = within(existing).getByTestId('gfs-access-row-user')+ const userRow = within(existing).getByTestId(userRowTestId)expect(userRow.querySelector('[data-subject-kind="user"] svg')).not.toBeNull()expect(within(userRow).queryByText(/direct grant|\buser\b/i)).toBeNull()expect(@@ -516,7 +519,7 @@ describe('GfsGrantPanel bulk access', () => {await submit('Share')const existing = await screen.findByRole('region', { name: 'People with access' })- expect(await within(existing).findByTestId('gfs-access-row-user')).toBeTruthy()+ expect(await within(existing).findByTestId(userRowTestId)).toBeTruthy()expect(initialSignal?.aborted).toBe(true)resolveInitialGrants({ items: [] })diff --git a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsxindex 921928f78..577997f9a 100644--- a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx+++ b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx@@ -5,6 +5,7 @@ import {deleteGfsShare,getAdminTeams,getAdminUsers,+ getGfsAffordances,getGfsGrants,getGfsResourceByPath,getGfsShares,@@ -23,6 +24,7 @@ vi.mock('@lib/api', () => ({getRecipes: vi.fn(),getGfsGrants: vi.fn(),getGfsShares: vi.fn(),+ getGfsAffordances: vi.fn(),getGfsResourceByPath: vi.fn(),deleteGfsGrant: vi.fn(),deleteGfsShare: vi.fn(),@@ -35,6 +37,7 @@ const mockGetHosts = vi.mocked(getHosts)const mockGetRecipes = vi.mocked(getRecipes)const mockGetGfsGrants = vi.mocked(getGfsGrants)const mockGetGfsShares = vi.mocked(getGfsShares)+const mockGetGfsAffordances = vi.mocked(getGfsAffordances)const mockGetGfsResourceByPath = vi.mocked(getGfsResourceByPath)const mockPutGfsGrant = vi.mocked(putGfsGrant)const mockDeleteGfsGrant = vi.mocked(deleteGfsGrant)@@ -67,6 +70,9 @@ const researchTeam = { type: 'team', id: '33333333-3333-3333-3333-333333333333'const FOLDER_GRANT_ID = '44444444-4444-4444-4444-444444444444'const ROOT_SHARE_ID = '66666666-6666-6666-6666-666666666666'const FILE_GRANT_ID = '77777777-7777-7777-7777-777777777777'+const miguelRowTestId = `gfs-access-row-user:${miguel.id}`+const marcelaRowTestId = `gfs-access-row-user:${marcela.id}`+const researchTeamRowTestId = `gfs-access-row-team:${researchTeam.id}`function byPathView(resourceId: string, name: string) {return {@@ -77,6 +83,7 @@ function byPathView(resourceId: string, name: string) {name,kind: 'directory',path: name ? `/${name}` : '/',+ version: 1,updatedAt: '2026-01-01T00:00:00Z',}}@@ -124,6 +131,13 @@ describe('GfsGrantPanel inherited access', () => {})mockGetHosts.mockResolvedValue({ items: [] })mockGetRecipes.mockResolvedValue({ items: [] })+ mockGetGfsAffordances.mockResolvedValue({+ resourceId: 'folder',+ held: ['read', 'write', 'delete', 'manage_acl', 'share'],+ canDelegate: true,+ grantableBits: ['read', 'write', 'delete', 'manage_acl', 'share'],+ canCreateShare: true,+ })mockGetGfsGrants.mockImplementation(async resourceId => {if (resourceId === FOLDER_ID) {return {@@ -185,7 +199,7 @@ describe('GfsGrantPanel inherited access', () => {renderPanel()const existing = await screen.findByRole('region', { name: 'People with access' })- const miguelRow = await within(existing).findByTestId('gfs-access-row-user')+ const miguelRow = await within(existing).findByTestId(miguelRowTestId)expect(within(miguelRow).getAllByText('Miguel')).toHaveLength(1)// Normal-looking row: role dropdown and actions menu, no inherited badge// or muted duplicate.@@ -198,7 +212,7 @@ describe('GfsGrantPanel inherited access', () => {// The root share covers descendants too, and the drive root's empty name// falls back to the drive label.- const teamRow = within(existing).getByTestId('gfs-access-row-team')+ const teamRow = within(existing).getByTestId(researchTeamRowTestId)expect(within(teamRow).getByText('Research')).toBeTruthy()expect(within(teamRow).getByRole('button', { name: 'Access role for Research' }).textContent@@ -243,7 +257,7 @@ describe('GfsGrantPanel inherited access', () => {renderPanel()const existing = await screen.findByRole('region', { name: 'People with access' })- const rows = await within(existing).findAllByTestId('gfs-access-row-user')+ const rows = await within(existing).findAllByTestId(miguelRowTestId)expect(rows).toHaveLength(1)// Effective role is the strongest across direct and inherited sources.expect(@@ -254,9 +268,10 @@ describe('GfsGrantPanel inherited access', () => {it('opens the parent-folder confirmation on any role change of an inherited row', async () => {renderPanel()const existing = await screen.findByRole('region', { name: 'People with access' })- const miguelRow = await within(existing).findByTestId('gfs-access-row-user')+ const miguelRow = await within(existing).findByTestId(miguelRowTestId)await chooseRole(miguelRow, 'Read')+ await waitFor(() => expect(mockGetGfsAffordances).toHaveBeenCalledWith(FOLDER_ID, 'main'))const dialog = await screen.findByRole('alertdialog')expect(within(dialog).getByText('Update role on parent folder?')).toBeTruthy()@@ -307,7 +322,7 @@ describe('GfsGrantPanel inherited access', () => {})renderPanel()const existing = await screen.findByRole('region', { name: 'People with access' })- const miguelRow = await within(existing).findByTestId('gfs-access-row-user')+ const miguelRow = await within(existing).findByTestId(miguelRowTestId)await chooseRole(miguelRow, 'Read')const dialog = await screen.findByRole('alertdialog')@@ -335,7 +350,7 @@ describe('GfsGrantPanel inherited access', () => {it('cancel reverts the dropdown without any API call', async () => {renderPanel()const existing = await screen.findByRole('region', { name: 'People with access' })- const miguelRow = await within(existing).findByTestId('gfs-access-row-user')+ const miguelRow = await within(existing).findByTestId(miguelRowTestId)await chooseRole(miguelRow, 'Read')const dialog = await screen.findByRole('alertdialog')@@ -351,7 +366,7 @@ describe('GfsGrantPanel inherited access', () => {it('removes an inherited member from the parent folder after confirmation', async () => {renderPanel()const existing = await screen.findByRole('region', { name: 'People with access' })- const miguelRow = await within(existing).findByTestId('gfs-access-row-user')+ const miguelRow = await within(existing).findByTestId(miguelRowTestId)fireEvent.click(within(miguelRow).getByRole('button', { name: 'Actions for Miguel' }))fireEvent.click(await screen.findByRole('menuitem', { name: 'Remove access' }))@@ -371,7 +386,7 @@ describe('GfsGrantPanel inherited access', () => {it('opens the help panel from Learn more and returns to the confirmation', async () => {renderPanel()const existing = await screen.findByRole('region', { name: 'People with access' })- const miguelRow = await within(existing).findByTestId('gfs-access-row-user')+ const miguelRow = await within(existing).findByTestId(miguelRowTestId)await chooseRole(miguelRow, 'Read')const dialog = await screen.findByRole('alertdialog')@@ -425,8 +440,10 @@ describe('GfsGrantPanel inherited access', () => {renderPanel()const existing = await screen.findByRole('region', { name: 'People with access' })+ expect(within(existing).getByTestId(miguelRowTestId)).toBeTruthy()+ expect(within(existing).getByTestId(marcelaRowTestId)).toBeTruthy()const marcelaRow = within(existing)- .getAllByTestId('gfs-access-row-user')+ .getAllByTestId(marcelaRowTestId).find(row => within(row).queryByText('Marcela') !== null)expect(marcelaRow).toBeTruthy()@@ -449,7 +466,7 @@ describe('GfsGrantPanel inherited access', () => {const existing = await screen.findByRole('region', { name: 'People with access' })// The folder's own direct rows render, toggleable as before.- const miguelRow = (await within(existing).findAllByTestId('gfs-access-row-user')).find(+ const miguelRow = (await within(existing).findAllByTestId(miguelRowTestId)).find(row => within(row).queryByText('Miguel') !== null)expect(miguelRow).toBeTruthy()@@ -517,7 +534,7 @@ describe('GfsGrantPanel inherited access', () => {renderPanel()const existing = await screen.findByRole('region', { name: 'People with access' })- const rows = await within(existing).findAllByTestId('gfs-access-row-user')+ const rows = await within(existing).findAllByTestId(miguelRowTestId)expect(rows).toHaveLength(1)expect(within(rows[0]).getByRole('button', { name: 'Access role for Miguel' }).textContent@@ -638,7 +655,7 @@ describe('GfsGrantPanel inherited access', () => {async function openRoleDialog(resource = nestedFile) {renderPanel(resource)const existing = await screen.findByRole('region', { name: 'People with access' })- const row = await within(existing).findByTestId('gfs-access-row-user')+ const row = await within(existing).findByTestId(miguelRowTestId)return row}diff --git a/control-ui/lib/api.ts b/control-ui/lib/api.tsindex 8c8cb5ad0..6c9df281e 100644--- a/control-ui/lib/api.ts+++ b/control-ui/lib/api.ts@@ -380,6 +380,14 @@ export type GfsShareListItem = {export type GfsGrantListResponse = { items: GfsGrantListItem[] }export type GfsShareListResponse = { items: GfsShareListItem[] }+export type GfsAffordances = {+ resourceId: string+ held: string[]+ canDelegate: boolean+ grantableBits: string[]+ canCreateShare: boolean+}+export type GfsGrantError = Error & {status?: numbercode?: string@@ -478,6 +486,19 @@ export async function getGfsShares()) as GfsShareListResponse}+/** Returns the operator-plane affordances used before an inherited role edit. */+export async function getGfsAffordances(+ resourceId: string,+ drive = 'main',+ signal?: AbortSignal+): Promise<GfsAffordances> {+ return (await apiGet(+ '/api/v1/gfs/resources/' + encodeURIComponent(resourceId) + '/affordances',+ { drive },+ { signal }+ )) as GfsAffordances+}+export async function deleteGfsShare(id: string): Promise<void> {await gfsMutate('DELETE', `/api/v1/gfs/shares/${encodeURIComponent(id)}`)}@@ -490,6 +511,7 @@ export type GfsResourceByPathView = {name: stringkind: stringpath: string | null+ version: numberupdatedAt: string}diff --git a/control-ui/next-env.d.ts b/control-ui/next-env.d.tsindex a419cbe4e..ce4e94a6b 100644--- a/control-ui/next-env.d.ts+++ b/control-ui/next-env.d.ts@@ -1,7 +1,7 @@/// <reference types="next" />/// <reference types="next/image-types/global" />-import "./.next/dev/types/routes.d.ts";-import "./.next/dev/types/root-params.d.ts";+import "./.next/types/routes.d.ts";+import "./.next/types/root-params.d.ts";// NOTE: This file should not be edited// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 5238431b6..8936b7013 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.605",+ "version": "0.1.606","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.605",+ "version": "0.1.606","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/control-ui/package.json b/control-ui/package.jsonindex e49332bf3..93db41c74 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.605",+ "version": "0.1.606","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/desktop-app/ui/src/gfs/GfsGrantList/index.tsx b/desktop-app/ui/src/gfs/GfsGrantList/index.tsxindex 0424f6ed0..92f740bb8 100644--- a/desktop-app/ui/src/gfs/GfsGrantList/index.tsx+++ b/desktop-app/ui/src/gfs/GfsGrantList/index.tsx@@ -217,7 +217,7 @@ export function GfsGrantList({<liclassName="da-gfs-grant-list__row"data-inherited="true"- data-testid={`gfs-access-row-inherited-${row.subject.type}`}+ data-testid={`gfs-access-row-inherited-${subjectKey(row.subject)}`}key={`inherited:${subjectKey(row.subject)}`}><spandiff --git a/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx b/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsxindex ab3aec73d..117f859dc 100644--- a/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx+++ b/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx@@ -18,6 +18,8 @@ import type {afterEach(cleanup)const agents = [{ id: '1st:mcp-host/chatllm', name: 'Chat LLM' }]+const userInheritedRowTestId = 'gfs-access-row-inherited-user:user-2'+const teamInheritedRowTestId = 'gfs-access-row-inherited-team:team-1'const subjects = [{ type: 'user' as const, id: 'user-2', label: 'Test Two', description: '[email protected]' },{ type: 'team' as const, id: 'team-1', label: 'Core Team' },@@ -254,7 +256,7 @@ describe('GfsGrantList', () => {/>)- const userRow = screen.getByTestId('gfs-access-row-inherited-user')+ const userRow = screen.getByTestId(userInheritedRowTestId)expect(within(userRow).getByText('Test Two')).toBeTruthy()expect(within(userRow).getByRole('button', { name: 'Access role for Test Two' }).textContent@@ -266,7 +268,7 @@ describe('GfsGrantList', () => {expect(userRow.getAttribute('data-inherited')).toBe('true')expect(userRow.querySelector('[data-subject-kind="user"] svg')).not.toBeNull()- const teamRow = screen.getByTestId('gfs-access-row-inherited-team')+ const teamRow = screen.getByTestId(teamInheritedRowTestId)expect(within(teamRow).getByRole('button', { name: 'Access role for Core Team' }).textContent).toContain('Read')@@ -288,13 +290,34 @@ describe('GfsGrantList', () => {// One row per member: the direct grant row is consumed by the merge.expect(screen.queryByTestId('gfs-access-row-grant-grant-1')).toBeNull()- const mergedRow = screen.getByTestId('gfs-access-row-inherited-user')+ const mergedRow = screen.getByTestId(userInheritedRowTestId)// Effective role is the strongest across direct and inherited sources.expect(within(mergedRow).getByRole('button', { name: 'Access role for Test Two' }).textContent).toContain('Editor')})+ it('uses the stable subject identity when two inherited subjects share a type', () => {+ render(+ <GfsGrantList+ agents={agents}+ inheritedItems={[+ inheritedItem({}),+ inheritedItem({ subject: { type: 'user', id: 'user-3' } }),+ ]}+ items={[]}+ mergeInherited+ onChangeInheritedRole={vi.fn()}+ onRemoveInherited={vi.fn()}+ onRevoke={vi.fn()}+ subjects={subjects}+ />+ )++ expect(screen.getByTestId('gfs-access-row-inherited-user:user-2')).toBeTruthy()+ expect(screen.getByTestId('gfs-access-row-inherited-user:user-3')).toBeTruthy()+ })+it('fires the inherited change and remove callbacks for merged rows', () => {const onChangeInheritedRole = vi.fn()const onRemoveInherited = vi.fn()@@ -312,7 +335,7 @@ describe('GfsGrantList', () => {/>)- const row = screen.getByTestId('gfs-access-row-inherited-user')+ const row = screen.getByTestId(userInheritedRowTestId)fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))fireEvent.click(screen.getByRole('option', { name: 'Read' }))expect(onChangeInheritedRole).toHaveBeenCalledTimes(1)@@ -352,7 +375,7 @@ describe('GfsGrantList', () => {)expect(screen.queryByTestId('gfs-access-row-share-share-1')).toBeNull()- expect(screen.getByTestId('gfs-access-row-inherited-team')).toBeTruthy()+ expect(screen.getByTestId(teamInheritedRowTestId)).toBeTruthy()})it('ignores inherited items without mergeInherited (folder dialogs unchanged)', () => {@@ -366,7 +389,7 @@ describe('GfsGrantList', () => {/>)- expect(screen.queryByTestId('gfs-access-row-inherited-user')).toBeNull()+ expect(screen.queryByTestId(userInheritedRowTestId)).toBeNull()expect(screen.getByText('No one has access yet.')).toBeTruthy()})diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsxindex c1845ba4f..d464cc243 100644--- a/desktop-app/ui/src/pages/FilesPage.tsx+++ b/desktop-app/ui/src/pages/FilesPage.tsx@@ -588,7 +588,7 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:try {await ctrl.grant([subjectKey], bits, item.inherit)pushToast?.(`${label} is now ${role === 'editor' ? 'an Editor' : 'Read-only'}`, 'success')- await ctrl.refreshGrants()+ await Promise.all([ctrl.refreshGrants(), ctrl.refreshShares()])} catch (roleError) {if (failClosedOnAuthorizationError(roleError)) returnpushToast?.(describeGfsGrantError(roleError).message, 'error')@@ -672,7 +672,7 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:const failPartially = async (updateError: unknown, summary: string) => {if (failClosedOnAuthorizationError(updateError)) returnpushToast?.(`${summary} (${describeGfsGrantError(updateError).message})`, 'error')- await Promise.all([ctrl.refreshGrants(), ctrl.refreshInheritedAccess()])+ await Promise.all([ctrl.refreshGrants(), ctrl.refreshInheritedAccess(), ctrl.refreshShares()])}try {if (request.mode === 'remove') {@@ -709,7 +709,11 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:: `Access removed on ${sources.length} folders and everything inside them`,'success')- await Promise.all([ctrl.refreshGrants(), ctrl.refreshInheritedAccess()])+ await Promise.all([+ ctrl.refreshGrants(),+ ctrl.refreshInheritedAccess(),+ ctrl.refreshShares(),+ ])return}const updates = request.updates@@ -741,13 +745,16 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:affordances?.grantableBits.includes(bit))// 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.+ // unavailable (or grant nothing). Do not send an empty grant after+ // the parent update; revoke the old direct grant instead so it+ // cannot keep masking the confirmed parent role.if (fileBits.length > 0) {await ctrl.grant([subjectKey], fileBits, request.row.grant?.inherit ?? false)+ } else if (request.row.grant) {+ // An empty affordance result cannot express the requested direct+ // role. Remove the old grant so it cannot keep masking the+ // parent-folder downgrade while the UI reports success.+ await ctrl.revokeGrant(request.row.grant.id)}for (const share of request.row.shares) await ctrl.revokeShare(share.id)} catch (updateError) {@@ -764,7 +771,7 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:: `${label} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${current?.name ?? 'this file'}`,'success')- await Promise.all([ctrl.refreshGrants(), ctrl.refreshInheritedAccess()])+ await Promise.all([ctrl.refreshGrants(), ctrl.refreshInheritedAccess(), ctrl.refreshShares()])} finally {setUpdatingAccessRole(false)}diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsxindex f1a6f5df9..3e99d99cc 100644--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx@@ -1762,7 +1762,7 @@ describe('FilesPage', () => {const manageDialog = await screen.findByRole('dialog', { name: 'Share file report.txt' })// Direct grant row is consumed by the deduped merged row (one per member).expect(within(manageDialog).queryByTestId('gfs-access-row-grant-grant-1')).toBeNull()- const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user')+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user:user-2')expect(within(row).getByText('Test Two')).toBeTruthy()expect(within(row).queryByText(/Inherited from/)).toBeNull()// Effective role is the strongest across direct and inherited sources.@@ -1785,7 +1785,7 @@ describe('FilesPage', () => {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')+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user:user-2')await act(async () => {fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))@@ -1843,33 +1843,69 @@ describe('FilesPage', () => {// while the toast claims Read-only.it('revokes the file’s direct shares when a confirmed parent role change downgrades the member', async () => {installInheritedDirectoryMocks()+ const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant+ const directShare = {+ id: 'file-share-1',+ drive: 'main',+ resourceId: 'file-1',+ subject: { type: 'user', id: 'user-2' },+ permissions: ['read', 'write'],+ includeDescendants: false,+ }+ const inheritedEditor = {+ subject: { type: 'user', id: 'user-2' },+ permissions: ['read', 'write'],+ inheritedFrom: ['Team folder'],+ sources: [+ {+ resourceId: 'folder-1',+ name: 'Team folder',+ permissions: ['read', 'write'],+ grantId: 'parent-grant-1',+ shareIds: [],+ },+ ],+ }+ let removeDirectShare: (() => void) | undefined+ let downgradeInherited: (() => void) | undefined+ parentGrant.mockImplementation(async () => {+ downgradeInherited?.()+ })const fileGrant = vi.fn(async () => undefined)const revokeShare = vi.fn(async () => undefined)+ const refreshShares = vi.fn(async () => undefined)const pushToast = vi.fn()- hookMock.useGfsBrowserController.mockReturnValue(- inheritedFileController({- grants: [],- shares: [+ hookMock.useGfsBrowserController.mockImplementation(() => {+ const [shares, setShares] = useState([directShare])+ const [inheritedAccess, setInheritedAccess] = useState([inheritedEditor])+ removeDirectShare = () => setShares([])+ downgradeInherited = () =>+ setInheritedAccess([{- id: 'file-share-1',- drive: 'main',- resourceId: 'file-1',- subject: { type: 'user', id: 'user-2' },- permissions: ['read', 'write'],- includeDescendants: false,+ ...inheritedEditor,+ permissions: ['read'],+ sources: [{ ...inheritedEditor.sources[0], permissions: ['read'] }],},- ],+ ])+ revokeShare.mockImplementation(async () => {+ removeDirectShare?.()+ })+ return inheritedFileController({+ grants: [],+ shares,+ inheritedAccess,grant: fileGrant,revokeShare,+ refreshShares,})- )+ })renderFilesPage(pushToast)await openManageDialog('report.txt')const manageDialog = await screen.findByRole('dialog', { name: 'Share file report.txt' })// The direct share row is consumed by the deduped merged row.expect(within(manageDialog).queryByTestId('gfs-access-row-share-file-share-1')).toBeNull()- const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user')+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user:user-2')await act(async () => {fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))@@ -1888,6 +1924,14 @@ describe('FilesPage', () => {await waitFor(() =>expect(fileGrant).toHaveBeenCalledWith(['user:user-2'], ['read', 'share'], false))+ await waitFor(() => expect(refreshShares).toHaveBeenCalled())+ await waitFor(() =>+ expect(+ within(screen.getByTestId('gfs-access-row-inherited-user:user-2')).getByRole('button', {+ name: 'Access role for Test Two',+ }).textContent+ ).toContain('Read')+ )expect(pushToast).toHaveBeenCalledWith('Test Two is now Read-only on Team folder and everything inside it','success'@@ -1919,7 +1963,7 @@ describe('FilesPage', () => {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')+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user:user-2')await act(async () => {fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))@@ -1988,7 +2032,7 @@ describe('FilesPage', () => {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')+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user:user-2')// Editor needs write on the parent; this folder cannot grant it.await act(async () => {@@ -2044,7 +2088,7 @@ describe('FilesPage', () => {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')+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user:user-2')await act(async () => {fireEvent.click(within(row).getByRole('button', { name: 'Actions for Test Two' }))@@ -2109,7 +2153,7 @@ describe('FilesPage', () => {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')+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user:user-2')return row}@@ -2287,7 +2331,7 @@ describe('FilesPage', () => {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')+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user:user-2')// The merged row displays the strongest role across sources.expect(within(row).getByRole('button', { name: 'Access role for Test Two' }).textContent@@ -2313,31 +2357,77 @@ 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 () => {+ // bits), the old direct grant must be revoked so it cannot keep masking+ // the parent update.+ it('revokes an unexpressible direct grant and renders the effective role after refresh', async () => {installInheritedDirectoryMocks()const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant- const fileGrant = vi.fn(async () => undefined)+ const editorGrant = {+ id: 'file-editor-grant',+ drive: 'main',+ resourceId: 'file-1',+ subject: { type: 'user', id: 'user-2' },+ permissions: ['read', 'write', 'delete', 'manage_acl', 'share'],+ inherit: false,+ }+ const inheritedEditor = {+ subject: { type: 'user', id: 'user-2' },+ permissions: ['read', 'write'],+ inheritedFrom: ['Team folder'],+ sources: [+ {+ resourceId: 'folder-1',+ name: 'Team folder',+ permissions: ['read', 'write'],+ grantId: 'parent-grant-1',+ shareIds: [],+ },+ ],+ }+ let removeEditorGrant: (() => void) | undefined+ let downgradeInherited: (() => void) | undefined+ parentGrant.mockImplementation(async () => {+ downgradeInherited?.()+ })+ const revokeGrant = vi.fn(async () => {+ removeEditorGrant?.()+ })+ const refreshGrants = vi.fn(async () => undefined)+ const refreshInheritedAccess = vi.fn(async () => undefined)+ const refreshShares = 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({+ hookMock.useGfsBrowserController.mockImplementation(() => {+ const [grants, setGrants] = useState([editorGrant])+ const [inheritedAccess, setInheritedAccess] = useState([inheritedEditor])+ removeEditorGrant = () => setGrants([])+ downgradeInherited = () =>+ setInheritedAccess([+ {+ ...inheritedEditor,+ permissions: ['read'],+ sources: [{ ...inheritedEditor.sources[0], permissions: ['read'] }],+ },+ ])+ return inheritedFileController({+ grants,+ inheritedAccess,affordances: {held: ['read', 'manage_acl'],canDelegate: true,grantableBits: [],canCreateShare: false,},- grant: fileGrant,+ revokeGrant,+ refreshGrants,+ refreshInheritedAccess,+ refreshShares,})- )+ })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')+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user:user-2')await act(async () => {fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))@@ -2360,9 +2450,18 @@ describe('FilesPage', () => {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()+ // The stale direct Editor grant is revoked instead of being left to+ // mask the parent result.+ await waitFor(() => expect(revokeGrant).toHaveBeenCalledWith('file-editor-grant'))+ // The observable merged row now reflects the effective Read role after+ // both the parent and direct surfaces refresh.+ await waitFor(() =>+ expect(+ within(screen.getByTestId('gfs-access-row-inherited-user:user-2')).getByRole('button', {+ name: 'Access role for Test Two',+ }).textContent+ ).toContain('Read')+ )await waitFor(() =>expect(pushToast).toHaveBeenCalledWith('Test Two is now Read-only on Team folder and everything inside it',