Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(ui): med-consent-effective-role disclose surviving Editor shares before the confirmation
M6baed6998c6a
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.cssindex 2ce73579c..7bf30c4a1 100644--- a/control-ui/app/globals.css+++ b/control-ui/app/globals.css@@ -14362,6 +14362,14 @@ button.cu-gfs-tree__button:focus-visible,color: var(--cu-text);}+/* R1-M5: the confirmation states the surviving Editor shares BEFORE the+ operator approves, not only in the post-change toast. */+.cu-gfs-parent-update__residual {+ margin: 0;+ color: var(--cu-text-muted);+ font-size: var(--cu-font-size-sm);+}+.cu-gfs-parent-update__help {display: grid;gap: var(--cu-space-2);diff --git a/control-ui/components/GfsGrantPanel.tsx b/control-ui/components/GfsGrantPanel.tsxindex 12554a5e3..b6307f130 100644--- a/control-ui/components/GfsGrantPanel.tsx+++ b/control-ui/components/GfsGrantPanel.tsx@@ -110,6 +110,29 @@ const ROLE_OPTIONS: SelectionDropdownOption[] = [{ value: 'editor', label: 'Editor' },]+/**+ * Folders whose SHARING entries still grant Editor after a downgrade (R1-M5):+ * a role change rewrites the folder's GRANT row only, so a share row survives+ * it and the member keeps Editor through it. The confirmation discloses these+ * BEFORE the operator approves; the post-change toast repeats the disclosure.+ */+function collectResidualEditorFolderNames(+ sources: readonly GfsInheritedAccessSource[],+ directShareEntries: readonly { permissions: string[] }[],+ directName: string+): string[] {+ return [+ ...new Set([+ ...sources+ .filter(source => source.shareEntries.some(entry => isEditorPermissions(entry.permissions)))+ .map(source => source.name),+ ...(directShareEntries.some(entry => isEditorPermissions(entry.permissions))+ ? [directName]+ : []),+ ]),+ ]+}+/*** A role promise is only as good as the coverage it was made under: when the* inherited walk did not complete, an ancestor the operator cannot see may@@ -186,6 +209,8 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme/** Grant-backed folders skipped because their own scope flag was* unknown — never written with a defaulted scope (R1-M5). */skippedFolderNames: string[]+ /** Folders whose sharing entries still grant Editor after the change. */+ residualEditorFolderNames: string[]}| { row: GfsFileAccessRow; mode: 'remove' }| null@@ -598,18 +623,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme// remains, the effective role claim must say so.const residualNames =nextRole === 'read'- ? [- ...new Set([- ...inheritedSources- .filter(source =>- source.shareEntries.some(entry => isEditorPermissions(entry.permissions))- )- .map(source => source.name),- ...(item.shareEntries.some(entry => isEditorPermissions(entry.permissions))- ? [resource.name]- : []),- ]),- ]+ ? collectResidualEditorFolderNames(inheritedSources, item.shareEntries, resource.name): []const details: string[] = []if (skippedFolderNames.length > 0) {@@ -705,6 +719,16 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Elemeaffected: updates,residualSources: plan.shareOnlySources,skippedFolderNames,+ // The surviving Editor shares are disclosed IN the confirmation, before+ // the operator approves a role that will not remove them.+ residualEditorFolderNames:+ nextRole === 'read'+ ? collectResidualEditorFolderNames(+ [...plan.shareOnlySources, ...writable],+ row.direct?.shareEntries ?? [],+ resource.name+ )+ : [],})}@@ -838,18 +862,11 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme// Read-only while a surviving share entry still grants Editor.const residualNames =request.nextRole === 'read'- ? [- ...new Set([- ...[...request.residualSources, ...affected.map(update => update.source)]- .filter(source =>- source.shareEntries.some(entry => isEditorPermissions(entry.permissions))- )- .map(source => source.name),- ...(row.direct?.shareEntries.some(entry => isEditorPermissions(entry.permissions))- ? [resource.name]- : []),- ]),- ]+ ? collectResidualEditorFolderNames(+ [...request.residualSources, ...affected.map(update => update.source)],+ row.direct?.shareEntries ?? [],+ resource.name+ ): []const details: string[] = []if (request.skippedFolderNames.length > 0) {@@ -1085,6 +1102,14 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme})),fileCurrentRole: roleForPermissions(parentUpdate.row.permissions),nextRole: parentUpdate.mode === 'change-role' ? parentUpdate.nextRole : undefined,+ // The surviving Editor shares are disclosed BEFORE the+ // operator approves: the effective role this dialog shows is+ // not the whole truth, and only the post-change toast used to+ // say so.+ ...(parentUpdate.mode === 'change-role' &&+ parentUpdate.residualEditorFolderNames.length > 0+ ? { residualEditorFolderNames: parentUpdate.residualEditorFolderNames }+ : {}),}: null}diff --git a/control-ui/components/GfsInheritedAccessDialog/index.tsx b/control-ui/components/GfsInheritedAccessDialog/index.tsxindex 0189b2491..ed973d7cb 100644--- a/control-ui/components/GfsInheritedAccessDialog/index.tsx+++ b/control-ui/components/GfsInheritedAccessDialog/index.tsx@@ -135,6 +135,12 @@ export function GfsInheritedAccessDialog({</span></div></div>+ {request.residualEditorFolderNames && request.residualEditorFolderNames.length > 0 ? (+ <p className="cu-gfs-parent-update__residual">+ Sharing entries on {request.residualEditorFolderNames.join(', ')} still grant Editor+ access. This change does not remove them.+ </p>+ ) : null}</>)}<div className="cu-modal-panel__foot">diff --git a/control-ui/components/GfsInheritedAccessDialog/types.ts b/control-ui/components/GfsInheritedAccessDialog/types.tsindex 657a001b5..c90974d83 100644--- a/control-ui/components/GfsInheritedAccessDialog/types.ts+++ b/control-ui/components/GfsInheritedAccessDialog/types.ts@@ -22,6 +22,14 @@ export type GfsInheritedAccessDialogRequest = {fileCurrentRole: GfsInheritedAccessRole/** change-role: the role that will replace the folders'/file's current role. */nextRole?: GfsInheritedAccessRole+ /**+ * Folders whose SHARING entries still grant Editor after this change. A+ * role change rewrites the folder's GRANT row only (R1-M5); a share row+ * survives it, so the member keeps Editor through it. The confirmation says+ * so BEFORE the user approves — the effective role it shows is not the whole+ * truth, and only the post-change toast used to say so.+ */+ residualEditorFolderNames?: string[]}export interface GfsInheritedAccessDialogProps {diff --git a/control-ui/components/GfsMoveConfirmDialog/index.tsx b/control-ui/components/GfsMoveConfirmDialog/index.tsxindex e0d85a3f2..0a3b7b0cc 100644--- a/control-ui/components/GfsMoveConfirmDialog/index.tsx+++ b/control-ui/components/GfsMoveConfirmDialog/index.tsx@@ -66,7 +66,8 @@ export function GfsMoveConfirmDialog({<div className="cu-gfs-move-confirm__body"><p className="cu-gfs-move-confirm__impact">Inherited access to this folder and its contents follows the new location. Direct- sharing entries stay with their items, and grantees may lose access.+ sharing entries stay with their items — including any access they grant — and grantees+ may lose access.</p>{request.canRename ? (<label className="cu-gfs-move-confirm__rename-toggle">diff --git a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsxindex 2211d3759..6ad328f29 100644--- a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx+++ b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx@@ -459,6 +459,55 @@ describe('GfsGrantPanel inherited access', () => {).toBeTruthy()})+ // R1-M5 — a role change rewrites the folder's GRANT row only; the folder's+ // SHARE row survives it, so the member keeps Editor through it. The+ // confirmation must disclose that BEFORE the operator approves.+ it('discloses the surviving Editor share in the confirmation before anything is applied', async () => {+ const FOLDER_SHARE_ID = '77777777-7777-4777-8777-777777777777'+ mockGetGfsGrants.mockImplementation(async resourceId => ({+ items:+ resourceId === FOLDER_ID+ ? [+ {+ id: FOLDER_GRANT_ID,+ drive: 'main',+ resourceId: FOLDER_ID,+ subject: miguel,+ permissions: ['read', 'write'],+ inherit: true,+ },+ ]+ : [],+ }))+ mockGetGfsShares.mockImplementation(async resourceId => ({+ items:+ resourceId === FOLDER_ID+ ? [+ {+ id: FOLDER_SHARE_ID,+ drive: 'main',+ resourceId: FOLDER_ID,+ subject: miguel,+ permissions: ['read', 'write'],+ includeDescendants: true,+ },+ ]+ : [],+ }))+ renderPanel()++ const existing = await screen.findByRole('region', { name: 'People with access' })+ const miguelRow = await within(existing).findByTestId(miguelRowTestId)+ await chooseRole(miguelRow, 'Read')++ const dialog = await screen.findByRole('alertdialog')+ expect(+ within(dialog).getByText(+ 'Sharing entries on team-docs still grant Editor access. This change does not remove them.'+ )+ ).toBeTruthy()+ })+it('discloses inherited Editor shares when only a direct grant can be changed', async () => {mockGetGfsGrants.mockImplementation(async resourceId => ({items:diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex fc3116761..bfdb09b07 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.742",+ "version": "0.1.743","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.742",+ "version": "0.1.743","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 818b97e0e..e7ee9b82e 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.742",+ "version": "0.1.743","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/index.tsx b/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/index.tsxindex 51a818e61..03544d280 100644--- a/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/index.tsx+++ b/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/index.tsx@@ -126,6 +126,12 @@ export function GfsInheritedAccessDialog({</span></div></div>+ {request.residualEditorFolderNames && request.residualEditorFolderNames.length > 0 ? (+ <p className="da-gfs-parent-update-dialog__residual">+ Sharing entries on {request.residualEditorFolderNames.join(', ')} still grant+ Editor access. This change does not remove them.+ </p>+ ) : null}</>)}</div>diff --git a/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/types.ts b/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/types.tsindex cf11d7260..7aa498cd7 100644--- a/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/types.ts+++ b/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/types.ts@@ -23,6 +23,14 @@ export type GfsInheritedAccessDialogRequest = {fileCurrentRole: GfsInheritedAccessRole/** change-role: the role that will replace the folders'/file's current role. */nextRole?: GfsInheritedAccessRole+ /**+ * Folders whose SHARING entries still grant Editor after this change. A+ * role change rewrites the folder's GRANT row only (R1-M5); a share row+ * survives it, so the member keeps Editor through it. The confirmation+ * says so BEFORE the user approves — the effective role it shows is not the+ * whole truth, and only the post-change toast used to say so.+ */+ residualEditorFolderNames?: string[]}export interface GfsInheritedAccessDialogProps {diff --git a/desktop-app/ui/src/gfs/moveConfirmDialog.tsx b/desktop-app/ui/src/gfs/moveConfirmDialog.tsxindex 2f5ca5ace..5bad992e2 100644--- a/desktop-app/ui/src/gfs/moveConfirmDialog.tsx+++ b/desktop-app/ui/src/gfs/moveConfirmDialog.tsx@@ -71,7 +71,8 @@ export function GfsMoveConfirmDialog({<div className="da-gfs-manage-dialog__body"><p className="da-gfs-move-confirm-dialog__impact">Inherited access to this folder and its contents follows the new location. Direct- sharing entries stay with their items, and you may lose access.+ sharing entries stay with their items — including any access they grant — and you may+ lose access.</p>{request.canRename ? (<label className="da-gfs-move-confirm-dialog__rename-toggle">diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsxindex eb1b90399..147fb8049 100644--- a/desktop-app/ui/src/pages/FilesPage.tsx+++ b/desktop-app/ui/src/pages/FilesPage.tsx@@ -135,6 +135,31 @@ function inheritedCoverageCaveat(coverage: GfsInheritedCoverageState | null): streturn '. Inherited access could not be verified, so access through parent folders you cannot see may still be stronger.'}+/**+ * Folders whose SHARING entries still grant Editor after a downgrade (R1-M5):+ * a role change rewrites the folder's GRANT row only, so a share row survives+ * it and the member keeps Editor through it. The confirmation discloses these+ * BEFORE the user approves; the post-change toast repeats the disclosure.+ */+function collectResidualEditorFolderNames(+ sources: readonly GfsInheritedAccessSource[],+ directShares: readonly { permissions: string[] }[],+ directName: string+): string[] {+ return [+ ...new Set([+ ...sources+ .filter(source =>+ source.shareEntries.some(entry => isEditorGfsPermissions(entry.permissions))+ )+ .map(source => source.name),+ ...(directShares.some(share => isEditorGfsPermissions(share.permissions))+ ? [directName]+ : []),+ ]),+ ]+}+function delegationSubjectOptions(directory: TeamDirectoryResult | undefined): GfsDelegationSubjectOption[] {@@ -305,6 +330,8 @@ export function FilesPage({updates: Array<{ source: GfsInheritedAccessSource; bits: string[] }>residualSources: GfsInheritedAccessSource[]skippedFolderNames: string[]+ /** Folders whose sharing entries still grant Editor after the change. */+ residualEditorFolderNames: string[]}| { row: GfsMergedAccessRow; label: string; mode: 'remove' }| null@@ -774,6 +801,14 @@ export function FilesPage({updates: [],residualSources: plan.shareOnlySources,skippedFolderNames,+ residualEditorFolderNames:+ role === 'read'+ ? collectResidualEditorFolderNames(+ plan.shareOnlySources,+ row.shares,+ current?.name ?? 'this file'+ )+ : [],})return}@@ -829,6 +864,16 @@ export function FilesPage({updates,residualSources: plan.shareOnlySources,skippedFolderNames,+ // The surviving Editor shares are disclosed IN the confirmation, before+ // the user approves a role that will not remove them.+ residualEditorFolderNames:+ role === 'read'+ ? collectResidualEditorFolderNames(+ [...plan.shareOnlySources, ...writable],+ row.shares,+ current?.name ?? 'this file'+ )+ : [],})}@@ -967,18 +1012,11 @@ export function FilesPage({// Read-only while a surviving share entry still grants Editor.const residualNames =request.nextRole === 'read'- ? [- ...new Set([- ...[...request.residualSources, ...updates.map(update => update.source)]- .filter(source =>- source.shareEntries.some(entry => isEditorGfsPermissions(entry.permissions))- )- .map(source => source.name),- ...(request.row.shares.some(share => isEditorGfsPermissions(share.permissions))- ? [current?.name ?? 'this item']- : []),- ]),- ]+ ? collectResidualEditorFolderNames(+ [...request.residualSources, ...updates.map(update => update.source)],+ request.row.shares,+ current?.name ?? 'this item'+ ): []const residualMessage =residualNames.length > 0@@ -2583,6 +2621,13 @@ export function FilesPage({})),fileCurrentRole: roleForAccessPermissions(parentUpdate.row.permissions),nextRole: parentUpdate.mode === 'change-role' ? parentUpdate.nextRole : undefined,+ // The surviving Editor shares are disclosed BEFORE the user+ // approves: the effective role this dialog shows is not the+ // whole truth, and only the post-change toast used to say so.+ ...(parentUpdate.mode === 'change-role' &&+ parentUpdate.residualEditorFolderNames.length > 0+ ? { residualEditorFolderNames: parentUpdate.residualEditorFolderNames }+ : {}),}: null}diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsxindex da38a9e71..b5dd6cb02 100644--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx@@ -1985,6 +1985,63 @@ describe('FilesPage', () => {expect(within(manageDialog).queryByText(/cannot see\./)).toBeNull()})+ it('discloses the surviving Editor share in the confirmation before anything is applied', async () => {+ // R1-M5: a role change rewrites the folder's GRANT row only; the folder's+ // SHARE row survives it, so the member keeps Editor through it. The+ // confirmation shows the effective role it is about to promise — it must+ // also say what survives, BEFORE the operator approves.+ installInheritedDirectoryMocks()+ const pushToast = vi.fn()+ hookMock.useGfsBrowserController.mockReturnValue(+ inheritedFileController({+ inheritedAccess: [+ {+ 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: ['parent-share-1'],+ grantPermissions: ['read', 'write'],+ grantInherit: true,+ shareEntries: [+ {+ rowId: 'parent-share-1',+ permissions: ['read', 'write'],+ includeDescendants: true,+ },+ ],+ },+ ],+ },+ ],+ })+ )++ 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:user-2')++ 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')+ expect(+ within(confirmDialog).getByText(+ 'Sharing entries on Team folder still grant Editor access. This change does not remove them.'+ )+ ).toBeTruthy()+ })+it('confirms an inherited role change against the parent folder and applies it there', async () => {installInheritedDirectoryMocks()const parentGrant = (window.clerum.gfs as unknown as { grant: ReturnType<typeof vi.fn> }).grantdiff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.cssindex 94b7573e0..a945a6afc 100644--- a/desktop-app/ui/src/styles.css+++ b/desktop-app/ui/src/styles.css@@ -16893,6 +16893,14 @@ pre {color: var(--text);}+/* R1-M5: the confirmation states the surviving Editor shares BEFORE the+ user approves, not only in the post-change toast. */+.da-gfs-parent-update-dialog__residual {+ margin: 0;+ color: var(--text-muted);+ font-size: var(--font-size-sm);+}+.da-gfs-parent-update-dialog__help {display: grid;gap: var(--space-2);