Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): filter directory-less members from who-has-access with an explanation
M5b6f66f525ce
diff --git a/desktop-app/ui/src/gfs/GfsGrantList/index.tsx b/desktop-app/ui/src/gfs/GfsGrantList/index.tsxindex 9af94c84a..dbbca1b95 100644--- a/desktop-app/ui/src/gfs/GfsGrantList/index.tsx+++ b/desktop-app/ui/src/gfs/GfsGrantList/index.tsx@@ -49,66 +49,35 @@ function AccessSubjectIcon({ kind }: { kind: AccessSubjectKind }) {* grants GET (the only revoke-id source: the grant PUT returns no ids). Subject* labels resolve host ids to agent names via the caller's own agent directory* and user/team ids via the visible team directory. A user/team subject outside- * that directory renders as "Hidden user"/"Hidden team" — never a raw UUID —- * and carries a hover explanation (plus the id for support) on the row; no row- * is ever hidden or mislabeled.+ * that directory has no name this surface can act on, so its row is filtered+ * and one muted line explains what isn't listed and why; unresolved host ids+ * keep their raw identifier (the agent tail is meaningful). No row is ever+ * mislabeled, and a filtered list never claims to be empty.*/-const HIDDEN_USER_LABEL = 'Hidden user'-const HIDDEN_TEAM_LABEL = 'Hidden team'--/** The hidden-kind of a user/team subject the visible directory cannot name;- * null when the subject resolves (or is not a directory-resolved kind). */-function hiddenSubjectKind(+/** True when a user/team subject is not in the caller's visible directory —+ * the surface cannot name it, so the row is filtered out. */+function isHiddenSubject(subject:| GfsGrantListItem['subject']| GfsShareListItem['subject']| GfsInheritedAccessItem['subject'],subjects: GfsDelegationSubjectOption[]-): 'user' | 'team' | null {+): boolean {if ((subject.type === 'user' || subject.type === 'team') && subject.id) {- const match = subjects.find(+ return !subjects.some(candidate => candidate.type === subject.type && candidate.id === subject.id)- if (!match) return subject.type}- return null+ return false}-/** One-phrase hover explanation for a subject the directory cannot name. */-function hiddenSubjectTitle(- subject:- | GfsGrantListItem['subject']- | GfsShareListItem['subject']- | GfsInheritedAccessItem['subject'],- subjects: GfsDelegationSubjectOption[]-): string | null {- const kind = hiddenSubjectKind(subject, subjects)- if (kind === 'user' && subject.type === 'user' && subject.id) {- return `This member isn’t in any of your teams, so EvenDrive can’t show their name. (${subject.id})`- }- if (kind === 'team' && subject.type === 'team' && subject.id) {- return `This team isn’t in your team list, so EvenDrive can’t show its name. (${subject.id})`- }- return null-}+/** The muted line under a list that filtered directory-less members. */+const HIDDEN_ACCESS_NOTICE =+ 'Members outside your teams aren’t listed here. Access can also follow from parent folders you cannot see.'-/** Accessible name for a hidden subject: the label alone would collide when a- * folder has more than one hidden member, so the id disambiguates for screen- * readers and menus while the visible row stays clean. */-function subjectAccessibleName(- subject:- | GfsGrantListItem['subject']- | GfsShareListItem['subject']- | GfsInheritedAccessItem['subject'],- subjects: GfsDelegationSubjectOption[],- label: string-): string {- const hidden = hiddenSubjectKind(subject, subjects)- if (!hidden) return label- const id = subject.type === 'user' || subject.type === 'team' ? (subject.id ?? '') : ''- return id ? `${label} (${id})` : label-}+/** Empty state when the filter removed every row. */+const ONLY_HIDDEN_ACCESS_NOTICE = 'Only members outside your teams have access here.'function subjectLabel(subject:@@ -130,7 +99,6 @@ function subjectLabel(candidate => candidate.type === subject.type && candidate.id === subject.id)if (match) return match.label- return subject.type === 'user' ? HIDDEN_USER_LABEL : HIDDEN_TEAM_LABEL}return subject.id ?? subject.type}@@ -175,6 +143,8 @@ export function GfsGrantList({const merged = new Map<string, GfsMergedAccessRow>()if (!mergeInherited) return mergedfor (const inherited of inheritedItems) {+ // A directory-less member has no name this surface can act on.+ if (isHiddenSubject(inherited.subject, subjects)) continueconst key = subjectKey(inherited.subject)const grant = items.find(item => subjectKey(item.subject) === key) ?? nullconst subjectShares = shares.filter(share => subjectKey(share.subject) === key)@@ -193,13 +163,28 @@ export function GfsGrantList({})}return merged- }, [inheritedItems, items, mergeInherited, shares])+ }, [inheritedItems, items, mergeInherited, shares, subjects])// Grants and shares are independent server surfaces with independent// failure modes (R4 spec §2): one list's error suppresses only its own rows// and never the other list's rows or revoke actions.- const showGrantRows = !error && items.length > 0- const showShareRows = !shareError && shares.length > 0+ const visibleItems = error ? [] : items.filter(item => !isHiddenSubject(item.subject, subjects))+ const visibleShares = shareError+ ? []+ : shares.filter(share => !isHiddenSubject(share.subject, subjects))+ // How many rows the filter removed: drives the muted explanation line and+ // the honest empty state (a filtered list never claims to be empty). An+ // errored surface's rows are error-suppressed, not filtered — never count+ // them, or a failure would be reported as a directory gap.+ const hiddenInheritedCount = mergeInherited+ ? inheritedItems.filter(item => isHiddenSubject(item.subject, subjects)).length+ : 0+ const hiddenCount =+ (error ? 0 : items.length - visibleItems.length) ++ (shareError ? 0 : shares.length - visibleShares.length) ++ hiddenInheritedCount+ const showGrantRows = visibleItems.length > 0+ const showShareRows = visibleShares.length > 0// Merged rows are a client-derived supplement: they render whenever the// derivation produced them, including while a direct list failed quietly.const showMergedRows = mergedByKey.size > 0@@ -234,11 +219,9 @@ export function GfsGrantList({{hasRows ? (<ul className="da-gfs-grant-list" aria-label="Resource access">{showGrantRows- ? items.map(item => {+ ? visibleItems.map(item => {if (mergedByKey.has(subjectKey(item.subject))) return nullconst label = subjectLabel(item.subject, agents, subjects)- const accessibleName = subjectAccessibleName(item.subject, subjects, label)- const hiddenTitle = hiddenSubjectTitle(item.subject, subjects)const kind = subjectKind(item.subject)return (<li@@ -254,13 +237,11 @@ export function GfsGrantList({<AccessSubjectIcon kind={kind} /></span><span className="da-gfs-grant-list__identity">- <span className="da-gfs-grant-list__label" title={hiddenTitle ?? undefined}>- {label}- </span>+ <span className="da-gfs-grant-list__label">{label}</span></span><span className="da-gfs-grant-list__meta"><DropdownSelect- ariaLabel={`Access role for ${accessibleName}`}+ ariaLabel={`Access role for ${label}`}className="da-gfs-grant-list__role"disabled={updatingRole || !onChangeRole}onChange={value => void onChangeRole?.(item, label, value as GfsAccessRole)}@@ -272,7 +253,7 @@ export function GfsGrantList({</span><AccessRowMenudisabled={revoking}- label={accessibleName}+ label={label}onRemove={() => onRevoke(item, label)}/></li>@@ -282,8 +263,6 @@ export function GfsGrantList({{showMergedRows? [...mergedByKey.values()].map(row => {const label = subjectLabel(row.subject, agents, subjects)- const accessibleName = subjectAccessibleName(row.subject, subjects, label)- const hiddenTitle = hiddenSubjectTitle(row.subject, subjects)const kind = subjectKind(row.subject)return (<li@@ -300,15 +279,13 @@ export function GfsGrantList({<AccessSubjectIcon kind={kind} /></span><span className="da-gfs-grant-list__identity">- <span className="da-gfs-grant-list__label" title={hiddenTitle ?? undefined}>- {label}- </span>+ <span className="da-gfs-grant-list__label">{label}</span></span><span className="da-gfs-grant-list__meta">{/* Normal toggleable row: any edit opens theparent-folder confirmation in the page. */}<DropdownSelect- ariaLabel={`Access role for ${accessibleName}`}+ ariaLabel={`Access role for ${label}`}className="da-gfs-grant-list__role"disabled={updatingRole || !onChangeInheritedRole}onChange={value =>@@ -322,7 +299,7 @@ export function GfsGrantList({</span><AccessRowMenudisabled={revoking || !onRemoveInherited}- label={accessibleName}+ label={label}onRemove={() => void onRemoveInherited?.(row, label)}/></li>@@ -330,11 +307,9 @@ export function GfsGrantList({}): null}{showShareRows- ? shares.map(item => {+ ? visibleShares.map(item => {if (mergedByKey.has(subjectKey(item.subject))) return nullconst label = subjectLabel(item.subject, agents, subjects)- const accessibleName = subjectAccessibleName(item.subject, subjects, label)- const hiddenTitle = hiddenSubjectTitle(item.subject, subjects)const kind = subjectKind(item.subject)return (<li@@ -350,9 +325,7 @@ export function GfsGrantList({<AccessSubjectIcon kind={kind} /></span><span className="da-gfs-grant-list__identity">- <span className="da-gfs-grant-list__label" title={hiddenTitle ?? undefined}>- {label}- </span>+ <span className="da-gfs-grant-list__label">{label}</span></span><span className="da-gfs-grant-list__meta"><span className="da-gfs-grant-list__role-label">@@ -361,7 +334,7 @@ export function GfsGrantList({</span><AccessRowMenudisabled={revokingShare || !onRevokeShare}- label={accessibleName}+ label={label}onRemove={() => onRevokeShare?.(item, label)}/></li>@@ -369,6 +342,13 @@ export function GfsGrantList({}): null}</ul>+ ) : !hasAnyError && hiddenCount > 0 ? (+ // The filter removed every row: never claim an empty folder.+ loading ? (+ <p className="muted">Loading access…</p>+ ) : (+ <p className="muted">{ONLY_HIDDEN_ACCESS_NOTICE}</p>+ )) : !hasAnyError ? (loading ? (<p className="muted">Loading access…</p>@@ -376,6 +356,9 @@ export function GfsGrantList({<p className="muted">No one has access yet.</p>)) : null}+ {hiddenCount > 0 && !loading && !hasAnyError ? (+ <p className="muted da-gfs-grant-list__hidden-notice">{HIDDEN_ACCESS_NOTICE}</p>+ ) : null}</>)}diff --git a/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx b/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsxindex c866c918b..3b2b13703 100644--- a/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx+++ b/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx@@ -12,15 +12,18 @@ import { mergeInheritedAccessItem } from '../inheritedAccessMerge'/*** "Who has access" list (Manage modal). Rows resolve host subjects to agent* names, user/team subjects through the visible team directory. A user/team- * outside the directory renders as "Hidden user"/"Hidden team" with a hover- * explanation (id included for support) — never a raw UUID in the row, and- * never a hidden row. Unresolved host ids keep their raw identifier. A- * manage_acl_required list failure is an expected state and renders as a- * quiet informational banner, not an error.+ * outside the directory has no name this surface can act on, so its row is+ * filtered and one muted line explains what isn't listed and why; a fully+ * filtered list says so instead of claiming to be empty. Unresolved host ids+ * keep their raw identifier. A manage_acl_required list failure is an+ * expected state and renders as a quiet informational banner, not an error.*/afterEach(cleanup)+const HIDDEN_ACCESS_NOTICE_TEXT =+ 'Members outside your teams aren’t listed here. Access can also follow from parent folders you cannot see.'+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'@@ -102,7 +105,7 @@ describe('GfsGrantList', () => {expect(workflowRow.querySelector('[data-subject-kind="workflow"] svg')).not.toBeNull()})- it('renders directory-less user and team subjects as hidden labels with a hover explanation', () => {+ it('filters directory-less user and team rows and explains what is not listed', () => {render(<GfsGrantListagents={agents}@@ -117,33 +120,54 @@ describe('GfsGrantList', () => {subject: { type: 'team', id: 'team-outside-directory' },permissions: ['read'],}),+ grantItem({+ id: 'grant-resolved',+ subject: { type: 'user', id: 'user-2' },+ permissions: ['read'],+ }),]}onRevoke={vi.fn()}subjects={subjects}/>)- const hiddenUserLabel = screen.getByText('Hidden user')+ // Directory-less members never render — not as rows, not as raw ids.+ expect(screen.queryByText('Hidden user')).toBeNull()+ expect(screen.queryByText('Hidden team')).toBeNull()expect(screen.queryByText('user-outside-directory')).toBeNull()- expect(hiddenUserLabel.getAttribute('title')).toBe(- 'This member isn’t in any of your teams, so EvenDrive can’t show their name. (user-outside-directory)'- )- // The accessible name keeps the id so multiple hidden members stay distinct.- expect(- screen.getByRole('button', { name: 'Access role for Hidden user (user-outside-directory)' })- ).toBeTruthy()- expect(- screen.getByRole('button', { name: 'Actions for Hidden user (user-outside-directory)' })- ).toBeTruthy()-- const hiddenTeamLabel = screen.getByText('Hidden team')expect(screen.queryByText('team-outside-directory')).toBeNull()- expect(hiddenTeamLabel.getAttribute('title')).toBe(- 'This team isn’t in your team list, so EvenDrive can’t show its name. (team-outside-directory)'+ expect(screen.queryByTestId('gfs-access-row-grant-grant-hidden-user')).toBeNull()+ expect(screen.queryByTestId('gfs-access-row-grant-grant-hidden-team')).toBeNull()+ // Resolved members stay, with no tooltip machinery.+ expect(screen.getByText('Test Two')).toBeTruthy()+ expect(screen.getByText('Test Two').getAttribute('title')).toBeNull()+ // The muted line explains the filtering once.+ expect(screen.getAllByText(HIDDEN_ACCESS_NOTICE_TEXT)).toHaveLength(1)+ })++ it('never claims an empty folder when the filter removed every row', () => {+ render(+ <GfsGrantList+ agents={agents}+ items={[+ grantItem({+ id: 'grant-hidden-user',+ subject: { type: 'user', id: 'user-outside-directory' },+ permissions: ['read'],+ }),+ ]}+ onRevoke={vi.fn()}+ subjects={subjects}+ />)- // A resolved subject carries no hover explanation.- const resolvedRow = render(+ expect(screen.queryByText('No one has access yet.')).toBeNull()+ expect(screen.getByText('Only members outside your teams have access here.')).toBeTruthy()+ expect(screen.getAllByText(HIDDEN_ACCESS_NOTICE_TEXT)).toHaveLength(1)+ })++ it('shows no hidden-members notice when every subject resolves', () => {+ render(<GfsGrantListagents={agents}items={[@@ -156,8 +180,10 @@ describe('GfsGrantList', () => {onRevoke={vi.fn()}subjects={subjects}/>- ).getByText('Test Two')!- expect(resolvedRow.getAttribute('title')).toBeNull()+ )++ expect(screen.queryByText(HIDDEN_ACCESS_NOTICE_TEXT)).toBeNull()+ expect(screen.getByText('Test Two')).toBeTruthy()})it('labels a host subject by its displayName, falling back to the identifier when blank', () => {@@ -373,7 +399,10 @@ describe('GfsGrantList', () => {onChangeInheritedRole={vi.fn()}onRemoveInherited={vi.fn()}onRevoke={vi.fn()}- subjects={subjects}+ subjects={[+ ...subjects,+ { type: 'user' as const, id: 'user-3', label: 'Test Three', description: 't3' },+ ]}/>)diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsxindex c1a1c60e8..c1bbd1158 100644--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx@@ -3285,7 +3285,18 @@ describe('FilesPage', () => {configurable: true,value: {agents: { listMine: vi.fn(async () => []) },- team: { directory: vi.fn(async () => ({ currentTeamId: 'team-1', items: [] })) },+ team: {+ directory: vi.fn(async () => ({+ currentTeamId: 'team-1',+ items: [+ {+ team: { id: 'team-1', name: 'Core Team' },+ role: 'admin',+ members: [{ id: 'user-9', name: 'Shared Member', email: '[email protected]' }],+ },+ ],+ })),+ },},})const revokeShare = vi.fn(async () => undefined)@@ -3323,16 +3334,64 @@ describe('FilesPage', () => {const shareRow = await screen.findByTestId('gfs-access-row-share-share-1')expect(shareRow.textContent).not.toContain('Includes contents')- // A share subject outside the visible team directory renders as a hidden- // label (never a raw UUID); the accessible name keeps the id distinct.- expect(screen.getByText('Hidden user')).toBeTruthy()- fireEvent.click(screen.getByRole('button', { name: 'Actions for Hidden user (user-9)' }))+ // A share whose subject resolves through the team directory lists the name.+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Shared Member' }))fireEvent.click(screen.getByRole('menuitem', { name: 'Remove access' }))await waitFor(() => expect(revokeShare).toHaveBeenCalledWith('share-1'))await waitFor(() =>- expect(pushToast).toHaveBeenCalledWith('Shared access revoked for Hidden user', 'success')+ expect(pushToast).toHaveBeenCalledWith('Shared access revoked for Shared Member', 'success')+ )+ })++ it('filters a directory-less share from the who-has-access list and explains why', async () => {+ Object.defineProperty(window, 'clerum', {+ configurable: true,+ value: {+ agents: { listMine: vi.fn(async () => []) },+ team: { directory: vi.fn(async () => ({ currentTeamId: 'team-1', items: [] })) },+ },+ })+ const revokeShare = vi.fn(async () => undefined)+ hookMock.useGfsBrowserController.mockReturnValue({+ ...baseController(),+ current: {+ resourceId: 'folder-1',+ gfsUri: 'gfs://main/folder',+ name: 'Team folder',+ kind: 'directory',+ },+ affordances: {+ held: ['read', 'manage_acl'],+ canDelegate: true,+ grantableBits: ['read'],+ canCreateShare: true,+ },+ grants: [],+ shares: [+ {+ id: 'share-1',+ drive: 'main',+ resourceId: 'folder-1',+ subject: { type: 'user', id: 'user-outside' },+ permissions: ['read'],+ includeDescendants: true,+ },+ ],+ revokeShare,+ })++ renderFilesPage()+ await openManageDialog('Team folder')++ // The directory-less member never renders — the muted line explains why+ // and the empty state never claims the folder has no access.+ await screen.findByText(+ 'Members outside your teams aren’t listed here. Access can also follow from parent folders you cannot see.')+ expect(screen.queryByTestId('gfs-access-row-share-share-1')).toBeNull()+ expect(screen.queryByText('user-outside')).toBeNull()+ expect(screen.getByText('Only members outside your teams have access here.')).toBeTruthy()})it('renders the fail-closed state when GFS access is revoked and retries on demand', async () => {