Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(ui): med-toasts-partial-coverage qualify role-change toasts under partial coverage
M445f563cbe5c
diff --git a/control-ui/components/GfsGrantPanel.tsx b/control-ui/components/GfsGrantPanel.tsxindex 9251c4eee..12554a5e3 100644--- a/control-ui/components/GfsGrantPanel.tsx+++ b/control-ui/components/GfsGrantPanel.tsx@@ -110,6 +110,26 @@ const ROLE_OPTIONS: SelectionDropdownOption[] = [{ value: 'editor', label: 'Editor' },]+/**+ * 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+ * still grant a stronger role. The success copy then states what was NOT+ * verified instead of promising an effective role the client never proved.+ *+ * The Control UI's role copy ends with a period, so the qualifier brings only+ * its own leading space.+ */+function inheritedCoverageCaveat(coverage: GfsInheritedAccessCoverage, loading: boolean): string {+ if (!loading && coverage === 'complete') return ''+ if (coverage === 'read-boundary') {+ return ' Access through parent folders you cannot see was not verified.'+ }+ if (coverage === 'acl-limited') {+ return ' Access through some parent folders was not verified because their sharing details are not visible to you.'+ }+ return ' Inherited access could not be verified, so access through parent folders you cannot see may still be stronger.'+}+export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Element {const { showToast } = useToast()const { confirm, confirmDialog } = useConfirmDialog()@@ -609,7 +629,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme)} else {showToast(- `${subjectLabel(item)} is now ${nextRole === 'editor' ? 'an Editor' : 'Read-only'}.`,+ `${subjectLabel(item)} is now ${nextRole === 'editor' ? 'an Editor' : 'Read-only'}.${inheritedCoverageCaveat(inheritedAccessCoverage, inheritedAccessLoading)}`,{ tone: 'success' })}@@ -850,8 +870,8 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme} else {showToast(affectedNames.length > 0- ? `${subjectLabel(row)} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${joinFolderNames(affectedNames)} and everything inside ${affectedNames.length > 1 ? 'them' : 'it'}.`- : `${subjectLabel(row)} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${resource.name}.`,+ ? `${subjectLabel(row)} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${joinFolderNames(affectedNames)} and everything inside ${affectedNames.length > 1 ? 'them' : 'it'}.${inheritedCoverageCaveat(inheritedAccessCoverage, inheritedAccessLoading)}`+ : `${subjectLabel(row)} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${resource.name}.${inheritedCoverageCaveat(inheritedAccessCoverage, inheritedAccessLoading)}`,{ tone: 'success' })}diff --git a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsxindex 416347718..2211d3759 100644--- a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx+++ b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx@@ -512,6 +512,47 @@ describe('GfsGrantPanel inherited access', () => {).toBeTruthy()})+ // A role promise is only as good as the coverage it was made under: an+ // ancestor the operator cannot see may still grant Editor, so the success+ // copy must say what was NOT verified instead of promising an effective+ // role.+ it('qualifies the role-change toast when the inherited coverage is incomplete', async () => {+ const actual = await vi.importActual<typeof import('@lib/api')>('@lib/api')+ const text = JSON.stringify({ error: 'request_failed', message: 'parent read failed' })+ const error = actual.formatApiError(new Response(text, { status: 403 }), text)+ mockGetGfsResourceByPath.mockImplementation(async (_drive, path) => {+ if (path === '/team-docs') return byPathView(FOLDER_ID, 'team-docs')+ throw error+ })+ mockGetGfsGrants.mockImplementation(async resourceId => ({+ items:+ resourceId === FILE_ID+ ? [+ {+ id: FILE_GRANT_ID,+ drive: 'main',+ resourceId: FILE_ID,+ subject: marcela,+ permissions: ['read', 'write'],+ inherit: false,+ },+ ]+ : [],+ }))+ renderPanel()++ const existing = await screen.findByRole('region', { name: 'People with access' })+ const row = await within(existing).findByTestId(marcelaRowTestId)+ await chooseRole(row, 'Read')++ await waitFor(() => expect(mockPutGfsGrant).toHaveBeenCalledTimes(1))+ expect(+ await screen.findByText(+ 'Marcela is now Read-only. Access through parent folders you cannot see was not verified.'+ )+ ).toBeTruthy()+ })+// R1-M5 — a share-only DIRECT row is not role-editable: the dropdown is// disabled (no grant would be created by a role change).it('disables the role dropdown for a share-only direct row', async () => {diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex b11bbefa3..fc3116761 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.741",+ "version": "0.1.742","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.741",+ "version": "0.1.742","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 8b868dff4..818b97e0e 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.741",+ "version": "0.1.742","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsxindex f05289ff0..eb1b90399 100644--- a/desktop-app/ui/src/pages/FilesPage.tsx+++ b/desktop-app/ui/src/pages/FilesPage.tsx@@ -63,7 +63,7 @@ import {type GfsDelegationSubjectOption,type GfsGrantListItem,} from '@/gfs/delegation'-import type { GfsInheritedAccessSource } from '@/gfs/delegation.types'+import type { GfsInheritedAccessSource, GfsInheritedCoverageState } from '@/gfs/delegation.types'import { useGfsDragAdjudication } from '@/gfs/dragAdjudication'import type { GfsDragSource, GfsDropRejection, GfsDropVerdict } from '@/gfs/dragSession'import { useGfsDragSession } from '@/gfs/dragSession'@@ -115,6 +115,26 @@ const INHERITED_READ_BOUNDARY_HINT =const INHERITED_ACL_LIMITED_NOTICE ='Sharing details on some parent folders are not visible to you.'+/**+ * A role promise is only as good as the coverage it was made under: when the+ * inherited walk did not complete, an ancestor the user cannot see may still+ * grant a stronger role. The success copy then states what was NOT verified+ * instead of promising an effective role the client never proved.+ *+ * The Desktop's role copy carries no trailing period, so the qualifier+ * brings its own.+ */+function inheritedCoverageCaveat(coverage: GfsInheritedCoverageState | null): string {+ if (coverage === 'complete') return ''+ if (coverage === 'read-boundary') {+ return '. Access through parent folders you cannot see was not verified.'+ }+ if (coverage === 'acl-limited') {+ return '. Access through some parent folders was not verified because their sharing details are not visible to you.'+ }+ return '. Inherited access could not be verified, so access through parent folders you cannot see may still be stronger.'+}+function delegationSubjectOptions(directory: TeamDirectoryResult | undefined): GfsDelegationSubjectOption[] {@@ -703,7 +723,12 @@ export function FilesPage({setUpdatingAccessRole(true)try {await ctrl.grant([subjectKey], bits, item.inherit)- pushToast?.(`${label} is now ${role === 'editor' ? 'an Editor' : 'Read-only'}`, 'success')+ pushToast?.(+ `${label} is now ${role === 'editor' ? 'an Editor' : 'Read-only'}${inheritedCoverageCaveat(+ ctrl.inheritedCoverage+ )}`,+ 'success'+ )await Promise.all([ctrl.refreshGrants(), ctrl.refreshShares()])} catch (roleError) {if (failClosedOnAuthorizationError(roleError)) return@@ -969,8 +994,8 @@ export function FilesPage({} else {pushToast?.(affectedNames.length > 0- ? `${label} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${joinFolderNames(affectedNames)} and everything inside ${affectedNames.length > 1 ? 'them' : 'it'}`- : `${label} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${current?.name ?? 'this file'}`,+ ? `${label} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${joinFolderNames(affectedNames)} and everything inside ${affectedNames.length > 1 ? 'them' : 'it'}${inheritedCoverageCaveat(ctrl.inheritedCoverage)}`+ : `${label} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${current?.name ?? 'this file'}${inheritedCoverageCaveat(ctrl.inheritedCoverage)}`,'success')}diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsxindex e97fe5cb9..da38a9e71 100644--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx@@ -57,6 +57,7 @@ function baseController() {loadingGrants: false,refreshGrants: vi.fn(),inheritedAccess: [],+ inheritedCoverage: 'complete',loadingInheritedAccess: false,refreshInheritedAccess: vi.fn(),revokeGrant: vi.fn(),@@ -3156,6 +3157,71 @@ describe('FilesPage', () => {expect(pushToast).toHaveBeenCalledWith('chatllm is now an Editor', 'success')})+ // A role promise is only as good as the coverage it was made under: an+ // ancestor the user cannot see may still grant Editor, so the success copy+ // must say what was NOT verified instead of promising an effective role.+ it('qualifies the role-change toast when the inherited coverage is incomplete', async () => {+ Object.defineProperty(window, 'clerum', {+ configurable: true,+ value: {+ agents: {+ listMine: vi.fn(async () => [+ {+ name: 'chatllm',+ contextRef: 'ctx-1',+ mcpServers: [],+ gfsSubject: { type: 'host', id: '1st:mcp-host/chatllm' },+ },+ ]),+ },+ team: { directory: vi.fn(async () => ({ currentTeamId: 'team-1', items: [] })) },+ },+ })+ const grant = vi.fn(async () => undefined)+ const pushToast = vi.fn()+ hookMock.useGfsBrowserController.mockReturnValue({+ ...baseController(),+ current: {+ resourceId: 'folder-1',+ gfsUri: 'gfs://main/folder',+ name: 'Team folder',+ kind: 'directory',+ },+ affordances: {+ held: ['read', 'write', 'manage_acl'],+ canDelegate: true,+ grantableBits: ['read', 'write'],+ canCreateShare: false,+ },+ grants: [+ {+ id: 'grant-1',+ drive: 'main',+ resourceId: 'folder-1',+ subject: { type: 'host', id: '1st:mcp-host/chatllm' },+ permissions: ['read'],+ inherit: true,+ },+ ],+ // The inherited walk stopped at a privacy boundary: an ancestor the+ // user cannot see may still grant Editor.+ inheritedCoverage: 'read-boundary',+ grant,+ })++ renderFilesPage(pushToast)+ await openManageDialog('Team folder')+ fireEvent.click(await screen.findByRole('button', { name: 'Access role for chatllm' }))+ fireEvent.click(screen.getByRole('option', { name: 'Editor' }))++ await waitFor(() =>+ expect(pushToast).toHaveBeenCalledWith(+ 'chatllm is now an Editor. Access through parent folders you cannot see was not verified.',+ 'success'+ )+ )+ })+it('lists direct shares in the who-has-access list and revokes them', async () => {Object.defineProperty(window, 'clerum', {configurable: true,