Skip to content

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

TypeScript

feat(control-ui): rebrand access management tabs to resolved agent access (Phase 2 / Category C)

Miguelon Peluchon610fea2b7b6b
diff --git a/control-ui/app/constants/createFlowLoading.ts b/control-ui/app/constants/createFlowLoading.ts
index fceaa2d7b..f8ccb5501 100644
--- a/control-ui/app/constants/createFlowLoading.ts
+++ b/control-ui/app/constants/createFlowLoading.ts
@@ -70,7 +70,7 @@ export const CREATE_FLOW_LOADING = {
title: 'Create team',
subtitle: 'Create a team now. You can assign a leader later.',
backLabel: 'Back to teams',
- steps: ['Team', 'Members', 'Contexts', 'Agents'],
+ steps: ['Team', 'Members', 'Access', 'Agents'],
stepFlowClassName: 'cu-create-step-flow--4 cu-team-create-panel',
},
installRegistryEntry: {
diff --git a/control-ui/app/profile-admin/teams/[teamId]/[tab]/page.tsx b/control-ui/app/profile-admin/teams/[teamId]/[tab]/page.tsx
index 3694137c3..cb4b8e95a 100644
--- a/control-ui/app/profile-admin/teams/[teamId]/[tab]/page.tsx
+++ b/control-ui/app/profile-admin/teams/[teamId]/[tab]/page.tsx
@@ -5,7 +5,7 @@ interface TeamTabPageProps {
params: Promise<{ tab: string }>
}
-const TEAM_DETAIL_TABS = ['members', 'contexts', 'agents']
+const TEAM_DETAIL_TABS = ['members', 'access', 'agents']
export default async function TeamTabPage({ params }: TeamTabPageProps) {
const { tab } = await params
diff --git a/control-ui/app/profile-admin/teams/[teamId]/page.tsx b/control-ui/app/profile-admin/teams/[teamId]/page.tsx
index 812092999..75b14c36d 100644
--- a/control-ui/app/profile-admin/teams/[teamId]/page.tsx
+++ b/control-ui/app/profile-admin/teams/[teamId]/page.tsx
@@ -16,6 +16,7 @@ import { IconUsers } from '../../../../components/Sidebar/icons'
import { IconCheck, IconMoreHorizontal, IconPencil, IconX } from '../../../../components/icons'
import {
AdminTeamPendingInvitation,
+ ContextResource,
HostResource,
TeamMember,
addAdminTeamMember,
@@ -42,12 +43,12 @@ import { formatTeamRole, permissionsForTeamRole } from '../../../../lib/teamRole
type Role = 'admin' | 'inviter' | 'member'
-type TeamTab = 'members' | 'contexts' | 'agents'
-const TEAM_TABS: TeamTab[] = ['members', 'contexts', 'agents']
+type TeamTab = 'members' | 'access' | 'agents'
+const TEAM_TABS: TeamTab[] = ['members', 'access', 'agents']
const TEAM_TAB_LABELS: Record<TeamTab, string> = {
members: 'Members',
- contexts: 'Contexts',
+ access: 'Access',
agents: 'Agents',
}
@@ -181,6 +182,7 @@ export default function TeamDetailsPage() {
const [deletedContextIds, setDeletedContextIds] = useState<string[]>([])
const [selectedContextIdsToAdd, setSelectedContextIdsToAdd] = useState<string[]>([])
const [hosts, setHosts] = useState<HostResource[]>([])
+ const [contextResources, setContextResources] = useState<ContextResource[]>([])
const [assignedAgentNames, setAssignedAgentNames] = useState<string[]>([])
const [observedAgentNames, setObservedAgentNames] = useState<string[]>([])
const [selectedAgentNamesToAdd, setSelectedAgentNamesToAdd] = useState<string[]>([])
@@ -201,6 +203,31 @@ export default function TeamDetailsPage() {
return String(item.spec?.contextId || item.metadata?.name || '').trim()
}
+ // Rows are context IDs on the wire, but the user sees what that access
+ // means: the owning agent(s) for private scopes, the stored display name
+ // for anything else, and the raw id as a last-resort muted fallback.
+ function accessLabelFor(contextId: string): { label: string; resolved: boolean } {
+ const owners = (hosts || [])
+ .map(host => {
+ const ref = String(
+ (host.spec as { contextRef?: string } | undefined)?.contextRef || ''
+ ).trim()
+ if (ref !== contextId) return ''
+ return (
+ String((host.spec as { host?: string } | undefined)?.host || '').trim() ||
+ String(host.metadata?.name || '')
+ )
+ })
+ .filter(Boolean)
+ .sort((a, b) => a.localeCompare(b))
+ if (owners.length > 0) return { label: owners.join(', '), resolved: true }
+ const display = contextResources
+ .find(item => contextIdFromResource(item as never) === contextId)
+ ?.spec?.displayName?.trim()
+ if (display) return { label: display, resolved: true }
+ return { label: contextId, resolved: false }
+ }
+
async function loadTeamData(
resolvedTeamId: string,
visibleContextIds = availableContextIds,
@@ -257,6 +284,7 @@ export default function TeamDetailsPage() {
])
setUsers(Array.isArray(usersData.items) ? usersData.items : [])
setHosts(Array.isArray(hostsData.items) ? hostsData.items : [])
+ setContextResources((contextsData.items || []) as ContextResource[])
const ids = (contextsData.items || [])
.map(item => contextIdFromResource(item as never))
.filter(Boolean)
@@ -479,16 +507,17 @@ export default function TeamDetailsPage() {
setSelectedContextIdsToAdd([])
showToast(message, { tone: 'success' })
} catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to update team contexts')
+ setError(e instanceof Error ? e.message : 'Failed to update team access')
} finally {
setBusy(false)
}
}
- async function removeContextAccess(contextId: string) {
+ async function removeAccess(contextId: string) {
+ const target = accessLabelFor(contextId).label
const shouldRemove = await confirm({
- title: 'Remove Context Access',
- message: `Remove ${teamName || 'this team'}'s access to ${contextId}?`,
+ title: 'Remove Access',
+ message: `Remove ${teamName || 'this team'}'s access to ${target}?`,
confirmLabel: 'Remove access',
tone: 'danger',
})
@@ -496,7 +525,7 @@ export default function TeamDetailsPage() {
await saveContexts(
assignedContextIds.filter(id => id !== contextId),
- 'Team contexts updated.'
+ 'Team access updated.'
)
}
@@ -571,8 +600,9 @@ export default function TeamDetailsPage() {
() =>
availableContextIds
.filter(contextId => !assignedContextIds.includes(contextId))
- .map(contextId => ({ value: contextId, label: contextId })),
- [assignedContextIds, availableContextIds]
+ .map(contextId => ({ value: contextId, label: accessLabelFor(contextId).label })),
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [assignedContextIds, availableContextIds, contextResources, hosts]
)
const availableAgentOptions = useMemo(
() =>
@@ -657,7 +687,7 @@ export default function TeamDetailsPage() {
? 'Name the new team.'
: initialLoading
? 'Loading team details...'
- : 'Members, contexts, and agent access.'
+ : 'Members, connector access, and agents.'
}
tabAriaLabel="Team sections"
tabs={
@@ -970,7 +1000,7 @@ export default function TeamDetailsPage() {
</>
)}
- {activeTab === 'contexts' && (
+ {activeTab === 'access' && (
<>
<div
style={{
@@ -983,7 +1013,7 @@ export default function TeamDetailsPage() {
}}
>
<p className="cu-muted" style={{ fontSize: '0.875rem', margin: 0 }}>
- Contexts this team may access.
+ Agents and connector scopes this team may access.
</p>
<button
type="button"
@@ -991,7 +1021,7 @@ export default function TeamDetailsPage() {
onClick={() => setShowAddContext(true)}
disabled={busy}
>
- Add context
+ Add access
</button>
</div>
{initialLoading ? (
@@ -1011,40 +1041,39 @@ export default function TeamDetailsPage() {
</div>
) : assignedContextIds.length === 0 ? (
<div className="cu-empty" style={{ padding: '0.5rem 0' }}>
- No contexts linked.
+ No access assigned yet.
</div>
) : (
<div role="list">
- {assignedContextIds.map(contextId => (
- <div key={contextId} className="cu-access-row" role="listitem">
- <button
- type="button"
- className="cu-link"
- onClick={() => router.push(CONTROL_ROUTES.contexts.detail(contextId))}
- >
- {contextId}
- </button>
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--danger-icon"
- onClick={() => void removeContextAccess(contextId)}
- disabled={busy}
- title="Remove"
- aria-label="Remove context"
- >
- <IconX width={16} height={16} />
- </button>
- </div>
- ))}
+ {assignedContextIds.map(contextId => {
+ const target = accessLabelFor(contextId)
+ return (
+ <div key={contextId} className="cu-access-row" role="listitem">
+ <span className={target.resolved ? undefined : 'cu-muted'}>
+ {target.label}
+ </span>
+ <button
+ type="button"
+ className="cu-btn cu-btn--icon cu-btn--danger-icon"
+ onClick={() => void removeAccess(contextId)}
+ disabled={busy}
+ title="Remove"
+ aria-label="Remove access"
+ >
+ <IconX width={16} height={16} />
+ </button>
+ </div>
+ )
+ })}
</div>
)}
{!initialLoading && deletedContextIds.length > 0 && (
<>
- <p className="cu-muted cu-deleted-access-heading">Deleted contexts</p>
+ <p className="cu-muted cu-deleted-access-heading">Removed access</p>
<div role="list">
{deletedContextIds.map(contextId => (
<div key={contextId} className="cu-access-row" role="listitem">
- <span>{contextId}</span>
+ <span>{accessLabelFor(contextId).label}</span>
<span className="cu-muted">Deleted</span>
</div>
))}
@@ -1367,12 +1396,12 @@ export default function TeamDetailsPage() {
<div
className="cu-modal-panel cu-modal-panel--selection"
role="dialog"
- aria-labelledby="add-context-title"
+ aria-labelledby="add-access-title"
onClick={e => e.stopPropagation()}
>
<div className="cu-modal-panel__head">
- <strong id="add-context-title" style={{ fontSize: '1rem', lineHeight: 1.35 }}>
- Add context
+ <strong id="add-access-title" style={{ fontSize: '1rem', lineHeight: 1.35 }}>
+ Add access
</strong>
<button
type="button"
@@ -1386,17 +1415,17 @@ export default function TeamDetailsPage() {
</div>
<div className="cu-field">
- <label htmlFor="team-context-picker">Contexts</label>
+ <label htmlFor="team-access-picker">Access</label>
<SelectionDropdown
- id="team-context-picker"
+ id="team-access-picker"
inline
value={selectedContextIdsToAdd}
onChange={setSelectedContextIdsToAdd}
options={availableContextOptions}
- placeholder="Select contexts"
- searchPlaceholder="Search contexts..."
- selectionLabel="Selected contexts"
- emptyLabel="No available contexts."
+ placeholder="Select access"
+ searchPlaceholder="Search access..."
+ selectionLabel="Selected access"
+ emptyLabel="No additional access available."
disabled={busy}
/>
</div>
@@ -1416,15 +1445,13 @@ export default function TeamDetailsPage() {
onClick={() => {
void saveContexts(
[...assignedContextIds, ...selectedContextIdsToAdd],
- selectedContextIdsToAdd.length === 1
- ? 'Team context updated.'
- : 'Team contexts updated.'
+ 'Team access updated.'
)
setShowAddContext(false)
}}
disabled={busy || selectedContextIdsToAdd.length === 0}
>
- {selectedContextIdsToAdd.length > 1 ? 'Add contexts' : 'Add context'}
+ Add access
</button>
</div>
</div>
diff --git a/control-ui/app/profile-admin/teams/new/page.tsx b/control-ui/app/profile-admin/teams/new/page.tsx
index 590fa0f2b..9ff3acfb9 100644
--- a/control-ui/app/profile-admin/teams/new/page.tsx
+++ b/control-ui/app/profile-admin/teams/new/page.tsx
@@ -30,7 +30,7 @@ type Role = 'admin' | 'inviter' | 'member'
type TeamCreateStep = 0 | 1 | 2 | 3
-const STEPS = ['Team', 'Members', 'Contexts', 'Agents'] as const
+const STEPS = ['Team', 'Members', 'Access', 'Agents'] as const
const STEP_DETAILS = [
{
@@ -44,9 +44,9 @@ const STEP_DETAILS = [
subtitle: 'Choose initial team members and roles.',
},
{
- description: 'Map context access',
- title: 'Contexts',
- subtitle: 'Select the contexts this team can access.',
+ description: 'Map access',
+ title: 'Access',
+ subtitle: 'Choose the agents and connector scopes this team can use.',
},
{
description: 'Map agent access',
@@ -72,6 +72,7 @@ export default function CreateTeamPage() {
const [loadingReferenceData, setLoadingReferenceData] = useState(true)
const [users, setUsers] = useState<AdminUser[]>([])
+ const [contextResources, setContextResources] = useState<ContextResource[]>([])
const [availableContextIds, setAvailableContextIds] = useState<string[]>([])
const [hosts, setHosts] = useState<HostResource[]>([])
const [teamName, setTeamName] = useState('')
@@ -96,6 +97,7 @@ export default function CreateTeamPage() {
getHosts(),
])
setUsers(Array.isArray(usersResponse.items) ? usersResponse.items : [])
+ setContextResources((contextsResponse.items || []) as ContextResource[])
setAvailableContextIds(
(contextsResponse.items || [])
.map((item: ContextResource) => contextIdFromResource(item))
@@ -130,9 +132,38 @@ export default function CreateTeamPage() {
})),
[users]
)
+ // Options keep context IDs as values (the write model) but show what the
+ // access means: the owning agent(s), else the stored display name.
const contextOptions = useMemo(
- () => availableContextIds.map(contextId => ({ value: contextId, label: contextId })),
- [availableContextIds]
+ () => {
+ const resolveLabel = (contextId: string): string => {
+ const owners = hosts
+ .map(host => {
+ const ref = String(
+ (host.spec as { contextRef?: string } | undefined)?.contextRef || ''
+ ).trim()
+ if (ref !== contextId) return ''
+ return (
+ String((host.spec as { host?: string } | undefined)?.host || '').trim() ||
+ String(host.metadata?.name || '')
+ )
+ })
+ .filter(Boolean)
+ .sort((a, b) => a.localeCompare(b))
+ if (owners.length > 0) return owners.join(', ')
+ return (
+ contextResources
+ .find(item => contextIdFromResource(item as never) === contextId)
+ ?.spec?.displayName?.trim() || contextId
+ )
+ }
+ return availableContextIds.map(contextId => ({
+ value: contextId,
+ label: resolveLabel(contextId),
+ }))
+ },
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [availableContextIds, contextResources, hosts]
)
const agentOptions = useMemo(
() =>
@@ -407,24 +438,26 @@ export default function CreateTeamPage() {
{step === 2 ? (
<div className="cu-form-stack cu-agent-form-stack--wide">
{loadingReferenceData ? (
- <div className="cu-muted cu-muted-note--compact">Loading contexts...</div>
+ <div className="cu-muted cu-muted-note--compact">Loading access...</div>
) : contextOptions.length > 0 ? (
- <Field htmlFor="new-team-context-picker" label="Contexts">
+ <Field htmlFor="new-team-access-picker" label="Access">
<SelectionDropdown
- id="new-team-context-picker"
+ id="new-team-access-picker"
options={contextOptions}
value={selectedContextIds}
onChange={setSelectedContextIds}
- placeholder="Select contexts"
- searchPlaceholder="Search contexts..."
- selectionLabel="Selected contexts"
- emptyLabel="No contexts match your search."
+ placeholder="Select access"
+ searchPlaceholder="Search access..."
+ selectionLabel="Selected access"
+ emptyLabel="Nothing matches your search."
disabled={saving}
showSelectedChips={false}
/>
</Field>
) : (
- <div className="cu-muted cu-muted-note--compact">No contexts available.</div>
+ <div className="cu-muted cu-muted-note--compact">
+ No access available to grant.
+ </div>
)}
</div>
) : null}
diff --git a/control-ui/app/profile-admin/users/[userId]/[tab]/page.tsx b/control-ui/app/profile-admin/users/[userId]/[tab]/page.tsx
index 5a594afec..f51e7bf3f 100644
--- a/control-ui/app/profile-admin/users/[userId]/[tab]/page.tsx
+++ b/control-ui/app/profile-admin/users/[userId]/[tab]/page.tsx
@@ -9,7 +9,7 @@ const USER_DETAIL_TABS = [
'contact',
'approval-dms',
'communication-channels',
- 'contexts',
+ 'access',
'teams',
'agents',
]
diff --git a/control-ui/app/profile-admin/users/[userId]/page.tsx b/control-ui/app/profile-admin/users/[userId]/page.tsx
index f76834962..1abf3a97b 100644
--- a/control-ui/app/profile-admin/users/[userId]/page.tsx
+++ b/control-ui/app/profile-admin/users/[userId]/page.tsx
@@ -19,6 +19,7 @@ import { UserApprovalMediumsPanel } from '../../../../components/UserApprovalMed
import { IconPencil, IconX } from '../../../../components/icons'
import {
AdminUserChannels,
+ ContextResource,
DeleteAdminUserRequest,
HostResource,
addAdminTeamMember,
@@ -48,18 +49,12 @@ import { formatTeamRole, permissionsForTeamRole } from '../../../../lib/teamRole
type TeamRole = 'admin' | 'inviter' | 'member'
-type UserTab =
- | 'contact'
- | 'approval-dms'
- | 'communication-channels'
- | 'contexts'
- | 'teams'
- | 'agents'
+type UserTab = 'contact' | 'approval-dms' | 'communication-channels' | 'access' | 'teams' | 'agents'
const USER_TABS: UserTab[] = [
'contact',
'approval-dms',
'communication-channels',
- 'contexts',
+ 'access',
'teams',
'agents',
]
@@ -68,7 +63,7 @@ const USER_TAB_LABELS: Record<UserTab, string> = {
contact: 'Contact',
'approval-dms': 'Approval DMs',
'communication-channels': 'Communication Channels',
- contexts: 'Contexts',
+ access: 'Access',
teams: 'Teams',
agents: 'Agents',
}
@@ -112,6 +107,7 @@ export default function UserDetailsPage() {
const [newSlackHandle, setNewSlackHandle] = useState('')
const [newTelegramId, setNewTelegramId] = useState('')
+ const [contextResources, setContextResources] = useState<ContextResource[]>([])
const [availableContextIds, setAvailableContextIds] = useState<string[]>([])
const [assignedContextIds, setAssignedContextIds] = useState<string[]>([])
const [deletedContextIds, setDeletedContextIds] = useState<string[]>([])
@@ -149,8 +145,9 @@ export default function UserDetailsPage() {
() =>
availableContextIds
.filter(contextId => !assignedContextIds.includes(contextId))
- .map(contextId => ({ value: contextId, label: contextId })),
- [assignedContextIds, availableContextIds]
+ .map(contextId => ({ value: contextId, label: accessLabelFor(contextId).label })),
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [assignedContextIds, availableContextIds, contextResources, hosts]
)
const availableTeamOptions = useMemo(
() =>
@@ -220,6 +217,31 @@ export default function UserDetailsPage() {
return String(item.spec?.contextId || item.metadata?.name || '').trim()
}
+ // Rows are context IDs on the wire, but the user sees what that access
+ // means: the owning agent(s) for private scopes, the stored display name
+ // for anything else, and the raw id as a last-resort muted fallback.
+ function accessLabelFor(contextId: string): { label: string; resolved: boolean } {
+ const owners = (hosts || [])
+ .map(host => {
+ const ref = String(
+ (host.spec as { contextRef?: string } | undefined)?.contextRef || ''
+ ).trim()
+ if (ref !== contextId) return ''
+ return (
+ String((host.spec as { host?: string } | undefined)?.host || '').trim() ||
+ String(host.metadata?.name || '')
+ )
+ })
+ .filter(Boolean)
+ .sort((a, b) => a.localeCompare(b))
+ if (owners.length > 0) return { label: owners.join(', '), resolved: true }
+ const display = contextResources
+ .find(item => contextIdFromResource(item as never) === contextId)
+ ?.spec?.displayName?.trim()
+ if (display) return { label: display, resolved: true }
+ return { label: contextId, resolved: false }
+ }
+
async function loadData() {
setBusy(true)
setError('')
@@ -284,6 +306,7 @@ export default function UserDetailsPage() {
])
setCommunicationChannels(communicationChannelsData.items || [])
setAvailableContextIds(ids)
+ setContextResources((contexts.items || []) as ContextResource[])
} catch (e) {
setError(e instanceof Error ? e.message : 'Failed to load member details')
} finally {
@@ -354,16 +377,17 @@ export default function UserDetailsPage() {
setSelectedContextIdsToAdd([])
showToast(message, { tone: 'success' })
} catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to update member context access')
+ setError(e instanceof Error ? e.message : 'Failed to update member access')
} finally {
setBusy(false)
}
}
- async function removeContextAccess(contextId: string) {
+ async function removeAccess(contextId: string) {
+ const target = accessLabelFor(contextId).label
const shouldRemove = await confirm({
- title: 'Remove Context Access',
- message: `Remove ${userName || emailDraft || 'this member'}'s access to ${contextId}?`,
+ title: 'Remove Access',
+ message: `Remove ${userName || emailDraft || 'this member'}'s access to ${target}?`,
confirmLabel: 'Remove access',
tone: 'danger',
})
@@ -371,7 +395,7 @@ export default function UserDetailsPage() {
await saveContexts(
assignedContextIds.filter(id => id !== contextId),
- 'Context access updated.'
+ 'Access updated.'
)
}
@@ -561,7 +585,7 @@ export default function UserDetailsPage() {
subtitle={
initialLoading
? 'Loading member details...'
- : 'Channels, approval DMs, context access, teams, and agents.'
+ : 'Channels, approval DMs, connector access, teams, and agents.'
}
tabAriaLabel="Member sections"
tabs={USER_TABS.map(tab => ({
@@ -934,7 +958,7 @@ export default function UserDetailsPage() {
</>
)}
- {activeTab === 'contexts' && (
+ {activeTab === 'access' && (
<>
<div
style={{
@@ -947,7 +971,7 @@ export default function UserDetailsPage() {
}}
>
<p className="cu-muted" style={{ fontSize: '0.875rem', margin: 0 }}>
- Contexts this member may access.
+ Agents and connector scopes this member may access.
</p>
<button
type="button"
@@ -955,7 +979,7 @@ export default function UserDetailsPage() {
onClick={() => setShowAddContext(true)}
disabled={busy}
>
- Add context
+ Add access
</button>
</div>
{initialLoading ? (
@@ -963,7 +987,7 @@ export default function UserDetailsPage() {
<table className="cu-table">
<thead>
<tr>
- <th>Context</th>
+ <th>Access</th>
<th></th>
</tr>
</thead>
@@ -984,64 +1008,63 @@ export default function UserDetailsPage() {
</div>
) : assignedContextIds.length === 0 ? (
<div className="cu-empty" style={{ padding: '0.5rem 0' }}>
- No contexts assigned.
+ No access assigned yet.
</div>
) : (
<div className="cu-table-wrap">
<table className="cu-table">
<thead>
<tr>
- <th>Context</th>
+ <th>Access</th>
<th></th>
</tr>
</thead>
<tbody>
- {assignedContextIds.map(contextId => (
- <tr key={contextId}>
- <td>
- <button
- type="button"
- className="cu-link"
- onClick={() => router.push(CONTROL_ROUTES.contexts.detail(contextId))}
- >
- {contextId}
- </button>
- </td>
- <td>
- <div
- style={{
- display: 'flex',
- gap: '0.35rem',
- justifyContent: 'flex-end',
- }}
- >
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--danger-icon"
- onClick={() => void removeContextAccess(contextId)}
- disabled={busy}
- title="Remove"
- aria-label="Remove context"
+ {assignedContextIds.map(contextId => {
+ const target = accessLabelFor(contextId)
+ return (
+ <tr key={contextId}>
+ <td>
+ <span className={target.resolved ? undefined : 'cu-muted'}>
+ {target.label}
+ </span>
+ </td>
+ <td>
+ <div
+ style={{
+ display: 'flex',
+ gap: '0.35rem',
+ justifyContent: 'flex-end',
+ }}
>
- <IconX width={16} height={16} />
- </button>
- </div>
- </td>
- </tr>
- ))}
+ <button
+ type="button"
+ className="cu-btn cu-btn--icon cu-btn--danger-icon"
+ onClick={() => void removeAccess(contextId)}
+ disabled={busy}
+ title="Remove"
+ aria-label="Remove access"
+ >
+ <IconX width={16} height={16} />
+ </button>
+ </div>
+ </td>
+ </tr>
+ )
+ })}
</tbody>
</table>
</div>
)}
{!initialLoading && deletedContextIds.length > 0 && (
<>
- <p className="cu-muted cu-deleted-access-heading">Deleted contexts</p>
+ <p className="cu-muted cu-deleted-access-heading">Removed access</p>
<div className="cu-table-wrap">
<table className="cu-table">
<tbody>
{deletedContextIds.map(contextId => (
<tr key={contextId}>
- <td>{contextId}</td>
+ <td>{accessLabelFor(contextId).label}</td>
<td className="cu-muted">Deleted</td>
</tr>
))}
@@ -1402,12 +1425,12 @@ export default function UserDetailsPage() {
<div
className="cu-modal-panel cu-modal-panel--selection"
role="dialog"
- aria-labelledby="add-context-title"
+ aria-labelledby="add-access-title"
onClick={e => e.stopPropagation()}
>
<div className="cu-modal-panel__head">
- <strong id="add-context-title" style={{ fontSize: '1rem', lineHeight: 1.35 }}>
- Add context
+ <strong id="add-access-title" style={{ fontSize: '1rem', lineHeight: 1.35 }}>
+ Add access
</strong>
<button
type="button"
@@ -1421,17 +1444,17 @@ export default function UserDetailsPage() {
</div>
<div className="cu-field">
- <label htmlFor="member-context-picker">Contexts</label>
+ <label htmlFor="member-access-picker">Access</label>
<SelectionDropdown
- id="member-context-picker"
+ id="member-access-picker"
inline
value={selectedContextIdsToAdd}
onChange={setSelectedContextIdsToAdd}
options={availableContextOptions}
- placeholder="Select contexts"
- searchPlaceholder="Search contexts..."
- selectionLabel="Selected contexts"
- emptyLabel="No available contexts."
+ placeholder="Select access"
+ searchPlaceholder="Search access..."
+ selectionLabel="Selected access"
+ emptyLabel="No additional access available."
disabled={busy}
/>
</div>
@@ -1451,15 +1474,13 @@ export default function UserDetailsPage() {
onClick={() => {
void saveContexts(
[...assignedContextIds, ...selectedContextIdsToAdd],
- selectedContextIdsToAdd.length === 1
- ? 'Context access updated.'
- : 'Contexts access updated.'
+ 'Access updated.'
)
setShowAddContext(false)
}}
disabled={busy || selectedContextIdsToAdd.length === 0}
>
- {selectedContextIdsToAdd.length > 1 ? 'Add contexts' : 'Add context'}
+ Add access
</button>
</div>
</div>
diff --git a/control-ui/components/ProfileAdminHome.tsx b/control-ui/components/ProfileAdminHome.tsx
index b338a4948..2bf6f3a4f 100644
--- a/control-ui/components/ProfileAdminHome.tsx
+++ b/control-ui/components/ProfileAdminHome.tsx
@@ -592,7 +592,7 @@ export function ProfileAdminHome({ activeTab, highlightedAdminId = '' }: Profile
{renderTeamSortButton('agents', 'Agents')}
</th>
<th style={{ width: '5rem', textAlign: 'right' }}>
- {renderTeamSortButton('contexts', 'Contexts')}
+ {renderTeamSortButton('contexts', 'Access')}
</th>
<th style={{ width: '4.5rem', textAlign: 'right' }} aria-label="Actions" />
</tr>
@@ -619,7 +619,7 @@ export function ProfileAdminHome({ activeTab, highlightedAdminId = '' }: Profile
{renderTeamSortButton('agents', 'Agents')}
</th>
<th style={{ width: '5rem', textAlign: 'right' }}>
- {renderTeamSortButton('contexts', 'Contexts')}
+ {renderTeamSortButton('contexts', 'Access')}
</th>
<th style={{ width: '4.5rem', textAlign: 'right' }} aria-label="Actions" />
</tr>
@@ -1085,7 +1085,7 @@ export function ProfileAdminHome({ activeTab, highlightedAdminId = '' }: Profile
</div>
<p className="cu-muted" style={{ fontSize: '0.875rem', margin: '0 0 1rem' }}>
Permanently delete <strong>{teamToDelete.name}</strong> and all memberships, pending
- invitations, and team context/agent mappings. This cannot be undone.
+ invitations, and team access/agent mappings. This cannot be undone.
</p>
{deleteDialogError ? (
<div className="cu-banner cu-banner--error" style={{ marginBottom: '0.75rem' }}>
diff --git a/control-ui/components/ProfileAdminPanel.tsx b/control-ui/components/ProfileAdminPanel.tsx
deleted file mode 100644
index 0a7065db1..000000000
--- a/control-ui/components/ProfileAdminPanel.tsx
+++ /dev/null
@@ -1,1007 +0,0 @@
-'use client'
-
-import React, { useEffect, useMemo, useState } from 'react'
-import { useRouter } from 'next/navigation'
-import { CONTROL_ROUTES } from '@constants/routes'
-import {
- AdminUser,
- AdminUserChannels,
- AdminUserContext,
- ContextResource,
- TeamMember,
- TeamSummary,
- createAdminTeam,
- deleteAdminMember,
- getAdminTeamMembers,
- getAdminUserContext,
- getAdminUserContexts,
- getAdminUserTeams,
- getAdminUsers,
- getContexts,
- inviteAdminTeamMember,
- renameAdminTeam,
- updateAdminMemberRole,
- updateAdminUserContext,
- updateAdminUserContexts,
-} from '../lib/api'
-import { useConfirmDialog } from './ConfirmDialog'
-import { useToast } from './Toast'
-
-type Role = 'admin' | 'inviter' | 'member'
-type InviteRole = Role
-
-type Member = TeamMember
-
-type ProfileAdminPanelProps = {
- initialUserId?: string
- onSelectedUserIdChange?: (userId: string | null) => void
-}
-
-export function ProfileAdminPanel({
- initialUserId = '',
- onSelectedUserIdChange,
-}: ProfileAdminPanelProps) {
- const router = useRouter()
- const [users, setUsers] = useState<AdminUser[]>([])
- const [selectedUserContext, setSelectedUserContext] = useState<AdminUserContext | null>(null)
- const [availableContextIds, setAvailableContextIds] = useState<string[]>([])
- const [assignedContextIds, setAssignedContextIds] = useState<string[]>([])
- const [selectedContextToAdd, setSelectedContextToAdd] = useState('')
- const [userQuery, setUserQuery] = useState('')
- const [userId, setUserId] = useState('')
- const [teams, setTeams] = useState<TeamSummary[]>([])
- const [selectedTeamId, setSelectedTeamId] = useState('')
- const [members, setMembers] = useState<Member[]>([])
- const [memberRoleDrafts, setMemberRoleDrafts] = useState<Record<string, Role>>({})
-
- const [newTeamName, setNewTeamName] = useState('')
- const [teamNameDraft, setTeamNameDraft] = useState('')
- const [inviteName, setInviteName] = useState('')
- const [inviteEmail, setInviteEmail] = useState('')
- const [inviteRole, setInviteRole] = useState<InviteRole>('member')
-
- const [busy, setBusy] = useState(false)
- const [error, setError] = useState('')
- const [emailDraft, setEmailDraft] = useState('')
- const { confirm, confirmDialog } = useConfirmDialog()
- const { showToast } = useToast()
- const [contactEmailsDraft, setContactEmailsDraft] = useState<string[]>([])
- const [slackHandlesDraft, setSlackHandlesDraft] = useState<string[]>([])
- const [telegramIdsDraft, setTelegramIdsDraft] = useState<string[]>([])
- const [newContactEmail, setNewContactEmail] = useState('')
- const [newSlackHandle, setNewSlackHandle] = useState('')
- const [newTelegramId, setNewTelegramId] = useState('')
-
- const selectedTeam = useMemo(
- () => teams.find(team => team.id === selectedTeamId) || null,
- [teams, selectedTeamId]
- )
-
- function uniqueTrimmed(values: string[], lowerCase = false): string[] {
- const seen = new Set<string>()
- const output: string[] = []
- values.forEach(raw => {
- const trimmed = (lowerCase ? raw.toLowerCase() : raw).trim()
- if (!trimmed || seen.has(trimmed)) return
- seen.add(trimmed)
- output.push(trimmed)
- })
- return output
- }
-
- function hydrateContextDraft(context: AdminUserContext) {
- setEmailDraft(context.email || '')
- setContactEmailsDraft(uniqueTrimmed(context.channels.emails || [], true))
- setSlackHandlesDraft(uniqueTrimmed(context.channels.slackUserNames || []))
- setTelegramIdsDraft(uniqueTrimmed(context.channels.telegramIds || []))
- setNewContactEmail('')
- setNewSlackHandle('')
- setNewTelegramId('')
- }
-
- function contextIdFromResource(resource: ContextResource): string {
- const fromSpec = String(resource.spec?.contextId || '').trim()
- if (fromSpec) return fromSpec
- return String(resource.metadata?.name || '').trim()
- }
-
- async function loadUsers(searchQuery = userQuery) {
- setError('')
- try {
- const data = await getAdminUsers(searchQuery.trim())
- setUsers(Array.isArray(data.items) ? data.items : [])
- } catch (e) {
- const message = e instanceof Error ? e.message : 'Failed to load users'
- setUsers([])
- if (message.includes('404')) {
- setError(
- 'Profile admin users endpoint is unavailable (404). Deploy/restart control-api with admin profile routes.'
- )
- } else {
- setError(message)
- }
- }
- }
-
- async function selectUserAndLoad(nextUserId: string) {
- setUserId(nextUserId)
- setBusy(true)
- setError('')
- try {
- const [context, contextAccess] = await Promise.all([
- getAdminUserContext(nextUserId),
- getAdminUserContexts(nextUserId),
- ])
- setSelectedUserContext(context)
- hydrateContextDraft(context)
- setAssignedContextIds(uniqueTrimmed(contextAccess.contextIds || []))
- setSelectedContextToAdd('')
- onSelectedUserIdChange?.(nextUserId)
- const teamId = await loadTeams(nextUserId)
- if (teamId) {
- await loadMembers(teamId)
- } else {
- setMembers([])
- }
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to load team context')
- } finally {
- setBusy(false)
- }
- }
-
- async function loadTeams(nextUserId?: string): Promise<string | null> {
- const resolvedUserId = (nextUserId ?? userId).trim()
- if (!resolvedUserId) {
- setTeams([])
- setSelectedTeamId('')
- setMembers([])
- setMemberRoleDrafts({})
- return null
- }
-
- const data = await getAdminUserTeams(resolvedUserId)
- const nextTeams = Array.isArray(data.items) ? data.items : []
- setTeams(nextTeams)
-
- const fallbackTeamId =
- data.currentTeamId && nextTeams.some(team => team.id === data.currentTeamId)
- ? data.currentTeamId
- : ''
- const teamIdToUse = fallbackTeamId || nextTeams[0]?.id || ''
- setSelectedTeamId(teamIdToUse)
- setTeamNameDraft(nextTeams.find(team => team.id === teamIdToUse)?.name || '')
- return teamIdToUse || null
- }
-
- async function loadMembers(teamId?: string): Promise<void> {
- const resolvedTeamId = (teamId ?? selectedTeamId).trim()
- if (!resolvedTeamId) {
- setMembers([])
- setMemberRoleDrafts({})
- return
- }
-
- const data = await getAdminTeamMembers(resolvedTeamId)
- const nextMembers = Array.isArray(data.items) ? data.items : []
- setMembers(nextMembers)
- setMemberRoleDrafts(
- nextMembers.reduce(
- (acc, member) => ({
- ...acc,
- [member.id]: member.role,
- }),
- {} as Record<string, Role>
- )
- )
- }
-
- async function loadForUser() {
- await selectUserAndLoad(userId.trim())
- }
-
- async function saveUserContext() {
- if (!selectedUserContext) return
- const payload: { email: string; channels: AdminUserChannels } = {
- email: emailDraft.trim().toLowerCase(),
- channels: {
- emails: uniqueTrimmed(contactEmailsDraft, true),
- slackUserNames: uniqueTrimmed(slackHandlesDraft),
- telegramIds: uniqueTrimmed(telegramIdsDraft),
- },
- }
- if (!payload.email) {
- setError('Email is required.')
- return
- }
-
- setBusy(true)
- setError('')
- try {
- const updated = await updateAdminUserContext(selectedUserContext.id, payload)
- setSelectedUserContext(updated)
- hydrateContextDraft(updated)
- showToast('User context updated.', { tone: 'success' })
- await loadUsers(userQuery)
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to update user context')
- } finally {
- setBusy(false)
- }
- }
-
- async function saveUserContexts(nextContextIds: string[], successMessage: string) {
- const resolvedUserId = userId.trim()
- if (!resolvedUserId) return
- setBusy(true)
- setError('')
- try {
- const updated = await updateAdminUserContexts(resolvedUserId, uniqueTrimmed(nextContextIds))
- setAssignedContextIds(uniqueTrimmed(updated.contextIds || []))
- setSelectedContextToAdd('')
- showToast(successMessage, { tone: 'success' })
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to update user context access')
- } finally {
- setBusy(false)
- }
- }
-
- async function addContextAccess() {
- const nextContextId = selectedContextToAdd.trim()
- if (!nextContextId || assignedContextIds.includes(nextContextId)) return
- await saveUserContexts([...assignedContextIds, nextContextId], 'Context access granted.')
- }
-
- async function deleteContextAccess(contextId: string) {
- const shouldDelete = await confirm({
- title: 'Remove Context Access',
- message: `Remove access to ${contextId}?`,
- confirmLabel: 'Remove access',
- tone: 'danger',
- })
- if (!shouldDelete) return
-
- await saveUserContexts(
- assignedContextIds.filter(existing => existing !== contextId),
- 'Context access removed.'
- )
- }
-
- function addContactEmail() {
- setContactEmailsDraft(prev => uniqueTrimmed([...prev, newContactEmail], true))
- setNewContactEmail('')
- }
-
- function addSlackHandle() {
- setSlackHandlesDraft(prev => uniqueTrimmed([...prev, newSlackHandle]))
- setNewSlackHandle('')
- }
-
- function addTelegramId() {
- setTelegramIdsDraft(prev => uniqueTrimmed([...prev, newTelegramId]))
- setNewTelegramId('')
- }
-
- function resetUserSelection() {
- setSelectedUserContext(null)
- setUserId('')
- setTeams([])
- setSelectedTeamId('')
- setMembers([])
- setMemberRoleDrafts({})
- setTeamNameDraft('')
- setEmailDraft('')
- setContactEmailsDraft([])
- setSlackHandlesDraft([])
- setTelegramIdsDraft([])
- setNewContactEmail('')
- setNewSlackHandle('')
- setNewTelegramId('')
- setError('')
- setAssignedContextIds([])
- setSelectedContextToAdd('')
- onSelectedUserIdChange?.(null)
- }
-
- useEffect(() => {
- async function loadReferenceData() {
- await loadUsers('')
- try {
- const data = await getContexts()
- const ids = (data.items || [])
- .map(item => contextIdFromResource(item))
- .filter(Boolean)
- .sort((a, b) => a.localeCompare(b))
- setAvailableContextIds(ids)
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to load contexts')
- }
- }
-
- void loadReferenceData()
- }, [])
-
- useEffect(() => {
- const nextUserId = initialUserId.trim()
- if (!nextUserId) {
- if (selectedUserContext) {
- resetUserSelection()
- }
- return
- }
- if (selectedUserContext?.id === nextUserId) return
- void selectUserAndLoad(nextUserId)
- }, [initialUserId])
-
- async function onTeamChange(nextTeamId: string) {
- setSelectedTeamId(nextTeamId)
- setTeamNameDraft(teams.find(team => team.id === nextTeamId)?.name || '')
- setBusy(true)
- setError('')
- try {
- await loadMembers(nextTeamId)
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to load team members')
- } finally {
- setBusy(false)
- }
- }
-
- async function createTeam() {
- const resolvedUserId = userId.trim()
- const name = newTeamName.trim()
- if (!name) return
-
- setBusy(true)
- setError('')
- try {
- const created = await createAdminTeam(name)
- setNewTeamName('')
- await loadTeams(resolvedUserId)
- setSelectedTeamId(created.id)
- setTeamNameDraft(created.name)
- await loadMembers(created.id)
- showToast('Team created.', { tone: 'success' })
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to create team')
- } finally {
- setBusy(false)
- }
- }
-
- async function renameTeam() {
- const teamId = selectedTeamId.trim()
- const name = teamNameDraft.trim()
- if (!teamId || !name) return
-
- setBusy(true)
- setError('')
- try {
- await renameAdminTeam(teamId, name)
- await loadTeams()
- showToast('Team renamed.', { tone: 'success' })
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to rename team')
- } finally {
- setBusy(false)
- }
- }
-
- async function inviteMember() {
- const teamId = selectedTeamId.trim()
- const name = inviteName.trim()
- const email = inviteEmail.trim().toLowerCase()
- if (!teamId || !name || !email) return
-
- setBusy(true)
- setError('')
- try {
- await inviteAdminTeamMember(teamId, {
- name,
- email,
- role: inviteRole,
- })
- setInviteName('')
- setInviteEmail('')
- showToast('Invitation created.', { tone: 'success' })
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to create invitation')
- } finally {
- setBusy(false)
- }
- }
-
- async function updateMemberRole(memberId: string) {
- const teamId = selectedTeamId.trim()
- const nextRole = memberRoleDrafts[memberId]
- if (!teamId || !nextRole) return
-
- setBusy(true)
- setError('')
- try {
- await updateAdminMemberRole(teamId, memberId, nextRole)
- await loadMembers(teamId)
- showToast('Member role updated.', { tone: 'success' })
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to update member role')
- } finally {
- setBusy(false)
- }
- }
-
- async function deleteMember(memberId: string) {
- const teamId = selectedTeamId.trim()
- if (!teamId) return
- const shouldDelete = await confirm({
- title: 'Delete Team Member',
- message: 'Delete this team member?',
- confirmLabel: 'Delete',
- tone: 'danger',
- })
- if (!shouldDelete) return
-
- setBusy(true)
- setError('')
- try {
- await deleteAdminMember(teamId, memberId)
- await loadMembers(teamId)
- showToast('Member removed.', { tone: 'success' })
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to remove member')
- } finally {
- setBusy(false)
- }
- }
-
- return (
- <section
- style={{
- border: '1px solid var(--cu-border)',
- borderRadius: 10,
- padding: 12,
- display: 'grid',
- gap: 12,
- }}
- >
- <h3 style={{ margin: 0 }}>Profile Admin (Team/Member)</h3>
- <div style={{ fontSize: 13, color: 'var(--cu-text-soft)' }}>
- Use explicit selectors. Load a user row to hydrate team context, then manage team members
- and roles.
- </div>
-
- {!selectedUserContext ? (
- <div
- style={{
- border: '1px solid var(--cu-border)',
- borderRadius: 8,
- padding: 10,
- display: 'grid',
- gap: 8,
- }}
- >
- <strong>Users</strong>
- <div style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>
- Showing the first 100 users ordered by email.
- </div>
- <div style={{ display: 'flex', gap: 8 }}>
- <input
- style={{ flex: 1 }}
- value={userQuery}
- onChange={e => setUserQuery(e.target.value)}
- placeholder="Search by email, name, or display name"
- />
- <button type="button" onClick={() => void loadUsers()} disabled={busy}>
- Search
- </button>
- </div>
- {users.length === 0 ? (
- <div style={{ color: 'var(--cu-text-soft)' }}>No users found for this query.</div>
- ) : (
- <div style={{ overflowX: 'auto' }}>
- <table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 13 }}>
- <thead>
- <tr style={{ textAlign: 'left', borderBottom: '1px solid var(--cu-border)' }}>
- <th style={{ padding: '6px 8px' }}>Name</th>
- <th style={{ padding: '6px 8px' }}>Email</th>
- <th style={{ padding: '6px 8px' }}>Display Name</th>
- <th style={{ padding: '6px 8px' }}>Teams</th>
- <th style={{ padding: '6px 8px' }}>Action</th>
- </tr>
- </thead>
- <tbody>
- {users.map(user => (
- <tr key={user.id} style={{ borderBottom: '1px solid var(--cu-border-subtle)' }}>
- <td style={{ padding: '6px 8px' }}>{user.name || '-'}</td>
- <td style={{ padding: '6px 8px' }}>{user.email}</td>
- <td style={{ padding: '6px 8px' }}>{user.displayName || '-'}</td>
- <td style={{ padding: '6px 8px' }}>{user.activeTeamCount}</td>
- <td style={{ padding: '6px 8px' }}>
- <button
- type="button"
- onClick={() => void selectUserAndLoad(user.id)}
- disabled={busy}
- >
- Load Context
- </button>
- </td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
- )}
- </div>
- ) : (
- <div
- style={{
- border: '1px solid var(--cu-border)',
- borderRadius: 8,
- padding: 10,
- display: 'grid',
- gap: 8,
- }}
- >
- <div
- style={{
- display: 'flex',
- justifyContent: 'space-between',
- alignItems: 'center',
- gap: 8,
- }}
- >
- <strong>User Context</strong>
- <div style={{ display: 'flex', gap: 8 }}>
- <button type="button" onClick={saveUserContext} disabled={busy || !emailDraft.trim()}>
- Save User
- </button>
- <button type="button" onClick={resetUserSelection} disabled={busy}>
- Back to Users
- </button>
- </div>
- </div>
- <div style={{ fontSize: 13 }}>
- <strong>
- {selectedUserContext.displayName ||
- selectedUserContext.name ||
- selectedUserContext.email}
- </strong>
- </div>
- <div style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>
- userId: {selectedUserContext.id}
- </div>
- <div
- style={{
- display: 'grid',
- gap: 6,
- borderTop: '1px solid var(--cu-border-subtle)',
- paddingTop: 8,
- }}
- >
- <label style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>Primary Email</label>
- <input
- value={emailDraft}
- onChange={e => setEmailDraft(e.target.value)}
- placeholder="[email protected]"
- />
- </div>
- <div
- style={{
- display: 'grid',
- gap: 6,
- borderTop: '1px solid var(--cu-border-subtle)',
- paddingTop: 8,
- }}
- >
- <div style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>
- <strong>Contact Emails</strong>
- </div>
- <div style={{ display: 'flex', gap: 8 }}>
- <input
- style={{ flex: 1 }}
- value={newContactEmail}
- onChange={e => setNewContactEmail(e.target.value)}
- placeholder="Add contact email"
- />
- <button
- type="button"
- onClick={addContactEmail}
- disabled={busy || !newContactEmail.trim()}
- >
- Add
- </button>
- </div>
- {contactEmailsDraft.length === 0 ? (
- <div style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>-</div>
- ) : (
- contactEmailsDraft.map(email => (
- <div
- key={email}
- style={{ display: 'flex', justifyContent: 'space-between', gap: 8 }}
- >
- <span style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>{email}</span>
- <button
- type="button"
- onClick={() =>
- setContactEmailsDraft(prev => prev.filter(value => value !== email))
- }
- disabled={busy}
- >
- Delete
- </button>
- </div>
- ))
- )}
- </div>
- <div
- style={{
- display: 'grid',
- gap: 6,
- borderTop: '1px solid var(--cu-border-subtle)',
- paddingTop: 8,
- }}
- >
- <div style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>
- <strong>Slack Handles</strong>
- </div>
- <div style={{ display: 'flex', gap: 8 }}>
- <input
- style={{ flex: 1 }}
- value={newSlackHandle}
- onChange={e => setNewSlackHandle(e.target.value)}
- placeholder="Add slack handle"
- />
- <button
- type="button"
- onClick={addSlackHandle}
- disabled={busy || !newSlackHandle.trim()}
- >
- Add
- </button>
- </div>
- {slackHandlesDraft.length === 0 ? (
- <div style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>-</div>
- ) : (
- slackHandlesDraft.map(handle => (
- <div
- key={handle}
- style={{ display: 'flex', justifyContent: 'space-between', gap: 8 }}
- >
- <span style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>{handle}</span>
- <button
- type="button"
- onClick={() =>
- setSlackHandlesDraft(prev => prev.filter(value => value !== handle))
- }
- disabled={busy}
- >
- Delete
- </button>
- </div>
- ))
- )}
- </div>
- <div
- style={{
- display: 'grid',
- gap: 6,
- borderTop: '1px solid var(--cu-border-subtle)',
- paddingTop: 8,
- }}
- >
- <div style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>
- <strong>Telegram IDs</strong>
- </div>
- <div style={{ display: 'flex', gap: 8 }}>
- <input
- style={{ flex: 1 }}
- value={newTelegramId}
- onChange={e => setNewTelegramId(e.target.value)}
- placeholder="Add telegram id"
- />
- <button
- type="button"
- onClick={addTelegramId}
- disabled={busy || !newTelegramId.trim()}
- >
- Add
- </button>
- </div>
- {telegramIdsDraft.length === 0 ? (
- <div style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>-</div>
- ) : (
- telegramIdsDraft.map(telegramId => (
- <div
- key={telegramId}
- style={{ display: 'flex', justifyContent: 'space-between', gap: 8 }}
- >
- <span style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>{telegramId}</span>
- <button
- type="button"
- onClick={() =>
- setTelegramIdsDraft(prev => prev.filter(value => value !== telegramId))
- }
- disabled={busy}
- >
- Delete
- </button>
- </div>
- ))
- )}
- </div>
- </div>
- )}
-
- {selectedUserContext && (
- <div style={{ display: 'grid', gap: 6 }}>
- <label style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>Selected userId</label>
- <div style={{ display: 'flex', gap: 8 }}>
- <input
- style={{ flex: 1 }}
- value={userId}
- onChange={e => setUserId(e.target.value)}
- placeholder="user UUID"
- />
- <button
- type="button"
- onClick={() => void loadForUser()}
- disabled={busy || !userId.trim()}
- >
- Reload User Context
- </button>
- </div>
- </div>
- )}
-
- {selectedUserContext && (
- <div style={{ display: 'grid', gap: 6 }}>
- <label style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>Team</label>
- <select
- value={selectedTeamId}
- onChange={e => onTeamChange(e.target.value)}
- disabled={busy || teams.length === 0}
- >
- {teams.length === 0 && <option value="">No teams loaded</option>}
- {teams.map(team => (
- <option key={team.id} value={team.id}>
- {team.name} ({team.role})
- </option>
- ))}
- </select>
- </div>
- )}
-
- {selectedUserContext && (
- <div
- style={{
- border: '1px solid var(--cu-border)',
- borderRadius: 8,
- padding: 10,
- display: 'grid',
- gap: 8,
- }}
- >
- <strong>Context Access</strong>
- <div style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>
- Associate this user with contexts that they can access.
- </div>
- <div style={{ display: 'flex', gap: 8 }}>
- <select
- style={{ flex: 1 }}
- value={selectedContextToAdd}
- onChange={e => setSelectedContextToAdd(e.target.value)}
- disabled={busy || availableContextIds.length === 0}
- >
- <option value="">Select context</option>
- {availableContextIds
- .filter(contextId => !assignedContextIds.includes(contextId))
- .map(contextId => (
- <option key={contextId} value={contextId}>
- {contextId}
- </option>
- ))}
- </select>
- <button
- type="button"
- onClick={() => void addContextAccess()}
- disabled={busy || !selectedContextToAdd}
- >
- Add Access
- </button>
- </div>
-
- {assignedContextIds.length === 0 ? (
- <div style={{ color: 'var(--cu-text-soft)', fontSize: 12 }}>
- No context access assigned.
- </div>
- ) : (
- assignedContextIds.map(contextId => (
- <div
- key={contextId}
- style={{
- borderTop: '1px solid var(--cu-border-subtle)',
- paddingTop: 8,
- display: 'flex',
- justifyContent: 'space-between',
- gap: 8,
- }}
- >
- <span style={{ fontSize: 13 }}>{contextId}</span>
- <div style={{ display: 'flex', gap: 8 }}>
- <button
- type="button"
- onClick={() => router.push(CONTROL_ROUTES.contexts.detail(contextId))}
- disabled={busy}
- >
- Open Context
- </button>
- <button
- type="button"
- onClick={() => void deleteContextAccess(contextId)}
- disabled={busy}
- >
- Delete Access
- </button>
- </div>
- </div>
- ))
- )}
- </div>
- )}
-
- {selectedUserContext && (
- <div
- style={{
- border: '1px solid var(--cu-border)',
- borderRadius: 8,
- padding: 10,
- display: 'grid',
- gap: 8,
- }}
- >
- <strong>Team Settings</strong>
- <input
- value={teamNameDraft}
- onChange={e => setTeamNameDraft(e.target.value)}
- placeholder="Team name"
- />
- <div style={{ display: 'flex', gap: 8 }}>
- <button
- type="button"
- onClick={renameTeam}
- disabled={busy || !selectedTeamId || !teamNameDraft.trim()}
- >
- Save Team Name
- </button>
- <input
- style={{ flex: 1 }}
- value={newTeamName}
- onChange={e => setNewTeamName(e.target.value)}
- placeholder="New team name"
- />
- <button type="button" onClick={createTeam} disabled={busy || !newTeamName.trim()}>
- Create Team
- </button>
- </div>
- </div>
- )}
-
- {selectedUserContext && (
- <div
- style={{
- border: '1px solid var(--cu-border)',
- borderRadius: 8,
- padding: 10,
- display: 'grid',
- gap: 8,
- }}
- >
- <strong>Invite Member</strong>
- <div style={{ display: 'flex', gap: 8 }}>
- <input
- style={{ flex: 1 }}
- value={inviteName}
- onChange={e => setInviteName(e.target.value)}
- placeholder="Invitee name"
- />
- <input
- style={{ flex: 1 }}
- value={inviteEmail}
- onChange={e => setInviteEmail(e.target.value)}
- placeholder="Invitee email"
- />
- <select value={inviteRole} onChange={e => setInviteRole(e.target.value as InviteRole)}>
- <option value="member">member</option>
- <option value="inviter">inviter</option>
- <option value="admin">admin</option>
- </select>
- <button
- type="button"
- onClick={inviteMember}
- disabled={busy || !inviteName.trim() || !inviteEmail.trim() || !selectedTeamId}
- >
- Invite
- </button>
- </div>
- </div>
- )}
-
- {selectedUserContext && (
- <div
- style={{
- border: '1px solid var(--cu-border)',
- borderRadius: 8,
- padding: 10,
- display: 'grid',
- gap: 8,
- }}
- >
- <strong>Team Members {selectedTeam ? `(${selectedTeam.name})` : ''}</strong>
- {members.length === 0 ? (
- <div style={{ color: 'var(--cu-text-soft)' }}>No members found for selected team.</div>
- ) : (
- members.map(member => (
- <div
- key={member.id}
- style={{
- borderTop: '1px solid var(--cu-border-subtle)',
- paddingTop: 8,
- display: 'grid',
- gap: 6,
- }}
- >
- <div
- style={{
- display: 'flex',
- justifyContent: 'space-between',
- alignItems: 'center',
- gap: 8,
- }}
- >
- <div>
- <div>{member.name || member.email}</div>
- <div style={{ fontSize: 12, color: 'var(--cu-text-soft)' }}>
- {member.email} | role: {member.role} | status: {member.status || 'active'}
- </div>
- </div>
- <button type="button" onClick={() => deleteMember(member.id)} disabled={busy}>
- Delete
- </button>
- </div>
- <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
- <select
- value={memberRoleDrafts[member.id] || member.role}
- onChange={e =>
- setMemberRoleDrafts(prev => ({
- ...prev,
- [member.id]: e.target.value as Role,
- }))
- }
- >
- <option value="admin">admin</option>
- <option value="inviter">inviter</option>
- <option value="member">member</option>
- </select>
- <button
- type="button"
- onClick={() => updateMemberRole(member.id)}
- disabled={
- busy ||
- !memberRoleDrafts[member.id] ||
- memberRoleDrafts[member.id] === member.role
- }
- >
- Save Role
- </button>
- </div>
- </div>
- ))
- )}
- </div>
- )}
-
- {error && <div style={{ color: '#ff8ea7' }}>{error}</div>}
- {confirmDialog}
- </section>
- )
-}
diff --git a/control-ui/next.config.js b/control-ui/next.config.js
index 029acc396..ab9b105b8 100644
--- a/control-ui/next.config.js
+++ b/control-ui/next.config.js
@@ -139,6 +139,17 @@ const nextConfig = {
destination: '/connectors/:name/edit/access',
permanent: true,
},
+ // Users & Teams "Contexts" tabs renamed to "Access".
+ {
+ source: '/users-and-teams/users/:id/contexts',
+ destination: '/users-and-teams/users/:id/access',
+ permanent: true,
+ },
+ {
+ source: '/users-and-teams/teams/:id/contexts',
+ destination: '/users-and-teams/teams/:id/access',
+ permanent: true,
+ },
{ source: '/marketplace', destination: '/marketplace/connectors', permanent: true },
{ source: '/cost-and-usage', destination: '/cost-and-usage/usage', permanent: true },
{
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index c7cda9813..886a7d583 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.459",
+ "version": "0.1.460",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.459",
+ "version": "0.1.460",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/llm-providers": "file:../packages/llm-providers",
diff --git a/control-ui/package.json b/control-ui/package.json
index 29e399255..94a5d9dd2 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.459",
+ "version": "0.1.460",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/docs/features/control-ui-context-removal.md b/docs/features/control-ui-context-removal.md
index 58946bf31..363fd60df 100644
--- a/docs/features/control-ui-context-removal.md
+++ b/docs/features/control-ui-context-removal.md
@@ -193,6 +193,7 @@ Tests updated in the same commit: `HostTable.test.tsx` (hover card now asserts a
| 2026-08-26 | — | Document created; baseline verified at `a584c259a`; research inventories completed (surfaces + test impact) |
| 2026-08-26 | 0 | E1/E2/E3 implemented: hover card shows neutral "Connectors" heading (no slug), click opens the agent's own Connectors tab (`onOpenConnectors`), wizard failure copy reworded, error mapping verified interceptor-covered. CSS family renamed (`cu-agent-connectors-summary*`, `cu-host-connectors-*`; dead `cu-host-context-select` removed). Tests: `HostTable.test.tsx` (+slug-never-renders invariant, +click-navigation), `HostWizard.test.tsx` copy. `tsc --noEmit` + full vitest green (1743 passed). No backend changes. |
| 2026-08-26 | 1 | Category B implemented. **B1** connectors list: expanded row now has one write-capable **Agents** group (per-binding remove, shared-scope confirm when a context backs >1 agent, "Add agents" modal picking agents); Teams/Users stay read-only; orphan contexts (no owning agent) are invisible; `McpServerTable` props reworked (`agentBindingsByConnectorName`, `agentTargets`, `onAdd/RemoveFromAgents`, `updatingAgentAccessKey`). **B2** connector edit: tab `context`→`access` ("Access"), section "Agent access", redirect added for `/connectors/:name/edit/context`. **B3** create connector: steps `['Connector','Access','Secrets']`, optional agent multi-select with access preview; no-selection path creates a private scope (CRD requires `spec.contextRef`, so the connector gets its own invisible scope — same as installs); partial-failure copy names agents. **B4** install page form: steps `['Package','Credentials','Install']`, silent private scope per install via new `lib/privateContext.ts` (also adopted by HostWizard); success copy reworded. **B5** CSS renames (`cu-entity-access*`, `cu-connector-agent-access*`). Dead `RegistryInstallModal` + test deleted (zero production importers; documented dead in self-hosted-registry-ux-redesign.md). New shared helper `lib/privateContext.ts` (create-POST with one collision retry; wire shape identical to wizard's). Tests updated: McpServerTable, ConnectorEditContext, CreateMcpServerForm, RegistryInstallForm. Full vitest green (1718 passed), `tsc --noEmit` clean. **No backend changes** (verified: registry install API still receives `contextRef`; McpServer CRD still gets a valid `spec.contextRef`). |
+| 2026-08-26 | 2 | Category C implemented. Member + team detail "Contexts" tabs → route `access` / label **"Access"**; rows now show resolved labels (owning agent name(s) → context `displayName` → muted raw id) and no longer link into `/contexts`; confirm/toast/error copy reworded ("Access updated.", "Removed access" for deleted mappings); add-modal relabeled with resolved-label picker, writing context IDs unchanged. Team wizard step "Contexts" → **"Access"** with resolved-label options; `createFlowLoading.createTeam` updated. Legacy `ProfileAdminPanel.tsx` deleted (zero importers). `ProfileAdminHome` "Contexts" column → **"Access"** (same sort/count source `teamContextCounts`); org-delete warning reworded. Redirects added for `/users-and-teams/{users,teams}/:id/contexts` → `…/access`. Full vitest + `tsc` green. No backend changes (GET/PUT `/admin/{users,teams}/:id/contexts` payloads byte-identical). |
## 11. Open questions / follow-ups (non-blocking)