Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(control-ui): agent ux polish for create wizard, host detail, and tables
Miguelon Peluchone3ff3801e050
diff --git a/control-ui/app/constants/hostDetails.ts b/control-ui/app/constants/hostDetails.tsindex c0d042ddc..49bdc12ea 100644--- a/control-ui/app/constants/hostDetails.ts+++ b/control-ui/app/constants/hostDetails.ts@@ -1,14 +1,5 @@export const HOST_DEFAULT_TAB = 'details'-export const HOST_TABS = [- 'details',- 'identity',- 'model',- 'contexts',- 'users',- 'teams',- 'approvals',- 'env',-] as const+export const HOST_TABS = ['details', 'identity', 'model', 'contexts', 'access', 'advanced'] as constexport type HostTab = (typeof HOST_TABS)[number]diff --git a/control-ui/app/globals.css b/control-ui/app/globals.cssindex 88da59318..6e4305c0b 100644--- a/control-ui/app/globals.css+++ b/control-ui/app/globals.css@@ -5897,6 +5897,10 @@ textarea.cu-input {color: var(--cu-text-muted);}+.cu-agent-input-shell__status--invalid {+ color: var(--cu-warning);+}+.cu-agent-namespace,.cu-agent-option-meta,.cu-agent-review,@@ -6038,32 +6042,6 @@ textarea.cu-input {line-height: 1.25;}-.cu-agent-info-card {- display: grid;- grid-template-columns: auto minmax(0, 1fr);- gap: 0.75rem;- margin-top: 0.55rem;- padding: 1rem;- border: 1px solid rgba(var(--cu-accent-rgb), 0.42);- border-radius: var(--cu-radius-sm);- background: rgba(var(--cu-accent-rgb), 0.1);- color: var(--cu-warning);-}--.cu-agent-info-card strong {- display: block;- margin-bottom: 0.35rem;- color: var(--cu-accent-hover);- font-size: 0.8125rem;-}--.cu-agent-info-card p {- margin: 0;- color: var(--cu-text-muted);- font-size: 0.8125rem;- line-height: 1.45;-}-.cu-agent-radio {display: flex;align-items: center;@@ -6324,6 +6302,39 @@ textarea.cu-input {line-height: 1.25;}+.cu-agent-select__providers {+ display: inline-flex;+ flex-wrap: wrap;+ align-items: center;+ gap: 0.35rem;+ color: var(--cu-text-soft);+ font-size: 0.75rem;+ line-height: 1.25;+}++.cu-agent-select__providers-label {+ margin-right: 0.1rem;+}++.cu-agent-select__provider {+ display: inline-flex;+ align-items: center;+ gap: 0.3rem;+}++.cu-agent-select__provider .cu-llm-provider-icon {+ width: 1.1rem;+ height: 1.1rem;+ flex-basis: 1.1rem;+ border-color: transparent;+ background: transparent;+ border-radius: 0.25rem;+}++.cu-agent-select__provider .cu-llm-provider-icon img {+ padding: 0;+}+.cu-agent-select__option:hover,.cu-agent-select__option:focus-visible,.cu-agent-select__option[data-active='true'] {@@ -7767,6 +7778,7 @@ textarea.cu-input {display: grid;gap: var(--cu-space-3);grid-template-rows: auto auto minmax(0, 1fr);+ flex: 1;min-height: 0;border: 1px solid var(--cu-border-subtle);border-radius: var(--cu-radius-sm);@@ -7803,19 +7815,29 @@ textarea.cu-input {}.cu-identity-editor {- display: grid;+ display: flex;+ flex-direction: column;gap: var(--cu-space-2);- grid-template-rows: minmax(24rem, 1fr) auto;- min-height: min(38rem, calc(100vh - 21rem));+ flex: 1;+ min-height: 0;}.cu-detail-flow-panel + .cu-card:has(.cu-identity-panel) {display: flex;flex-direction: column;+ min-height: calc(100vh - 18rem);}.cu-detail-flow-panel + .cu-card:has(.cu-identity-panel) > .cu-card__body {- display: grid;+ display: flex;+ flex-direction: column;+ flex: 1;+ min-height: 0;+}++.cu-identity-panel {+ display: flex;+ flex-direction: column;flex: 1;min-height: 0;}@@ -7825,8 +7847,8 @@ textarea.cu-input {border-radius: var(--cu-radius-sm);background: var(--cu-surface);overflow: hidden;- height: 100%;- min-height: 24rem;+ flex: 1;+ min-height: 20rem;transition:border-color 0.15s,box-shadow 0.15s;@@ -7892,17 +7914,31 @@ textarea.cu-input {.cu-markdown-editor .w-md-editor-text-input {color: var(--cu-text) !important;- -webkit-text-fill-color: var(--cu-text);caret-color: var(--cu-text);font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',monospace;}+.cu-markdown-editor .w-md-editor-text-input::placeholder {+ color: var(--cu-text-muted) !important;+ -webkit-text-fill-color: var(--cu-text-muted) !important;+ opacity: 0.35 !important;+}+.cu-markdown-editor .w-md-editor-text-pre {color: var(--cu-text-muted);}+.cu-access-section__header {+ display: flex;+ flex-wrap: wrap;+ justify-content: space-between;+ align-items: center;+ gap: 0.5rem;+ margin-bottom: 1rem;+}+.cu-markdown-editor .wmde-markdown {background: var(--cu-surface);color: var(--cu-text);diff --git a/control-ui/app/hosts/[name]/[tab]/page.tsx b/control-ui/app/hosts/[name]/[tab]/page.tsxindex 52b04221d..172081535 100644--- a/control-ui/app/hosts/[name]/[tab]/page.tsx+++ b/control-ui/app/hosts/[name]/[tab]/page.tsx@@ -7,16 +7,7 @@ interface HostTabPageProps {export default async function HostTabPage({ params }: HostTabPageProps) {const { tab } = await params- const tabs = [- 'overview',- 'model',- 'approvals',- 'identity',- 'contexts',- 'env-vars',- 'member-access',- 'team-access',- ]+ const tabs = ['overview', 'model', 'identity', 'contexts', 'access', 'advanced']if (!tabs.includes(tab)) notFound()return <HostDetailsPage />diff --git a/control-ui/app/hosts/[name]/page.tsx b/control-ui/app/hosts/[name]/page.tsxindex 6729e08c6..034c515ca 100644--- a/control-ui/app/hosts/[name]/page.tsx+++ b/control-ui/app/hosts/[name]/page.tsx@@ -4,12 +4,11 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'import { useParams, useRouter } from 'next/navigation'import { useConfirmDialog } from '@components/ConfirmDialog'import { DetailPageShell } from '@components/DetailPageShell'-import { SelectionDropdown } from '@components/SelectionDropdown'import { useToast } from '@components/Toast'import { HOST_DEFAULT_TAB, HOST_TABS } from '@constants/hostDetails'import { CONTROL_ROUTES } from '@constants/routes'-import { HostApprovalSection } from '../../../components/HostApprovalSection'-import { HostEnvTable } from '../../../components/HostEnvTable'+import { HostAccessTab } from '../../../components/HostAccessTab'+import { HostAdvancedTab } from '../../../components/HostAdvancedTab'import { HostIdentityTab } from '../../../components/HostIdentityTab'import { LlmProviderConfig } from '../../../components/LlmProviderConfig'import { IconRobot } from '../../../components/Sidebar/icons'@@ -51,22 +50,18 @@ import type { ChannelResource, HostTab } from './types'const TAB_LABELS: Record<HostTab, string> = {details: 'Overview',model: 'Models & creds',- approvals: 'Per-tool approval',+ advanced: 'Advanced',contexts: 'Context',- env: 'Env vars',- users: 'Member access',- teams: 'Team access',+ access: 'Access',identity: 'Identity',}const TAB_SLUGS: Record<HostTab, string> = {details: 'overview',model: 'model',- approvals: 'approvals',+ advanced: 'advanced',contexts: 'contexts',- env: 'env-vars',- users: 'member-access',- teams: 'team-access',+ access: 'access',identity: 'identity',}@@ -106,8 +101,6 @@ export default function HostDetailsPage() {const [error, setError] = useState('')const [initialLoading, setInitialLoading] = useState(true)- const [showAddUser, setShowAddUser] = useState(false)- const [showAddTeam, setShowAddTeam] = useState(false)const [editingOverview, setEditingOverview] = useState(false)const [editingModel, setEditingModel] = useState(false)const [editingContext, setEditingContext] = useState(false)@@ -157,49 +150,7 @@ export default function HostDetailsPage() {const [availableContexts, setAvailableContexts] = useState<string[]>([])const [availableSecrets, setAvailableSecrets] = useState<string[]>([])- const [allUsers, setAllUsers] = useState<- Array<{ id: string; email: string; name: string | null; displayName: string | null }>- >([])- const [allTeams, setAllTeams] = useState<- Array<{ id: string; name: string; memberCount: number }>- >([])- const [usersWithAccess, setUsersWithAccess] = useState<- Array<{ id: string; email: string; name: string | null; displayName: string | null }>- >([])- const [teamsWithAccess, setTeamsWithAccess] = useState<Array<{ id: string; name: string }>>([])- const [selectedUserIdsToGrant, setSelectedUserIdsToGrant] = useState<string[]>([])- const [selectedTeamIdsToGrant, setSelectedTeamIdsToGrant] = useState<string[]>([])- const userIdsWithAccess = useMemo(- () => new Set(usersWithAccess.map(u => u.id)),- [usersWithAccess]- )- const teamIdsWithAccess = useMemo(- () => new Set(teamsWithAccess.map(t => t.id)),- [teamsWithAccess]- )- const memberGrantOptions = useMemo(- () =>- allUsers- .filter(user => !userIdsWithAccess.has(user.id))- .map(user => ({- value: user.id,- label: user.displayName || user.name || user.email || user.id,- description: user.email || user.id,- })),- [allUsers, userIdsWithAccess]- )- const teamGrantOptions = useMemo(- () =>- allTeams- .filter(team => !teamIdsWithAccess.has(team.id))- .map(team => ({- value: team.id,- label: team.name,- badge: team.memberCount === 1 ? '1 member' : `${team.memberCount} members`,- })),- [allTeams, teamIdsWithAccess]- )const hasPendingRename = hostNameDraft.trim() && hostNameDraft.trim() !== routeNameconst providerModelOptions = useMemo(() => getModelOptions(allowedCatalog, providerDraft),@@ -270,15 +221,7 @@ export default function HostDetailsPage() {setError('')try {const detail = await getHostDetailBundle(routeName)- const {- host,- contexts: contextsList,- secrets: secretsList,- users,- teams,- agentUsers,- agentTeams,- } = detail+ const { host, contexts: contextsList, secrets: secretsList } = detailif (!mountedRef.current) returnconst spec = host.spec || {}// AP-6: remember the version of THIS read — the edit drafts below are@@ -351,10 +294,6 @@ export default function HostDetailsPage() {if (name) keysMap[name] = Array.isArray(item.keys) ? item.keys : []}setSecretKeysByName(keysMap)- setAllUsers(Array.isArray(users) ? users : [])- setAllTeams(Array.isArray(teams) ? teams : [])- setUsersWithAccess(Array.isArray(agentUsers) ? agentUsers : [])- setTeamsWithAccess(Array.isArray(agentTeams) ? agentTeams : [])} catch (e) {if (!mountedRef.current) returnsetError(e instanceof Error ? e.message : 'Failed to load agent details')@@ -458,7 +397,20 @@ export default function HostDetailsPage() {updatedChannels.push({ name: channelName, previousSpec: channel.spec })}- for (const user of usersWithAccess) {+ // Fetch the freshest user/team access lists so a grant/revoke done+ // in the Access tab right before this rename still applies here.+ const [usersAccessSnapshot, teamsAccessSnapshot] = await Promise.all([+ getAgentUsers(routeName),+ getAgentTeams(routeName),+ ])+ const renameUsersWithAccess = Array.isArray(usersAccessSnapshot.items)+ ? usersAccessSnapshot.items+ : []+ const renameTeamsWithAccess = Array.isArray(teamsAccessSnapshot.items)+ ? teamsAccessSnapshot.items+ : []++ for (const user of renameUsersWithAccess) {const userAccess = await getAdminUserAgents(user.id)const previousAgentNames = (userAccess.agentNames || []).map(String)@@ -474,7 +426,7 @@ export default function HostDetailsPage() {])}- for (const team of teamsWithAccess) {+ for (const team of renameTeamsWithAccess) {const teamAccess = await getAdminTeamAgents(team.id)const previousAgentNames = (teamAccess.agentNames || []).map(String)@@ -775,137 +727,6 @@ export default function HostDetailsPage() {[routeName])- async function grantUserAccess() {- if (selectedUserIdsToGrant.length === 0 || hasPendingRename) return- setBusy(true)- setError('')- try {- await Promise.all(- selectedUserIdsToGrant.map(async userId => {- const current = await getAdminUserAgents(userId)- const next = Array.from(new Set([...(current.agentNames || []), routeName]))- await updateAdminUserAgents(userId, next, [- ...(current.agentNames || []),- ...(current.deletedAgentNames || []),- ])- })- )- const grantedUserIds = selectedUserIdsToGrant- const grantedUser = allUsers.find(u => u.id === grantedUserIds[0])- setSelectedUserIdsToGrant([])- const refreshed = await getAgentUsers(routeName)- setUsersWithAccess(Array.isArray(refreshed.items) ? refreshed.items : [])- showToast(- grantedUserIds.length === 1- ? `${grantedUser?.displayName || grantedUser?.name || grantedUserIds[0]} can now use this agent.`- : `${grantedUserIds.length} members can now use this agent.`,- { tone: 'success' }- )- } catch (e) {- setError(e instanceof Error ? e.message : 'Failed to grant member access')- } finally {- setBusy(false)- }- }-- async function revokeUserAccess(userId: string) {- if (hasPendingRename) return- const user = usersWithAccess.find(item => item.id === userId)- const shouldRevoke = await confirm({- title: 'Revoke Member Access',- message: `Revoke ${user?.displayName || user?.name || user?.email || 'this member'}'s access to ${routeName}?`,- confirmLabel: 'Revoke',- tone: 'danger',- })- if (!shouldRevoke) return-- setBusy(true)- setError('')- try {- const current = await getAdminUserAgents(userId)- const next = (current.agentNames || []).filter(name => name !== routeName)- await updateAdminUserAgents(userId, next, [- ...(current.agentNames || []),- ...(current.deletedAgentNames || []),- ])- const removedUser = usersWithAccess.find(u => u.id === userId)- setUsersWithAccess(prev => prev.filter(u => u.id !== userId))- showToast(- `${removedUser?.displayName || removedUser?.name || userId} can no longer use this agent.`,- { tone: 'success' }- )- } catch (e) {- setError(e instanceof Error ? e.message : 'Failed to revoke member access')- } finally {- setBusy(false)- }- }-- async function grantTeamAccess() {- if (selectedTeamIdsToGrant.length === 0 || hasPendingRename) return- setBusy(true)- setError('')- try {- await Promise.all(- selectedTeamIdsToGrant.map(async teamId => {- const current = await getAdminTeamAgents(teamId)- const next = Array.from(new Set([...(current.agentNames || []), routeName]))- await updateAdminTeamAgents(teamId, next, [- ...(current.agentNames || []),- ...(current.deletedAgentNames || []),- ])- })- )- const grantedTeamIds = selectedTeamIdsToGrant- const grantedTeam = allTeams.find(t => t.id === grantedTeamIds[0])- setSelectedTeamIdsToGrant([])- const refreshed = await getAgentTeams(routeName)- setTeamsWithAccess(Array.isArray(refreshed.items) ? refreshed.items : [])- showToast(- grantedTeamIds.length === 1- ? `${grantedTeam?.name || grantedTeamIds[0]} can now use this agent.`- : `${grantedTeamIds.length} teams can now use this agent.`,- { tone: 'success' }- )- } catch (e) {- setError(e instanceof Error ? e.message : 'Failed to grant team access')- } finally {- setBusy(false)- }- }-- async function revokeTeamAccess(teamId: string) {- if (hasPendingRename) return- const team = teamsWithAccess.find(item => item.id === teamId)- const shouldRevoke = await confirm({- title: 'Revoke Team Access',- message: `Revoke ${team?.name || 'this team'}'s access to ${routeName}?`,- confirmLabel: 'Revoke',- tone: 'danger',- })- if (!shouldRevoke) return-- setBusy(true)- setError('')- try {- const current = await getAdminTeamAgents(teamId)- const next = (current.agentNames || []).filter(name => name !== routeName)- await updateAdminTeamAgents(teamId, next, [- ...(current.agentNames || []),- ...(current.deletedAgentNames || []),- ])- const removedTeam = teamsWithAccess.find(t => t.id === teamId)- setTeamsWithAccess(prev => prev.filter(team => team.id !== teamId))- showToast(`${removedTeam?.name || teamId} can no longer use this agent.`, {- tone: 'success',- })- } catch (e) {- setError(e instanceof Error ? e.message : 'Failed to revoke team access')- } finally {- setBusy(false)- }- }-async function deleteAgentPermanently() {setDeletingAgent(true)setDeleteAgentDialogError('')@@ -941,7 +762,7 @@ export default function HostDetailsPage() {tabAriaLabel="Agent sections"tabClassName="cu-tabs--compact"contentClassName={- activeTab === 'approvals' || (activeTab === 'model' && editingModel)+ activeTab === 'advanced' || (activeTab === 'model' && editingModel)? 'cu-agent-detail-card': undefined}@@ -1248,13 +1069,13 @@ export default function HostDetailsPage() {</>)}- {activeTab === 'approvals' && !initialLoading && (- <HostApprovalSection- initialTools={approvalToolsData}- onSave={persistApprovalTools}+ {activeTab === 'advanced' && (+ <HostAdvancedTabbusy={busy}- canWrite={true /* TODO: wire to actual host:write check if/when per-field RBAC lands */}- defaultEditing+ hostName={routeName}+ initialLoading={initialLoading}+ initialTools={approvalToolsData}+ onSaveApprovalTools={persistApprovalTools}/>)}@@ -1352,340 +1173,10 @@ export default function HostDetailsPage() {</>)}- {activeTab === 'env' && <HostEnvTable hostRef={routeName} />}-{activeTab === 'identity' && <HostIdentityTab hostName={routeName} />}- {activeTab === 'users' && (- <>- <div- style={{- display: 'flex',- flexWrap: 'wrap',- justifyContent: 'space-between',- alignItems: 'center',- gap: '0.5rem',- marginBottom: '1rem',- }}- >- <p className="cu-muted" style={{ fontSize: '0.875rem', margin: 0 }}>- Grant or revoke which members can use this agent.- </p>- <button- type="button"- className="cu-btn cu-btn--primary cu-btn--sm"- onClick={() => setShowAddUser(true)}- disabled={busy || hasPendingRename}- >- Add member- </button>- </div>- <div className="cu-table-wrap">- <table className="cu-table cu-table--header-band">- <thead>- <tr>- <th>Member</th>- <th className="cu-table__col-actions">Actions</th>- </tr>- </thead>- <tbody>- {initialLoading ? (- [1, 2, 3].map(i => (- <tr key={i}>- <td>- <div- className="cu-skeleton cu-skeleton--cell"- style={{ width: '10rem' }}- ></div>- </td>- <td></td>- </tr>- ))- ) : usersWithAccess.length === 0 ? (- <tr>- <td colSpan={2} className="cu-empty">- No members have access yet.- </td>- </tr>- ) : (- usersWithAccess.map(user => (- <tr key={user.id}>- <td>- <button- type="button"- className="cu-link"- onClick={() => router.push(CONTROL_ROUTES.usersAndTeams.user(user.id))}- >- {user.displayName || user.name || user.email}- </button>- </td>- <td className="cu-table__cell-actions">- <div className="cu-row-actions">- <button- type="button"- className="cu-btn cu-btn--icon cu-btn--danger-icon"- onClick={() => void revokeUserAccess(user.id)}- disabled={busy || hasPendingRename}- title="Revoke"- aria-label="Revoke member access"- >- <IconX width={16} height={16} />- </button>- </div>- </td>- </tr>- ))- )}- </tbody>- </table>- </div>- </>- )}-- {activeTab === 'teams' && (- <>- <div- style={{- display: 'flex',- flexWrap: 'wrap',- justifyContent: 'space-between',- alignItems: 'center',- gap: '0.5rem',- marginBottom: '1rem',- }}- >- <p className="cu-muted" style={{ fontSize: '0.875rem', margin: 0 }}>- Grant or revoke team-level access to this agent.- </p>- <button- type="button"- className="cu-btn cu-btn--primary cu-btn--sm"- onClick={() => setShowAddTeam(true)}- disabled={busy || hasPendingRename}- >- Add team- </button>- </div>- <div className="cu-table-wrap">- <table className="cu-table cu-table--header-band">- <thead>- <tr>- <th>Team</th>- <th className="cu-table__col-actions">Actions</th>- </tr>- </thead>- <tbody>- {initialLoading ? (- [1, 2, 3].map(i => (- <tr key={i}>- <td>- <div- className="cu-skeleton cu-skeleton--cell"- style={{ width: '10rem' }}- ></div>- </td>- <td></td>- </tr>- ))- ) : teamsWithAccess.length === 0 ? (- <tr>- <td colSpan={2} className="cu-empty">- No teams have access yet.- </td>- </tr>- ) : (- teamsWithAccess.map(team => (- <tr key={team.id}>- <td>- <button- type="button"- className="cu-link"- onClick={() => router.push(CONTROL_ROUTES.usersAndTeams.team(team.id))}- >- {team.name}- </button>- </td>- <td className="cu-table__cell-actions">- <div className="cu-row-actions">- <button- type="button"- className="cu-btn cu-btn--icon cu-btn--danger-icon"- onClick={() => void revokeTeamAccess(team.id)}- disabled={busy || hasPendingRename}- title="Revoke"- aria-label="Revoke team access"- >- <IconX width={16} height={16} />- </button>- </div>- </td>- </tr>- ))- )}- </tbody>- </table>- </div>- </>- )}+ {activeTab === 'access' && <HostAccessTab hostName={routeName} />}</div>- {showAddUser && (- <div- style={{- position: 'fixed',- inset: 0,- background: 'var(--cu-overlay)',- display: 'flex',- alignItems: 'center',- justifyContent: 'center',- zIndex: 1000,- padding: '1rem',- }}- role="presentation"- onClick={e => {- if (e.target === e.currentTarget && !busy) setShowAddUser(false)- }}- >- <div- className="cu-modal-panel cu-modal-panel--selection"- role="dialog"- aria-labelledby="add-user-title"- onClick={e => e.stopPropagation()}- >- <div className="cu-modal-panel__head">- <strong id="add-user-title" style={{ fontSize: '1rem', lineHeight: 1.35 }}>- Add member- </strong>- <button- type="button"- className="cu-btn cu-btn--icon cu-btn--ghost"- onClick={() => setShowAddUser(false)}- disabled={busy}- aria-label="Close"- >- <IconX width={18} height={18} />- </button>- </div>-- <div className="cu-field">- <label htmlFor="agent-member-picker">Members</label>- <SelectionDropdown- id="agent-member-picker"- inline- value={selectedUserIdsToGrant}- onChange={setSelectedUserIdsToGrant}- options={memberGrantOptions}- placeholder="Select members"- searchPlaceholder="Search members..."- selectionLabel="Selected members"- emptyLabel="No available members."- disabled={busy || hasPendingRename}- />- </div>-- <div className="cu-modal-panel__foot">- <button- type="button"- className="cu-btn cu-btn--ghost cu-btn--sm"- onClick={() => setShowAddUser(false)}- disabled={busy}- >- Cancel- </button>- <button- type="button"- className="cu-btn cu-btn--primary"- onClick={async () => {- await grantUserAccess()- setShowAddUser(false)- }}- disabled={busy || selectedUserIdsToGrant.length === 0 || hasPendingRename}- >- {selectedUserIdsToGrant.length > 1 ? 'Add members' : 'Add member'}- </button>- </div>- </div>- </div>- )}-- {showAddTeam && (- <div- style={{- position: 'fixed',- inset: 0,- background: 'var(--cu-overlay)',- display: 'flex',- alignItems: 'center',- justifyContent: 'center',- zIndex: 1000,- padding: '1rem',- }}- role="presentation"- onClick={e => {- if (e.target === e.currentTarget && !busy) setShowAddTeam(false)- }}- >- <div- className="cu-modal-panel cu-modal-panel--selection"- role="dialog"- aria-labelledby="add-team-title"- onClick={e => e.stopPropagation()}- >- <div className="cu-modal-panel__head">- <strong id="add-team-title" style={{ fontSize: '1rem', lineHeight: 1.35 }}>- Add team- </strong>- <button- type="button"- className="cu-btn cu-btn--icon cu-btn--ghost"- onClick={() => setShowAddTeam(false)}- disabled={busy}- aria-label="Close"- >- <IconX width={18} height={18} />- </button>- </div>-- <div className="cu-field">- <label htmlFor="agent-team-picker">Teams</label>- <SelectionDropdown- id="agent-team-picker"- inline- value={selectedTeamIdsToGrant}- onChange={setSelectedTeamIdsToGrant}- options={teamGrantOptions}- placeholder="Select teams"- searchPlaceholder="Search teams..."- selectionLabel="Selected teams"- emptyLabel="No available teams."- disabled={busy || hasPendingRename}- />- </div>-- <div className="cu-modal-panel__foot">- <button- type="button"- className="cu-btn cu-btn--ghost cu-btn--sm"- onClick={() => setShowAddTeam(false)}- disabled={busy}- >- Cancel- </button>- <button- type="button"- className="cu-btn cu-btn--primary"- onClick={async () => {- await grantTeamAccess()- setShowAddTeam(false)- }}- disabled={busy || selectedTeamIdsToGrant.length === 0 || hasPendingRename}- >- {selectedTeamIdsToGrant.length > 1 ? 'Add teams' : 'Add team'}- </button>- </div>- </div>- </div>- )}-{showDeleteAgentConfirm && (<divstyle={{diff --git a/control-ui/components/HostAccessTab/index.tsx b/control-ui/components/HostAccessTab/index.tsxnew file mode 100644index 000000000..03526295f--- /dev/null+++ b/control-ui/components/HostAccessTab/index.tsx@@ -0,0 +1,552 @@+'use client'++import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'+import { useRouter } from 'next/navigation'+import { useConfirmDialog } from '@components/ConfirmDialog'+import { SelectionDropdown } from '@components/SelectionDropdown'+import { TabBar } from '@components/TabBar'+import { useToast } from '@components/Toast'+import { IconX } from '@components/icons'+import { CONTROL_ROUTES } from '@constants/routes'+import {+ getAdminTeamAgents,+ getAdminUserAgents,+ getAgentTeams,+ getAgentUsers,+ getHostDetailBundle,+ updateAdminTeamAgents,+ updateAdminUserAgents,+} from '@lib/api'+import type { AccessSubTab, AccessTeamRow, AccessUserRow, HostAccessTabProps } from './types'++const ACCESS_SUB_TABS: { key: AccessSubTab; label: string }[] = [+ { key: 'members', label: 'Members' },+ { key: 'teams', label: 'Teams' },+]++export function HostAccessTab({ hostName }: HostAccessTabProps) {+ const router = useRouter()+ const { confirm, dialog: confirmDialog } = useConfirmDialog()+ const { showToast } = useToast()+ const mountedRef = useRef(true)+ const loadRequestId = useRef(0)++ const [subTab, setSubTab] = useState<AccessSubTab>('members')+ const [allUsers, setAllUsers] = useState<AccessUserRow[]>([])+ const [allTeams, setAllTeams] = useState<AccessTeamRow[]>([])+ const [usersWithAccess, setUsersWithAccess] = useState<AccessUserRow[]>([])+ const [teamsWithAccess, setTeamsWithAccess] = useState<AccessTeamRow[]>([])+ const [selectedUserIdsToGrant, setSelectedUserIdsToGrant] = useState<string[]>([])+ const [selectedTeamIdsToGrant, setSelectedTeamIdsToGrant] = useState<string[]>([])+ const [showAddUser, setShowAddUser] = useState(false)+ const [showAddTeam, setShowAddTeam] = useState(false)+ const [initialLoading, setInitialLoading] = useState(true)+ const [busy, setBusy] = useState(false)+ const [error, setError] = useState('')++ useEffect(() => {+ mountedRef.current = true+ return () => {+ mountedRef.current = false+ }+ }, [])++ const loadAccess = useCallback(async () => {+ const requestId = loadRequestId.current + 1+ loadRequestId.current = requestId+ setInitialLoading(true)+ setError('')+ try {+ const detail = await getHostDetailBundle(hostName)+ if (!mountedRef.current || requestId !== loadRequestId.current) return+ setAllUsers(Array.isArray(detail.users) ? detail.users : [])+ setAllTeams(Array.isArray(detail.teams) ? detail.teams : [])+ setUsersWithAccess(Array.isArray(detail.agentUsers) ? detail.agentUsers : [])+ setTeamsWithAccess(Array.isArray(detail.agentTeams) ? detail.agentTeams : [])+ } catch (e) {+ if (!mountedRef.current || requestId !== loadRequestId.current) return+ const message = e instanceof Error ? e.message : 'Failed to load access data'+ setError(message)+ showToast(message, { tone: 'error' })+ } finally {+ if (mountedRef.current && requestId === loadRequestId.current) {+ setInitialLoading(false)+ }+ }+ }, [hostName, showToast])++ useEffect(() => {+ void loadAccess()+ return () => {+ loadRequestId.current += 1+ }+ }, [loadAccess])++ const userIdsWithAccess = useMemo(+ () => new Set(usersWithAccess.map(u => u.id)),+ [usersWithAccess]+ )+ const teamIdsWithAccess = useMemo(+ () => new Set(teamsWithAccess.map(t => t.id)),+ [teamsWithAccess]+ )+ const memberGrantOptions = useMemo(+ () =>+ allUsers+ .filter(user => !userIdsWithAccess.has(user.id))+ .map(user => ({+ value: user.id,+ label: user.displayName || user.name || user.email || user.id,+ description: user.email || user.id,+ })),+ [allUsers, userIdsWithAccess]+ )+ const teamGrantOptions = useMemo(+ () =>+ allTeams+ .filter(team => !teamIdsWithAccess.has(team.id))+ .map(team => ({+ value: team.id,+ label: team.name,+ badge: team.memberCount === 1 ? '1 member' : `${team.memberCount} members`,+ })),+ [allTeams, teamIdsWithAccess]+ )++ async function grantUserAccess() {+ if (selectedUserIdsToGrant.length === 0) return+ setBusy(true)+ setError('')+ try {+ await Promise.all(+ selectedUserIdsToGrant.map(async userId => {+ const current = await getAdminUserAgents(userId)+ const next = Array.from(new Set([...(current.agentNames || []), hostName]))+ await updateAdminUserAgents(userId, next, [+ ...(current.agentNames || []),+ ...(current.deletedAgentNames || []),+ ])+ })+ )+ const grantedUserIds = selectedUserIdsToGrant+ const grantedUser = allUsers.find(u => u.id === grantedUserIds[0])+ setSelectedUserIdsToGrant([])+ const refreshed = await getAgentUsers(hostName)+ if (!mountedRef.current) return+ setUsersWithAccess(Array.isArray(refreshed.items) ? refreshed.items : [])+ showToast(+ grantedUserIds.length === 1+ ? `${grantedUser?.displayName || grantedUser?.name || grantedUserIds[0]} can now use this agent.`+ : `${grantedUserIds.length} members can now use this agent.`,+ { tone: 'success' }+ )+ } catch (e) {+ setError(e instanceof Error ? e.message : 'Failed to grant member access')+ } finally {+ if (mountedRef.current) setBusy(false)+ }+ }++ async function revokeUserAccess(userId: string) {+ const user = usersWithAccess.find(item => item.id === userId)+ const shouldRevoke = await confirm({+ title: 'Revoke Member Access',+ message: `Revoke ${user?.displayName || user?.name || user?.email || 'this member'}'s access to ${hostName}?`,+ confirmLabel: 'Revoke',+ tone: 'danger',+ })+ if (!shouldRevoke) return++ setBusy(true)+ setError('')+ try {+ const current = await getAdminUserAgents(userId)+ const next = (current.agentNames || []).filter(name => name !== hostName)+ await updateAdminUserAgents(userId, next, [+ ...(current.agentNames || []),+ ...(current.deletedAgentNames || []),+ ])+ if (!mountedRef.current) return+ const removedUser = usersWithAccess.find(u => u.id === userId)+ setUsersWithAccess(prev => prev.filter(u => u.id !== userId))+ showToast(+ `${removedUser?.displayName || removedUser?.name || userId} can no longer use this agent.`,+ { tone: 'success' }+ )+ } catch (e) {+ setError(e instanceof Error ? e.message : 'Failed to revoke member access')+ } finally {+ if (mountedRef.current) setBusy(false)+ }+ }++ async function grantTeamAccess() {+ if (selectedTeamIdsToGrant.length === 0) return+ setBusy(true)+ setError('')+ try {+ await Promise.all(+ selectedTeamIdsToGrant.map(async teamId => {+ const current = await getAdminTeamAgents(teamId)+ const next = Array.from(new Set([...(current.agentNames || []), hostName]))+ await updateAdminTeamAgents(teamId, next, [+ ...(current.agentNames || []),+ ...(current.deletedAgentNames || []),+ ])+ })+ )+ const grantedTeamIds = selectedTeamIdsToGrant+ const grantedTeam = allTeams.find(t => t.id === grantedTeamIds[0])+ setSelectedTeamIdsToGrant([])+ const refreshed = await getAgentTeams(hostName)+ if (!mountedRef.current) return+ setTeamsWithAccess(Array.isArray(refreshed.items) ? refreshed.items : [])+ showToast(+ grantedTeamIds.length === 1+ ? `${grantedTeam?.name || grantedTeamIds[0]} can now use this agent.`+ : `${grantedTeamIds.length} teams can now use this agent.`,+ { tone: 'success' }+ )+ } catch (e) {+ setError(e instanceof Error ? e.message : 'Failed to grant team access')+ } finally {+ if (mountedRef.current) setBusy(false)+ }+ }++ async function revokeTeamAccess(teamId: string) {+ const team = teamsWithAccess.find(item => item.id === teamId)+ const shouldRevoke = await confirm({+ title: 'Revoke Team Access',+ message: `Revoke ${team?.name || 'this team'}'s access to ${hostName}?`,+ confirmLabel: 'Revoke',+ tone: 'danger',+ })+ if (!shouldRevoke) return++ setBusy(true)+ setError('')+ try {+ const current = await getAdminTeamAgents(teamId)+ const next = (current.agentNames || []).filter(name => name !== hostName)+ await updateAdminTeamAgents(teamId, next, [+ ...(current.agentNames || []),+ ...(current.deletedAgentNames || []),+ ])+ if (!mountedRef.current) return+ const removedTeam = teamsWithAccess.find(t => t.id === teamId)+ setTeamsWithAccess(prev => prev.filter(team => team.id !== teamId))+ showToast(`${removedTeam?.name || teamId} can no longer use this agent.`, {+ tone: 'success',+ })+ } catch (e) {+ setError(e instanceof Error ? e.message : 'Failed to revoke team access')+ } finally {+ if (mountedRef.current) setBusy(false)+ }+ }++ const subTabDescription =+ subTab === 'members'+ ? 'Grant or revoke which members can use this agent.'+ : 'Grant or revoke team-level access to this agent.'++ return (+ <section className="cu-access-tab" aria-label="Access">+ {error ? (+ <div className="cu-banner cu-banner--error" style={{ marginBottom: '0.75rem' }}>+ {error}+ </div>+ ) : null}++ <TabBar<AccessSubTab>+ activeValue={subTab}+ ariaLabel="Access type"+ className="cu-tabs--compact cu-access-tabs"+ onChange={setSubTab}+ options={ACCESS_SUB_TABS.map(tab => ({ label: tab.label, value: tab.key }))}+ />++ <div className="cu-access-section">+ <div className="cu-access-section__header">+ <p className="cu-muted cu-access-section__description">{subTabDescription}</p>+ {subTab === 'members' ? (+ <button+ type="button"+ className="cu-btn cu-btn--primary cu-btn--sm"+ onClick={() => setShowAddUser(true)}+ disabled={busy}+ >+ Add member+ </button>+ ) : (+ <button+ type="button"+ className="cu-btn cu-btn--primary cu-btn--sm"+ onClick={() => setShowAddTeam(true)}+ disabled={busy}+ >+ Add team+ </button>+ )}+ </div>++ <div className="cu-table-wrap">+ <table className="cu-table cu-table--header-band">+ <thead>+ <tr>+ <th>{subTab === 'members' ? 'Member' : 'Team'}</th>+ <th className="cu-table__col-actions">Actions</th>+ </tr>+ </thead>+ <tbody>+ {initialLoading ? (+ [1, 2, 3].map(i => (+ <tr key={i}>+ <td>+ <div+ className="cu-skeleton cu-skeleton--cell"+ style={{ width: '10rem' }}+ ></div>+ </td>+ <td></td>+ </tr>+ ))+ ) : subTab === 'members' ? (+ usersWithAccess.length === 0 ? (+ <tr>+ <td colSpan={2} className="cu-empty">+ No members have access yet.+ </td>+ </tr>+ ) : (+ usersWithAccess.map(user => (+ <tr key={user.id}>+ <td>+ <button+ type="button"+ className="cu-link"+ onClick={() => router.push(CONTROL_ROUTES.usersAndTeams.user(user.id))}+ >+ {user.displayName || user.name || user.email}+ </button>+ </td>+ <td className="cu-table__cell-actions">+ <div className="cu-row-actions">+ <button+ type="button"+ className="cu-btn cu-btn--icon cu-btn--danger-icon"+ onClick={() => void revokeUserAccess(user.id)}+ disabled={busy}+ title="Revoke"+ aria-label="Revoke member access"+ >+ <IconX width={16} height={16} />+ </button>+ </div>+ </td>+ </tr>+ ))+ )+ ) : teamsWithAccess.length === 0 ? (+ <tr>+ <td colSpan={2} className="cu-empty">+ No teams have access yet.+ </td>+ </tr>+ ) : (+ teamsWithAccess.map(team => (+ <tr key={team.id}>+ <td>+ <button+ type="button"+ className="cu-link"+ onClick={() => router.push(CONTROL_ROUTES.usersAndTeams.team(team.id))}+ >+ {team.name}+ </button>+ </td>+ <td className="cu-table__cell-actions">+ <div className="cu-row-actions">+ <button+ type="button"+ className="cu-btn cu-btn--icon cu-btn--danger-icon"+ onClick={() => void revokeTeamAccess(team.id)}+ disabled={busy}+ title="Revoke"+ aria-label="Revoke team access"+ >+ <IconX width={16} height={16} />+ </button>+ </div>+ </td>+ </tr>+ ))+ )}+ </tbody>+ </table>+ </div>+ </div>++ {showAddUser ? (+ <AccessGrantModal+ busy={busy}+ emptyLabel="No available members."+ id="agent-member-picker"+ label="Members"+ onClose={() => setShowAddUser(false)}+ onConfirm={async () => {+ await grantUserAccess()+ setShowAddUser(false)+ }}+ options={memberGrantOptions}+ placeholder="Select members"+ searchPlaceholder="Search members..."+ selectionLabel="Selected members"+ submitLabel={selectedUserIdsToGrant.length > 1 ? 'Add members' : 'Add member'}+ title="Add member"+ titleId="add-user-title"+ value={selectedUserIdsToGrant}+ onChange={setSelectedUserIdsToGrant}+ />+ ) : null}++ {showAddTeam ? (+ <AccessGrantModal+ busy={busy}+ emptyLabel="No available teams."+ id="agent-team-picker"+ label="Teams"+ onClose={() => setShowAddTeam(false)}+ onConfirm={async () => {+ await grantTeamAccess()+ setShowAddTeam(false)+ }}+ options={teamGrantOptions}+ placeholder="Select teams"+ searchPlaceholder="Search teams..."+ selectionLabel="Selected teams"+ submitLabel={selectedTeamIdsToGrant.length > 1 ? 'Add teams' : 'Add team'}+ title="Add team"+ titleId="add-team-title"+ value={selectedTeamIdsToGrant}+ onChange={setSelectedTeamIdsToGrant}+ />+ ) : null}++ {confirmDialog}+ </section>+ )+}++type AccessGrantModalProps = {+ busy: boolean+ emptyLabel: string+ id: string+ label: string+ onChange: (next: string[]) => void+ onClose: () => void+ onConfirm: () => Promise<void>+ options: { value: string; label: string; description?: string; badge?: string }[]+ placeholder: string+ searchPlaceholder: string+ selectionLabel: string+ submitLabel: string+ title: string+ titleId: string+ value: string[]+}++function AccessGrantModal({+ busy,+ emptyLabel,+ id,+ label,+ onChange,+ onClose,+ onConfirm,+ options,+ placeholder,+ searchPlaceholder,+ selectionLabel,+ submitLabel,+ title,+ titleId,+ value,+}: AccessGrantModalProps) {+ return (+ <div+ style={{+ position: 'fixed',+ inset: 0,+ background: 'var(--cu-overlay)',+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'center',+ zIndex: 1000,+ padding: '1rem',+ }}+ role="presentation"+ onClick={e => {+ if (e.target === e.currentTarget && !busy) onClose()+ }}+ >+ <div+ className="cu-modal-panel cu-modal-panel--selection"+ role="dialog"+ aria-labelledby={titleId}+ onClick={e => e.stopPropagation()}+ >+ <div className="cu-modal-panel__head">+ <strong id={titleId} style={{ fontSize: '1rem', lineHeight: 1.35 }}>+ {title}+ </strong>+ <button+ type="button"+ className="cu-btn cu-btn--icon cu-btn--ghost"+ onClick={onClose}+ disabled={busy}+ aria-label="Close"+ >+ <IconX width={18} height={18} />+ </button>+ </div>++ <div className="cu-field">+ <label htmlFor={id}>{label}</label>+ <SelectionDropdown+ emptyLabel={emptyLabel}+ id={id}+ inline+ disabled={busy}+ onChange={onChange}+ options={options}+ placeholder={placeholder}+ searchPlaceholder={searchPlaceholder}+ selectionLabel={selectionLabel}+ value={value}+ />+ </div>++ <div className="cu-modal-panel__foot">+ <button+ type="button"+ className="cu-btn cu-btn--ghost cu-btn--sm"+ onClick={onClose}+ disabled={busy}+ >+ Cancel+ </button>+ <button+ type="button"+ className="cu-btn cu-btn--primary"+ onClick={() => void onConfirm()}+ disabled={busy || value.length === 0}+ >+ {submitLabel}+ </button>+ </div>+ </div>+ </div>+ )+}diff --git a/control-ui/components/HostAccessTab/types.ts b/control-ui/components/HostAccessTab/types.tsnew file mode 100644index 000000000..d658e8528--- /dev/null+++ b/control-ui/components/HostAccessTab/types.ts@@ -0,0 +1,18 @@+export type AccessSubTab = 'members' | 'teams'++export type AccessUserRow = {+ id: string+ email: string+ name: string | null+ displayName: string | null+}++export type AccessTeamRow = {+ id: string+ name: string+ memberCount: number+}++export type HostAccessTabProps = {+ hostName: string+}diff --git a/control-ui/components/HostAdvancedTab/index.tsx b/control-ui/components/HostAdvancedTab/index.tsxnew file mode 100644index 000000000..0d268359a--- /dev/null+++ b/control-ui/components/HostAdvancedTab/index.tsx@@ -0,0 +1,50 @@+'use client'++import React, { useState } from 'react'+import { HostApprovalSection } from '@components/HostApprovalSection'+import { HostEnvTable } from '@components/HostEnvTable'+import { TabBar } from '@components/TabBar'+import type { AdvancedSubTab, HostAdvancedTabProps } from './types'++const ADVANCED_SUB_TABS: { key: AdvancedSubTab; label: string }[] = [+ { key: 'approvals', label: 'Per-tool approval' },+ { key: 'env', label: 'Env vars' },+]++export function HostAdvancedTab({+ busy,+ hostName,+ initialLoading,+ initialTools,+ onSaveApprovalTools,+}: HostAdvancedTabProps) {+ const [subTab, setSubTab] = useState<AdvancedSubTab>('approvals')++ return (+ <section className="cu-advanced-tab" aria-label="Advanced">+ <TabBar<AdvancedSubTab>+ activeValue={subTab}+ ariaLabel="Advanced settings"+ className="cu-tabs--compact cu-advanced-tabs"+ onChange={setSubTab}+ options={ADVANCED_SUB_TABS.map(tab => ({ label: tab.label, value: tab.key }))}+ />++ <div className="cu-advanced-section">+ {subTab === 'approvals' ? (+ initialLoading ? null : (+ <HostApprovalSection+ busy={busy}+ canWrite+ defaultEditing+ initialTools={initialTools}+ onSave={onSaveApprovalTools}+ />+ )+ ) : (+ <HostEnvTable hostRef={hostName} />+ )}+ </div>+ </section>+ )+}diff --git a/control-ui/components/HostAdvancedTab/types.ts b/control-ui/components/HostAdvancedTab/types.tsnew file mode 100644index 000000000..1f0e534dd--- /dev/null+++ b/control-ui/components/HostAdvancedTab/types.ts@@ -0,0 +1,11 @@+import type { HostApprovalSectionProps } from '../HostApprovalSection/types'++export type AdvancedSubTab = 'approvals' | 'env'++export type HostAdvancedTabProps = {+ busy: boolean+ hostName: string+ initialLoading: boolean+ initialTools: HostApprovalSectionProps['initialTools']+ onSaveApprovalTools: HostApprovalSectionProps['onSave']+}diff --git a/control-ui/components/HostIdentityTab/constants.ts b/control-ui/components/HostIdentityTab/constants.tsindex 51446c090..232770225 100644--- a/control-ui/components/HostIdentityTab/constants.ts+++ b/control-ui/components/HostIdentityTab/constants.ts@@ -14,30 +14,59 @@ export const IDENTITY_FIELD_ORDER: IdentityFieldKey[] = ['identity', 'soul', 'agexport const IDENTITY_FIELDS: IdentityFieldConfig[] = [{fileName: 'IDENTITY.md',- help: "Appears under '## Identity' in the agent's system prompt.",+ help: 'Who this agent is — name, role, and voice. The agent treats this as its self-description.',key: 'identity',label: 'Identity',+ placeholder: `# Name: Atrios+# Role: Senior code reviewer+# Voice: Direct, concise, cites file paths++You are Atrios, a senior code reviewer on the Platform team. You read every+file before suggesting a change, and you always quote the path you are+touching.`,promptHeader: '## Identity',},{fileName: 'SOUL.md',- help: "Appears under '## Core Values'.",+ help: 'Non-negotiable values and guardrails. Short bullets the model should never violate.',key: 'soul',label: 'Soul',+ placeholder: `# Values+- Prefer correctness over speed — never ship a fix you have not verified+- Always cite the file path when changing code+- Never invent API endpoints, env vars, or config keys+- If unsure, ask instead of guessing`,promptHeader: '## Core Values',},{fileName: 'AGENTS.md',- help: "Appears under '## Agent Instructions'.",+ help: 'Standing rules the agent follows on every task — conventions, skills, and review habits.',key: 'agents',label: 'Agent instructions',+ placeholder: `# Workflow+- Read AGENTS.md and CLAUDE.md before any task+- Use pnpm for installs, never npm or yarn+- Run tests before reporting a task complete++# Code style+- Prefer composition over inheritance+- Keep functions under 40 lines+- No silent catches — log or rethrow`,promptHeader: '## Agent Instructions',},{fileName: 'USER.md',- help: "Appears under '## User Context'.",+ help: 'Background about who uses this agent — team, environment, conventions — so replies fit the audience.',key: 'user',label: 'User context',+ placeholder: `# Operating environment+- Team: Platform engineering+- Timezone: America/Mexico_City+- Preferred review style: PR-first, no live deploys++# Communication+- Default to Spanish when writing docs+- Reply in bullet points, not paragraphs`,promptHeader: '## User Context',},]diff --git a/control-ui/components/HostIdentityTab/index.tsx b/control-ui/components/HostIdentityTab/index.tsxindex c7c3c57ee..07713d72d 100644--- a/control-ui/components/HostIdentityTab/index.tsx+++ b/control-ui/components/HostIdentityTab/index.tsx@@ -221,6 +221,7 @@ export function HostIdentityTab({ hostName }: { hostName: string }) {className="cu-identity-editor__markdown"invalid={activeTooLarge}onChange={value => setField(activeConfig.key, value)}+ placeholder={activeConfig.placeholder}value={activeValue}/><div className={activeTooLarge ? 'cu-field__error' : 'cu-field__hint'}>diff --git a/control-ui/components/HostIdentityTab/types.ts b/control-ui/components/HostIdentityTab/types.tsindex 585b2b6b7..6dfd3b141 100644--- a/control-ui/components/HostIdentityTab/types.ts+++ b/control-ui/components/HostIdentityTab/types.ts@@ -7,6 +7,7 @@ export type IdentityFieldConfig = {help: stringkey: IdentityFieldKeylabel: string+ placeholder: stringpromptHeader: string}diff --git a/control-ui/components/HostTable.tsx b/control-ui/components/HostTable.tsxindex 706c4808e..c9a6a8532 100644--- a/control-ui/components/HostTable.tsx+++ b/control-ui/components/HostTable.tsx@@ -218,17 +218,7 @@ export function HostTable({aria-label={`Open agent ${name}`}><td>- <button- type="button"- className="cu-link"- onClick={e => {- e.stopPropagation()- openAgent()- }}- onKeyDown={e => e.stopPropagation()}- >- {name}- </button>+ <span className="cu-expandable-row__name">{name}</span></td><td><HostLifecycleBadge lifecycle={lifecycle} />diff --git a/control-ui/components/HostWizard/index.tsx b/control-ui/components/HostWizard/index.tsxindex 72e00f6ca..6ea4f357a 100644--- a/control-ui/components/HostWizard/index.tsx+++ b/control-ui/components/HostWizard/index.tsx@@ -1,12 +1,13 @@'use client'-import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'+import React, { Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react'import { CreateFlowPanel } from '@/components/CreateFlowPanel'import { CreateStepFlow } from '@/components/CreateStepFlow'import { LlmProviderConfig } from '@/components/LlmProviderConfig'+import { LlmProviderIcon } from '@/components/LlmProviderIcon'import { SelectionDropdown } from '@/components/SelectionDropdown'import { useToast } from '@/components/Toast'-import { IconAlertTriangle, IconCheck, IconInfoCircle, IconX } from '@/components/icons'+import { IconAlertTriangle, IconCheck, IconX } from '@/components/icons'import { Button, CheckboxField, Field, TextInput } from '@/components/ui'import {apiGet,@@ -18,6 +19,7 @@ import {} from '@/lib/api'import { cn } from '@/lib/cn'import { useLlmAllowedModels } from '@/lib/hooks/useLlmAllowedModels'+import { getAgentNameError } from '@/lib/k8sValidation'import {type HostAllowedModel,type LlmPolicy,@@ -84,7 +86,20 @@ function WizardSelect({><span className="cu-agent-select__button-copy"><span>{selectedOption?.label || placeholder}</span>- {selectedOption?.meta ? (+ {selectedOption?.providers && selectedOption.providers.length > 0 ? (+ <span className="cu-agent-select__providers">+ <span className="cu-agent-select__providers-label">Providers: </span>+ {selectedOption.providers.map((provider, index) => (+ <Fragment key={provider.id}>+ {index > 0 ? ', ' : null}+ <span className="cu-agent-select__provider">+ <LlmProviderIcon provider={provider.id} label={provider.label} />+ <span>{provider.label}</span>+ </span>+ </Fragment>+ ))}+ </span>+ ) : selectedOption?.meta ? (<span className="cu-agent-select__button-meta">{selectedOption.meta}</span>) : null}</span>@@ -110,7 +125,20 @@ function WizardSelect({><span className="cu-agent-select__option-copy"><span className="cu-agent-select__option-name">{option.label}</span>- {option.meta ? (+ {option.providers && option.providers.length > 0 ? (+ <span className="cu-agent-select__providers">+ <span className="cu-agent-select__providers-label">Providers: </span>+ {option.providers.map((provider, index) => (+ <Fragment key={provider.id}>+ {index > 0 ? ', ' : null}+ <span className="cu-agent-select__provider">+ <LlmProviderIcon provider={provider.id} label={provider.label} />+ <span>{provider.label}</span>+ </span>+ </Fragment>+ ))}+ </span>+ ) : option.meta ? (<span className="cu-agent-select__option-meta">{option.meta}</span>) : null}</span>@@ -143,7 +171,8 @@ function isStepValid(directoryLoadFailed: boolean}): boolean {- if (stepIndex === 0) return state.hostName.trim().length > 0+ if (stepIndex === 0)+ return state.hostName.trim().length > 0 && getAgentNameError(state.hostName) === ''if (stepIndex === 1) {if (state.contextMode === 'existing') return state.selectedExistingContext.trim().length > 0return state.contextName.trim().length > 0@@ -197,14 +226,13 @@ export function HostWizard({const [hostName, setHostName] = useState('')const hostNamespace = HOST_NAMESPACE+ const agentNameError = getAgentNameError(hostName)const [contextName, setContextName] = useState('')const [contextMode, setContextMode] = useState<'existing' | 'new'>('existing')const [selectedExistingContext, setSelectedExistingContext] = useState('')- const [contextSelectOpen, setContextSelectOpen] = useState(false)const [selectedMcp, setSelectedMcp] = useState<string[]>([])const [existingContexts, setExistingContexts] = useState<ContextOption[]>([])- const contextSelectRef = useRef<HTMLDivElement | null>(null)// Reuse an existing shared Secret by default. Creating an agent-specific Secret// remains available when the operator explicitly chooses New credential.@@ -264,7 +292,11 @@ export function HostWizard({return {value: name,label: name,- meta: `${secret.metadata?.namespace || HOST_NAMESPACE} · ${providerSummary}`,+ meta: providerSummary,+ providers:+ providers && providers.length > 0+ ? providers.map(id => ({ id, label: getProviderLabel(id) }))+ : undefined,}}).filter(option => option !== null)@@ -277,7 +309,6 @@ export function HostWizard({null,[existingContexts, selectedExistingContext])- const selectedContextLabel = selectedContextOption?.contextId || 'Select context...'const providerModelOptions = useMemo(() => getModelOptions(allowedCatalog, provider),[allowedCatalog, provider]@@ -486,7 +517,10 @@ export function HostWizard({)const validationMessage = useMemo(() => {- if (step === 0 && !hostName.trim()) return 'Agent name is required.'+ if (step === 0) {+ const agentNameError = getAgentNameError(hostName)+ if (agentNameError) return agentNameError+ }if (step === 1 && contextMode === 'existing' && !selectedExistingContext.trim())return 'Select an existing context.'if (step === 1 && contextMode === 'new' && !contextName.trim())@@ -548,7 +582,6 @@ export function HostWizard({setContextName('')setContextMode('existing')setSelectedExistingContext('')- setContextSelectOpen(false)setSelectedMcp([])setSecretMode('existing')setExistingSecret('')@@ -580,7 +613,6 @@ export function HostWizard({function selectExistingContext(context: ContextOption) {setSelectedExistingContext(`${context.namespace}/${context.name}`)- setContextSelectOpen(false)}async function submitAll() {@@ -750,9 +782,18 @@ export function HostWizard({autoFocus/>{hostName.trim() ? (- <span className="cu-agent-input-shell__status" aria-label="Valid agent name">- <IconCheck width={16} height={16} />- </span>+ agentNameError ? (+ <span+ className="cu-agent-input-shell__status cu-agent-input-shell__status--invalid"+ aria-label={agentNameError}+ >+ <IconAlertTriangle width={16} height={16} />+ </span>+ ) : (+ <span className="cu-agent-input-shell__status" aria-label="Valid agent name">+ <IconCheck width={16} height={16} />+ </span>+ )) : null}</span></Field>@@ -801,16 +842,6 @@ export function HostWizard({</div></div>) : null}- <div className="cu-agent-info-card">- <IconInfoCircle width={16} height={16} />- <div>- <strong>Naming conventions</strong>- <p>- Use lowercase letters, numbers, and hyphens only. Must start with a letter and be- 3-63 characters long.- </p>- </div>- </div></div>)}@@ -848,50 +879,26 @@ export function HostWizard({<><div className="cu-agent-access-section"><strong>Select Context</strong>- <div- className="cu-agent-select"- ref={contextSelectRef}- onBlur={event => {- if (!event.currentTarget.contains(event.relatedTarget)) {- setContextSelectOpen(false)- }+ <SelectionDropdown+ multiple={false}+ value={selectedExistingContext ? [selectedExistingContext] : []}+ onChange={values => {+ const next = values[0] || ''+ const context = existingContexts.find(+ ctx => `${ctx.namespace}/${ctx.name}` === next+ )+ if (context) selectExistingContext(context)+ else setSelectedExistingContext('')}}- >- <button- type="button"- className="cu-agent-select__button"- aria-expanded={contextSelectOpen}- aria-haspopup="listbox"- onClick={() => setContextSelectOpen(open => !open)}- >- <span>{selectedContextLabel}</span>- <span className="cu-agent-select__chevron" aria-hidden="true" />- </button>- {contextSelectOpen ? (- <div className="cu-agent-select__menu" role="listbox">- {existingContexts.length === 0 ? (- <span className="cu-agent-select__empty">No contexts available.</span>- ) : (- existingContexts.map(ctx => {- const value = `${ctx.namespace}/${ctx.name}`- return (- <button- key={value}- type="button"- className="cu-agent-select__option"- data-active={selectedExistingContext === value ? 'true' : 'false'}- role="option"- aria-selected={selectedExistingContext === value}- onClick={() => selectExistingContext(ctx)}- >- {ctx.contextId}- </button>- )- })- )}- </div>- ) : null}- </div>+ options={existingContexts.map(ctx => ({+ value: `${ctx.namespace}/${ctx.name}`,+ label: ctx.contextId,+ }))}+ placeholder="Select context..."+ searchPlaceholder="Search contexts..."+ selectionLabel="Selected context"+ emptyLabel="No contexts available."+ /></div>{selectedContextOption && (<section@@ -958,7 +965,7 @@ export function HostWizard({<div className="cu-agent-access-section"><strong>Credentials</strong><span className="cu-muted cu-agent-access-hint">- Store this agent's own LLM credentials, or use a shared Kubernetes Secret.+ Store this agent's own LLM credentials, or use a shared secret.</span><div className="cu-agent-radio-group"><label className="cu-agent-radio cu-agent-radio--card">@@ -968,9 +975,9 @@ export function HostWizard({onChange={() => setSecretMode('existing')}/><span className="cu-agent-radio__copy">- <span className="cu-agent-radio__title">Use an existing Secret</span>+ <span className="cu-agent-radio__title">Use an existing secret</span><span className="cu-agent-radio__description">- Select a saved Kubernetes Secret that already contains LLM API keys.+ Select a saved secret that already contains LLM API keys.</span></span></label>@@ -981,9 +988,9 @@ export function HostWizard({onChange={() => setSecretMode('new')}/><span className="cu-agent-radio__copy">- <span className="cu-agent-radio__title">New credential</span>+ <span className="cu-agent-radio__title">New secret</span><span className="cu-agent-radio__description">- Create a new Secret for this agent. Its name is derived from the agent name.+ Create a new secret for this agent. Its name is derived from the agent name.</span></span></label>diff --git a/control-ui/components/HostWizard/types.ts b/control-ui/components/HostWizard/types.tsindex 3dabd3e8d..99b2ac176 100644--- a/control-ui/components/HostWizard/types.ts+++ b/control-ui/components/HostWizard/types.ts@@ -31,6 +31,7 @@ export type HostWizardProps = {export type WizardSelectOption = {label: ReactNodemeta?: ReactNode+ providers?: { id: string; label: string }[]value: string}diff --git a/control-ui/components/MarkdownEditor/index.tsx b/control-ui/components/MarkdownEditor/index.tsxindex 501944075..b0c7bd227 100644--- a/control-ui/components/MarkdownEditor/index.tsx+++ b/control-ui/components/MarkdownEditor/index.tsx@@ -16,6 +16,7 @@ export function MarkdownEditor({className,invalid = false,onChange,+ placeholder,value,}: MarkdownEditorProps) {return (@@ -31,6 +32,7 @@ export function MarkdownEditor({textareaProps={{'aria-label': ariaLabel,className: invalid ? 'cu-input--invalid' : undefined,+ placeholder,}}value={value}visibleDragbar={false}diff --git a/control-ui/components/MarkdownEditor/types.ts b/control-ui/components/MarkdownEditor/types.tsindex 09f94d35d..69fe37b34 100644--- a/control-ui/components/MarkdownEditor/types.ts+++ b/control-ui/components/MarkdownEditor/types.ts@@ -3,5 +3,6 @@ export type MarkdownEditorProps = {className?: stringinvalid?: booleanonChange: (value: string) => void+ placeholder?: stringvalue: string}diff --git a/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx b/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsxindex 61e8f2dc9..366cef0c4 100644--- a/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx+++ b/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx@@ -31,6 +31,12 @@ vi.mock('../HostIdentityTab', () => ({),}))+vi.mock('../HostAccessTab', () => ({+ HostAccessTab: ({ hostName }: { hostName: string }) => (+ <div data-testid="access-tab">Access editor for {hostName}</div>+ ),+}))+vi.mock('../../lib/api', () => ({apiGet: vi.fn(),apiSend: vi.fn(),diff --git a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsxindex 0935a0898..55cff0fdc 100644--- a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx+++ b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx@@ -31,6 +31,12 @@ vi.mock('../HostIdentityTab', () => ({),}))+vi.mock('../HostAccessTab', () => ({+ HostAccessTab: ({ hostName }: { hostName: string }) => (+ <div data-testid="access-tab">Access editor for {hostName}</div>+ ),+}))+vi.mock('../../lib/api', () => ({apiGet: vi.fn(),apiSend: vi.fn(),@@ -113,10 +119,8 @@ describe('HostDetailsPage identity integration', () => {'Identity','Models & creds','Context',- 'Member access',- 'Team access',- 'Per-tool approval',- 'Env vars',+ 'Access',+ 'Advanced',])})@@ -145,7 +149,7 @@ describe('HostDetailsPage identity integration', () => {})it('keeps Per-tool approval actions in the top toolbar without a duplicate title', async () => {- mockParams = { name: 'foo', tab: 'approvals' }+ mockParams = { name: 'foo', tab: 'advanced' }const { container } = render(<HostDetailsPage />)expect(await screen.findByLabelText('http_request')).toBeInTheDocument()diff --git a/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsx b/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsxindex 830d31846..fab0c1693 100644--- a/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsx+++ b/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsx@@ -31,6 +31,12 @@ vi.mock('../HostIdentityTab', () => ({),}))+vi.mock('../HostAccessTab', () => ({+ HostAccessTab: ({ hostName }: { hostName: string }) => (+ <div data-testid="access-tab">Access editor for {hostName}</div>+ ),+}))+vi.mock('../../lib/api', () => ({apiGet: vi.fn(),apiSend: vi.fn(),diff --git a/control-ui/components/__tests__/HostWizard.test.tsx b/control-ui/components/__tests__/HostWizard.test.tsxindex 3fc83fa88..142d63604 100644--- a/control-ui/components/__tests__/HostWizard.test.tsx+++ b/control-ui/components/__tests__/HostWizard.test.tsx@@ -174,7 +174,8 @@ describe('HostWizard — credential draft is projected onto the active providerfireEvent.click(screen.getByLabelText(/Use an existing Secret/i))fireEvent.click(screen.getByRole('button', { name: /Select secret/i }))- expect(screen.getByText(/Providers: OpenAI, Amazon Bedrock/)).toBeInTheDocument()+ const option = screen.getByRole('option', { name: /shared-llm-keys/ })+ expect(option).toHaveTextContent(/Providers: OpenAI, Amazon Bedrock/)})it('matches the primary provider to the selected credential', async () => {@@ -219,11 +220,11 @@ describe('HostWizard — credential draft is projected onto the active providerfireEvent.click(screen.getByRole('button', { name: 'Next' }))const existingCard = screen.getByLabelText(/Use an existing Secret/i).closest('label')- const newCard = screen.getByLabelText(/New credential/i).closest('label')+ const newCard = screen.getByLabelText(/New secret/i).closest('label')expect(existingCard).not.toBeNull()expect(newCard).not.toBeNull()expect(screen.getByLabelText(/Use an existing Secret/i)).toBeChecked()- expect(screen.getByLabelText(/New credential/i)).not.toBeChecked()+ expect(screen.getByLabelText(/New secret/i)).not.toBeChecked()expect(screen.getByText('Credential', { selector: 'strong' })).toBeInTheDocument()expect(existingCard?.compareDocumentPosition(newCard as Node)).toBe(Node.DOCUMENT_POSITION_FOLLOWING@@ -252,7 +253,7 @@ describe('HostWizard — credential draft is projected onto the active providerfireEvent.click(screen.getByRole('button', { name: 'Next' }))// Step 2: explicitly create a new Secret and make the OpenAI primary usable.- fireEvent.click(screen.getByLabelText(/New credential/i))+ fireEvent.click(screen.getByLabelText(/New secret/i))fireEvent.change(screen.getByLabelText(/OpenAI API key/i), { target: { value: 'sk-openai' } })// Add a fallback and switch it to Bedrock (a different provider than thediff --git a/control-ui/lib/__tests__/k8sValidation.test.ts b/control-ui/lib/__tests__/k8sValidation.test.tsindex fa147bfeb..9ce1177a0 100644--- a/control-ui/lib/__tests__/k8sValidation.test.ts+++ b/control-ui/lib/__tests__/k8sValidation.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from 'vitest'-import { isValidK8sName, toK8sName } from '../k8sValidation'+import { getAgentNameError, isValidK8sName, toK8sName } from '../k8sValidation'describe('isValidK8sName', () => {it('accepts RFC 1123 DNS labels', () => {@@ -16,6 +16,38 @@ describe('isValidK8sName', () => {})})+describe('getAgentNameError', () => {+ it('accepts a valid agent name', () => {+ expect(getAgentNameError('my-agent')).toBe('')+ expect(getAgentNameError('abc')).toBe('')+ expect(getAgentNameError('a'.repeat(63))).toBe('')+ })++ it('requires a name', () => {+ expect(getAgentNameError('')).toBe('Agent name is required.')+ expect(getAgentNameError(' ')).toBe('Agent name is required.')+ })++ it('rejects invalid characters', () => {+ expect(getAgentNameError('my_agent')).not.toBe('')+ expect(getAgentNameError('MyAgent')).not.toBe('')+ })++ it('requires a leading letter', () => {+ expect(getAgentNameError('1agent')).toBe('Agent name must start with a letter.')+ expect(getAgentNameError('-agent')).toBe('Agent name must start with a letter.')+ })++ it('requires an alphanumeric end', () => {+ expect(getAgentNameError('agent-')).toBe('Agent name must end with a letter or number.')+ })++ it('enforces the 3-63 character range', () => {+ expect(getAgentNameError('ab')).toBe('Agent name must be at least 3 characters long.')+ expect(getAgentNameError('a'.repeat(64))).toBe('Agent name must be 63 characters or fewer.')+ })+})+describe('toK8sName', () => {it('derives a valid label from a scoped registry name', () => {expect(toK8sName('@test-oss-jose/helloo')).toBe('test-oss-jose-helloo')diff --git a/control-ui/lib/k8sValidation.ts b/control-ui/lib/k8sValidation.tsindex cbd7f4563..7a749a5b3 100644--- a/control-ui/lib/k8sValidation.ts+++ b/control-ui/lib/k8sValidation.ts@@ -18,6 +18,17 @@ export function isValidK8sName(name: string): boolean {* e.g. `@test-oss-jose/helloo` → `test-oss-jose-helloo`. May return `""` when* the input has no usable characters (the caller then leaves the field empty).*/+export function getAgentNameError(name: string): string {+ if (!name.trim()) return 'Agent name is required.'+ if (!/^[a-z0-9-]+$/.test(name))+ return 'Agent name may only use lowercase letters, numbers, and hyphens.'+ if (!/^[a-z]/.test(name)) return 'Agent name must start with a letter.'+ if (!/[a-z0-9]$/.test(name)) return 'Agent name must end with a letter or number.'+ if (name.length > 63) return 'Agent name must be 63 characters or fewer.'+ if (name.length < 3) return 'Agent name must be at least 3 characters long.'+ return ''+}+export function toK8sName(raw: string): string {return raw.toLowerCase()diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 2bf8dcc16..141817c09 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.396",+ "version": "0.1.397","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.396",+ "version": "0.1.397","dependencies": {"@clerum/llm-providers": "file:../packages/llm-providers","@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 053a09b2e..bb4eb3a4d 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.396",+ "version": "0.1.397","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",