Skip to content

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

TypeScript

feat(evendrive): inherited file permissions with parent-folder update flow

M6d28ae41fabf
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.css
index 969231f0c..87159e90f 100644
--- a/control-ui/app/globals.css
+++ b/control-ui/app/globals.css
@@ -13899,19 +13899,76 @@ button.cu-gfs-tree__button:focus-visible,
font-weight: 500;
}
-.cu-gfs-existing-access__item--inherited .cu-gfs-existing-access__subject {
- color: var(--cu-text-soft);
- font-weight: 400;
+/* Parent-folder confirmation for inherited access rows (Share dialog). */
+.cu-gfs-parent-update {
+ width: min(34rem, calc(100vw - (var(--cu-space-4) * 2)));
+}
+
+.cu-gfs-parent-update__learn-more {
+ padding: 0;
+ border: none;
+ background: none;
+ color: var(--cu-link);
+ font: inherit;
+ text-decoration: underline;
+ text-underline-offset: 0.2em;
+ cursor: pointer;
+}
+
+.cu-gfs-parent-update__learn-more:focus-visible {
+ outline: 2px solid var(--cu-focus);
+ outline-offset: 2px;
+}
+
+.cu-gfs-parent-update__columns {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: var(--cu-space-2);
+}
+
+.cu-gfs-parent-update__column {
+ display: grid;
+ gap: var(--cu-space-05);
+ padding: var(--cu-space-2);
+ border: 1px solid var(--cu-border-subtle);
+ border-radius: var(--cu-radius-sm);
+ background: var(--cu-bg-subtle);
}
-.cu-gfs-existing-access__inherited-from {
+.cu-gfs-parent-update__name {
overflow: hidden;
- color: var(--cu-text-muted);
- font-size: var(--cu-font-size-xs);
+ color: var(--cu-text);
+ font-size: var(--cu-font-size-md);
+ font-weight: 500;
text-overflow: ellipsis;
white-space: nowrap;
}
+.cu-gfs-parent-update__change {
+ display: flex;
+ align-items: center;
+ gap: var(--cu-space-1);
+ color: var(--cu-text-muted);
+ font-size: var(--cu-font-size-sm);
+}
+
+.cu-gfs-parent-update__role {
+ color: var(--cu-text-soft);
+ font-weight: 500;
+}
+
+.cu-gfs-parent-update__role--next {
+ color: var(--cu-text);
+}
+
+.cu-gfs-parent-update__help {
+ display: grid;
+ gap: var(--cu-space-2);
+ margin: 0;
+ padding-inline-start: 1.25rem;
+ color: var(--cu-text-muted);
+}
+
.cu-gfs-existing-access__chips {
display: inline-flex;
flex-wrap: wrap;
diff --git a/control-ui/components/GfsGrantPanel.tsx b/control-ui/components/GfsGrantPanel.tsx
index 3ee114973..9ee85cd14 100644
--- a/control-ui/components/GfsGrantPanel.tsx
+++ b/control-ui/components/GfsGrantPanel.tsx
@@ -3,6 +3,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { RecordList, RecordListRow, RowActionMenu } from '@clerum/frontend-components'
import { useConfirmDialog } from '@components/ConfirmDialog'
+import { GfsInheritedAccessDialog } from '@components/GfsInheritedAccessDialog'
import { GfsSubjectPicker } from '@components/GfsSubjectPicker'
import { SelectionDropdown } from '@components/SelectionDropdown'
import type { SelectionDropdownOption } from '@components/SelectionDropdown/types'
@@ -34,8 +35,14 @@ import {
getRecipes,
putGfsGrant,
} from '@lib/api'
-import type { GfsExistingAccessItem, GfsGrantPanelProps } from './GfsGrantPanel.types'
+import type {
+ GfsExistingAccessItem,
+ GfsFileAccessRow,
+ GfsGrantPanelProps,
+ GfsInheritedAccessItem,
+} from './GfsGrantPanel.types'
import { buildGfsBulkSubjectOptions, toGfsBulkSubjectInputs } from './gfsGrantSubjectOptions'
+import { loadGfsInheritedAccess } from './gfsInheritedAccess'
/**
* P4-S07 — Operator delegation panel for the Global File System. The operator
@@ -113,7 +120,22 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme
const [existingAccessError, setExistingAccessError] = useState('')
const existingAccessRequest = useRef(0)
const existingAccessController = useRef<AbortController | null>(null)
+ // Inherited access is derived separately: it comes from ancestor folders,
+ // not from this resource's direct grant/share rows. Only FILE dialogs use
+ // the derivation — folder dialogs keep their direct-only behavior.
+ const [inheritedAccess, setInheritedAccess] = useState<GfsInheritedAccessItem[]>([])
+ const [inheritedAccessLoading, setInheritedAccessLoading] = useState(true)
+ const inheritedAccessRequest = useRef(0)
+ const inheritedAccessController = useRef<AbortController | null>(null)
+ // Pending parent-folder confirmation (role change or removal) for a member
+ // whose access is inherited from an ancestor folder.
+ const [parentUpdate, setParentUpdate] = useState<
+ | { row: GfsFileAccessRow; mode: 'change-role'; nextRole: AccessRole }
+ | { row: GfsFileAccessRow; mode: 'remove' }
+ | null
+ >(null)
const canIncludeDescendants = resource.kind === 'directory'
+ const resourceIsFile = resource.kind === 'file'
const loadExistingAccess = useCallback(async () => {
existingAccessController.current?.abort()
@@ -177,6 +199,42 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme
}
}, [loadExistingAccess])
+ const loadInheritedAccess = useCallback(async () => {
+ inheritedAccessController.current?.abort()
+ const requestId = ++inheritedAccessRequest.current
+ if (!resourceIsFile || !resource.path) {
+ inheritedAccessController.current = null
+ setInheritedAccess([])
+ setInheritedAccessLoading(false)
+ return
+ }
+ const controller = new AbortController()
+ inheritedAccessController.current = controller
+ setInheritedAccessLoading(true)
+ try {
+ const items = await loadGfsInheritedAccess(resource.path, DRIVE, controller.signal)
+ if (requestId !== inheritedAccessRequest.current) return
+ setInheritedAccess(items)
+ } catch {
+ if (requestId !== inheritedAccessRequest.current) return
+ setInheritedAccess([])
+ } finally {
+ if (requestId === inheritedAccessRequest.current) {
+ inheritedAccessController.current = null
+ setInheritedAccessLoading(false)
+ }
+ }
+ }, [resource.path, resourceIsFile])
+
+ useEffect(() => {
+ void loadInheritedAccess()
+ return () => {
+ inheritedAccessController.current?.abort()
+ inheritedAccessController.current = null
+ inheritedAccessRequest.current += 1
+ }
+ }, [loadInheritedAccess])
+
useEffect(() => {
let active = true
@@ -323,7 +381,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme
}
const subjectLabel = useCallback(
- (item: GfsExistingAccessItem): string => {
+ (item: { subject: GfsSubjectInput }): string => {
if (item.subject.type === 'operator') return 'Operator'
const option = bulkSubjectOptions.find(
candidate =>
@@ -340,7 +398,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme
)
const subjectKind = useCallback(
- (item: GfsExistingAccessItem): AccessSubjectKind => {
+ (item: { subject: GfsSubjectInput }): AccessSubjectKind => {
if (item.subject.type !== 'host') return item.subject.type
const option = bulkSubjectOptions.find(
candidate =>
@@ -353,18 +411,53 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme
[bulkSubjectOptions]
)
+ const bySubjectLabel = useCallback(
+ (left: { subject: GfsSubjectInput }, right: { subject: GfsSubjectInput }): number =>
+ subjectLabel(left).localeCompare(subjectLabel(right), undefined, {
+ numeric: true,
+ sensitivity: 'base',
+ }) || subjectKey(left.subject).localeCompare(subjectKey(right.subject)),
+ [subjectLabel]
+ )
+
const sortedExistingAccess = useMemo(
- () =>
- [...existingAccess].sort(
- (left, right) =>
- subjectLabel(left).localeCompare(subjectLabel(right), undefined, {
- numeric: true,
- sensitivity: 'base',
- }) || subjectKey(left.subject).localeCompare(subjectKey(right.subject))
- ),
- [existingAccess, subjectLabel]
+ () => [...existingAccess].sort(bySubjectLabel),
+ [bySubjectLabel, existingAccess]
)
+ // File dialogs dedupe to exactly one row per member across direct grants
+ // and inherited ancestor grants; the effective role is the strongest.
+ const sortedFileAccessRows = useMemo<GfsFileAccessRow[]>(() => {
+ if (!resourceIsFile) return []
+ const bySubjectRow = new Map<string, GfsFileAccessRow>()
+ for (const direct of existingAccess) {
+ bySubjectRow.set(subjectKey(direct.subject), {
+ subject: direct.subject,
+ permissions: [...direct.permissions],
+ direct,
+ inherited: null,
+ })
+ }
+ for (const inherited of inheritedAccess) {
+ const key = subjectKey(inherited.subject)
+ const existingRow = bySubjectRow.get(key)
+ if (existingRow) {
+ existingRow.inherited = inherited
+ existingRow.permissions = [
+ ...new Set([...existingRow.permissions, ...inherited.permissions]),
+ ]
+ } else {
+ bySubjectRow.set(key, {
+ subject: inherited.subject,
+ permissions: [...inherited.permissions],
+ direct: null,
+ inherited,
+ })
+ }
+ }
+ return [...bySubjectRow.values()].sort(bySubjectLabel)
+ }, [bySubjectLabel, existingAccess, inheritedAccess, resourceIsFile])
+
async function revokeAccess(item: GfsExistingAccessItem) {
const label = subjectLabel(item)
const confirmed = await confirm({
@@ -426,6 +519,80 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme
}
}
+ /** Concurrent removal already did the work — treat those verdicts as success. */
+ function isAlreadyMissing(caught: unknown): boolean {
+ const accessError = caught as GfsGrantError
+ return (
+ accessError.status === 404 &&
+ (accessError.code === 'grant_not_found' || accessError.code === 'share_not_found')
+ )
+ }
+
+ /**
+ * Confirmed edit of an inherited row: the change is applied to the parent
+ * folder that configures the access (its grant cascades to everything
+ * inside), and the file's own direct rows are aligned so they cannot mask
+ * the chosen role. Cancel never reaches this path — the dropdown reverts.
+ */
+ async function confirmParentUpdate() {
+ const request = parentUpdate
+ if (!request) return
+ const row = request.row
+ const inherited = row.inherited
+ if (!inherited) {
+ setParentUpdate(null)
+ return
+ }
+ const source = inherited.source
+ setParentUpdate(null)
+ setBusy(true)
+ setError('')
+ const reload = async () => {
+ await Promise.all([loadExistingAccess(), loadInheritedAccess()])
+ }
+ try {
+ if (request.mode === 'change-role') {
+ const permissions = rolePermissions(request.nextRole, hostOnlySubject(row.subject))
+ await putGfsGrant({
+ drive: DRIVE,
+ resourceId: source.resourceId,
+ subject: row.subject,
+ permissions,
+ inherit: true,
+ })
+ for (const shareId of source.shareIds) await deleteGfsShare(shareId)
+ if (row.direct) {
+ await putGfsGrant({
+ drive: DRIVE,
+ resourceId: resource.resourceId,
+ subject: row.subject,
+ permissions,
+ inherit: row.direct.inherit,
+ })
+ for (const shareId of row.direct.shareIds) await deleteGfsShare(shareId)
+ }
+ showToast(
+ `${subjectLabel(row)} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${source.name} and everything inside it.`,
+ { tone: 'success' }
+ )
+ } else {
+ if (source.grantId) await deleteGfsGrant(source.grantId)
+ for (const shareId of source.shareIds) await deleteGfsShare(shareId)
+ showToast(`Access removed on ${source.name} and everything inside it.`, {
+ tone: 'success',
+ })
+ }
+ await reload()
+ } catch (caught) {
+ if (!isAlreadyMissing(caught)) {
+ setError(caught instanceof Error ? caught.message : 'Failed to update access')
+ }
+ await reload()
+ } finally {
+ setBusy(false)
+ }
+ }
+
return (
<div className="cu-gfs-grant-panel">
<div
@@ -505,7 +672,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme
<div className="cu-gfs-existing-access__header">
<h4>People with access</h4>
</div>
- {existingAccessLoading ? (
+ {existingAccessLoading || inheritedAccessLoading ? (
<p className="cu-gfs-existing-access__empty" role="status">
Loading access…
</p>
@@ -518,67 +685,159 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme
Retry
</Button>
</div>
- ) : existingAccess.length === 0 ? (
+ ) : existingAccess.length === 0 && inheritedAccess.length === 0 ? (
<p className="cu-gfs-existing-access__empty">No one has access yet.</p>
) : (
<RecordList className="cu-gfs-existing-access__list" aria-label="Resource access">
- {sortedExistingAccess.map(item => {
- const label = subjectLabel(item)
- const kind = subjectKind(item)
- return (
- <RecordListRow
- className="cu-gfs-existing-access__item"
- data-testid={`gfs-access-row-${item.subject.type}`}
- data-access-id={item.grantId ?? item.shareIds[0]}
- key={`${item.subject.type}:${item.grantId ?? item.shareIds[0]}`}
- >
- <span
- aria-hidden="true"
- className={`cu-gfs-existing-access__avatar cu-gfs-existing-access__avatar--${kind}`}
- data-subject-kind={kind}
- >
- <AccessSubjectIcon kind={kind} />
- </span>
- <span className="cu-gfs-existing-access__identity">
- <span className="cu-gfs-existing-access__subject">{label}</span>
- </span>
- <span className="cu-gfs-existing-access__meta">
- <SelectionDropdown
- ariaLabel={`Access role for ${label}`}
- className="cu-gfs-existing-access__role"
- disabled={actionPending}
- multiple={false}
- onChange={next =>
- void updateAccessRole(item, (next[0] ?? 'read') as AccessRole)
- }
- menuClassName="cu-gfs-existing-access__role-menu"
- options={ROLE_OPTIONS}
- placeholder="Role"
- portal
- searchable={false}
- showSelectedChips={false}
- value={[roleForPermissions(item.permissions)]}
- />
- </span>
- <RowActionMenu
- actions={[
- {
- key: 'remove',
- label: 'Remove access',
- danger: true,
- disabled: actionPending,
- onSelect: () => void revokeAccess(item),
- },
- ]}
- ariaLabel={`Actions for ${label}`}
- />
- </RecordListRow>
- )
- })}
+ {resourceIsFile
+ ? sortedFileAccessRows.map(row => {
+ const label = subjectLabel(row)
+ const kind = subjectKind(row)
+ const inherited = row.inherited !== null
+ return (
+ <RecordListRow
+ className="cu-gfs-existing-access__item"
+ data-testid={`gfs-access-row-${row.subject.type}`}
+ data-access-id={row.direct?.grantId ?? row.direct?.shareIds[0]}
+ data-inherited={inherited ? 'true' : undefined}
+ key={`file:${subjectKey(row.subject)}`}
+ >
+ <span
+ aria-hidden="true"
+ className={`cu-gfs-existing-access__avatar cu-gfs-existing-access__avatar--${kind}`}
+ data-subject-kind={kind}
+ >
+ <AccessSubjectIcon kind={kind} />
+ </span>
+ <span className="cu-gfs-existing-access__identity">
+ <span className="cu-gfs-existing-access__subject">{label}</span>
+ </span>
+ <span className="cu-gfs-existing-access__meta">
+ <SelectionDropdown
+ ariaLabel={`Access role for ${label}`}
+ className="cu-gfs-existing-access__role"
+ disabled={actionPending}
+ multiple={false}
+ onChange={next =>
+ inherited
+ ? setParentUpdate({
+ row,
+ mode: 'change-role',
+ nextRole: (next[0] ?? 'read') as AccessRole,
+ })
+ : void updateAccessRole(
+ row.direct as GfsExistingAccessItem,
+ (next[0] ?? 'read') as AccessRole
+ )
+ }
+ menuClassName="cu-gfs-existing-access__role-menu"
+ options={ROLE_OPTIONS}
+ placeholder="Role"
+ portal
+ searchable={false}
+ showSelectedChips={false}
+ value={[roleForPermissions(row.permissions)]}
+ />
+ </span>
+ <RowActionMenu
+ actions={[
+ {
+ key: 'remove',
+ label: 'Remove access',
+ danger: true,
+ disabled: actionPending,
+ onSelect: () =>
+ inherited
+ ? setParentUpdate({ row, mode: 'remove' })
+ : void revokeAccess(row.direct as GfsExistingAccessItem),
+ },
+ ]}
+ ariaLabel={`Actions for ${label}`}
+ />
+ </RecordListRow>
+ )
+ })
+ : sortedExistingAccess.map(item => {
+ const label = subjectLabel(item)
+ const kind = subjectKind(item)
+ return (
+ <RecordListRow
+ className="cu-gfs-existing-access__item"
+ data-testid={`gfs-access-row-${item.subject.type}`}
+ data-access-id={item.grantId ?? item.shareIds[0]}
+ key={`${item.subject.type}:${item.grantId ?? item.shareIds[0]}`}
+ >
+ <span
+ aria-hidden="true"
+ className={`cu-gfs-existing-access__avatar cu-gfs-existing-access__avatar--${kind}`}
+ data-subject-kind={kind}
+ >
+ <AccessSubjectIcon kind={kind} />
+ </span>
+ <span className="cu-gfs-existing-access__identity">
+ <span className="cu-gfs-existing-access__subject">{label}</span>
+ </span>
+ <span className="cu-gfs-existing-access__meta">
+ <SelectionDropdown
+ ariaLabel={`Access role for ${label}`}
+ className="cu-gfs-existing-access__role"
+ disabled={actionPending}
+ multiple={false}
+ onChange={next =>
+ void updateAccessRole(item, (next[0] ?? 'read') as AccessRole)
+ }
+ menuClassName="cu-gfs-existing-access__role-menu"
+ options={ROLE_OPTIONS}
+ placeholder="Role"
+ portal
+ searchable={false}
+ showSelectedChips={false}
+ value={[roleForPermissions(item.permissions)]}
+ />
+ </span>
+ <RowActionMenu
+ actions={[
+ {
+ key: 'remove',
+ label: 'Remove access',
+ danger: true,
+ disabled: actionPending,
+ onSelect: () => void revokeAccess(item),
+ },
+ ]}
+ ariaLabel={`Actions for ${label}`}
+ />
+ </RecordListRow>
+ )
+ })}
</RecordList>
)}
</section>
) : null}
+ <GfsInheritedAccessDialog
+ busy={busy}
+ request={
+ parentUpdate?.row.inherited
+ ? {
+ mode: parentUpdate.mode,
+ memberLabel: subjectLabel(parentUpdate.row),
+ parentFolderName: parentUpdate.row.inherited.source.name,
+ fileName: resource.name,
+ parentCurrentRole: roleForPermissions(
+ parentUpdate.row.inherited.source.permissions
+ ),
+ fileCurrentRole: roleForPermissions(parentUpdate.row.permissions),
+ nextRole: parentUpdate.mode === 'change-role' ? parentUpdate.nextRole : undefined,
+ fileRemainingRole:
+ parentUpdate.mode === 'remove' && parentUpdate.row.direct
+ ? roleForPermissions(parentUpdate.row.direct.permissions)
+ : null,
+ }
+ : null
+ }
+ onCancel={() => setParentUpdate(null)}
+ onConfirm={() => void confirmParentUpdate()}
+ />
{confirmDialog}
</div>
)
diff --git a/control-ui/components/GfsGrantPanel.types.ts b/control-ui/components/GfsGrantPanel.types.ts
index 63f04212c..3c79324ea 100644
--- a/control-ui/components/GfsGrantPanel.types.ts
+++ b/control-ui/components/GfsGrantPanel.types.ts
@@ -25,6 +25,8 @@ export type GfsGrantResource = {
name: string
gfsUri: string
kind?: string
+ /** Canonical drive path; powers the inherited-access derivation. */
+ path?: string | null
}
export interface GfsGrantPanelProps {
@@ -45,3 +47,47 @@ export type GfsExistingAccessItem = {
grantId: string | null
shareIds: string[]
}
+
+/**
+ * A FILE's "People with access" row: direct rows and derived ancestor rows
+ * deduped to exactly one row per subject (the Google Drive model). The
+ * effective role is the strongest across sources; a member with an inherited
+ * floor is edited through the parent-folder confirmation dialog, never
+ * directly on the file.
+ */
+export type GfsFileAccessRow = {
+ subject: GfsSubjectInput
+ permissions: string[]
+ direct: GfsExistingAccessItem | null
+ inherited: GfsInheritedAccessItem | null
+}
+
+/**
+ * The ancestor folder a subject's inherited access is edited through: the
+ * contributing folder with the strongest role (nearest among equals). Its
+ * grant/share ids let the Share dialog route a confirmed change to the
+ * folder that actually configures the access.
+ */
+export type GfsInheritedAccessSource = {
+ resourceId: string
+ /** Folder label as shown in the confirmation dialog (root falls back to the drive name). */
+ name: string
+ permissions: string[]
+ grantId: string | null
+ shareIds: string[]
+}
+
+/**
+ * An access row derived from an ancestor folder's inheriting grant
+ * (inherit=true) or descendant-covering share (includeDescendants=true). The
+ * grants/shares GETs expose only direct rows, so inheritance is derived on
+ * the client by walking the resource's ancestor folders.
+ */
+export type GfsInheritedAccessItem = {
+ subject: GfsSubjectInput
+ permissions: string[]
+ /** Contributing ancestor folder labels, nearest first, deduplicated. */
+ inheritedFrom: string[]
+ /** The folder a confirmed role change or removal is applied to. */
+ source: GfsInheritedAccessSource
+}
diff --git a/control-ui/components/GfsInheritedAccessDialog/index.tsx b/control-ui/components/GfsInheritedAccessDialog/index.tsx
new file mode 100644
index 000000000..be7dcf9c5
--- /dev/null
+++ b/control-ui/components/GfsInheritedAccessDialog/index.tsx
@@ -0,0 +1,180 @@
+'use client'
+
+import { useEffect, useId, useRef, useState } from 'react'
+import type { GfsInheritedAccessDialogProps, GfsInheritedAccessRole } from './types'
+
+/**
+ * Google-Drive-style confirmation for editing an inherited access row in the
+ * Share dialog: the member's access is configured on a parent folder, so any
+ * role change (or removal) is applied there and cascades to everything inside
+ * the folder. "Learn more" swaps the confirmation for a short help panel
+ * explaining the cascade and the limited-access-folder alternative.
+ */
+
+const ROLE_LABELS: Record<GfsInheritedAccessRole, string> = {
+ read: 'Read',
+ editor: 'Editor',
+}
+
+const HELP_POINTS = [
+ "A folder's permissions apply to every file and subfolder inside it.",
+ "You can't give someone less access on a single file than they have on its parent folder.",
+ 'To limit access to one file, create a folder with limited access and share the file from there.',
+]
+
+export function GfsInheritedAccessDialog({
+ request,
+ busy = false,
+ onConfirm,
+ onCancel,
+}: GfsInheritedAccessDialogProps): React.JSX.Element | null {
+ const titleId = useId()
+ const bodyId = useId()
+ const columnsId = useId()
+ const cancelButtonRef = useRef<HTMLButtonElement | null>(null)
+ const [showHelp, setShowHelp] = useState(false)
+
+ useEffect(() => {
+ if (!request) return
+ const previousActiveElement =
+ document.activeElement instanceof HTMLElement ? document.activeElement : null
+ cancelButtonRef.current?.focus()
+
+ function onKeyDown(event: KeyboardEvent) {
+ if (event.key === 'Escape') onCancel()
+ }
+
+ window.addEventListener('keydown', onKeyDown)
+ return () => {
+ window.removeEventListener('keydown', onKeyDown)
+ previousActiveElement?.focus()
+ }
+ }, [onCancel, request])
+
+ // A new request always reopens on the confirmation view.
+ useEffect(() => {
+ setShowHelp(false)
+ }, [request])
+
+ if (!request) return null
+
+ const isRemove = request.mode === 'remove'
+ const nextLabel = isRemove
+ ? request.fileRemainingRole
+ ? ROLE_LABELS[request.fileRemainingRole]
+ : 'No access'
+ : request.nextRole
+ ? ROLE_LABELS[request.nextRole]
+ : ''
+ const parentNextLabel = isRemove ? 'No access' : nextLabel
+ const confirmLabel = isRemove ? 'Remove' : 'Update role'
+ const title = isRemove ? 'Remove access on parent folder?' : 'Update role on parent folder?'
+ const lead = isRemove
+ ? `Removing ${request.memberLabel}'s access to this item will also remove their access on a parent folder.`
+ : `Changing ${request.memberLabel}'s permissions on this item will also change permissions on a parent folder.`
+
+ return (
+ <div
+ className="cu-modal-backdrop"
+ role="presentation"
+ onMouseDown={event => {
+ if (event.target === event.currentTarget) onCancel()
+ }}
+ >
+ <section
+ className="cu-modal-panel cu-modal-panel--confirm cu-gfs-parent-update"
+ role="alertdialog"
+ aria-modal="true"
+ aria-labelledby={titleId}
+ aria-describedby={showHelp ? `${bodyId}` : `${bodyId} ${columnsId}`}
+ onMouseDown={event => event.stopPropagation()}
+ >
+ <div className="cu-modal-panel__head">
+ <h3 id={titleId} className="cu-modal-panel__title">
+ {showHelp ? 'How sharing works in EvenDrive' : title}
+ </h3>
+ </div>
+ {showHelp ? (
+ <div id={bodyId} className="cu-modal-copy">
+ <ul className="cu-gfs-parent-update__help">
+ {HELP_POINTS.map(point => (
+ <li key={point}>{point}</li>
+ ))}
+ </ul>
+ </div>
+ ) : (
+ <>
+ <p id={bodyId} className="cu-modal-copy">
+ {lead} Alternatively, create a folder with limited access.{' '}
+ <button
+ type="button"
+ className="cu-gfs-parent-update__learn-more"
+ onClick={() => setShowHelp(true)}
+ >
+ Learn more
+ </button>
+ </p>
+ <div id={columnsId} className="cu-gfs-parent-update__columns">
+ <div className="cu-gfs-parent-update__column">
+ <span className="cu-gfs-parent-update__name">{request.parentFolderName}</span>
+ <span className="cu-gfs-parent-update__change">
+ <span className="cu-gfs-parent-update__role">
+ {ROLE_LABELS[request.parentCurrentRole]}
+ </span>
+ <span aria-hidden="true">→</span>
+ <span className="cu-gfs-parent-update__role cu-gfs-parent-update__role--next">
+ {parentNextLabel}
+ </span>
+ </span>
+ </div>
+ <div className="cu-gfs-parent-update__column">
+ <span className="cu-gfs-parent-update__name">{request.fileName}</span>
+ <span className="cu-gfs-parent-update__change">
+ <span className="cu-gfs-parent-update__role">
+ {ROLE_LABELS[request.fileCurrentRole]}
+ </span>
+ <span aria-hidden="true">→</span>
+ <span className="cu-gfs-parent-update__role cu-gfs-parent-update__role--next">
+ {nextLabel}
+ </span>
+ </span>
+ </div>
+ </div>
+ </>
+ )}
+ <div className="cu-modal-panel__foot">
+ {showHelp ? (
+ <button
+ ref={cancelButtonRef}
+ type="button"
+ className="cu-btn cu-btn--ghost"
+ onClick={() => setShowHelp(false)}
+ >
+ Back
+ </button>
+ ) : (
+ <>
+ <button
+ ref={cancelButtonRef}
+ type="button"
+ className="cu-btn cu-btn--ghost"
+ disabled={busy}
+ onClick={onCancel}
+ >
+ Cancel
+ </button>
+ <button
+ type="button"
+ className={`cu-btn ${isRemove ? 'cu-btn--danger' : 'cu-btn--primary'}`}
+ disabled={busy}
+ onClick={onConfirm}
+ >
+ {busy ? 'Updating…' : confirmLabel}
+ </button>
+ </>
+ )}
+ </div>
+ </section>
+ </div>
+ )
+}
diff --git a/control-ui/components/GfsInheritedAccessDialog/types.ts b/control-ui/components/GfsInheritedAccessDialog/types.ts
new file mode 100644
index 000000000..cbce00bf1
--- /dev/null
+++ b/control-ui/components/GfsInheritedAccessDialog/types.ts
@@ -0,0 +1,25 @@
+export type GfsInheritedAccessRole = 'read' | 'editor'
+
+export type GfsInheritedAccessDialogRequest = {
+ /** 'change-role' confirms a parent-folder role update; 'remove' removes the member from the parent folder. */
+ mode: 'change-role' | 'remove'
+ memberLabel: string
+ parentFolderName: string
+ /** The file whose Share dialog opened this confirmation. */
+ fileName: string
+ /** Role the member holds on the parent folder today. */
+ parentCurrentRole: GfsInheritedAccessRole
+ /** Role the member effectively holds on this file today. */
+ fileCurrentRole: GfsInheritedAccessRole
+ /** change-role: the role that will replace parentCurrentRole/fileCurrentRole. */
+ nextRole?: GfsInheritedAccessRole
+ /** remove: the direct access that survives on the file, null for none. */
+ fileRemainingRole?: GfsInheritedAccessRole | null
+}
+
+export interface GfsInheritedAccessDialogProps {
+ request: GfsInheritedAccessDialogRequest | null
+ busy?: boolean
+ onConfirm: () => void
+ onCancel: () => void
+}
diff --git a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx
new file mode 100644
index 000000000..a0c1bd9cb
--- /dev/null
+++ b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx
@@ -0,0 +1,515 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'
+import {
+ deleteGfsGrant,
+ getAdminTeams,
+ getAdminUsers,
+ getGfsGrants,
+ getGfsResourceByPath,
+ getGfsShares,
+ getHosts,
+ getRecipes,
+ putGfsGrant,
+} from '@lib/api'
+import { GfsGrantPanel } from '../GfsGrantPanel'
+import { ToastProvider } from '../Toast'
+import { gfsAncestorPaths } from '../gfsInheritedAccess'
+
+vi.mock('@lib/api', () => ({
+ getAdminTeams: vi.fn(),
+ getAdminUsers: vi.fn(),
+ getHosts: vi.fn(),
+ getRecipes: vi.fn(),
+ getGfsGrants: vi.fn(),
+ getGfsShares: vi.fn(),
+ getGfsResourceByPath: vi.fn(),
+ deleteGfsGrant: vi.fn(),
+ deleteGfsShare: vi.fn(),
+ putGfsGrant: vi.fn(),
+}))
+
+const mockGetAdminUsers = vi.mocked(getAdminUsers)
+const mockGetAdminTeams = vi.mocked(getAdminTeams)
+const mockGetHosts = vi.mocked(getHosts)
+const mockGetRecipes = vi.mocked(getRecipes)
+const mockGetGfsGrants = vi.mocked(getGfsGrants)
+const mockGetGfsShares = vi.mocked(getGfsShares)
+const mockGetGfsResourceByPath = vi.mocked(getGfsResourceByPath)
+const mockPutGfsGrant = vi.mocked(putGfsGrant)
+const mockDeleteGfsGrant = vi.mocked(deleteGfsGrant)
+
+const FILE_ID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
+const FOLDER_ID = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'
+const ROOT_ID = 'cccccccc-cccc-cccc-cccc-cccccccccccc'
+
+const fileResource = {
+ resourceId: FILE_ID,
+ name: 'report.md',
+ gfsUri: 'gfs://main/report',
+ kind: 'file',
+ path: '/team-docs/report.md',
+}
+
+const folderResource = {
+ resourceId: FOLDER_ID,
+ name: 'team-docs',
+ gfsUri: 'gfs://main/team-docs',
+ kind: 'directory',
+ path: '/team-docs',
+}
+
+const miguel = { type: 'user', id: '11111111-1111-1111-1111-111111111111' } as const
+const marcela = { type: 'user', id: '22222222-2222-2222-2222-222222222222' } as const
+const researchTeam = { type: 'team', id: '33333333-3333-3333-3333-333333333333' } as const
+
+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'
+
+function byPathView(resourceId: string, name: string) {
+ return {
+ resourceId,
+ rid: resourceId.replace(/-/g, ''),
+ gfsUri: `gfs://main/${resourceId}`,
+ drive: 'main',
+ name,
+ kind: 'directory',
+ path: name ? `/${name}` : '/',
+ updatedAt: '2026-01-01T00:00:00Z',
+ }
+}
+
+function renderPanel(resource = fileResource) {
+ return render(
+ <ToastProvider>
+ <GfsGrantPanel resource={resource} />
+ </ToastProvider>
+ )
+}
+
+/** Opens the row's role dropdown and picks a role option. */
+async function chooseRole(row: HTMLElement, option: 'Read' | 'Editor') {
+ const trigger = within(row).getByRole('button', { name: /Access role for/ })
+ fireEvent.click(trigger)
+ fireEvent.click(await screen.findByRole('option', { name: option }))
+}
+
+describe('GfsGrantPanel inherited access', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ mockGetAdminUsers.mockResolvedValue({
+ items: [
+ {
+ id: miguel.id,
+ email: '[email protected]',
+ name: 'Miguel',
+ displayName: 'Miguel',
+ picture: null,
+ activeTeamCount: 1,
+ },
+ {
+ id: marcela.id,
+ email: '[email protected]',
+ name: 'Marcela',
+ displayName: 'Marcela',
+ picture: null,
+ activeTeamCount: 1,
+ },
+ ],
+ })
+ mockGetAdminTeams.mockResolvedValue({
+ items: [{ id: researchTeam.id, name: 'Research', memberCount: 2 }],
+ })
+ mockGetHosts.mockResolvedValue({ items: [] })
+ mockGetRecipes.mockResolvedValue({ items: [] })
+ mockGetGfsGrants.mockImplementation(async resourceId => {
+ if (resourceId === FOLDER_ID) {
+ return {
+ items: [
+ {
+ id: FOLDER_GRANT_ID,
+ drive: 'main',
+ resourceId: FOLDER_ID,
+ subject: miguel,
+ permissions: ['read', 'write', 'delete', 'manage_acl', 'share'],
+ inherit: true,
+ },
+ {
+ id: '55555555-5555-5555-5555-555555555555',
+ drive: 'main',
+ resourceId: FOLDER_ID,
+ subject: marcela,
+ permissions: ['read'],
+ inherit: false,
+ },
+ ],
+ }
+ }
+ return { items: [] }
+ })
+ mockGetGfsShares.mockImplementation(async resourceId => {
+ if (resourceId === ROOT_ID) {
+ return {
+ items: [
+ {
+ id: ROOT_SHARE_ID,
+ drive: 'main',
+ resourceId: ROOT_ID,
+ subject: researchTeam,
+ permissions: ['read'],
+ includeDescendants: true,
+ },
+ ],
+ }
+ }
+ return { items: [] }
+ })
+ mockGetGfsResourceByPath.mockImplementation(async (_drive, path) => {
+ if (path === '/team-docs') return byPathView(FOLDER_ID, 'team-docs')
+ if (path === '/') return byPathView(ROOT_ID, '')
+ throw Object.assign(new Error('404 not_found'), { status: 404 })
+ })
+ mockPutGfsGrant.mockResolvedValue({ ok: true, resourceId: FILE_ID, updated: [], count: 0 })
+ mockDeleteGfsGrant.mockResolvedValue(undefined)
+ })
+
+ it('derives ancestor folder paths nearest first', () => {
+ expect(gfsAncestorPaths('/a/b/c/report.md')).toEqual(['/a/b/c', '/a/b', '/a', '/'])
+ expect(gfsAncestorPaths('/report.md')).toEqual(['/'])
+ expect(gfsAncestorPaths('/')).toEqual([])
+ })
+
+ it('shows inherited members as normal toggleable rows with their strongest role', async () => {
+ renderPanel()
+
+ const existing = await screen.findByRole('region', { name: 'People with access' })
+ const miguelRow = await within(existing).findByTestId('gfs-access-row-user')
+ expect(within(miguelRow).getAllByText('Miguel')).toHaveLength(1)
+ // Normal-looking row: role dropdown and actions menu, no inherited badge
+ // or muted duplicate.
+ expect(
+ within(miguelRow).getByRole('button', { name: 'Access role for Miguel' }).textContent
+ ).toContain('Editor')
+ expect(within(miguelRow).getByRole('button', { name: 'Actions for Miguel' })).toBeTruthy()
+ expect(within(miguelRow).queryByText(/Inherited from/)).toBeNull()
+ expect(miguelRow.className).not.toContain('inherited')
+
+ // 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')
+ expect(within(teamRow).getByText('Research')).toBeTruthy()
+ expect(
+ within(teamRow).getByRole('button', { name: 'Access role for Research' }).textContent
+ ).toContain('Read')
+
+ // A non-inheriting ancestor grant applies to the folder only — never a row.
+ expect(within(existing).queryByText('Marcela')).toBeNull()
+ })
+
+ it('dedupes a member with both a direct grant and inherited access into one row', async () => {
+ mockGetGfsGrants.mockImplementation(async resourceId => {
+ if (resourceId === FILE_ID) {
+ return {
+ items: [
+ {
+ id: FILE_GRANT_ID,
+ drive: 'main',
+ resourceId: FILE_ID,
+ subject: miguel,
+ permissions: ['read', 'share'],
+ inherit: false,
+ },
+ ],
+ }
+ }
+ if (resourceId === FOLDER_ID) {
+ return {
+ items: [
+ {
+ id: FOLDER_GRANT_ID,
+ drive: 'main',
+ resourceId: FOLDER_ID,
+ subject: miguel,
+ permissions: ['read', 'write'],
+ inherit: true,
+ },
+ ],
+ }
+ }
+ return { items: [] }
+ })
+ renderPanel()
+
+ const existing = await screen.findByRole('region', { name: 'People with access' })
+ const rows = await within(existing).findAllByTestId('gfs-access-row-user')
+ expect(rows).toHaveLength(1)
+ // Effective role is the strongest across direct and inherited sources.
+ expect(
+ within(rows[0]).getByRole('button', { name: 'Access role for Miguel' }).textContent
+ ).toContain('Editor')
+ })
+
+ 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')
+
+ await chooseRole(miguelRow, 'Read')
+
+ const dialog = await screen.findByRole('alertdialog')
+ expect(within(dialog).getByText('Update role on parent folder?')).toBeTruthy()
+ expect(
+ within(dialog).getByText(
+ "Changing Miguel's permissions on this item will also change permissions on a parent folder. Alternatively, create a folder with limited access."
+ )
+ ).toBeTruthy()
+ expect(within(dialog).getByText('Learn more')).toBeTruthy()
+ // Two-column before/after: parent folder and file, current -> new role.
+ expect(within(dialog).getByText('team-docs')).toBeTruthy()
+ expect(within(dialog).getByText('report.md')).toBeTruthy()
+ expect(within(dialog).getAllByText('Editor')).toHaveLength(2)
+ expect(within(dialog).getAllByText('Read')).toHaveLength(2)
+ })
+
+ it('applies a confirmed role change to the parent folder grant and keeps the file aligned', async () => {
+ mockGetGfsGrants.mockImplementation(async resourceId => {
+ if (resourceId === FILE_ID) {
+ return {
+ items: [
+ {
+ id: FILE_GRANT_ID,
+ drive: 'main',
+ resourceId: FILE_ID,
+ subject: miguel,
+ permissions: ['read', 'share'],
+ inherit: false,
+ },
+ ],
+ }
+ }
+ if (resourceId === FOLDER_ID) {
+ return {
+ items: [
+ {
+ id: FOLDER_GRANT_ID,
+ drive: 'main',
+ resourceId: FOLDER_ID,
+ subject: miguel,
+ permissions: ['read', 'write'],
+ inherit: true,
+ },
+ ],
+ }
+ }
+ return { items: [] }
+ })
+ renderPanel()
+ const existing = await screen.findByRole('region', { name: 'People with access' })
+ const miguelRow = await within(existing).findByTestId('gfs-access-row-user')
+
+ await chooseRole(miguelRow, 'Read')
+ const dialog = await screen.findByRole('alertdialog')
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Update role' }))
+
+ await waitFor(() => expect(mockPutGfsGrant).toHaveBeenCalledTimes(2))
+ // The parent folder's grant is updated first and keeps cascading.
+ expect(mockPutGfsGrant).toHaveBeenNthCalledWith(1, {
+ drive: 'main',
+ resourceId: FOLDER_ID,
+ subject: miguel,
+ permissions: ['read', 'share'],
+ inherit: true,
+ })
+ // The file's own direct grant is aligned so it cannot mask the new role.
+ expect(mockPutGfsGrant).toHaveBeenNthCalledWith(2, {
+ drive: 'main',
+ resourceId: FILE_ID,
+ subject: miguel,
+ permissions: ['read', 'share'],
+ inherit: false,
+ })
+ })
+
+ 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')
+
+ await chooseRole(miguelRow, 'Read')
+ const dialog = await screen.findByRole('alertdialog')
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Cancel' }))
+
+ expect(screen.queryByRole('alertdialog')).toBeNull()
+ expect(mockPutGfsGrant).not.toHaveBeenCalled()
+ expect(
+ within(miguelRow).getByRole('button', { name: 'Access role for Miguel' }).textContent
+ ).toContain('Editor')
+ })
+
+ 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')
+
+ fireEvent.click(within(miguelRow).getByRole('button', { name: 'Actions for Miguel' }))
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Remove access' }))
+
+ const dialog = await screen.findByRole('alertdialog')
+ expect(within(dialog).getByText('Remove access on parent folder?')).toBeTruthy()
+ expect(
+ within(dialog).getByText(
+ "Removing Miguel's access to this item will also remove their access on a parent folder. Alternatively, create a folder with limited access."
+ )
+ ).toBeTruthy()
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Remove' }))
+
+ await waitFor(() => expect(mockDeleteGfsGrant).toHaveBeenCalledWith(FOLDER_GRANT_ID))
+ })
+
+ 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')
+
+ await chooseRole(miguelRow, 'Read')
+ const dialog = await screen.findByRole('alertdialog')
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Learn more' }))
+
+ const help = await screen.findByRole('alertdialog')
+ expect(within(help).getByText('How sharing works in EvenDrive')).toBeTruthy()
+ expect(
+ within(help).getByText(
+ "You can't give someone less access on a single file than they have on its parent folder."
+ )
+ ).toBeTruthy()
+ expect(within(help).getByText(/create a folder with limited access/)).toBeTruthy()
+
+ fireEvent.click(within(help).getByRole('button', { name: 'Back' }))
+ expect(await within(screen.getByRole('alertdialog')).getByText('Update role on parent folder?'))
+ })
+
+ it('keeps direct-only rows on the old direct path (change applies to the file)', async () => {
+ mockGetGfsGrants.mockImplementation(async resourceId => {
+ if (resourceId === FILE_ID) {
+ return {
+ items: [
+ {
+ id: FILE_GRANT_ID,
+ drive: 'main',
+ resourceId: FILE_ID,
+ subject: marcela,
+ permissions: ['read', 'share'],
+ inherit: false,
+ },
+ ],
+ }
+ }
+ if (resourceId === FOLDER_ID) {
+ return {
+ items: [
+ {
+ id: FOLDER_GRANT_ID,
+ drive: 'main',
+ resourceId: FOLDER_ID,
+ subject: miguel,
+ permissions: ['read', 'write'],
+ inherit: true,
+ },
+ ],
+ }
+ }
+ return { items: [] }
+ })
+ renderPanel()
+
+ const existing = await screen.findByRole('region', { name: 'People with access' })
+ const marcelaRow = within(existing)
+ .getAllByTestId('gfs-access-row-user')
+ .find(row => within(row).queryByText('Marcela') !== null)
+ expect(marcelaRow).toBeTruthy()
+
+ await chooseRole(marcelaRow as HTMLElement, 'Editor')
+ // Direct row: no confirmation modal, the file grant is updated directly.
+ expect(screen.queryByRole('alertdialog')).toBeNull()
+ await waitFor(() =>
+ expect(mockPutGfsGrant).toHaveBeenCalledWith({
+ drive: 'main',
+ resourceId: FILE_ID,
+ subject: marcela,
+ permissions: ['read', 'write', 'delete', 'manage_acl', 'share'],
+ inherit: false,
+ })
+ )
+ })
+
+ it('keeps folder dialogs unchanged: direct rows only, no derived ancestor rows', async () => {
+ renderPanel(folderResource)
+
+ 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(
+ row => within(row).queryByText('Miguel') !== null
+ )
+ expect(miguelRow).toBeTruthy()
+ expect(
+ within(miguelRow as HTMLElement).getByRole('button', { name: 'Access role for Miguel' })
+ .textContent
+ ).toContain('Editor')
+ expect(within(miguelRow as HTMLElement).queryByText(/Inherited from/)).toBeNull()
+ // Ancestor derivation never runs for folders.
+ await waitFor(() => expect(mockGetGfsResourceByPath).not.toHaveBeenCalled())
+ expect(within(existing).queryByText('Research')).toBeNull()
+ })
+
+ it('skips derivation when the resource has no path and hides no direct rows', async () => {
+ renderPanel({ ...fileResource, path: null })
+
+ const existing = await screen.findByRole('region', { name: 'People with access' })
+ await waitFor(() => expect(within(existing).getByText('No one has access yet.')).toBeTruthy())
+ expect(mockGetGfsResourceByPath).not.toHaveBeenCalled()
+ })
+
+ it('merges the same subject inherited through several folders into one row with the strongest source', async () => {
+ mockGetGfsResourceByPath.mockImplementation(async (_drive, path) => {
+ if (path === '/team-docs') return byPathView(FOLDER_ID, 'team-docs')
+ if (path === '/') return byPathView(ROOT_ID, '')
+ throw Object.assign(new Error('404 not_found'), { status: 404 })
+ })
+ mockGetGfsGrants.mockImplementation(async resourceId => {
+ if (resourceId === FOLDER_ID || resourceId === ROOT_ID) {
+ return {
+ items: [
+ {
+ id: `g-${resourceId}`,
+ drive: 'main',
+ resourceId,
+ subject: miguel,
+ permissions: resourceId === FOLDER_ID ? ['read', 'write'] : ['read'],
+ inherit: true,
+ },
+ ],
+ }
+ }
+ return { items: [] }
+ })
+ renderPanel()
+
+ const existing = await screen.findByRole('region', { name: 'People with access' })
+ const rows = await within(existing).findAllByTestId('gfs-access-row-user')
+ expect(rows).toHaveLength(1)
+ expect(
+ within(rows[0]).getByRole('button', { name: 'Access role for Miguel' }).textContent
+ ).toContain('Editor')
+
+ // A confirmed change routes to the strongest contributing folder.
+ await chooseRole(rows[0], 'Read')
+ const dialog = await screen.findByRole('alertdialog')
+ expect(within(dialog).getByText('team-docs')).toBeTruthy()
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Update role' }))
+ await waitFor(() =>
+ expect(mockPutGfsGrant).toHaveBeenCalledWith(
+ expect.objectContaining({ resourceId: FOLDER_ID, inherit: true })
+ )
+ )
+ })
+})
diff --git a/control-ui/components/gfsInheritedAccess.ts b/control-ui/components/gfsInheritedAccess.ts
new file mode 100644
index 000000000..918d10eaa
--- /dev/null
+++ b/control-ui/components/gfsInheritedAccess.ts
@@ -0,0 +1,162 @@
+import {
+ type GfsResourceByPathView,
+ getGfsGrants,
+ getGfsResourceByPath,
+ getGfsShares,
+} from '@lib/api'
+import type { GfsSubjectInput } from '@lib/api'
+import type { GfsInheritedAccessItem } from './GfsGrantPanel.types'
+
+/**
+ * Frontend inheritance derivation for the Share dialog. The grants/shares GETs
+ * list only the rows configured directly on one resource, so a file's
+ * inherited access is derived by walking the ancestor folders of the
+ * resource's canonical path and keeping the rows that apply to descendants
+ * (grants with inherit=true, shares with includeDescendants=true — the same
+ * rule the server's allow() evaluation uses). Rows are merged per subject and
+ * each subject keeps the strongest contributing folder as its editable
+ * `source` (with the grant/share ids to mutate), so a confirmed change is
+ * applied on the folder that configures the access.
+ */
+
+/** `/docs/report.md` → `['/docs', '/']` (nearest ancestor first). */
+export function gfsAncestorPaths(path: string): string[] {
+ const segments = (path.startsWith('/') ? path : `/${path}`)
+ .split('/')
+ .filter(segment => segment.length > 0)
+ if (segments.length === 0) return []
+ const ancestors: string[] = []
+ for (let count = segments.length - 1; count > 0; count -= 1) {
+ ancestors.push(`/${segments.slice(0, count).join('/')}`)
+ }
+ ancestors.push('/')
+ return ancestors
+}
+
+/** Stable per-subject merge key. Mirrors the panel's direct-row subject key. */
+function inheritedSubjectKey(subject: GfsSubjectInput): string {
+ return `${subject.type}:${'id' in subject ? subject.id : ''}`
+}
+
+/** Editor-strength rows (write/delete/manage_acl) outrank read-only rows. */
+function isEditorPermissions(permissions: string[]): boolean {
+ return permissions.some(permission => ['write', 'delete', 'manage_acl'].includes(permission))
+}
+
+/** One inheriting row on an ancestor folder, carrying its mutable row ids. */
+interface InheritingRow {
+ subject: GfsSubjectInput
+ permissions: string[]
+ grantId: string | null
+ shareIds: string[]
+}
+
+async function listInheritingRows(
+ folder: GfsResourceByPathView,
+ drive: string,
+ signal?: AbortSignal
+): Promise<InheritingRow[]> {
+ const [grants, shares] = await Promise.all([
+ getGfsGrants(folder.resourceId, drive, signal),
+ getGfsShares(folder.resourceId, drive, signal),
+ ])
+ return [
+ ...grants.items
+ .filter(grant => grant.inherit)
+ .map(grant => ({
+ subject: grant.subject,
+ permissions: grant.permissions,
+ grantId: grant.id,
+ shareIds: [],
+ })),
+ ...shares.items
+ .filter(share => share.includeDescendants)
+ .map(share => ({
+ subject: share.subject,
+ permissions: share.permissions,
+ grantId: null,
+ shareIds: [share.id],
+ })),
+ ]
+}
+
+/**
+ * Derives the inherited access for one resource path. Ancestors that cannot be
+ * resolved or listed (moved, deleted, rate-limited) are skipped — the walk is
+ * best-effort and never fails the whole derivation. The drive root carries an
+ * empty name, so its label falls back to the drive name, matching the browser
+ * breadcrumb.
+ */
+export async function loadGfsInheritedAccess(
+ path: string,
+ drive: string,
+ signal?: AbortSignal
+): Promise<GfsInheritedAccessItem[]> {
+ const bySubject = new Map<string, GfsInheritedAccessItem>()
+ for (const ancestorPath of gfsAncestorPaths(path)) {
+ let folder: GfsResourceByPathView
+ try {
+ folder = await getGfsResourceByPath(drive, ancestorPath, signal)
+ } catch (error) {
+ if (signal?.aborted) throw error
+ continue
+ }
+ let rows: InheritingRow[]
+ try {
+ rows = await listInheritingRows(folder, drive, signal)
+ } catch (error) {
+ if (signal?.aborted) throw error
+ continue
+ }
+ const folderLabel = folder.name || drive
+ for (const row of rows) {
+ const key = inheritedSubjectKey(row.subject)
+ const existing = bySubject.get(key)
+ if (!existing) {
+ bySubject.set(key, {
+ subject: row.subject,
+ permissions: [...row.permissions],
+ inheritedFrom: [folderLabel],
+ source: {
+ resourceId: folder.resourceId,
+ name: folderLabel,
+ permissions: [...row.permissions],
+ grantId: row.grantId,
+ shareIds: [...row.shareIds],
+ },
+ })
+ continue
+ }
+ existing.permissions = [...new Set([...existing.permissions, ...row.permissions])]
+ if (!existing.inheritedFrom.includes(folderLabel)) {
+ existing.inheritedFrom.push(folderLabel)
+ }
+ const sameFolder = existing.source.resourceId === folder.resourceId
+ if (sameFolder) {
+ // A grant and a share for one subject on the same folder are edited
+ // together: union the ids so the change consolidates both rows.
+ existing.source = {
+ ...existing.source,
+ permissions: [...new Set([...existing.source.permissions, ...row.permissions])],
+ grantId: existing.source.grantId ?? row.grantId,
+ shareIds: [...new Set([...existing.source.shareIds, ...row.shareIds])],
+ }
+ } else if (
+ !isEditorPermissions(existing.source.permissions) &&
+ isEditorPermissions(row.permissions)
+ ) {
+ // The editable source is the strongest contributing folder (nearest
+ // among equals): editing a weaker ancestor could not change the
+ // subject's effective access.
+ existing.source = {
+ resourceId: folder.resourceId,
+ name: folderLabel,
+ permissions: [...row.permissions],
+ grantId: row.grantId,
+ shareIds: [...row.shareIds],
+ }
+ }
+ }
+ }
+ return [...bySubject.values()]
+}
diff --git a/control-ui/lib/api.ts b/control-ui/lib/api.ts
index 66ed6a69f..8c8cb5ad0 100644
--- a/control-ui/lib/api.ts
+++ b/control-ui/lib/api.ts
@@ -482,6 +482,26 @@ export async function deleteGfsShare(id: string): Promise<void> {
await gfsMutate('DELETE', `/api/v1/gfs/shares/${encodeURIComponent(id)}`)
}
+export type GfsResourceByPathView = {
+ resourceId: string
+ rid: string
+ gfsUri: string
+ drive: string
+ name: string
+ kind: string
+ path: string | null
+ updatedAt: string
+}
+
+/** Resolves one drive path to its canonical resource view (GET /api/v1/gfs/by-path). */
+export async function getGfsResourceByPath(
+ drive: string,
+ path: string,
+ signal?: AbortSignal
+): Promise<GfsResourceByPathView> {
+ return (await apiGet('/api/v1/gfs/by-path', { drive, path }, { signal })) as GfsResourceByPathView
+}
+
export type AdminLoginResponse = {
me: { id: string; username?: string; email?: string | null; role: 'admin' }
}
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 03eccd756..74da16267 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.577",
+ "version": "0.1.578",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.577",
+ "version": "0.1.578",
"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.json
index 3028160ce..1b1fd6549 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.577",
+ "version": "0.1.578",
"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.tsx
index 6ba8afdc0..14778bb7a 100644
--- a/desktop-app/ui/src/gfs/GfsGrantList/index.tsx
+++ b/desktop-app/ui/src/gfs/GfsGrantList/index.tsx
@@ -1,3 +1,4 @@
+import { useMemo } from 'react'
import { DropdownSelect, StatusBanner } from '@components/Common'
import {
IconAgents,
@@ -10,16 +11,24 @@ import type {
GfsAgentSubjectOption,
GfsDelegationSubjectOption,
GfsGrantListItem,
+ GfsInheritedAccessItem,
GfsShareListItem,
} from '@/gfs/delegation.types'
import { AccessRowMenu } from './AccessRowMenu'
-import type { GfsGrantListProps } from './types'
+import type { GfsGrantListProps, GfsMergedAccessRow } from './types'
import type { GfsAccessRole } from './types'
type AccessSubjectKind = 'agent' | 'context' | 'team' | 'user' | 'workflow'
+function subjectKey(subject: { type: string; id?: string }): string {
+ return `${subject.type}:${subject.id ?? ''}`
+}
+
function subjectKind(
- subject: GfsGrantListItem['subject'] | GfsShareListItem['subject']
+ subject:
+ | GfsGrantListItem['subject']
+ | GfsShareListItem['subject']
+ | GfsInheritedAccessItem['subject']
): AccessSubjectKind {
if (subject.type === 'team') return 'team'
if (subject.type === 'host') return subject.id?.startsWith('3rd:') ? 'workflow' : 'agent'
@@ -44,7 +53,10 @@ function AccessSubjectIcon({ kind }: { kind: AccessSubjectKind }) {
*/
function subjectLabel(
- subject: GfsGrantListItem['subject'] | GfsShareListItem['subject'],
+ subject:
+ | GfsGrantListItem['subject']
+ | GfsShareListItem['subject']
+ | GfsInheritedAccessItem['subject'],
agents: GfsAgentSubjectOption[],
subjects: GfsDelegationSubjectOption[]
): string {
@@ -78,6 +90,8 @@ const ROLE_OPTIONS = [
export function GfsGrantList({
items,
shares = [],
+ inheritedItems = [],
+ mergeInherited = false,
loading = false,
error = null,
shareError = null,
@@ -85,17 +99,50 @@ export function GfsGrantList({
subjects,
onRevoke,
onChangeRole,
+ onChangeInheritedRole,
+ onRemoveInherited,
onRevokeShare,
revoking = false,
revokingShare = false,
updatingRole = false,
}: GfsGrantListProps) {
+ // File dialogs dedupe to exactly one row per member across the direct
+ // grant, direct shares, and derived ancestor access; the merged row keeps
+ // the strongest effective role. Direct rows for a merged subject are
+ // consumed so the member never renders twice.
+ const mergedByKey = useMemo(() => {
+ const merged = new Map<string, GfsMergedAccessRow>()
+ if (!mergeInherited) return merged
+ for (const inherited of inheritedItems) {
+ const key = subjectKey(inherited.subject)
+ const grant = items.find(item => subjectKey(item.subject) === key) ?? null
+ const subjectShares = shares.filter(share => subjectKey(share.subject) === key)
+ merged.set(key, {
+ subject: inherited.subject,
+ permissions: [
+ ...new Set([
+ ...inherited.permissions,
+ ...(grant?.permissions ?? []),
+ ...subjectShares.flatMap(share => share.permissions),
+ ]),
+ ],
+ grant,
+ shares: subjectShares,
+ inherited,
+ })
+ }
+ return merged
+ }, [inheritedItems, items, mergeInherited, shares])
+
// 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 hasRows = showGrantRows || showShareRows
+ // 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
+ const hasRows = showGrantRows || showShareRows || showMergedRows
const hasAnyError = Boolean(error || shareError)
return (
@@ -120,6 +167,7 @@ export function GfsGrantList({
<ul className="da-gfs-grant-list" aria-label="Resource access">
{showGrantRows
? items.map(item => {
+ if (mergedByKey.has(subjectKey(item.subject))) return null
const label = subjectLabel(item.subject, agents, subjects)
const kind = subjectKind(item.subject)
return (
@@ -159,8 +207,55 @@ export function GfsGrantList({
)
})
: null}
+ {showMergedRows
+ ? [...mergedByKey.values()].map(row => {
+ const label = subjectLabel(row.subject, agents, subjects)
+ const kind = subjectKind(row.subject)
+ return (
+ <li
+ className="da-gfs-grant-list__row"
+ data-inherited="true"
+ data-testid={`gfs-access-row-inherited-${row.subject.type}`}
+ key={`inherited:${subjectKey(row.subject)}`}
+ >
+ <span
+ aria-hidden="true"
+ className={`da-gfs-grant-list__avatar da-gfs-grant-list__avatar--${kind}`}
+ data-subject-kind={kind}
+ >
+ <AccessSubjectIcon kind={kind} />
+ </span>
+ <span className="da-gfs-grant-list__identity">
+ <span className="da-gfs-grant-list__label">{label}</span>
+ </span>
+ <span className="da-gfs-grant-list__meta">
+ {/* Normal toggleable row: any edit opens the
+ parent-folder confirmation in the page. */}
+ <DropdownSelect
+ ariaLabel={`Access role for ${label}`}
+ className="da-gfs-grant-list__role"
+ disabled={updatingRole || !onChangeInheritedRole}
+ onChange={value =>
+ void onChangeInheritedRole?.(row, label, value as GfsAccessRole)
+ }
+ options={ROLE_OPTIONS}
+ placeholder="Role"
+ portal
+ value={roleForPermissions(row.permissions)}
+ />
+ </span>
+ <AccessRowMenu
+ disabled={revoking || !onRemoveInherited}
+ label={label}
+ onRemove={() => void onRemoveInherited?.(row, label)}
+ />
+ </li>
+ )
+ })
+ : null}
{showShareRows
? shares.map(item => {
+ if (mergedByKey.has(subjectKey(item.subject))) return null
const label = subjectLabel(item.subject, agents, subjects)
const kind = subjectKind(item.subject)
return (
diff --git a/desktop-app/ui/src/gfs/GfsGrantList/types.ts b/desktop-app/ui/src/gfs/GfsGrantList/types.ts
index 5f4c1fc8b..c77702928 100644
--- a/desktop-app/ui/src/gfs/GfsGrantList/types.ts
+++ b/desktop-app/ui/src/gfs/GfsGrantList/types.ts
@@ -3,14 +3,38 @@ import type {
GfsAgentSubjectOption,
GfsDelegationSubjectOption,
GfsGrantListItem,
+ GfsInheritedAccessItem,
GfsShareListItem,
} from '@/gfs/delegation.types'
export type GfsAccessRole = 'read' | 'editor'
+/**
+ * A FILE dialog's deduped row: one per member across the direct grant, direct
+ * shares, and derived ancestor access (the Google Drive model). The effective
+ * role is the strongest across sources; a member with an inherited floor is
+ * edited through the parent-folder confirmation, never directly on the file.
+ */
+export interface GfsMergedAccessRow {
+ subject: { type: string; id?: string }
+ permissions: string[]
+ grant: GfsGrantListItem | null
+ shares: GfsShareListItem[]
+ inherited: GfsInheritedAccessItem | null
+}
+
export interface GfsGrantListProps {
items: GfsGrantListItem[]
shares?: GfsShareListItem[]
+ /**
+ * Client-derived rows inherited from ancestor folders. Ignored unless
+ * `mergeInherited` is set (file dialogs): they merge into one normal,
+ * toggleable row per member whose edits route through the parent-folder
+ * confirmation.
+ */
+ inheritedItems?: GfsInheritedAccessItem[]
+ /** File-dialog mode: dedupe members across direct and inherited access. */
+ mergeInherited?: boolean
loading?: boolean
/**
* Mapped list-load failure. Severity 'quiet' (manage_acl_required) renders an
@@ -28,6 +52,14 @@ export interface GfsGrantListProps {
label: string,
role: GfsAccessRole
) => void | Promise<void>
+ /** Role change requested on a merged row that carries an inherited floor. */
+ onChangeInheritedRole?: (
+ row: GfsMergedAccessRow,
+ label: string,
+ role: GfsAccessRole
+ ) => void | Promise<void>
+ /** Removal requested on a merged row that carries an inherited floor. */
+ onRemoveInherited?: (row: GfsMergedAccessRow, label: string) => void | Promise<void>
onRevokeShare?: (item: GfsShareListItem, label: string) => void | Promise<void>
revoking?: boolean
revokingShare?: boolean
diff --git a/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/index.tsx b/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/index.tsx
new file mode 100644
index 000000000..c556e521a
--- /dev/null
+++ b/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/index.tsx
@@ -0,0 +1,144 @@
+import { useEffect, useId, useState } from 'react'
+import { Button } from '@components/Common'
+import type { GfsInheritedAccessDialogProps, GfsInheritedAccessRole } from './types'
+
+/**
+ * Google-Drive-style confirmation for editing an inherited access row in the
+ * Share dialog: the member's access is configured on a parent folder, so any
+ * role change (or removal) is applied there and cascades to everything inside
+ * the folder. "Learn more" swaps the confirmation for a short help panel
+ * explaining the cascade and the limited-access-folder alternative.
+ */
+
+const ROLE_LABELS: Record<GfsInheritedAccessRole, string> = {
+ read: 'Read',
+ editor: 'Editor',
+}
+
+const HELP_POINTS = [
+ "A folder's permissions apply to every file and subfolder inside it.",
+ "You can't give someone less access on a single file than they have on its parent folder.",
+ 'To limit access to one file, create a folder with limited access and share the file from there.',
+]
+
+export function GfsInheritedAccessDialog({
+ request,
+ busy = false,
+ onConfirm,
+ onCancel,
+}: GfsInheritedAccessDialogProps) {
+ const titleId = useId()
+ const [showHelp, setShowHelp] = useState(false)
+
+ useEffect(() => {
+ setShowHelp(false)
+ }, [request])
+
+ if (!request) return null
+
+ const isRemove = request.mode === 'remove'
+ const nextLabel = isRemove
+ ? request.fileRemainingRole
+ ? ROLE_LABELS[request.fileRemainingRole]
+ : 'No access'
+ : request.nextRole
+ ? ROLE_LABELS[request.nextRole]
+ : ''
+ const parentNextLabel = isRemove ? 'No access' : nextLabel
+ const title = isRemove ? 'Remove access on parent folder?' : 'Update role on parent folder?'
+ const lead = isRemove
+ ? `Removing ${request.memberLabel}'s access to this item will also remove their access on a parent folder.`
+ : `Changing ${request.memberLabel}'s permissions on this item will also change permissions on a parent folder.`
+
+ return (
+ <div
+ className="da-gfs-manage-modal da-gfs-parent-update-modal"
+ role="presentation"
+ onMouseDown={event => {
+ if (event.target === event.currentTarget && !busy) onCancel()
+ }}
+ >
+ <section
+ aria-labelledby={titleId}
+ aria-modal="true"
+ className="da-gfs-parent-update-dialog"
+ role="alertdialog"
+ >
+ <header className="da-gfs-parent-update-dialog__header">
+ <h3 id={titleId}>{showHelp ? 'How sharing works in EvenDrive' : title}</h3>
+ </header>
+ <div className="da-gfs-parent-update-dialog__body">
+ {showHelp ? (
+ <ul className="da-gfs-parent-update-dialog__help">
+ {HELP_POINTS.map(point => (
+ <li key={point}>{point}</li>
+ ))}
+ </ul>
+ ) : (
+ <>
+ <p className="da-gfs-parent-update-dialog__lead">
+ {lead} Alternatively, create a folder with limited access.{' '}
+ <button
+ className="da-gfs-parent-update-dialog__learn-more"
+ onClick={() => setShowHelp(true)}
+ type="button"
+ >
+ Learn more
+ </button>
+ </p>
+ <div className="da-gfs-parent-update-dialog__columns">
+ <div className="da-gfs-parent-update-dialog__column">
+ <span className="da-gfs-parent-update-dialog__name">
+ {request.parentFolderName}
+ </span>
+ <span className="da-gfs-parent-update-dialog__change">
+ <span className="da-gfs-parent-update-dialog__role">
+ {ROLE_LABELS[request.parentCurrentRole]}
+ </span>
+ <span aria-hidden="true">→</span>
+ <span className="da-gfs-parent-update-dialog__role da-gfs-parent-update-dialog__role--next">
+ {parentNextLabel}
+ </span>
+ </span>
+ </div>
+ <div className="da-gfs-parent-update-dialog__column">
+ <span className="da-gfs-parent-update-dialog__name">{request.fileName}</span>
+ <span className="da-gfs-parent-update-dialog__change">
+ <span className="da-gfs-parent-update-dialog__role">
+ {ROLE_LABELS[request.fileCurrentRole]}
+ </span>
+ <span aria-hidden="true">→</span>
+ <span className="da-gfs-parent-update-dialog__role da-gfs-parent-update-dialog__role--next">
+ {nextLabel}
+ </span>
+ </span>
+ </div>
+ </div>
+ </>
+ )}
+ </div>
+ <footer className="da-gfs-parent-update-dialog__actions">
+ {showHelp ? (
+ <Button onClick={() => setShowHelp(false)} type="button" variant="ghost">
+ Back
+ </Button>
+ ) : (
+ <>
+ <Button autoFocus disabled={busy} onClick={onCancel} type="button" variant="ghost">
+ Cancel
+ </Button>
+ <Button
+ color={isRemove ? 'danger' : undefined}
+ loading={busy}
+ onClick={onConfirm}
+ type="button"
+ >
+ {isRemove ? 'Remove' : 'Update role'}
+ </Button>
+ </>
+ )}
+ </footer>
+ </section>
+ </div>
+ )
+}
diff --git a/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/types.ts b/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/types.ts
new file mode 100644
index 000000000..cbce00bf1
--- /dev/null
+++ b/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/types.ts
@@ -0,0 +1,25 @@
+export type GfsInheritedAccessRole = 'read' | 'editor'
+
+export type GfsInheritedAccessDialogRequest = {
+ /** 'change-role' confirms a parent-folder role update; 'remove' removes the member from the parent folder. */
+ mode: 'change-role' | 'remove'
+ memberLabel: string
+ parentFolderName: string
+ /** The file whose Share dialog opened this confirmation. */
+ fileName: string
+ /** Role the member holds on the parent folder today. */
+ parentCurrentRole: GfsInheritedAccessRole
+ /** Role the member effectively holds on this file today. */
+ fileCurrentRole: GfsInheritedAccessRole
+ /** change-role: the role that will replace parentCurrentRole/fileCurrentRole. */
+ nextRole?: GfsInheritedAccessRole
+ /** remove: the direct access that survives on the file, null for none. */
+ fileRemainingRole?: GfsInheritedAccessRole | null
+}
+
+export interface GfsInheritedAccessDialogProps {
+ request: GfsInheritedAccessDialogRequest | null
+ busy?: boolean
+ onConfirm: () => void
+ onCancel: () => void
+}
diff --git a/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx b/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx
index a9c154e02..13df8c7be 100644
--- a/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx
+++ b/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx
@@ -2,7 +2,11 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { cleanup, fireEvent, render, screen, within } from '@testing-library/react'
import { GfsGrantList } from '../GfsGrantList'
-import type { GfsGrantListItem, GfsShareListItem } from '../delegation.types'
+import type {
+ GfsGrantListItem,
+ GfsInheritedAccessItem,
+ GfsShareListItem,
+} from '../delegation.types'
/**
* "Who has access" list (Manage modal). Rows resolve host subjects to agent
@@ -214,6 +218,182 @@ describe('GfsGrantList', () => {
expect(screen.getByText('No one has access yet.')).toBeTruthy()
})
+ describe('inherited rows (file dialogs)', () => {
+ const inheritedItem = (overrides: Partial<GfsInheritedAccessItem>): GfsInheritedAccessItem => ({
+ subject: { type: 'user', id: 'user-2' },
+ permissions: ['read', 'write'],
+ inheritedFrom: ['team-docs'],
+ source: {
+ resourceId: 'folder-1',
+ name: 'team-docs',
+ permissions: ['read', 'write'],
+ grantId: 'parent-grant-1',
+ shareIds: [],
+ },
+ ...overrides,
+ })
+
+ it('renders inherited members as normal toggleable rows with their strongest role', () => {
+ const onChangeInheritedRole = vi.fn()
+ const onRemoveInherited = vi.fn()
+ render(
+ <GfsGrantList
+ agents={agents}
+ inheritedItems={[
+ inheritedItem({}),
+ inheritedItem({ subject: { type: 'team', id: 'team-1' }, permissions: ['read'] }),
+ ]}
+ items={[]}
+ mergeInherited
+ onChangeInheritedRole={onChangeInheritedRole}
+ onRemoveInherited={onRemoveInherited}
+ onRevoke={vi.fn()}
+ subjects={subjects}
+ />
+ )
+
+ const userRow = screen.getByTestId('gfs-access-row-inherited-user')
+ expect(within(userRow).getByText('Test Two')).toBeTruthy()
+ expect(
+ within(userRow).getByRole('button', { name: 'Access role for Test Two' }).textContent
+ ).toContain('Editor')
+ expect(within(userRow).getByRole('button', { name: 'Actions for Test Two' })).toBeTruthy()
+ // Normal-looking row: no inherited label, no muted duplicate.
+ expect(within(userRow).queryByText(/Inherited from/)).toBeNull()
+ expect(userRow.className).not.toContain('inherited')
+ 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')
+ expect(
+ within(teamRow).getByRole('button', { name: 'Access role for Core Team' }).textContent
+ ).toContain('Read')
+ })
+
+ it('dedupes a member with both a direct grant and inherited access into one row', () => {
+ render(
+ <GfsGrantList
+ agents={agents}
+ inheritedItems={[inheritedItem({ permissions: ['read', 'write'] })]}
+ items={[grantItem({ subject: { type: 'user', id: 'user-2' }, permissions: ['read'] })]}
+ mergeInherited
+ onChangeInheritedRole={vi.fn()}
+ onRemoveInherited={vi.fn()}
+ onRevoke={vi.fn()}
+ subjects={subjects}
+ />
+ )
+
+ // 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')
+ // 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('fires the inherited change and remove callbacks for merged rows', () => {
+ const onChangeInheritedRole = vi.fn()
+ const onRemoveInherited = vi.fn()
+ const item = inheritedItem({})
+ render(
+ <GfsGrantList
+ agents={agents}
+ inheritedItems={[item]}
+ items={[]}
+ mergeInherited
+ onChangeInheritedRole={onChangeInheritedRole}
+ onRemoveInherited={onRemoveInherited}
+ onRevoke={vi.fn()}
+ subjects={subjects}
+ />
+ )
+
+ const row = screen.getByTestId('gfs-access-row-inherited-user')
+ fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))
+ fireEvent.click(screen.getByRole('option', { name: 'Read' }))
+ expect(onChangeInheritedRole).toHaveBeenCalledTimes(1)
+ const [changedRow, label, role] = onChangeInheritedRole.mock.calls[0]
+ expect(changedRow.inherited).toBe(item)
+ expect(changedRow.permissions).toEqual(['read', 'write'])
+ expect(label).toBe('Test Two')
+ expect(role).toBe('read')
+
+ fireEvent.click(within(row).getByRole('button', { name: 'Actions for Test Two' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Remove access' }))
+ expect(onRemoveInherited).toHaveBeenCalledWith(
+ expect.objectContaining({ inherited: item }),
+ 'Test Two'
+ )
+ })
+
+ it('consumes direct share rows of a merged member', () => {
+ render(
+ <GfsGrantList
+ agents={agents}
+ inheritedItems={[
+ inheritedItem({
+ subject: { type: 'team', id: 'team-1' },
+ permissions: ['read'],
+ }),
+ ]}
+ items={[]}
+ mergeInherited
+ onChangeInheritedRole={vi.fn()}
+ onRemoveInherited={vi.fn()}
+ onRevoke={vi.fn()}
+ onRevokeShare={vi.fn()}
+ shares={[shareItem({})]}
+ subjects={subjects}
+ />
+ )
+
+ expect(screen.queryByTestId('gfs-access-row-share-share-1')).toBeNull()
+ expect(screen.getByTestId('gfs-access-row-inherited-team')).toBeTruthy()
+ })
+
+ it('ignores inherited items without mergeInherited (folder dialogs unchanged)', () => {
+ render(
+ <GfsGrantList
+ agents={agents}
+ inheritedItems={[inheritedItem({})]}
+ items={[]}
+ onRevoke={vi.fn()}
+ subjects={subjects}
+ />
+ )
+
+ expect(screen.queryByTestId('gfs-access-row-inherited-user')).toBeNull()
+ expect(screen.getByText('No one has access yet.')).toBeTruthy()
+ })
+
+ it('keeps direct-only rows editable alongside merged rows and never the empty notice', () => {
+ const onRevoke = vi.fn()
+ const grant = grantItem({ id: 'grant-1' })
+ render(
+ <GfsGrantList
+ agents={agents}
+ inheritedItems={[
+ inheritedItem({ subject: { type: 'team', id: 'team-1' }, permissions: ['read'] }),
+ ]}
+ items={[grant]}
+ mergeInherited
+ onChangeRole={vi.fn()}
+ onRevoke={onRevoke}
+ subjects={subjects}
+ />
+ )
+
+ expect(screen.queryByText('No one has access yet.')).toBeNull()
+ fireEvent.click(screen.getByRole('button', { name: 'Access role for Chat LLM' }))
+ fireEvent.click(screen.getByRole('option', { name: 'Editor' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Chat LLM' }))
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Remove access' }))
+ expect(onRevoke).toHaveBeenCalled()
+ })
+ })
+
// R4 spec §2 — grants and shares fail independently: a share-list error
// must not hide successful grant rows or their revoke actions, and vice
// versa. Regression for the early-return that swallowed grants whenever
diff --git a/desktop-app/ui/src/gfs/__tests__/GfsInheritedAccessDialog.test.tsx b/desktop-app/ui/src/gfs/__tests__/GfsInheritedAccessDialog.test.tsx
new file mode 100644
index 000000000..ec3ed6d7f
--- /dev/null
+++ b/desktop-app/ui/src/gfs/__tests__/GfsInheritedAccessDialog.test.tsx
@@ -0,0 +1,107 @@
+// @vitest-environment jsdom
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { cleanup, fireEvent, render, screen, within } from '@testing-library/react'
+import { GfsInheritedAccessDialog } from '../GfsInheritedAccessDialog'
+
+afterEach(() => {
+ cleanup()
+ vi.restoreAllMocks()
+})
+
+describe('GfsInheritedAccessDialog', () => {
+ const changeRequest = {
+ mode: 'change-role' as const,
+ memberLabel: 'Test Two',
+ parentFolderName: 'Team folder',
+ fileName: 'report.txt',
+ parentCurrentRole: 'editor' as const,
+ fileCurrentRole: 'editor' as const,
+ nextRole: 'read' as const,
+ }
+
+ it('renders the two-column before/after for a role change', () => {
+ render(
+ <GfsInheritedAccessDialog request={changeRequest} onCancel={vi.fn()} onConfirm={vi.fn()} />
+ )
+
+ const dialog = screen.getByRole('alertdialog')
+ expect(within(dialog).getByText('Update role on parent folder?')).toBeTruthy()
+ expect(
+ within(dialog).getByText(
+ "Changing Test Two's permissions on this item will also change permissions on a parent folder. Alternatively, create a folder with limited access."
+ )
+ ).toBeTruthy()
+ expect(within(dialog).getByText('Team folder')).toBeTruthy()
+ expect(within(dialog).getByText('report.txt')).toBeTruthy()
+ expect(within(dialog).getAllByText('Editor')).toHaveLength(2)
+ expect(within(dialog).getAllByText('Read')).toHaveLength(2)
+ })
+
+ it('adapts to removal with the surviving direct role on the file column', () => {
+ render(
+ <GfsInheritedAccessDialog
+ request={{
+ mode: 'remove',
+ memberLabel: 'Test Two',
+ parentFolderName: 'Team folder',
+ fileName: 'report.txt',
+ parentCurrentRole: 'editor',
+ fileCurrentRole: 'editor',
+ fileRemainingRole: 'read',
+ }}
+ onCancel={vi.fn()}
+ onConfirm={vi.fn()}
+ />
+ )
+
+ const dialog = screen.getByRole('alertdialog')
+ expect(within(dialog).getByText('Remove access on parent folder?')).toBeTruthy()
+ // Parent column drops to No access; the file keeps its direct-only role.
+ expect(within(dialog).getAllByText('No access')).toHaveLength(1)
+ expect(within(dialog).getAllByText('Read')).toHaveLength(1)
+ expect(within(dialog).getByRole('button', { name: 'Remove' })).toBeTruthy()
+ })
+
+ it('opens the help panel from Learn more and returns to the confirmation', () => {
+ render(
+ <GfsInheritedAccessDialog request={changeRequest} onCancel={vi.fn()} onConfirm={vi.fn()} />
+ )
+
+ const dialog = screen.getByRole('alertdialog')
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Learn more' }))
+ expect(within(dialog).getByText('How sharing works in EvenDrive')).toBeTruthy()
+ expect(
+ within(dialog).getByText(
+ "You can't give someone less access on a single file than they have on its parent folder."
+ )
+ ).toBeTruthy()
+ expect(within(dialog).getByText(/create a folder with limited access/)).toBeTruthy()
+
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Back' }))
+ expect(within(dialog).getByText('Update role on parent folder?')).toBeTruthy()
+ })
+
+ it('reports cancel and confirm to the caller', () => {
+ const onCancel = vi.fn()
+ const onConfirm = vi.fn()
+ const { rerender } = render(
+ <GfsInheritedAccessDialog request={changeRequest} onCancel={onCancel} onConfirm={onConfirm} />
+ )
+
+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }))
+ expect(onCancel).toHaveBeenCalledTimes(1)
+
+ rerender(
+ <GfsInheritedAccessDialog request={changeRequest} onCancel={onCancel} onConfirm={onConfirm} />
+ )
+ fireEvent.click(screen.getByRole('button', { name: 'Update role' }))
+ expect(onConfirm).toHaveBeenCalledTimes(1)
+ })
+
+ it('renders nothing without a request', () => {
+ const { container } = render(
+ <GfsInheritedAccessDialog request={null} onCancel={vi.fn()} onConfirm={vi.fn()} />
+ )
+ expect(container.firstElementChild).toBeNull()
+ })
+})
diff --git a/desktop-app/ui/src/gfs/__tests__/inheritedAccess.test.ts b/desktop-app/ui/src/gfs/__tests__/inheritedAccess.test.ts
new file mode 100644
index 000000000..932d70eb5
--- /dev/null
+++ b/desktop-app/ui/src/gfs/__tests__/inheritedAccess.test.ts
@@ -0,0 +1,257 @@
+// @vitest-environment jsdom
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { deriveGfsInheritedAccess } from '../inheritedAccess'
+
+/** Walk shape: file → team-docs (inheriting grants) → drive root (share). */
+const FILE_ID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
+const FOLDER_ID = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'
+const ROOT_ID = 'cccccccc-cccc-cccc-cccc-cccccccccccc'
+
+function resolveView(
+ resourceId: string,
+ name: string,
+ parentResourceId: string | null,
+ kind = 'directory'
+) {
+ return {
+ drive: 'main',
+ resourceId,
+ parentResourceId,
+ rid: resourceId.replace(/-/g, ''),
+ gfsUri: `gfs://main/${resourceId}`,
+ name,
+ kind,
+ pathCache: null,
+ version: 1,
+ }
+}
+
+function installClerumGfs(
+ resolve: (uri: string) => Promise<ReturnType<typeof resolveView> | null>,
+ listGrants: (resourceId: string) => Promise<unknown[]>,
+ listShares: (resourceId: string) => Promise<unknown[]>
+) {
+ Object.defineProperty(window, 'clerum', {
+ configurable: true,
+ value: {
+ gfs: {
+ resolve,
+ listGrants,
+ listShares,
+ },
+ },
+ })
+}
+
+describe('deriveGfsInheritedAccess', () => {
+ afterEach(() => {
+ vi.restoreAllMocks()
+ })
+
+ it('collects inheriting rows with their editable source folder, nearest first', async () => {
+ installClerumGfs(
+ async uri => {
+ if (uri.endsWith(FILE_ID.replace(/-/g, ''))) {
+ return resolveView(FILE_ID, 'report.md', FOLDER_ID, 'file')
+ }
+ if (uri.endsWith(FOLDER_ID.replace(/-/g, ''))) {
+ return resolveView(FOLDER_ID, 'team-docs', ROOT_ID)
+ }
+ if (uri.endsWith(ROOT_ID.replace(/-/g, ''))) {
+ return resolveView(ROOT_ID, '', null)
+ }
+ return null
+ },
+ async resourceId =>
+ resourceId === FOLDER_ID
+ ? [
+ {
+ id: 'g1',
+ drive: 'main',
+ resourceId: FOLDER_ID,
+ subject: { type: 'user', id: 'miguel' },
+ permissions: ['read', 'write'],
+ inherit: true,
+ },
+ {
+ id: 'g2',
+ drive: 'main',
+ resourceId: FOLDER_ID,
+ subject: { type: 'user', id: 'marcela' },
+ permissions: ['read'],
+ inherit: false,
+ },
+ ]
+ : [],
+ async resourceId =>
+ resourceId === ROOT_ID
+ ? [
+ {
+ id: 's1',
+ drive: 'main',
+ resourceId: ROOT_ID,
+ subject: { type: 'team', id: 'research' },
+ permissions: ['read'],
+ includeDescendants: true,
+ },
+ ]
+ : []
+ )
+
+ const items = await deriveGfsInheritedAccess(FILE_ID)
+
+ expect(items).toEqual([
+ {
+ subject: { type: 'user', id: 'miguel' },
+ permissions: ['read', 'write'],
+ inheritedFrom: ['team-docs'],
+ source: {
+ resourceId: FOLDER_ID,
+ name: 'team-docs',
+ permissions: ['read', 'write'],
+ grantId: 'g1',
+ shareIds: [],
+ },
+ },
+ {
+ subject: { type: 'team', id: 'research' },
+ permissions: ['read'],
+ // The root's empty name falls back to the drive label.
+ inheritedFrom: ['main'],
+ source: {
+ resourceId: ROOT_ID,
+ name: 'main',
+ permissions: ['read'],
+ grantId: null,
+ shareIds: ['s1'],
+ },
+ },
+ ])
+ })
+
+ it('stops the walk at an ancestor the caller cannot resolve and skips unviewable ACLs', async () => {
+ const listGrants = vi.fn(async () => {
+ throw new Error('403 manage_acl_required')
+ })
+ installClerumGfs(
+ async uri => {
+ if (uri.endsWith(FILE_ID.replace(/-/g, ''))) {
+ return resolveView(FILE_ID, 'report.md', FOLDER_ID, 'file')
+ }
+ if (uri.endsWith(FOLDER_ID.replace(/-/g, ''))) {
+ throw new Error('403 forbidden')
+ }
+ return null
+ },
+ listGrants,
+ async () => []
+ )
+
+ const items = await deriveGfsInheritedAccess(FILE_ID)
+
+ expect(items).toEqual([])
+ expect(listGrants).not.toHaveBeenCalled()
+ })
+
+ it('merges one subject inherited through multiple folders into a single strongest-source row', async () => {
+ installClerumGfs(
+ async uri => {
+ if (uri.endsWith(FILE_ID.replace(/-/g, ''))) {
+ return resolveView(FILE_ID, 'report.md', FOLDER_ID, 'file')
+ }
+ if (uri.endsWith(FOLDER_ID.replace(/-/g, ''))) {
+ return resolveView(FOLDER_ID, 'team-docs', ROOT_ID)
+ }
+ if (uri.endsWith(ROOT_ID.replace(/-/g, ''))) {
+ return resolveView(ROOT_ID, '', null)
+ }
+ return null
+ },
+ async resourceId =>
+ resourceId === FOLDER_ID || resourceId === ROOT_ID
+ ? [
+ {
+ id: `g-${resourceId}`,
+ drive: 'main',
+ resourceId,
+ subject: { type: 'user', id: 'miguel' },
+ permissions: resourceId === FOLDER_ID ? ['read', 'write'] : ['read', 'share'],
+ inherit: true,
+ },
+ ]
+ : [],
+ async () => []
+ )
+
+ const items = await deriveGfsInheritedAccess(FILE_ID)
+
+ expect(items).toHaveLength(1)
+ const merged = items[0]
+ expect(merged?.permissions.sort()).toEqual(['read', 'share', 'write'])
+ expect(merged?.inheritedFrom).toEqual(['team-docs', 'main'])
+ // The nearest editor folder is the editable source, even though the root
+ // also grants read: editing the weaker ancestor could not change the
+ // subject's effective access.
+ expect(merged?.source).toEqual({
+ resourceId: FOLDER_ID,
+ name: 'team-docs',
+ permissions: ['read', 'write'],
+ grantId: `g-${FOLDER_ID}`,
+ shareIds: [],
+ })
+ })
+
+ it('unions a grant and a share for one subject on the same folder into one source', async () => {
+ installClerumGfs(
+ async uri => {
+ if (uri.endsWith(FILE_ID.replace(/-/g, ''))) {
+ return resolveView(FILE_ID, 'report.md', FOLDER_ID, 'file')
+ }
+ if (uri.endsWith(FOLDER_ID.replace(/-/g, ''))) {
+ return resolveView(FOLDER_ID, 'team-docs', ROOT_ID)
+ }
+ if (uri.endsWith(ROOT_ID.replace(/-/g, ''))) {
+ return resolveView(ROOT_ID, '', null)
+ }
+ return null
+ },
+ async resourceId =>
+ resourceId === FOLDER_ID
+ ? [
+ {
+ id: 'g1',
+ drive: 'main',
+ resourceId: FOLDER_ID,
+ subject: { type: 'user', id: 'miguel' },
+ permissions: ['read', 'write'],
+ inherit: true,
+ },
+ ]
+ : [],
+ async resourceId =>
+ resourceId === FOLDER_ID
+ ? [
+ {
+ id: 's1',
+ drive: 'main',
+ resourceId: FOLDER_ID,
+ subject: { type: 'user', id: 'miguel' },
+ permissions: ['read'],
+ includeDescendants: true,
+ },
+ ]
+ : []
+ )
+
+ const items = await deriveGfsInheritedAccess(FILE_ID)
+
+ expect(items).toHaveLength(1)
+ expect(items[0]?.source).toEqual({
+ resourceId: FOLDER_ID,
+ name: 'team-docs',
+ permissions: ['read', 'write'],
+ grantId: 'g1',
+ shareIds: ['s1'],
+ })
+ })
+})
diff --git a/desktop-app/ui/src/gfs/delegation.types.ts b/desktop-app/ui/src/gfs/delegation.types.ts
index 5fd9ef487..4b0d8a7b3 100644
--- a/desktop-app/ui/src/gfs/delegation.types.ts
+++ b/desktop-app/ui/src/gfs/delegation.types.ts
@@ -62,3 +62,34 @@ export interface GfsShareListItem {
permissions: string[]
includeDescendants: boolean
}
+
+/**
+ * The ancestor folder a subject's inherited access is edited through: the
+ * contributing folder with the strongest role (nearest among equals). Its
+ * grant/share ids let the Share dialog route a confirmed change to the
+ * folder that actually configures the access.
+ */
+export interface GfsInheritedAccessSource {
+ resourceId: string
+ /** Folder label as shown in the confirmation dialog (root falls back to the drive name). */
+ name: string
+ permissions: string[]
+ grantId: string | null
+ shareIds: string[]
+}
+
+/**
+ * An inherited access row: an ancestor folder's inheriting grant
+ * (inherit=true) or descendant-covering share (includeDescendants=true),
+ * derived on the client because the grants/shares GETs list only direct rows.
+ * Rendered as a normal toggleable row; every edit routes through the
+ * parent-folder confirmation.
+ */
+export interface GfsInheritedAccessItem {
+ subject: { type: string; id?: string }
+ permissions: string[]
+ /** Contributing ancestor folder labels, nearest first, deduplicated. */
+ inheritedFrom: string[]
+ /** The folder a confirmed role change or removal is applied to. */
+ source: GfsInheritedAccessSource
+}
diff --git a/desktop-app/ui/src/gfs/inheritedAccess.ts b/desktop-app/ui/src/gfs/inheritedAccess.ts
new file mode 100644
index 000000000..2b8df5913
--- /dev/null
+++ b/desktop-app/ui/src/gfs/inheritedAccess.ts
@@ -0,0 +1,162 @@
+import { GFS_BREADCRUMB_MAX_DEPTH } from '@constants/gfsBrowser'
+import type { GfsInheritedAccessItem, GfsInheritedAccessSource } from './delegation.types'
+
+/**
+ * Derives the inherited access for one resource on the client. The user-plane
+ * grants/shares GETs list only the rows configured directly on a resource, so
+ * inheritance is reconstructed by walking the ancestor folders (the same
+ * resolve-based walk the breadcrumb trail uses) and keeping the rows that
+ * apply to descendants: grants with inherit=true and shares with
+ * includeDescendants=true — the server's allow() rule. The walk is
+ * best-effort: ancestors this caller cannot resolve or whose ACL it may not
+ * view (view-ACL = manage-ACL server-side) are skipped. Each subject keeps
+ * the strongest contributing folder as its editable `source` (with the
+ * grant/share ids to mutate), so a confirmed change is applied on the folder
+ * that configures the access.
+ */
+
+const DEFAULT_DRIVE = 'main'
+
+function ridOf(resourceId: string): string {
+ return resourceId.replace(/-/g, '').toLowerCase()
+}
+
+function subjectKey(subject: { type: string; id?: string }): string {
+ return `${subject.type}:${subject.id ?? ''}`
+}
+
+/** Editor-strength rows (write/delete/manage_acl) outrank read-only rows. */
+function isEditorPermissions(permissions: string[]): boolean {
+ return permissions.some(permission => ['write', 'delete', 'manage_acl'].includes(permission))
+}
+
+interface InheritingRow {
+ subject: { type: string; id?: string }
+ permissions: string[]
+ grantId: string | null
+ shareIds: string[]
+}
+
+function sourceFor(
+ row: InheritingRow,
+ folderResourceId: string,
+ folderLabel: string
+): GfsInheritedAccessSource {
+ return {
+ resourceId: folderResourceId,
+ name: folderLabel,
+ permissions: [...row.permissions],
+ grantId: row.grantId,
+ shareIds: [...row.shareIds],
+ }
+}
+
+function mergeInto(
+ bySubject: Map<string, GfsInheritedAccessItem>,
+ row: InheritingRow,
+ folderResourceId: string,
+ folderLabel: string
+): void {
+ const key = subjectKey(row.subject)
+ const existing = bySubject.get(key)
+ if (!existing) {
+ bySubject.set(key, {
+ subject: row.subject,
+ permissions: [...row.permissions],
+ inheritedFrom: [folderLabel],
+ source: sourceFor(row, folderResourceId, folderLabel),
+ })
+ return
+ }
+ existing.permissions = [...new Set([...existing.permissions, ...row.permissions])]
+ if (!existing.inheritedFrom.includes(folderLabel)) {
+ existing.inheritedFrom.push(folderLabel)
+ }
+ if (existing.source.resourceId === folderResourceId) {
+ // A grant and a share for one subject on the same folder are edited
+ // together: union the ids so the change consolidates both rows.
+ existing.source = {
+ ...existing.source,
+ permissions: [...new Set([...existing.source.permissions, ...row.permissions])],
+ grantId: existing.source.grantId ?? row.grantId,
+ shareIds: [...new Set([...existing.source.shareIds, ...row.shareIds])],
+ }
+ } else if (
+ !isEditorPermissions(existing.source.permissions) &&
+ isEditorPermissions(row.permissions)
+ ) {
+ // The editable source is the strongest contributing folder (nearest
+ // among equals): editing a weaker ancestor could not change the
+ // subject's effective access.
+ existing.source = sourceFor(row, folderResourceId, folderLabel)
+ }
+}
+
+export async function deriveGfsInheritedAccess(
+ resourceId: string,
+ drive: string = DEFAULT_DRIVE
+): Promise<GfsInheritedAccessItem[]> {
+ const target = await window.clerum.gfs.resolve(`gfs://${drive}/${ridOf(resourceId)}`)
+ const bySubject = new Map<string, GfsInheritedAccessItem>()
+ const seenResourceIds = new Set([target.resourceId])
+ let parentResourceId = target.parentResourceId
+
+ while (parentResourceId && seenResourceIds.size - 1 < GFS_BREADCRUMB_MAX_DEPTH) {
+ if (seenResourceIds.has(parentResourceId)) break
+ seenResourceIds.add(parentResourceId)
+
+ let parent: Awaited<ReturnType<typeof window.clerum.gfs.resolve>>
+ try {
+ parent = await window.clerum.gfs.resolve(`gfs://${drive}/${ridOf(parentResourceId)}`)
+ } catch {
+ // A direct file grant can be readable while its parent is not; stop at
+ // the first ancestor the caller may not resolve.
+ break
+ }
+ if (parent.kind !== 'directory') break
+
+ // The drive root carries an empty name; its label falls back to the drive.
+ const folderLabel = parent.name || drive
+ try {
+ const [grants, shares] = await Promise.all([
+ window.clerum.gfs.listGrants(parent.resourceId, drive),
+ window.clerum.gfs.listShares(parent.resourceId, drive),
+ ])
+ for (const grant of grants) {
+ if (!grant.inherit) continue
+ mergeInto(
+ bySubject,
+ {
+ subject: grant.subject,
+ permissions: grant.permissions,
+ grantId: grant.id,
+ shareIds: [],
+ },
+ parent.resourceId,
+ folderLabel
+ )
+ }
+ for (const share of shares) {
+ if (!share.includeDescendants) continue
+ mergeInto(
+ bySubject,
+ {
+ subject: share.subject,
+ permissions: share.permissions,
+ grantId: null,
+ shareIds: [share.id],
+ },
+ parent.resourceId,
+ folderLabel
+ )
+ }
+ } catch {
+ // Viewing an ancestor's ACL requires manage_acl on it; an ancestor
+ // this caller may not view contributes no rows.
+ }
+
+ parentResourceId = parent.parentResourceId
+ }
+
+ return [...bySubject.values()]
+}
diff --git a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx
index e53dcaa8c..7fe05a884 100644
--- a/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/useGfsBrowserController.test.tsx
@@ -903,7 +903,7 @@ describe('useGfsBrowserController', () => {
await waitFor(() => expect(screen.getByTestId('accessible-count').textContent).toBe('0'))
expect(screen.getByTestId('accessible-error').textContent).toBe('none')
expect(screen.getByTestId('accessible-notice').textContent).toContain(
- 'Automatic GFS discovery is not available'
+ 'Automatic EvenDrive discovery is not available'
)
await act(async () => {
@@ -937,7 +937,7 @@ describe('useGfsBrowserController', () => {
await waitFor(() =>
expect(screen.getByTestId('accessible-notice').textContent).toContain(
- 'Automatic GFS discovery is not available'
+ 'Automatic EvenDrive discovery is not available'
)
)
expect(screen.getByTestId('accessible-error').textContent).toBe('none')
diff --git a/desktop-app/ui/src/hooks/domain/queryKeys.ts b/desktop-app/ui/src/hooks/domain/queryKeys.ts
index 1214aac8d..df1e38ce7 100644
--- a/desktop-app/ui/src/hooks/domain/queryKeys.ts
+++ b/desktop-app/ui/src/hooks/domain/queryKeys.ts
@@ -27,6 +27,8 @@ export const desktopQueryKeys = {
['desktop-app', 'gfs', sessionScope, 'grants', drive, resourceId] as const,
gfsShares: (sessionScope: string, resourceId: string, drive: string) =>
['desktop-app', 'gfs', sessionScope, 'shares', drive, resourceId] as const,
+ gfsInheritedAccess: (sessionScope: string, resourceId: string, drive: string) =>
+ ['desktop-app', 'gfs', sessionScope, 'inherited-access', drive, resourceId] as const,
// Proactive connectors panel (spec 11 U2). Invalidated on connect/disconnect
// completion (U3/U4) so the tri-state re-reads the authoritative grant store.
connectors: ['desktop-app', 'connectors'] as const,
diff --git a/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts b/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts
index aea7d5be0..9360285ec 100644
--- a/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts
+++ b/desktop-app/ui/src/hooks/domain/useGfsBrowserController.ts
@@ -9,6 +9,7 @@ import {
} from '@tanstack/react-query'
import { GFS_BREADCRUMB_MAX_DEPTH } from '@constants/gfsBrowser'
import type { GfsGrantListItem, GfsShareListItem } from '@/gfs/delegation.types'
+import { deriveGfsInheritedAccess } from '@/gfs/inheritedAccess'
import { desktopQueryKeys } from './queryKeys'
/**
@@ -347,6 +348,25 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {
enabled:
Boolean(sessionScope) && Boolean(current) && grantsListEnabled && accessState === 'active',
})
+ // Inherited access (ancestor folders' inheriting grants/shares) is derived
+ // client-side because the grants/shares GETs list only direct rows. Only
+ // FILE dialogs consume the derivation — folder dialogs keep their
+ // direct-only behavior. A derivation failure only means no inherited rows
+ // render — the direct grants/shares surfaces keep their own error
+ // reporting. Gated to the Manage dialog like the direct listings.
+ const inheritedAccessQuery = useQuery({
+ queryKey: desktopQueryKeys.gfsInheritedAccess(
+ sessionScope ?? 'anonymous',
+ current?.resourceId ?? '',
+ DRIVE
+ ),
+ queryFn: () => deriveGfsInheritedAccess(current!.resourceId, DRIVE),
+ enabled:
+ Boolean(sessionScope) &&
+ current?.kind === 'file' &&
+ grantsListEnabled &&
+ accessState === 'active',
+ })
const refreshShares = useCallback(async () => {
const resourceId = current?.resourceId
if (!resourceId) return
@@ -363,6 +383,16 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {
queryKey: desktopQueryKeys.gfsGrants(sessionScope ?? 'anonymous', resourceId, DRIVE),
})
}, [current?.resourceId, queryClient, sessionScope])
+ // Re-derives inherited access after a confirmed parent-folder edit changed
+ // the ancestor rows the walk collected.
+ const refreshInheritedAccess = useCallback(async () => {
+ const resourceId = current?.resourceId
+ if (!resourceId) return
+ await queryClient.invalidateQueries({
+ exact: true,
+ queryKey: desktopQueryKeys.gfsInheritedAccess(sessionScope ?? 'anonymous', resourceId, DRIVE),
+ })
+ }, [current?.resourceId, queryClient, sessionScope])
const refreshGfs = useCallback(async () => {
await queryClient.invalidateQueries({
queryKey: desktopQueryKeys.gfsRoot,
@@ -603,12 +633,16 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {
() => (authorityPending ? [] : (sharesQuery.data ?? [])),
[authorityPending, sharesQuery.data]
)
+ const inheritedAccess = useMemo(
+ () => (authorityPending || accessState === 'revoked' ? [] : (inheritedAccessQuery.data ?? [])),
+ [accessState, authorityPending, inheritedAccessQuery.data]
+ )
const accessibleErrorMessage = accessibleQuery.error ? toMessage(accessibleQuery.error) : null
const accessibleNotice =
sessionScope && !canListAccessibleResources
- ? 'Automatic GFS discovery is not available in this desktop runtime. You can still open any GFS link you have.'
+ ? 'Automatic EvenDrive discovery is not available in this desktop runtime. You can still open any EvenDrive link you have.'
: accessibleErrorMessage && isResourceDiscoveryUnavailable(accessibleErrorMessage)
- ? 'Automatic GFS discovery is not available from this server yet. You can still open any GFS link you have.'
+ ? 'Automatic EvenDrive discovery is not available from this server yet. You can still open any EvenDrive link you have.'
: null
const openUri = useCallback(
@@ -872,6 +906,13 @@ export function useGfsBrowserController(options: GfsBrowserControllerOptions = {
sharesError: sharesQuery.error,
loadingShares: sharesQuery.isFetching,
refreshShares,
+ // Client-derived ancestor access for FILE Manage dialogs: normal-looking
+ // toggleable rows whose edits route through the parent-folder
+ // confirmation. Failures stay silent — the direct surfaces own error
+ // reporting.
+ inheritedAccess,
+ loadingInheritedAccess: inheritedAccessQuery.isFetching,
+ refreshInheritedAccess,
revokeShare: (shareId: string) => revokeShareMutation.mutateAsync(shareId),
revokingShare: revokeShareMutation.isPending,
createShare,
diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsx
index 44e913da4..deaec7ed3 100644
--- a/desktop-app/ui/src/pages/FilesPage.tsx
+++ b/desktop-app/ui/src/pages/FilesPage.tsx
@@ -46,6 +46,9 @@ import { gfsVideoPreviewMimeType } from '@lib/gfsVideoPreview'
import { formatSharedFileSize } from '@lib/sharedFiles'
import { GfsGrantList } from '@/gfs/GfsGrantList'
import type { GfsAccessRole } from '@/gfs/GfsGrantList'
+import type { GfsMergedAccessRow } from '@/gfs/GfsGrantList/types'
+import { GfsInheritedAccessDialog } from '@/gfs/GfsInheritedAccessDialog'
+import type { GfsInheritedAccessDialogRequest } from '@/gfs/GfsInheritedAccessDialog/types'
import {
type GfsAgentSubjectOption,
GfsDelegationPanel,
@@ -66,6 +69,13 @@ function hasBit(affordances: { held?: string[] } | null, bit: string): boolean {
return Boolean(affordances?.held?.includes(bit))
}
+/** Maps a permission set onto the Share dialog's two roles (Editor > Read). */
+function roleForAccessPermissions(permissions: string[]): GfsAccessRole {
+ return permissions.some(permission => ['write', 'delete', 'manage_acl'].includes(permission))
+ ? 'editor'
+ : 'read'
+}
+
function hasDraggedFiles(event: ReactDragEvent<HTMLElement>): boolean {
return Array.from(event.dataTransfer.types || []).includes('Files')
}
@@ -224,6 +234,13 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:
const [manageOpen, setManageOpen] = useState(false)
const [shareDetailsOpen, setShareDetailsOpen] = useState(false)
const [updatingAccessRole, setUpdatingAccessRole] = useState(false)
+ // Pending parent-folder confirmation (role change or removal) for a member
+ // whose file access is inherited from an ancestor folder.
+ const [parentUpdate, setParentUpdate] = useState<
+ | { row: GfsMergedAccessRow; label: string; mode: 'change-role'; nextRole: GfsAccessRole }
+ | { row: GfsMergedAccessRow; label: string; mode: 'remove' }
+ | null
+ >(null)
const [filePreview, setFilePreview] = useState<GfsPreviewResource | null>(null)
const [dragActive, setDragActive] = useState(false)
const [droppedUploadCount, setDroppedUploadCount] = useState(0)
@@ -473,6 +490,12 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:
if (!manageOpen && !openLinkOpen && !moveTarget && !renameTarget) return
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key !== 'Escape') return
+ // The parent-folder confirmation is the top-most dialog: Escape cancels
+ // it alone and leaves the Share dialog open.
+ if (parentUpdate) {
+ setParentUpdate(null)
+ return
+ }
closeManage()
setOpenLinkOpen(false)
setMoveTarget(null)
@@ -480,7 +503,7 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:
}
window.addEventListener('keydown', handleKeyDown)
return () => window.removeEventListener('keydown', handleKeyDown)
- }, [closeManage, manageOpen, openLinkOpen, moveTarget, renameTarget])
+ }, [closeManage, manageOpen, openLinkOpen, moveTarget, parentUpdate, renameTarget])
// One atomic bulk grant for every selected subject — the server grants all or
// none (a `subjects_invalid` rejects the whole request), so there is no
@@ -552,6 +575,71 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:
}
}
+ // A merged row whose access comes from a parent folder: any edit (upgrade,
+ // downgrade, or removal — no exceptions) is confirmed against the parent
+ // folder before anything is sent. Cancel reverts the dropdown untouched.
+ const handleInheritedRoleChange = (
+ row: GfsMergedAccessRow,
+ label: string,
+ role: GfsAccessRole
+ ) => {
+ setParentUpdate({ row, label, mode: 'change-role', nextRole: role })
+ }
+
+ const handleInheritedRemove = (row: GfsMergedAccessRow, label: string) => {
+ setParentUpdate({ row, label, mode: 'remove' })
+ }
+
+ const confirmParentUpdate = async () => {
+ const request = parentUpdate
+ const inherited = request?.row.inherited
+ if (!request || !inherited) {
+ setParentUpdate(null)
+ return
+ }
+ const source = inherited.source
+ const subject = inherited.subject
+ const subjectKey = subject.id ? `${subject.type}:${subject.id}` : subject.type
+ const label = request.label
+ setParentUpdate(null)
+ setUpdatingAccessRole(true)
+ try {
+ if (request.mode === 'change-role') {
+ const requested =
+ subject.type === 'host'
+ ? request.nextRole === 'editor'
+ ? ['read', 'write']
+ : ['read']
+ : request.nextRole === 'editor'
+ ? ['read', 'write', 'delete', 'manage_acl', 'share']
+ : ['read', 'share']
+ const bits = requested.filter(bit => affordances?.grantableBits.includes(bit))
+ // The parent folder's grant is updated first and keeps cascading to
+ // everything inside; its superseded share rows are consolidated.
+ await window.clerum.gfs.grant(source.resourceId, [subjectKey], bits, GFS_DRIVE_MAIN, true)
+ for (const shareId of source.shareIds) await ctrl.revokeShare(shareId)
+ // The file's own direct grant is aligned so it cannot mask the role.
+ if (request.row.grant) {
+ await ctrl.grant([subjectKey], bits, request.row.grant.inherit)
+ }
+ pushToast?.(
+ `${label} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${source.name} and everything inside it`,
+ 'success'
+ )
+ } else {
+ if (source.grantId) await ctrl.revokeGrant(source.grantId)
+ for (const shareId of source.shareIds) await ctrl.revokeShare(shareId)
+ pushToast?.(`Access removed on ${source.name} and everything inside it`, 'success')
+ }
+ await Promise.all([ctrl.refreshGrants(), ctrl.refreshInheritedAccess()])
+ } catch (updateError) {
+ if (failClosedOnAuthorizationError(updateError)) return
+ pushToast?.(describeGfsGrantError(updateError).message, 'error')
+ } finally {
+ setUpdatingAccessRole(false)
+ }
+ }
+
const handleDownload = async (uri: string, name: string) => {
try {
const { bytes } = await window.clerum.gfs.download(uri)
@@ -1716,7 +1804,10 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:
loading={
ctrl.loadingGrants || ctrl.loadingShares || ctrl.loadingInheritedAccess
}
+ mergeInherited={currentIsFile}
+ onChangeInheritedRole={handleInheritedRoleChange}
onChangeRole={affordances?.canDelegate ? handleAccessRoleChange : undefined}
+ onRemoveInherited={handleInheritedRemove}
onRevoke={(item, label) => void handleRevokeGrant(item.id, label)}
onRevokeShare={(item, label) => void handleRevokeShare(item.id, label)}
revoking={ctrl.revoking}
@@ -1733,6 +1824,35 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:
</div>
) : null}
+ <GfsInheritedAccessDialog
+ busy={updatingAccessRole}
+ request={
+ parentUpdate?.row.inherited
+ ? {
+ mode: parentUpdate.mode,
+ memberLabel: parentUpdate.label,
+ parentFolderName: parentUpdate.row.inherited.source.name,
+ fileName: current?.name ?? '',
+ parentCurrentRole: roleForAccessPermissions(
+ parentUpdate.row.inherited.source.permissions
+ ),
+ fileCurrentRole: roleForAccessPermissions(parentUpdate.row.permissions),
+ nextRole: parentUpdate.mode === 'change-role' ? parentUpdate.nextRole : undefined,
+ fileRemainingRole:
+ parentUpdate.mode === 'remove' &&
+ (parentUpdate.row.grant || parentUpdate.row.shares.length > 0)
+ ? roleForAccessPermissions([
+ ...(parentUpdate.row.grant?.permissions ?? []),
+ ...parentUpdate.row.shares.flatMap(share => share.permissions),
+ ])
+ : null,
+ }
+ : null
+ }
+ onCancel={() => setParentUpdate(null)}
+ onConfirm={() => void confirmParentUpdate()}
+ />
+
{createFolderOpen && currentIsFolder && canWriteCurrent ? (
<div
className="da-gfs-manage-modal da-gfs-new-folder-modal"
diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
index 019b402ff..b1fda1011 100644
--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx
@@ -54,6 +54,9 @@ function baseController() {
grantsError: null,
loadingGrants: false,
refreshGrants: vi.fn(),
+ inheritedAccess: [],
+ loadingInheritedAccess: false,
+ refreshInheritedAccess: vi.fn(),
revokeGrant: vi.fn(),
revoking: false,
shares: [],
@@ -1661,6 +1664,201 @@ describe('FilesPage', () => {
expect(pushToast).toHaveBeenCalledWith('Access granted to 1 subject', 'success')
})
+ // TASK-243 — inherited access on a FILE: one normal toggleable row per
+ // member; any edit confirms against the parent folder and applies there.
+ function inheritedFileController(overrides: Record<string, unknown> = {}) {
+ return {
+ ...baseController(),
+ current: {
+ resourceId: 'file-1',
+ gfsUri: 'gfs://main/file-1',
+ name: 'report.txt',
+ kind: 'file' as const,
+ version: 3,
+ },
+ affordances: {
+ held: ['read', 'manage_acl'],
+ canDelegate: true,
+ grantableBits: ['read', 'share', 'write'],
+ canCreateShare: false,
+ },
+ grants: [
+ {
+ id: 'grant-1',
+ drive: 'main',
+ resourceId: 'file-1',
+ subject: { type: 'user', id: 'user-2' },
+ permissions: ['read', 'share'],
+ inherit: false,
+ },
+ ],
+ inheritedAccess: [
+ {
+ subject: { type: 'user', id: 'user-2' },
+ permissions: ['read', 'write'],
+ inheritedFrom: ['Team folder'],
+ source: {
+ resourceId: 'folder-1',
+ name: 'Team folder',
+ permissions: ['read', 'write'],
+ grantId: 'parent-grant-1',
+ shareIds: [],
+ },
+ },
+ ],
+ ...overrides,
+ }
+ }
+
+ function installInheritedDirectoryMocks() {
+ Object.defineProperty(window, 'clerum', {
+ configurable: true,
+ value: {
+ gfs: {
+ getPathForFile: vi.fn((file: File) => `/tmp/${file.name}`),
+ grant: vi.fn(async () => undefined),
+ },
+ agents: { listMine: vi.fn(async () => []) },
+ team: {
+ directory: vi.fn(async () => ({
+ currentTeamId: 'team-1',
+ items: [
+ {
+ team: { id: 'team-1', name: 'Core Team', role: 'admin' },
+ members: [
+ {
+ id: 'user-2',
+ email: '[email protected]',
+ name: 'Test Two',
+ role: 'member',
+ status: 'active',
+ },
+ ],
+ contextIds: [],
+ agentNames: [],
+ },
+ ],
+ })),
+ },
+ },
+ })
+ }
+
+ it('shows one normal toggleable row per member with inherited access on a file', async () => {
+ installInheritedDirectoryMocks()
+ hookMock.useGfsBrowserController.mockReturnValue(inheritedFileController())
+
+ renderFilesPage()
+ await openManageDialog('report.txt')
+
+ 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')
+ expect(within(row).getByText('Test Two')).toBeTruthy()
+ expect(within(row).queryByText(/Inherited from/)).toBeNull()
+ // Effective role is the strongest across direct and inherited sources.
+ expect(
+ within(row).getByRole('button', { name: 'Access role for Test Two' }).textContent
+ ).toContain('Editor')
+ })
+
+ it('confirms an inherited role change against the parent folder and applies it there', async () => {
+ installInheritedDirectoryMocks()
+ const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant
+ const refreshGrants = vi.fn(async () => undefined)
+ const refreshInheritedAccess = vi.fn(async () => undefined)
+ const fileGrant = vi.fn(async () => undefined)
+ const pushToast = vi.fn()
+ hookMock.useGfsBrowserController.mockReturnValue(
+ inheritedFileController({ refreshGrants, refreshInheritedAccess, grant: fileGrant })
+ )
+
+ renderFilesPage(pushToast)
+ await openManageDialog('report.txt')
+ const manageDialog = await screen.findByRole('dialog', { name: 'Share file report.txt' })
+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user')
+
+ await act(async () => {
+ fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))
+ })
+ await act(async () => {
+ fireEvent.click(screen.getByRole('option', { name: 'Read' }))
+ })
+
+ const confirmDialog = await screen.findByRole('alertdialog')
+ expect(
+ within(confirmDialog).getByText('Update role on parent folder?', { selector: 'h3' })
+ ).toBeTruthy()
+ expect(within(confirmDialog).getByText('Team folder')).toBeTruthy()
+ expect(within(confirmDialog).getByText('report.txt')).toBeTruthy()
+
+ // Cancel reverts the dropdown and sends nothing.
+ fireEvent.click(within(confirmDialog).getByRole('button', { name: 'Cancel' }))
+ expect(screen.queryByRole('alertdialog')).toBeNull()
+ expect(parentGrant).not.toHaveBeenCalled()
+ expect(
+ within(row).getByRole('button', { name: 'Access role for Test Two' }).textContent
+ ).toContain('Editor')
+
+ // Confirm applies the new role to the parent folder grant first…
+ 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 confirmDialogAgain = await screen.findByRole('alertdialog')
+ await act(async () => {
+ fireEvent.click(within(confirmDialogAgain).getByRole('button', { name: 'Update role' }))
+ })
+
+ await waitFor(() =>
+ expect(parentGrant).toHaveBeenCalledWith(
+ 'folder-1',
+ ['user:user-2'],
+ ['read', 'share'],
+ 'main',
+ true
+ )
+ )
+ // …then aligns the file's own direct grant so it cannot mask the role.
+ await waitFor(() =>
+ expect(fileGrant).toHaveBeenCalledWith(['user:user-2'], ['read', 'share'], false)
+ )
+ await waitFor(() => expect(refreshGrants).toHaveBeenCalled())
+ await waitFor(() => expect(refreshInheritedAccess).toHaveBeenCalled())
+ })
+
+ it('removes an inherited member from the parent folder after confirmation', async () => {
+ installInheritedDirectoryMocks()
+ const revokeGrant = vi.fn(async () => undefined)
+ const pushToast = vi.fn()
+ hookMock.useGfsBrowserController.mockReturnValue(inheritedFileController({ revokeGrant }))
+
+ renderFilesPage(pushToast)
+ await openManageDialog('report.txt')
+ const manageDialog = await screen.findByRole('dialog', { name: 'Share file report.txt' })
+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user')
+
+ await act(async () => {
+ fireEvent.click(within(row).getByRole('button', { name: 'Actions for Test Two' }))
+ })
+ await act(async () => {
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Remove access' }))
+ })
+
+ const confirmDialog = await screen.findByRole('alertdialog')
+ expect(
+ within(confirmDialog).getByText('Remove access on parent folder?', { selector: 'h3' })
+ ).toBeTruthy()
+ await act(async () => {
+ fireEvent.click(within(confirmDialog).getByRole('button', { name: 'Remove' }))
+ })
+
+ await waitFor(() => expect(revokeGrant).toHaveBeenCalledWith('parent-grant-1'))
+ })
+
it('does not render resource options inside the share dialog', async () => {
Object.defineProperty(window, 'clerum', {
configurable: true,
diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.css
index 526a5c62c..31376a73d 100644
--- a/desktop-app/ui/src/styles.css
+++ b/desktop-app/ui/src/styles.css
@@ -16249,6 +16249,114 @@ pre {
font-weight: var(--font-weight-medium);
}
+/* Parent-folder confirmation for inherited access rows (Share dialog). */
+.da-gfs-parent-update-dialog {
+ width: min(460px, 94vw);
+ display: grid;
+ gap: var(--space-4);
+ padding: var(--space-5);
+ border: 1px solid rgba(var(--edge-rgb), 0.42);
+ border-radius: var(--radius-xl);
+ background: var(--bg-elev);
+ box-shadow: var(--shadow-hard);
+}
+
+.da-gfs-parent-update-dialog__header h3 {
+ margin: 0;
+ color: var(--text);
+ font-size: var(--font-size-xl);
+ font-weight: var(--font-weight-semibold);
+ line-height: var(--line-height-tight);
+}
+
+.da-gfs-parent-update-dialog__body {
+ min-width: 0;
+ display: grid;
+ gap: var(--space-3);
+}
+
+.da-gfs-parent-update-dialog__lead {
+ margin: 0;
+ color: var(--text-muted);
+ font-size: var(--font-size-sm);
+ line-height: var(--line-height-normal);
+}
+
+.da-gfs-parent-update-dialog__learn-more {
+ padding: 0;
+ border: none;
+ background: none;
+ color: var(--accent);
+ font: inherit;
+ text-decoration: underline;
+ text-underline-offset: 0.2em;
+ cursor: pointer;
+}
+
+.da-gfs-parent-update-dialog__learn-more:focus-visible {
+ outline: 2px solid rgba(var(--focus-rgb), 0.8);
+ outline-offset: 2px;
+}
+
+.da-gfs-parent-update-dialog__columns {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: var(--space-2);
+}
+
+.da-gfs-parent-update-dialog__column {
+ display: grid;
+ gap: var(--space-1);
+ padding: var(--space-3);
+ border: 1px solid rgba(var(--edge-rgb), 0.32);
+ border-radius: var(--radius-lg);
+ background: var(--bg);
+}
+
+.da-gfs-parent-update-dialog__name {
+ overflow: hidden;
+ color: var(--text);
+ font-size: var(--font-size-sm);
+ font-weight: var(--font-weight-medium);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.da-gfs-parent-update-dialog__change {
+ display: flex;
+ align-items: center;
+ gap: var(--space-2);
+ color: var(--text-muted);
+ font-size: var(--font-size-sm);
+}
+
+.da-gfs-parent-update-dialog__role {
+ color: var(--text-muted);
+ font-weight: var(--font-weight-medium);
+}
+
+.da-gfs-parent-update-dialog__role--next {
+ color: var(--text);
+}
+
+.da-gfs-parent-update-dialog__help {
+ display: grid;
+ gap: var(--space-2);
+ margin: 0;
+ padding-inline-start: 1.25rem;
+ color: var(--text-muted);
+ font-size: var(--font-size-sm);
+ line-height: var(--line-height-normal);
+}
+
+.da-gfs-parent-update-dialog__actions {
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ gap: var(--space-2);
+ margin-top: var(--space-2);
+}
+
.da-gfs-grant-list__chips {
display: inline-flex;
flex-wrap: wrap;