Skip to content

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

TypeScript

fix: refine agent settings and notification accessibility

Miguelon Peluchon411e22ba4815
diff --git a/control-ui/app/constants/hostDetails.ts b/control-ui/app/constants/hostDetails.ts
index d9a3dc1fa..c0d042ddc 100644
--- a/control-ui/app/constants/hostDetails.ts
+++ b/control-ui/app/constants/hostDetails.ts
@@ -1,5 +1,14 @@
export const HOST_DEFAULT_TAB = 'details'
-export const HOST_TABS = ['details', 'identity', 'contexts', 'env', 'users', 'teams'] as const
+export const HOST_TABS = [
+ 'details',
+ 'identity',
+ 'model',
+ 'contexts',
+ 'users',
+ 'teams',
+ 'approvals',
+ 'env',
+] as const
export type HostTab = (typeof HOST_TABS)[number]
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.css
index 6ecbbb199..7e075c769 100644
--- a/control-ui/app/globals.css
+++ b/control-ui/app/globals.css
@@ -4362,6 +4362,124 @@ textarea.cu-input {
border-top-right-radius: 0;
}
+.cu-app-layout .cu-main.cu-detail-layout:has(> .cu-agent-detail-card) {
+ height: 100vh;
+ min-height: 0;
+ overflow: hidden;
+ padding-bottom: 0;
+}
+
+.cu-agent-detail-card {
+ display: flex;
+ flex: 1;
+ min-height: 0;
+}
+
+.cu-agent-detail-card > .cu-card__body {
+ display: flex;
+ flex: 1;
+ min-height: 0;
+ padding: 0;
+ overflow: hidden;
+}
+
+.cu-agent-detail-scroll {
+ flex: 1;
+ min-width: 0;
+ min-height: 0;
+ padding: var(--cu-space-5);
+ overflow-y: auto;
+}
+
+.cu-card:not(.cu-agent-detail-card) > .cu-card__body > .cu-agent-detail-scroll {
+ display: contents;
+}
+
+.cu-agent-detail-heading {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: var(--cu-space-2);
+ margin-bottom: var(--cu-space-4);
+}
+
+.cu-agent-detail-heading__actions {
+ display: inline-flex;
+ align-items: center;
+ justify-content: flex-end;
+ flex-wrap: wrap;
+ gap: var(--cu-space-2);
+ margin-left: auto;
+}
+
+.cu-agent-detail-toolbar {
+ position: sticky;
+ top: 0;
+ z-index: 3;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: var(--cu-space-3);
+ margin: calc(var(--cu-space-5) * -1) calc(var(--cu-space-5) * -1) var(--cu-space-4);
+ padding: var(--cu-space-4) var(--cu-space-5);
+ border-bottom: 1px solid var(--cu-border-subtle);
+ background: var(--cu-surface);
+}
+
+.cu-agent-detail-toolbar__actions {
+ display: inline-flex;
+ align-items: center;
+ justify-content: flex-end;
+ flex-wrap: wrap;
+ gap: var(--cu-space-2);
+ margin-left: auto;
+}
+
+.cu-agent-detail-toolbar__actions .cu-btn--primary {
+ min-width: var(--cu-create-action-min-width);
+}
+
+.cu-agent-detail-scroll:has(> .cu-host-approval-section) {
+ overflow: hidden;
+}
+
+.cu-host-approval-section {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ min-height: 0;
+}
+
+.cu-host-approval-section__description {
+ flex: 0 0 auto;
+ margin: 0;
+ padding-bottom: var(--cu-space-3);
+ font-size: 0.8125rem;
+}
+
+.cu-host-approval-section__content {
+ flex: 1;
+ min-height: 0;
+ overflow-y: auto;
+}
+
+.cu-host-approval-section__actions {
+ display: flex;
+ flex: 0 0 auto;
+ align-items: center;
+ justify-content: flex-end;
+ gap: var(--cu-space-2);
+ padding-top: var(--cu-space-3);
+ border-top: 1px solid var(--cu-border-subtle);
+ background: var(--cu-surface);
+}
+
+.cu-host-approval-section__actions .cu-btn--primary {
+ min-width: var(--cu-create-action-min-width);
+}
+
.cu-marketplace-detail {
display: grid;
gap: 0;
@@ -6776,24 +6894,6 @@ textarea.cu-input {
gap: 0.75rem;
}
-.cu-llm-config__model-row--with-credential {
- grid-template-columns: repeat(3, minmax(0, 1fr));
- align-items: start;
-}
-
-.cu-llm-cred-group--inline {
- min-width: 0;
- padding: 0;
- border: 0;
- background: transparent;
-}
-
-@media (max-width: 720px) {
- .cu-llm-config__model-row--with-credential {
- grid-template-columns: 1fr;
- }
-}
-
.cu-llm-provider-icon {
display: inline-grid;
place-items: center;
@@ -6834,6 +6934,13 @@ textarea.cu-input {
filter: brightness(0);
}
+:root[data-theme='light']
+ .cu-llm-config__provider-select
+ .cu-llm-provider-icon[data-provider='openai']
+ img {
+ filter: brightness(0);
+}
+
.cu-llm-config__fallback-creds {
display: flex;
flex-direction: column;
diff --git a/control-ui/app/hosts/[name]/[tab]/page.tsx b/control-ui/app/hosts/[name]/[tab]/page.tsx
index e88314d7d..52b04221d 100644
--- a/control-ui/app/hosts/[name]/[tab]/page.tsx
+++ b/control-ui/app/hosts/[name]/[tab]/page.tsx
@@ -7,7 +7,16 @@ interface HostTabPageProps {
export default async function HostTabPage({ params }: HostTabPageProps) {
const { tab } = await params
- const tabs = ['overview', 'identity', 'contexts', 'env-vars', 'member-access', 'team-access']
+ const tabs = [
+ 'overview',
+ 'model',
+ 'approvals',
+ 'identity',
+ 'contexts',
+ 'env-vars',
+ 'member-access',
+ 'team-access',
+ ]
if (!tabs.includes(tab)) notFound()
return <HostDetailsPage />
diff --git a/control-ui/app/hosts/[name]/page.tsx b/control-ui/app/hosts/[name]/page.tsx
index 6ffd1f4bc..65a2b4cb0 100644
--- a/control-ui/app/hosts/[name]/page.tsx
+++ b/control-ui/app/hosts/[name]/page.tsx
@@ -50,7 +50,9 @@ import type { ChannelResource, HostTab } from './types'
const TAB_LABELS: Record<HostTab, string> = {
details: 'Overview',
- contexts: 'Contexts',
+ model: 'Models & creds',
+ approvals: 'Per-tool approval',
+ contexts: 'Context',
env: 'Env vars',
users: 'Member access',
teams: 'Team access',
@@ -59,6 +61,8 @@ const TAB_LABELS: Record<HostTab, string> = {
const TAB_SLUGS: Record<HostTab, string> = {
details: 'overview',
+ model: 'model',
+ approvals: 'approvals',
contexts: 'contexts',
env: 'env-vars',
users: 'member-access',
@@ -105,6 +109,7 @@ export default function HostDetailsPage() {
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)
const [showDeleteAgentConfirm, setShowDeleteAgentConfirm] = useState(false)
const [deletingAgent, setDeletingAgent] = useState(false)
@@ -387,74 +392,6 @@ export default function HostDetailsPage() {
const nextHostName = hostNameDraft.trim()
if (!nextHostName) return false
- // Client-side mirror of control-api's write gate (spec R5.3): block a save
- // with an out-of-allowlist fallback model before the round-trip. Skip the
- // check when the allowlist failed to load (`allowedCatalog` empty) — every
- // model would falsely flag as "not enabled", blocking unrelated Overview
- // edits on a Host that merely has an llmPolicy; the backend 422 stays the
- // source of truth for that case (matching how spec.model has no client gate).
- if (llmPolicyDraft && allowedCatalog.length > 0) {
- const policyErrors = validateLlmPolicy(llmPolicyDraft, allowedCatalog)
- if (policyErrors.length > 0) {
- setError(policyErrors[0])
- return false
- }
- }
-
- // The full allowlist validation above is skipped when the catalog failed to
- // load (`allowedCatalog` empty), which also skips the triggerOn check inside
- // `validateLlmPolicy`. An explicitly-empty `triggerOn` on a policy that HAS
- // fallbacks means "fail over on nothing" — the runtime silently disables
- // failover. Guard it here regardless of the catalog (least-surprising: block
- // rather than persist a policy that quietly no-ops), so the operator never
- // saves a self-disabled policy just because the allowlist was unavailable.
- if (
- llmPolicyDraft &&
- llmPolicyDraft.fallbacks.length > 0 &&
- Array.isArray(llmPolicyDraft.triggerOn) &&
- llmPolicyDraft.triggerOn.length === 0
- ) {
- setError(LLM_EMPTY_TRIGGER_ERROR)
- return false
- }
-
- // Asymmetric usable gate (spec Topic 1b): block save when the PRIMARY
- // provider isn't usable. "Usable" counts both a stored key (existingKeys)
- // and a freshly typed rotation, so switching to a provider whose key is
- // already stored stays allowed. Enforced only when we have real key signal —
- // the Secret listed at least one key OR the operator typed a rotation. An
- // empty/unlisted key set is treated as unknown (the backend stays the source
- // of truth), so an unrelated Overview edit is never blocked by stale listing.
- const primaryPresent = (dataKey: string): boolean =>
- (llmKeyDraft[dataKey] ?? '').trim().length > 0 || currentSecretKeys.includes(dataKey)
- const typedAnyCredential = Object.values(llmKeyDraft).some(value => value.trim().length > 0)
- if (
- secretRefDraft.trim() &&
- (currentSecretKeys.length > 0 || typedAnyCredential) &&
- !isProviderUsable(providerDraft, primaryPresent)
- ) {
- setError(`Add the ${getProviderLabel(providerDraft)} credential for the primary model.`)
- return false
- }
-
- // Write-only credential rotations + slot retirement (merge PUT, never a
- // full replace — a full replace of this shared Secret would drop fallback
- // keys the operator didn't re-type). The draft is PROJECTED onto the active
- // domain first, so a value typed for a since-unmounted provider (primary
- // switched, or a fallback removed) is neither validated nor written — no
- // stale block, no orphan key. Then validate cross-slot shape up front.
- const activeCredentialKeys = getActiveCredentialKeys(providerDraft, llmPolicyDraft)
- const rotatedData = projectCredentialDraft(llmKeyDraft, activeCredentialKeys)
- const removeKeys = retireCandidates.filter(key => !(key in rotatedData))
- // Cross-slot shape check on the rotated keys only. Note: rotating one half of
- // the Bedrock pair fails this (both must be written together) — matching the
- // server contract; the operator re-enters both to rotate either.
- const credentialSlotErrors = validateLlmSecretData(rotatedData)
- if (credentialSlotErrors.length > 0) {
- setError(credentialSlotErrors[0])
- return false
- }
-
setBusy(true)
setError('')
try {
@@ -463,16 +400,16 @@ export default function HostDetailsPage() {
const currentHost = await getHost(routeName)
const currentLifecycle = currentHost.spec?.lifecycle
const currentWorkflowControl = currentHost.spec?.workflowControl
+ // Overview owns only identity/shape fields (name, display, context,
+ // channels, lifecycle). Model, secret, fallback policy and the per-host
+ // model allowlist are owned by the "Model & credentials" tab and are
+ // preserved here via the `...currentHost.spec` spread (full-replace
+ // semantics — omitting them is what keeps them intact).
const nextSpec: Record<string, unknown> = {
...currentHost.spec,
host: hostDisplayDraft.trim() || nextHostName,
contextRef: contextRefDraft.trim(),
- secretRef: secretRefDraft.trim(),
channels: channelsDraft,
- model: {
- provider: providerDraft,
- name: modelNameDraft.trim(),
- },
// Echo spec.lifecycle explicitly: the admin facade full-replaces the
// spec, so leaving lifecycle implicit would strip the stateless flag.
...(statelessDraft || currentLifecycle
@@ -482,22 +419,6 @@ export default function HostDetailsPage() {
? { workflowControl: { scopes: [...FIRST_PARTY_CHANNEL_WORKFLOW_CONTROL_SCOPES] } }
: {}),
}
- // Opt-in fallback policy: set it when configured, otherwise drop it so a
- // Host with no policy stays exactly as today (full-replace semantics).
- if (llmPolicyDraft && llmPolicyDraft.fallbacks.length > 0) {
- nextSpec.llmPolicy = llmPolicyDraft
- } else {
- delete nextSpec.llmPolicy
- }
- // Per-host model allowlist subset (Topic 3a): emit only genuine subsets
- // (providers the operator restricted); drop the field entirely when every
- // provider is unrestricted so absent=all-global holds (full-replace
- // semantics — a Host that restricts nothing saves exactly as today).
- if (effectiveAllowedModelsSpec.length > 0) {
- nextSpec.allowedModels = effectiveAllowedModelsSpec
- } else {
- delete nextSpec.allowedModels
- }
if (nextHostName !== routeName) {
let createdNewHost = false
@@ -621,6 +542,144 @@ export default function HostDetailsPage() {
}
}
+ const formResourceVersion = formResourceVersionRef.current
+ await apiSend('PUT', `/api/v1/admin/hosts/${encodeURIComponent(routeName)}`, {
+ // AP-6: carry the resourceVersion captured at form load so the API
+ // rejects this save with 409 {error:'conflict'} if the Host changed
+ // while the operator was editing, instead of silently overwriting the
+ // concurrent change with this form's stale echo.
+ ...(formResourceVersion ? { metadata: { resourceVersion: formResourceVersion } } : {}),
+ spec: nextSpec,
+ })
+ await loadData()
+ showToast('Agent configuration saved.', { tone: 'success' })
+ return true
+ } catch (e) {
+ const status = (e as { status?: number } | null)?.status
+ const code = (e as { code?: string } | null)?.code
+ if (status === 409 && code === 'conflict') {
+ // AP-6 conflict: the Host changed between the form-load read and this
+ // save. The resourceVersion precondition is whole-object (K8s has no
+ // field-level precondition), so the true cause may be another operator's
+ // edit OR the agent's own lifecycle machine ticking (HCC bumping
+ // status.lifecycle / wake-requested on a stateless host). The 409 carries
+ // no field diff, so the message must cover both causes without asserting
+ // the wrong one — while keeping the reload + re-apply recovery.
+ setError(
+ "This agent changed since you opened the form (another edit, or the agent's own lifecycle state updated). Reload to see the latest, then re-apply your change."
+ )
+ } else {
+ setError(e instanceof Error ? e.message : 'Failed to save agent')
+ }
+ return false
+ } finally {
+ setBusy(false)
+ }
+ }
+
+ // Scoped save for the "Model & credentials" tab. Owns provider/model,
+ // secretRef, the opt-in fallback policy, the per-host model allowlist, and
+ // write-only credential rotations/retirements. All other spec fields
+ // (identity, context, channels, lifecycle) are preserved via the
+ // `...currentHost.spec` spread (full-replace semantics).
+ async function saveModelAndCredentials(): Promise<boolean> {
+ // Client-side mirror of control-api's write gate (spec R5.3): block a save
+ // with an out-of-allowlist fallback model before the round-trip. Skip the
+ // check when the allowlist failed to load (`allowedCatalog` empty) — every
+ // model would falsely flag as "not enabled"; the backend 422 stays the
+ // source of truth for that case (matching how spec.model has no client gate).
+ if (llmPolicyDraft && allowedCatalog.length > 0) {
+ const policyErrors = validateLlmPolicy(llmPolicyDraft, allowedCatalog)
+ if (policyErrors.length > 0) {
+ setError(policyErrors[0])
+ return false
+ }
+ }
+
+ // The full allowlist validation above is skipped when the catalog failed to
+ // load (`allowedCatalog` empty), which also skips the triggerOn check inside
+ // `validateLlmPolicy`. An explicitly-empty `triggerOn` on a policy that HAS
+ // fallbacks means "fail over on nothing" — the runtime silently disables
+ // failover. Guard it here regardless of the catalog (least-surprising: block
+ // rather than persist a policy that quietly no-ops), so the operator never
+ // saves a self-disabled policy just because the allowlist was unavailable.
+ if (
+ llmPolicyDraft &&
+ llmPolicyDraft.fallbacks.length > 0 &&
+ Array.isArray(llmPolicyDraft.triggerOn) &&
+ llmPolicyDraft.triggerOn.length === 0
+ ) {
+ setError(LLM_EMPTY_TRIGGER_ERROR)
+ return false
+ }
+
+ // Asymmetric usable gate (spec Topic 1b): block save when the PRIMARY
+ // provider isn't usable. "Usable" counts both a stored key (existingKeys)
+ // and a freshly typed rotation, so switching to a provider whose key is
+ // already stored stays allowed. Enforced only when we have real key signal —
+ // the Secret listed at least one key OR the operator typed a rotation. An
+ // empty/unlisted key set is treated as unknown (the backend stays the source
+ // of truth), so the save is never blocked by stale listing.
+ const primaryPresent = (dataKey: string): boolean =>
+ (llmKeyDraft[dataKey] ?? '').trim().length > 0 || currentSecretKeys.includes(dataKey)
+ const typedAnyCredential = Object.values(llmKeyDraft).some(value => value.trim().length > 0)
+ if (
+ secretRefDraft.trim() &&
+ (currentSecretKeys.length > 0 || typedAnyCredential) &&
+ !isProviderUsable(providerDraft, primaryPresent)
+ ) {
+ setError(`Add the ${getProviderLabel(providerDraft)} credential for the primary model.`)
+ return false
+ }
+
+ // Write-only credential rotations + slot retirement (merge PUT, never a
+ // full replace — a full replace of this shared Secret would drop fallback
+ // keys the operator didn't re-type). The draft is PROJECTED onto the active
+ // domain first, so a value typed for a since-unmounted provider (primary
+ // switched, or a fallback removed) is neither validated nor written — no
+ // stale block, no orphan key. Then validate cross-slot shape up front.
+ const activeCredentialKeys = getActiveCredentialKeys(providerDraft, llmPolicyDraft)
+ const rotatedData = projectCredentialDraft(llmKeyDraft, activeCredentialKeys)
+ const removeKeys = retireCandidates.filter(key => !(key in rotatedData))
+ // Cross-slot shape check on the rotated keys only. Note: rotating one half of
+ // the Bedrock pair fails this (both must be written together) — matching the
+ // server contract; the operator re-enters both to rotate either.
+ const credentialSlotErrors = validateLlmSecretData(rotatedData)
+ if (credentialSlotErrors.length > 0) {
+ setError(credentialSlotErrors[0])
+ return false
+ }
+
+ setBusy(true)
+ setError('')
+ try {
+ // Re-fetch to preserve fields outside this tab's domain (full replace).
+ const currentHost = await getHost(routeName)
+ const nextSpec: Record<string, unknown> = {
+ ...currentHost.spec,
+ secretRef: secretRefDraft.trim(),
+ model: {
+ provider: providerDraft,
+ name: modelNameDraft.trim(),
+ },
+ }
+ // Opt-in fallback policy: set it when configured, otherwise drop it so a
+ // Host with no policy stays exactly as today (full-replace semantics).
+ if (llmPolicyDraft && llmPolicyDraft.fallbacks.length > 0) {
+ nextSpec.llmPolicy = llmPolicyDraft
+ } else {
+ delete nextSpec.llmPolicy
+ }
+ // Per-host model allowlist subset (Topic 3a): emit only genuine subsets
+ // (providers the operator restricted); drop the field entirely when every
+ // provider is unrestricted so absent=all-global holds (full-replace
+ // semantics — a Host that restricts nothing saves exactly as today).
+ if (effectiveAllowedModelsSpec.length > 0) {
+ nextSpec.allowedModels = effectiveAllowedModelsSpec
+ } else {
+ delete nextSpec.allowedModels
+ }
+
const formResourceVersion = formResourceVersionRef.current
await apiSend('PUT', `/api/v1/admin/hosts/${encodeURIComponent(routeName)}`, {
// AP-6: carry the resourceVersion captured at form load so the API
@@ -642,24 +701,19 @@ export default function HostDetailsPage() {
})
}
await loadData()
- showToast('Agent configuration saved.', { tone: 'success' })
+ showToast('Model & credentials saved.', { tone: 'success' })
return true
} catch (e) {
const status = (e as { status?: number } | null)?.status
const code = (e as { code?: string } | null)?.code
if (status === 409 && code === 'conflict') {
- // AP-6 conflict: the Host changed between the form-load read and this
- // save. The resourceVersion precondition is whole-object (K8s has no
- // field-level precondition), so the true cause may be another operator's
- // edit OR the agent's own lifecycle machine ticking (HCC bumping
- // status.lifecycle / wake-requested on a stateless host). The 409 carries
- // no field diff, so the message must cover both causes without asserting
- // the wrong one — while keeping the reload + re-apply recovery.
+ // AP-6 conflict (see saveHost for full rationale): the Host changed
+ // between the form-load read and this save. Reload to re-apply.
setError(
"This agent changed since you opened the form (another edit, or the agent's own lifecycle state updated). Reload to see the latest, then re-apply your change."
)
} else {
- setError(e instanceof Error ? e.message : 'Failed to save agent')
+ setError(e instanceof Error ? e.message : 'Failed to save model & credentials')
}
return false
} finally {
@@ -849,6 +903,11 @@ export default function HostDetailsPage() {
subtitle="Configuration and access for this agent."
tabAriaLabel="Agent sections"
tabClassName="cu-tabs--compact"
+ contentClassName={
+ activeTab === 'approvals' || (activeTab === 'model' && editingModel)
+ ? 'cu-agent-detail-card'
+ : undefined
+ }
tabs={HOST_TABS.map(tab => ({
value: tab,
label: TAB_LABELS[tab],
@@ -856,147 +915,235 @@ export default function HostDetailsPage() {
}))}
title={`Agent: ${routeName}`}
>
- {activeTab === 'details' && (
- <>
- {statelessRejectionMessage ? (
- <div className="cu-banner cu-banner--warning" style={{ marginBottom: '1rem' }}>
- <strong>Stateless mode rejected:</strong> {statelessRejectionMessage}
- </div>
- ) : null}
- <div
- style={{
- display: 'flex',
- flexWrap: 'wrap',
- justifyContent: 'space-between',
- alignItems: 'center',
- gap: '0.5rem',
- marginBottom: '1rem',
- }}
- >
- <div style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '0.5rem' }}>
- <p className="cu-muted" style={{ fontSize: '0.875rem', margin: 0 }}>
- Agent configuration and settings.
- </p>
- {savedStateless && lifecycleState ? (
- <span className="cu-chip">
- {`Lifecycle: ${lifecycleState}${
- lifecycleReason ? ` — ${friendlyLifecycleReason(lifecycleReason)}` : ''
- }`}
- </span>
- ) : null}
- </div>
- {!editingOverview && (
- <button
- type="button"
- className="cu-btn cu-btn--ghost cu-btn--sm"
- onClick={() => setEditingOverview(true)}
- disabled={busy}
+ <div className="cu-agent-detail-scroll">
+ {activeTab === 'details' && (
+ <>
+ {statelessRejectionMessage ? (
+ <div className="cu-banner cu-banner--warning" style={{ marginBottom: '1rem' }}>
+ <strong>Stateless mode rejected:</strong> {statelessRejectionMessage}
+ </div>
+ ) : null}
+ <div className="cu-agent-detail-heading">
+ <div
+ style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '0.5rem' }}
>
- Edit
- </button>
- )}
- </div>
- <div className="cu-form-stack">
- <div className="cu-field">
- <label htmlFor="host-name">Name</label>
- {editingOverview ? (
- <input
- id="host-name"
- value={hostNameDraft}
- onChange={e => setHostNameDraft(e.target.value)}
- disabled={busy}
- autoFocus
- />
- ) : (
- <div className="cu-field__readonly">{hostNameDraft || routeName}</div>
- )}
- </div>
- <div className="cu-field">
- <label htmlFor="host-display">Display ID</label>
- {editingOverview ? (
- <input
- id="host-display"
- value={hostDisplayDraft}
- onChange={e => setHostDisplayDraft(e.target.value)}
- disabled={busy}
- />
- ) : (
- <div className="cu-field__readonly">{hostDisplayDraft || '-'}</div>
- )}
+ <p className="cu-muted" style={{ fontSize: '0.875rem', margin: 0 }}>
+ Agent configuration and settings.
+ </p>
+ {savedStateless && lifecycleState ? (
+ <span className="cu-chip">
+ {`Lifecycle: ${lifecycleState}${
+ lifecycleReason ? ` — ${friendlyLifecycleReason(lifecycleReason)}` : ''
+ }`}
+ </span>
+ ) : null}
+ </div>
+ <div className="cu-agent-detail-heading__actions">
+ {editingOverview ? (
+ <>
+ <button
+ type="button"
+ className="cu-btn cu-btn--ghost cu-btn--sm"
+ onClick={() => setEditingOverview(false)}
+ disabled={busy}
+ >
+ Cancel
+ </button>
+ <button
+ type="button"
+ className="cu-btn cu-btn--primary"
+ onClick={async () => {
+ // AP-6: stay in edit mode on failure so the operator's
+ // draft survives alongside the error/conflict banner.
+ if (await saveHost()) {
+ setEditingOverview(false)
+ }
+ }}
+ disabled={busy || !hostNameDraft.trim()}
+ >
+ {busy ? 'Saving…' : 'Save'}
+ </button>
+ </>
+ ) : (
+ <button
+ type="button"
+ className="cu-btn cu-btn--ghost cu-btn--sm"
+ onClick={() => setEditingOverview(true)}
+ disabled={busy}
+ >
+ Edit
+ </button>
+ )}
+ </div>
</div>
- {!editingOverview && (
+ <div className="cu-form-stack">
<div className="cu-field">
- <label htmlFor="host-provider">Model provider</label>
- <div className="cu-field__readonly">{getProviderLabel(providerDraft)}</div>
+ <label htmlFor="host-name">Name</label>
+ {editingOverview ? (
+ <input
+ id="host-name"
+ value={hostNameDraft}
+ onChange={e => setHostNameDraft(e.target.value)}
+ disabled={busy}
+ autoFocus
+ />
+ ) : (
+ <div className="cu-field__readonly">{hostNameDraft}</div>
+ )}
</div>
- )}
- {!editingOverview && (
- <div className="cu-field">
- <label htmlFor="host-model">Model name</label>
- <div className="cu-field__readonly">{modelNameDraft || '-'}</div>
+ <div className="cu-field" style={{ marginBottom: 0 }}>
+ <label htmlFor="host-agent-type">Type</label>
+ {editingOverview ? (
+ <>
+ <select
+ id="host-agent-type"
+ value={statelessDraft ? 'stateless' : 'stateful'}
+ onChange={e => setStatelessDraft(e.target.value === 'stateless')}
+ disabled={busy}
+ >
+ <option value="stateful">Stateful (always on)</option>
+ <option value="stateless">Stateless (suspends when idle)</option>
+ </select>
+ <span className="cu-field__hint">
+ Stateless agents suspend after the idle window and wake on demand.
+ Communication channels keep stateless agents always-on unless the cluster
+ explicitly enables wake-on-interaction; desktop still requires a stateful
+ agent.
+ </span>
+ </>
+ ) : (
+ <div className="cu-field__readonly">
+ {statelessDraft ? 'Stateless (suspends when idle)' : 'Stateful (always on)'}
+ </div>
+ )}
</div>
- )}
- <div className="cu-field">
- <label htmlFor="host-agent-type">Agent type</label>
- {editingOverview ? (
- <>
- <select
- id="host-agent-type"
- value={statelessDraft ? 'stateless' : 'stateful'}
- onChange={e => setStatelessDraft(e.target.value === 'stateless')}
- disabled={busy}
- >
- <option value="stateful">Stateful (always on)</option>
- <option value="stateless">Stateless (suspends when idle)</option>
- </select>
- <span className="cu-field__hint">
- Stateless agents suspend after the idle window and wake on demand. Communication
- channels keep stateless agents always-on unless the cluster explicitly enables
- wake-on-interaction; desktop still requires a stateful agent.
- </span>
- </>
- ) : (
- <div className="cu-field__readonly">
- {statelessDraft ? 'Stateless (suspends when idle)' : 'Stateful (always on)'}
- </div>
- )}
</div>
- <div className="cu-field" style={{ marginBottom: 0 }}>
- <label htmlFor="host-secret">Secret ref</label>
- {editingOverview ? (
- <select
- id="host-secret"
- value={secretRefDraft}
- onChange={e => setSecretRefDraft(e.target.value)}
+
+ {!initialLoading && (
+ <div
+ style={{
+ marginTop: '2rem',
+ paddingTop: '1.25rem',
+ borderTop: '1px solid var(--cu-border)',
+ }}
+ >
+ <p className="cu-section-title" style={{ marginBottom: '0.5rem' }}>
+ Danger zone
+ </p>
+ <p className="cu-muted" style={{ fontSize: '0.8125rem', marginBottom: '0.75rem' }}>
+ Permanently delete this agent and its direct access mappings.
+ </p>
+ <button
+ type="button"
+ className="cu-btn cu-btn--ghost cu-btn--sm"
+ style={{ color: 'var(--cu-danger)' }}
+ onClick={() => {
+ setDeleteAgentDialogError('')
+ setShowDeleteAgentConfirm(true)
+ }}
disabled={busy}
>
- <option value="">Select LLM secret</option>
- {availableSecrets.map(secretName => (
- <option key={secretName} value={secretName}>
- {secretName}
- </option>
- ))}
- {secretRefDraft && !availableSecrets.includes(secretRefDraft) ? (
- <option value={secretRefDraft}>{secretRefDraft} (custom)</option>
- ) : null}
- </select>
- ) : (
- <div className="cu-field__readonly">{secretRefDraft || '-'}</div>
- )}
+ Delete agent...
+ </button>
+ </div>
+ )}
+ </>
+ )}
+
+ {activeTab === 'model' && (
+ <>
+ <div className={editingModel ? 'cu-agent-detail-toolbar' : 'cu-agent-detail-heading'}>
+ <p className="cu-muted" style={{ fontSize: '0.875rem', margin: 0 }}>
+ Provider, allowed models, fallback policy, and credentials for this agent.
+ </p>
+ <div
+ className={
+ editingModel
+ ? 'cu-agent-detail-toolbar__actions'
+ : 'cu-agent-detail-heading__actions'
+ }
+ >
+ {editingModel ? (
+ <>
+ <button
+ type="button"
+ className="cu-btn cu-btn--ghost cu-btn--sm"
+ onClick={() => setEditingModel(false)}
+ disabled={busy}
+ >
+ Cancel
+ </button>
+ <button
+ type="button"
+ className="cu-btn cu-btn--primary"
+ onClick={async () => {
+ // AP-6: stay in edit mode on failure so the operator's
+ // draft survives alongside the error/conflict banner.
+ if (await saveModelAndCredentials()) {
+ setEditingModel(false)
+ }
+ }}
+ disabled={busy}
+ >
+ {busy ? 'Saving…' : 'Save'}
+ </button>
+ </>
+ ) : (
+ <button
+ type="button"
+ className="cu-btn cu-btn--ghost cu-btn--sm"
+ onClick={() => setEditingModel(true)}
+ disabled={busy}
+ >
+ Edit
+ </button>
+ )}
+ </div>
</div>
- </div>
- <div
- style={{
- marginTop: '1.5rem',
- paddingTop: '1.25rem',
- borderTop: '1px solid var(--cu-border)',
- }}
- >
- <p className="cu-section-title" style={{ marginBottom: '0.5rem' }}>
- Model &amp; credentials
- </p>
- {editingOverview ? (
+ {!editingModel ? (
+ <div className="cu-form-stack">
+ <div className="cu-field">
+ <label htmlFor="model-provider">Model provider</label>
+ <div className="cu-field__readonly">{getProviderLabel(providerDraft)}</div>
+ </div>
+ <div className="cu-field">
+ <label htmlFor="model-allowed">Allowed models</label>
+ {allowedModelsSummary.length > 0 ? (
+ <ul className="cu-llm-policy__summary">
+ {allowedModelsSummary.map(entry => (
+ <li key={entry.provider} className="cu-field__readonly">
+ {getProviderLabel(entry.provider)} · {entry.models.join(', ')}
+ </li>
+ ))}
+ </ul>
+ ) : (
+ <div className="cu-field__readonly">
+ All models — this agent offers every enabled model for its provider(s).
+ </div>
+ )}
+ </div>
+ <div className="cu-field">
+ <label htmlFor="model-secret">Secret reference</label>
+ <div className="cu-field__readonly">{secretRefDraft || '-'}</div>
+ </div>
+ <div className="cu-field">
+ <label htmlFor="model-fallback">Fallback policy</label>
+ {llmPolicyDraft && llmPolicyDraft.fallbacks.length > 0 ? (
+ <ol className="cu-llm-policy__summary">
+ {llmPolicyDraft.fallbacks.map((entry, index) => (
+ <li key={index} className="cu-field__readonly">
+ {getProviderLabel(entry.provider)} · {entry.model || '-'}
+ {entry.credentialSlot ? ` · ${entry.credentialSlot}` : ''}
+ </li>
+ ))}
+ </ol>
+ ) : (
+ <div className="cu-field__readonly">No fallback configured.</div>
+ )}
+ </div>
+ </div>
+ ) : (
<>
{retireCandidates.length > 0 ? (
<div className="cu-banner cu-banner--warning" style={{ marginBottom: '0.75rem' }}>
@@ -1014,6 +1161,27 @@ export default function HostDetailsPage() {
</button>
</div>
) : null}
+ <div className="cu-form-stack" style={{ marginBottom: '1rem' }}>
+ <div className="cu-field">
+ <label htmlFor="host-secret">Secret reference</label>
+ <select
+ id="host-secret"
+ value={secretRefDraft}
+ onChange={e => setSecretRefDraft(e.target.value)}
+ disabled={busy}
+ >
+ <option value="">Select LLM secret</option>
+ {availableSecrets.map(secretName => (
+ <option key={secretName} value={secretName}>
+ {secretName}
+ </option>
+ ))}
+ {secretRefDraft && !availableSecrets.includes(secretRefDraft) ? (
+ <option value={secretRefDraft}>{secretRefDraft} (custom)</option>
+ ) : null}
+ </select>
+ </div>
+ </div>
<LlmProviderConfig
provider={providerDraft}
model={modelNameDraft}
@@ -1028,6 +1196,7 @@ export default function HostDetailsPage() {
catalog={allowedCatalog}
catalogLoading={modelsLoading}
catalogError={modelsError}
+ replacePrimaryModelWithAllowedModels
credentials={{
draft: llmKeyDraft,
onChange: (dataKey, value) =>
@@ -1038,380 +1207,290 @@ export default function HostDetailsPage() {
disabled={busy}
/>
</>
- ) : llmPolicyDraft && llmPolicyDraft.fallbacks.length > 0 ? (
- <ol className="cu-llm-policy__summary">
- {llmPolicyDraft.fallbacks.map((entry, index) => (
- <li key={index} className="cu-field__readonly">
- {getProviderLabel(entry.provider)} · {entry.model || '-'}
- {entry.credentialSlot ? ` · ${entry.credentialSlot}` : ''}
- </li>
- ))}
- </ol>
- ) : (
- <p className="cu-muted" style={{ fontSize: '0.8125rem', margin: 0 }}>
- No fallback configured.
- </p>
)}
- {!editingOverview ? (
- <div style={{ marginTop: '0.75rem' }}>
- <p className="cu-muted" style={{ fontSize: '0.75rem', margin: '0 0 0.35rem' }}>
- Allowed models
- </p>
- {allowedModelsSummary.length > 0 ? (
- <ul className="cu-llm-policy__summary">
- {allowedModelsSummary.map(entry => (
- <li key={entry.provider} className="cu-field__readonly">
- {getProviderLabel(entry.provider)} · {entry.models.join(', ')}
- </li>
- ))}
- </ul>
- ) : (
- <p className="cu-muted" style={{ fontSize: '0.8125rem', margin: 0 }}>
- All models — this agent offers every enabled model for its provider(s).
- </p>
- )}
- </div>
- ) : null}
- </div>
+ </>
+ )}
- {editingOverview && (
- <div className="cu-save-bar">
- <button
- type="button"
- className="cu-btn cu-btn--ghost cu-btn--sm"
- onClick={() => setEditingOverview(false)}
- disabled={busy}
- >
- Cancel
- </button>
- <button
- type="button"
- className="cu-btn cu-btn--primary"
- onClick={async () => {
- // AP-6: stay in edit mode on failure so the operator's
- // draft survives alongside the error/conflict banner.
- if (await saveHost()) {
- setEditingOverview(false)
- }
- }}
- disabled={busy || !hostNameDraft.trim()}
- >
- {busy ? 'Saving…' : 'Save'}
- </button>
+ {activeTab === 'approvals' && !initialLoading && (
+ <HostApprovalSection
+ initialTools={approvalToolsData}
+ onSave={persistApprovalTools}
+ busy={busy}
+ canWrite={true /* TODO: wire to actual host:write check if/when per-field RBAC lands */}
+ defaultEditing
+ />
+ )}
+
+ {activeTab === 'contexts' && (
+ <>
+ <p className="cu-muted" style={{ fontSize: '0.875rem', marginBottom: '1rem' }}>
+ Associated context for this agent.
+ </p>
+ <div className="cu-table-wrap">
+ <table className="cu-table cu-table--header-band cu-table--static-rows">
+ <thead>
+ <tr>
+ <th>Context</th>
+ <th className="cu-table__col-actions">Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ {initialLoading ? (
+ <tr>
+ <td colSpan={2} className="cu-empty">
+ Loading…
+ </td>
+ </tr>
+ ) : (
+ <tr>
+ <td>
+ {editingContext ? (
+ <select
+ className="cu-input cu-host-context-select"
+ value={contextRefDraft}
+ onChange={e => setContextRefDraft(e.target.value)}
+ disabled={busy}
+ autoFocus
+ onKeyDown={e => {
+ if (e.key === 'Escape') {
+ setEditingContext(false)
+ }
+ }}
+ >
+ <option value="">Select context</option>
+ {availableContexts.map(contextId => (
+ <option key={contextId} value={contextId}>
+ {contextId}
+ </option>
+ ))}
+ </select>
+ ) : contextRefDraft.trim() ? (
+ <button
+ type="button"
+ className="cu-link"
+ onClick={() =>
+ router.push(CONTROL_ROUTES.contexts.detail(contextRefDraft.trim()))
+ }
+ >
+ {contextRefDraft}
+ </button>
+ ) : (
+ <span className="cu-table__cell-muted">No context selected</span>
+ )}
+ </td>
+ <td className="cu-table__cell-actions">
+ {editingContext ? (
+ <button
+ type="button"
+ className="cu-btn cu-btn--icon cu-btn--toolbar"
+ onClick={async () => {
+ if (await saveHost()) {
+ setEditingContext(false)
+ }
+ }}
+ disabled={busy}
+ aria-label="Save context"
+ title="Save context"
+ >
+ <IconCheck width={16} height={16} />
+ </button>
+ ) : (
+ <button
+ type="button"
+ className="cu-btn cu-btn--icon cu-btn--toolbar"
+ onClick={() => setEditingContext(true)}
+ disabled={busy}
+ aria-label="Edit context"
+ title="Edit context"
+ >
+ <IconPencil width={16} height={16} />
+ </button>
+ )}
+ </td>
+ </tr>
+ )}
+ </tbody>
+ </table>
</div>
- )}
+ </>
+ )}
- {!initialLoading && (
- <HostApprovalSection
- initialTools={approvalToolsData}
- onSave={persistApprovalTools}
- busy={busy}
- canWrite={
- true /* TODO: wire to actual host:write check if/when per-field RBAC lands */
- }
- />
- )}
+ {activeTab === 'env' && <HostEnvTable hostRef={routeName} />}
- {!initialLoading && (
+ {activeTab === 'identity' && <HostIdentityTab hostName={routeName} />}
+
+ {activeTab === 'users' && (
+ <>
<div
style={{
- marginTop: '2rem',
- paddingTop: '1.25rem',
- borderTop: '1px solid var(--cu-border)',
+ display: 'flex',
+ flexWrap: 'wrap',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ gap: '0.5rem',
+ marginBottom: '1rem',
}}
>
- <p className="cu-section-title" style={{ marginBottom: '0.5rem' }}>
- Danger zone
- </p>
- <p className="cu-muted" style={{ fontSize: '0.8125rem', marginBottom: '0.75rem' }}>
- Permanently delete this agent and its direct access mappings.
+ <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--ghost cu-btn--sm"
- style={{ color: 'var(--cu-danger)' }}
- onClick={() => {
- setDeleteAgentDialogError('')
- setShowDeleteAgentConfirm(true)
- }}
- disabled={busy}
+ className="cu-btn cu-btn--primary cu-btn--sm"
+ onClick={() => setShowAddUser(true)}
+ disabled={busy || hasPendingRename}
>
- Delete agent...
+ Add member
</button>
</div>
- )}
- </>
- )}
-
- {activeTab === 'contexts' && (
- <>
- <p className="cu-muted" style={{ fontSize: '0.875rem', marginBottom: '1rem' }}>
- Associated context for this agent.
- </p>
- <div className="cu-table-wrap">
- <table className="cu-table cu-table--header-band cu-table--static-rows">
- <thead>
- <tr>
- <th>Context</th>
- <th className="cu-table__col-actions">Actions</th>
- </tr>
- </thead>
- <tbody>
- {initialLoading ? (
- <tr>
- <td colSpan={2} className="cu-empty">
- Loading…
- </td>
- </tr>
- ) : (
+ <div className="cu-table-wrap">
+ <table className="cu-table cu-table--header-band">
+ <thead>
<tr>
- <td>
- {editingContext ? (
- <select
- className="cu-input cu-host-context-select"
- value={contextRefDraft}
- onChange={e => setContextRefDraft(e.target.value)}
- disabled={busy}
- autoFocus
- onKeyDown={e => {
- if (e.key === 'Escape') {
- setEditingContext(false)
- }
- }}
- >
- <option value="">Select context</option>
- {availableContexts.map(contextId => (
- <option key={contextId} value={contextId}>
- {contextId}
- </option>
- ))}
- </select>
- ) : contextRefDraft.trim() ? (
- <button
- type="button"
- className="cu-link"
- onClick={() =>
- router.push(CONTROL_ROUTES.contexts.detail(contextRefDraft.trim()))
- }
- >
- {contextRefDraft}
- </button>
- ) : (
- <span className="cu-table__cell-muted">No context selected</span>
- )}
- </td>
- <td className="cu-table__cell-actions">
- {editingContext ? (
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--toolbar"
- onClick={async () => {
- if (await saveHost()) {
- setEditingContext(false)
- }
- }}
- disabled={busy}
- aria-label="Save context"
- title="Save context"
- >
- <IconCheck width={16} height={16} />
- </button>
- ) : (
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--toolbar"
- onClick={() => setEditingContext(true)}
- disabled={busy}
- aria-label="Edit context"
- title="Edit context"
- >
- <IconPencil width={16} height={16} />
- </button>
- )}
- </td>
+ <th>Member</th>
+ <th className="cu-table__col-actions">Actions</th>
</tr>
- )}
- </tbody>
- </table>
- </div>
- </>
- )}
-
- {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>
+ </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>
- <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">
+ ) : (
+ usersWithAccess.map(user => (
+ <tr key={user.id}>
+ <td>
<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"
+ className="cu-link"
+ onClick={() => router.push(CONTROL_ROUTES.usersAndTeams.user(user.id))}
>
- <IconX width={16} height={16} />
+ {user.displayName || user.name || user.email}
</button>
- </div>
- </td>
- </tr>
- ))
- )}
- </tbody>
- </table>
- </div>
- </>
- )}
+ </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}
+ {activeTab === 'teams' && (
+ <>
+ <div
+ style={{
+ display: 'flex',
+ flexWrap: 'wrap',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ gap: '0.5rem',
+ marginBottom: '1rem',
+ }}
>
- 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 ? (
+ <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>
- <td colSpan={2} className="cu-empty">
- No teams have access yet.
- </td>
+ <th>Team</th>
+ <th className="cu-table__col-actions">Actions</th>
</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>
+ </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>
- <td className="cu-table__cell-actions">
- <div className="cu-row-actions">
+ </tr>
+ ) : (
+ teamsWithAccess.map(team => (
+ <tr key={team.id}>
+ <td>
<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"
+ className="cu-link"
+ onClick={() => router.push(CONTROL_ROUTES.usersAndTeams.team(team.id))}
>
- <IconX width={16} height={16} />
+ {team.name}
</button>
- </div>
- </td>
- </tr>
- ))
- )}
- </tbody>
- </table>
- </div>
- </>
- )}
+ </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>
+ </>
+ )}
+ </div>
{showAddUser && (
<div
style={{
diff --git a/control-ui/components/HostApprovalSection/index.tsx b/control-ui/components/HostApprovalSection/index.tsx
index 75fa8fd2e..2afdbadd3 100644
--- a/control-ui/components/HostApprovalSection/index.tsx
+++ b/control-ui/components/HostApprovalSection/index.tsx
@@ -34,8 +34,9 @@ export function HostApprovalSection({
onSave,
busy,
canWrite,
+ defaultEditing = false,
}: HostApprovalSectionProps) {
- const [editing, setEditing] = useState(false)
+ const [editing, setEditing] = useState(defaultEditing)
const draftAPI = useApprovalToolsDraft(initialTools)
// Build a sorted view that pairs each known-tool meta with its current state.
@@ -70,13 +71,13 @@ export function HostApprovalSection({
function handleCancel() {
draftAPI.reset()
- setEditing(false)
+ setEditing(defaultEditing)
}
async function handleSave() {
try {
await onSave(draftAPI.toToolsMap())
- setEditing(false)
+ setEditing(defaultEditing)
} catch {
// Parent surfaced an error banner. Stay in edit mode so the operator's
// draft survives the failure and they can retry or Cancel.
@@ -84,18 +85,57 @@ export function HostApprovalSection({
}
return (
- <div
- style={{
- marginTop: '2rem',
- paddingTop: '1.25rem',
- borderTop: '1px solid var(--cu-border)',
- }}
- >
- <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between' }}>
- <p className="cu-section-title" style={{ marginBottom: '0.5rem' }}>
- Per-tool approval
- </p>
- {!editing && canWrite && (
+ <div className="cu-host-approval-section">
+ <p className="cu-muted cu-host-approval-section__description">
+ Skip or require approval for individual tools when an agent calls them. Defaults to the
+ safest setting per tool. Changes apply to the next task.
+ </p>
+
+ <div className="cu-host-approval-section__content">
+ {!editing ? (
+ readOnlyRows.length === 0 ? (
+ <div className="cu-empty">
+ No per-tool overrides configured. All tools use their built-in approval defaults.
+ </div>
+ ) : (
+ <div>
+ {readOnlyRows.map(row => (
+ <ReadOnlyRow
+ key={row.name}
+ name={row.name}
+ state={row.state}
+ riskHint={row.meta?.riskHint}
+ codeDefault={row.meta?.codeDefault}
+ />
+ ))}
+ </div>
+ )
+ ) : (
+ <EditMode knownRows={knownRows} draftAPI={draftAPI} busy={busy} />
+ )}
+ </div>
+
+ <div className="cu-host-approval-section__actions">
+ {editing ? (
+ <>
+ <button
+ type="button"
+ className="cu-btn cu-btn--ghost cu-btn--sm"
+ onClick={handleCancel}
+ disabled={busy}
+ >
+ Cancel
+ </button>
+ <button
+ type="button"
+ className="cu-btn cu-btn--primary"
+ onClick={handleSave}
+ disabled={busy || !draftAPI.isDirty}
+ >
+ {busy ? 'Saving…' : 'Save'}
+ </button>
+ </>
+ ) : canWrite ? (
<button
type="button"
className="cu-btn cu-btn--ghost cu-btn--sm"
@@ -104,41 +144,8 @@ export function HostApprovalSection({
>
Edit
</button>
- )}
+ ) : null}
</div>
-
- <p className="cu-muted" style={{ fontSize: '0.8125rem', marginBottom: '0.75rem' }}>
- Skip or require approval for individual tools when an agent calls them. Defaults to the
- safest setting per tool. Changes apply to the next task.
- </p>
-
- {!editing ? (
- readOnlyRows.length === 0 ? (
- <div className="cu-empty">
- No per-tool overrides configured. All tools use their built-in approval defaults.
- </div>
- ) : (
- <div>
- {readOnlyRows.map(row => (
- <ReadOnlyRow
- key={row.name}
- name={row.name}
- state={row.state}
- riskHint={row.meta?.riskHint}
- codeDefault={row.meta?.codeDefault}
- />
- ))}
- </div>
- )
- ) : (
- <EditMode
- knownRows={knownRows}
- draftAPI={draftAPI}
- busy={busy}
- onCancel={handleCancel}
- onSave={handleSave}
- />
- )}
</div>
)
}
@@ -174,11 +181,9 @@ interface EditModeProps {
knownRows: Array<{ meta: (typeof NATIVE_TOOLS)[number]; state: RowState }>
draftAPI: ReturnType<typeof useApprovalToolsDraft>
busy: boolean
- onCancel: () => void
- onSave: () => void
}
-function EditMode({ knownRows, draftAPI, busy, onCancel, onSave }: EditModeProps) {
+function EditMode({ knownRows, draftAPI, busy }: EditModeProps) {
const [advancedOpen, setAdvancedOpen] = useState(false)
const [customName, setCustomName] = useState('')
const [customState, setCustomState] = useState<Exclude<RowState, 'default'>>('required')
@@ -321,25 +326,6 @@ function EditMode({ knownRows, draftAPI, busy, onCancel, onSave }: EditModeProps
</div>
)}
</div>
-
- <div className="cu-save-bar">
- <button
- type="button"
- className="cu-btn cu-btn--ghost cu-btn--sm"
- onClick={onCancel}
- disabled={busy}
- >
- Cancel
- </button>
- <button
- type="button"
- className="cu-btn cu-btn--primary"
- onClick={onSave}
- disabled={busy || !draftAPI.isDirty}
- >
- {busy ? 'Saving…' : 'Save'}
- </button>
- </div>
</>
)
}
diff --git a/control-ui/components/HostApprovalSection/types.ts b/control-ui/components/HostApprovalSection/types.ts
index 67c82530a..5f7ea1021 100644
--- a/control-ui/components/HostApprovalSection/types.ts
+++ b/control-ui/components/HostApprovalSection/types.ts
@@ -12,6 +12,10 @@ export interface HostApprovalSectionProps {
onSave: (tools: Record<string, boolean>) => Promise<void>
busy: boolean
canWrite: boolean
+ // Render the full editable tool list immediately instead of the read-only
+ // summary. The section stays expanded through Save/Cancel (Cancel discards
+ // the in-progress draft but keeps the list visible).
+ defaultEditing?: boolean
}
export type { CodeDefault, NativeToolMeta }
diff --git a/control-ui/components/HostEnvTable.tsx b/control-ui/components/HostEnvTable.tsx
index f40e19cd0..dfb2df9f0 100644
--- a/control-ui/components/HostEnvTable.tsx
+++ b/control-ui/components/HostEnvTable.tsx
@@ -196,8 +196,7 @@ export function HostEnvTable({ hostRef }: { hostRef: string }) {
}}
>
<div>
- <h2 style={{ margin: 0, fontSize: '1.1rem' }}>Environment variables</h2>
- <p className="cu-muted" style={{ margin: '0.25rem 0 0', fontSize: '0.85rem' }}>
+ <p className="cu-muted" style={{ margin: 0, fontSize: '0.85rem' }}>
Operator-managed env vars for this Host. Applied within ~1 second; no pod restart.
Provider keys live in the LLM Secrets tab.
</p>
diff --git a/control-ui/components/HostWizard/index.tsx b/control-ui/components/HostWizard/index.tsx
index efe0f64aa..4a2864523 100644
--- a/control-ui/components/HostWizard/index.tsx
+++ b/control-ui/components/HostWizard/index.tsx
@@ -1527,6 +1527,8 @@ export function HostWizard({
catalog={allowedCatalog}
catalogLoading={modelsLoading}
catalogError={modelsError}
+ modelLabel="Default model"
+ showAllowedModels={false}
credentials={
secretMode === 'new'
? {
@@ -1536,7 +1538,6 @@ export function HostWizard({
}
: undefined
}
- inlinePrimaryCredential
secretKeys={secretMode === 'new' ? llmSecretKeys : []}
disabled={busy}
/>
diff --git a/control-ui/components/LlmProviderConfig/index.tsx b/control-ui/components/LlmProviderConfig/index.tsx
index 44d4bca6a..f62735a87 100644
--- a/control-ui/components/LlmProviderConfig/index.tsx
+++ b/control-ui/components/LlmProviderConfig/index.tsx
@@ -108,8 +108,10 @@ export function LlmProviderConfig({
catalog,
catalogLoading = false,
catalogError,
+ modelLabel = 'Model',
+ showAllowedModels = true,
+ replacePrimaryModelWithAllowedModels = false,
credentials,
- inlinePrimaryCredential = false,
secretKeys = [],
disabled = false,
}: LlmProviderConfigProps) {
@@ -163,6 +165,14 @@ export function LlmProviderConfig({
const others = allowedModels.filter(entry => entry.provider !== providerId)
const additions = models.map(nextModel => ({ provider: providerId, model: nextModel }))
onAllowedModelsChange([...others, ...additions])
+ if (
+ replacePrimaryModelWithAllowedModels &&
+ providerId === provider &&
+ models.length > 0 &&
+ !models.includes(model)
+ ) {
+ onPrimaryChange({ provider, model: models[0] })
+ }
}
// The distinct fallback providers whose subset is NOT already curated by the
@@ -232,16 +242,11 @@ export function LlmProviderConfig({
<span className="cu-llm-config__block-tag">Required</span>
</div>
- <div
- className={cn(
- 'cu-llm-config__model-row',
- credentials && inlinePrimaryCredential && 'cu-llm-config__model-row--with-credential'
- )}
- >
+ <div className="cu-llm-config__model-row">
<Field htmlFor="llm-primary-provider" label="Provider">
<SelectionDropdown
id="llm-primary-provider"
- className="cu-llm-config__primary-select"
+ className="cu-llm-config__primary-select cu-llm-config__provider-select"
value={[provider]}
options={primaryProviderOptions}
placeholder="Select provider…"
@@ -268,39 +273,38 @@ export function LlmProviderConfig({
/>
</Field>
- <Field htmlFor="llm-primary-model" label="Model">
- <SelectionDropdown
- id="llm-primary-model"
- className="cu-llm-config__primary-select"
- value={model ? [model] : []}
- options={primaryModelSelectOptions}
- placeholder={primaryModelOptions.length === 0 ? 'No enabled models' : 'Select model…'}
- searchPlaceholder="Search models…"
- selectionLabel="model"
- multiple={false}
- showSelectedChips={false}
- disabled={disabled}
- invalid={primaryModelOutOfAllowlist}
- onChange={next => {
- const nextModel = next[0]
- if (!nextModel) return
- onPrimaryChange({ provider, model: nextModel })
- }}
- />
- </Field>
-
- {credentials && inlinePrimaryCredential ? (
- <ProviderCredentialBlock
- variant="primary"
- group={primaryGroup}
- slots={primaryGroup.slots}
- idPrefix="llm-primary"
- wiring={credentials}
- present={present}
+ {replacePrimaryModelWithAllowedModels && showAllowedModels ? (
+ <AllowedModelsField
+ provider={provider}
+ catalog={catalog}
+ allowedModels={allowedModels}
+ onChange={handleProviderAllowedChange}
disabled={disabled}
- inline
/>
- ) : null}
+ ) : (
+ <Field htmlFor="llm-primary-model" label={modelLabel}>
+ <SelectionDropdown
+ id="llm-primary-model"
+ className="cu-llm-config__primary-select"
+ value={model ? [model] : []}
+ options={primaryModelSelectOptions}
+ placeholder={
+ primaryModelOptions.length === 0 ? 'No enabled models' : 'Select model…'
+ }
+ searchPlaceholder="Search models…"
+ selectionLabel="model"
+ multiple={false}
+ showSelectedChips={false}
+ disabled={disabled}
+ invalid={primaryModelOutOfAllowlist}
+ onChange={next => {
+ const nextModel = next[0]
+ if (!nextModel) return
+ onPrimaryChange({ provider, model: nextModel })
+ }}
+ />
+ </Field>
+ )}
</div>
{catalogError ? (
@@ -311,7 +315,7 @@ export function LlmProviderConfig({
</p>
) : null}
- {primaryModelOutOfAllowlist ? (
+ {primaryModelOutOfAllowlist && !replacePrimaryModelWithAllowedModels ? (
<p className="cu-llm-config__warn">
{model} isn&apos;t in the models offered for {getProviderLabel(provider)} — end users
won&apos;t be offered it. Pick a model from the list, or add it under Allowed models
@@ -319,15 +323,17 @@ export function LlmProviderConfig({
</p>
) : null}
- <AllowedModelsField
- provider={provider}
- catalog={catalog}
- allowedModels={allowedModels}
- onChange={handleProviderAllowedChange}
- disabled={disabled}
- />
+ {showAllowedModels && !replacePrimaryModelWithAllowedModels ? (
+ <AllowedModelsField
+ provider={provider}
+ catalog={catalog}
+ allowedModels={allowedModels}
+ onChange={handleProviderAllowedChange}
+ disabled={disabled}
+ />
+ ) : null}
- {credentials && !inlinePrimaryCredential ? (
+ {credentials ? (
<ProviderCredentialBlock
variant="primary"
group={primaryGroup}
@@ -356,7 +362,7 @@ export function LlmProviderConfig({
/>
</div>
- {fallbackAllowedProviders.length > 0 ? (
+ {showAllowedModels && fallbackAllowedProviders.length > 0 ? (
<div className="cu-llm-config__block">
<div className="cu-llm-config__block-head">
<span className="cu-llm-config__block-title">Allowed models · fallback providers</span>
@@ -534,7 +540,6 @@ type ProviderCredentialBlockProps = {
wiring: LlmCredentialWiring
present: (dataKey: string) => boolean
disabled: boolean
- inline?: boolean
}
// One provider's credential block: the usable/partial/absent chip, its slot
@@ -550,7 +555,6 @@ function ProviderCredentialBlock({
wiring,
present,
disabled,
- inline = false,
}: ProviderCredentialBlockProps) {
const chip = describeLlmCompleteness(group, present)
const providerLabel = getProviderLabel(group.provider)
@@ -563,22 +567,17 @@ function ProviderCredentialBlock({
const usable = chip.state === 'present'
return (
- <section
- className={cn('cu-llm-cred-group', inline && 'cu-llm-cred-group--inline')}
- aria-label={`${group.label} credentials`}
- >
- {!inline ? (
- <div className="cu-llm-cred-group__head">
- <span className="cu-llm-cred-group__title">{group.label}</span>
- <span
- className={cn('cu-slot-chip', `cu-slot-chip--${chip.state}`)}
- aria-label={`${group.label} credentials ${chip.text}`}
- >
- <span aria-hidden="true">{chip.symbol}</span>
- {chip.text}
- </span>
- </div>
- ) : null}
+ <section className="cu-llm-cred-group" aria-label={`${group.label} credentials`}>
+ <div className="cu-llm-cred-group__head">
+ <span className="cu-llm-cred-group__title">{group.label}</span>
+ <span
+ className={cn('cu-slot-chip', `cu-slot-chip--${chip.state}`)}
+ aria-label={`${group.label} credentials ${chip.text}`}
+ >
+ <span aria-hidden="true">{chip.symbol}</span>
+ {chip.text}
+ </span>
+ </div>
{slots.map(slot => {
const inputId = `${idPrefix}-${slot.dataKey}`
diff --git a/control-ui/components/LlmProviderConfig/types.ts b/control-ui/components/LlmProviderConfig/types.ts
index edfdfeded..9703b422d 100644
--- a/control-ui/components/LlmProviderConfig/types.ts
+++ b/control-ui/components/LlmProviderConfig/types.ts
@@ -34,13 +34,20 @@ export type LlmProviderConfigProps = {
catalogLoading?: boolean
catalogError?: string
+ // Copy and model-restriction controls vary by surface. The agent creation
+ // flow selects one default model without exposing per-host restrictions,
+ // while the edit surface retains the full allowed-models editor.
+ modelLabel?: string
+ showAllowedModels?: boolean
+ // Existing-agent layout: preserve the saved default model internally and
+ // put the primary provider's Allowed models control in the model field's
+ // place. Provider changes still resolve a valid default model automatically.
+ replacePrimaryModelWithAllowedModels?: boolean
+
// Credential editing. Omit to render the model + fallback structure WITHOUT
// credential inputs (create flow reusing an existing shared Secret, where the
// wizard cannot introspect the Secret's keys).
credentials?: LlmCredentialWiring
- // Create-flow layout: place the primary credential beside Provider + Model.
- // Edit screens leave this off and retain the full-width credential block.
- inlinePrimaryCredential?: boolean
// Data keys already present in the Host's own Secret — feeds the fallback
// credentialSlot dropdown's extra keys (e.g. `claude-api-key-fb1`).
diff --git a/control-ui/components/RegistryCatalog.tsx b/control-ui/components/RegistryCatalog.tsx
index 34083a585..b6f055176 100644
--- a/control-ui/components/RegistryCatalog.tsx
+++ b/control-ui/components/RegistryCatalog.tsx
@@ -1,6 +1,7 @@
'use client'
import { Fragment, useEffect, useMemo, useState } from 'react'
+import Link from 'next/link'
import { usePathname, useRouter } from 'next/navigation'
import { SectionSearchInput } from '@components/SectionSearchInput'
import { IconStore } from '@components/Sidebar/icons'
@@ -380,7 +381,14 @@ export default function RegistryCatalog() {
/>
</td>
<td>
- <div className="cu-registry-name">{entry.name}</div>
+ <Link
+ className="cu-registry-name cu-link"
+ href={CONTROL_ROUTES.marketplace.entry(entry.name, entry.version)}
+ onClick={event => event.stopPropagation()}
+ onKeyDown={event => event.stopPropagation()}
+ >
+ {entry.name}
+ </Link>
<div className="cu-registry-description" title={entry.description}>
{entry.description}
</div>
diff --git a/control-ui/components/TokenBudgetForm/index.tsx b/control-ui/components/TokenBudgetForm/index.tsx
index 87dc9c8d6..58c032fed 100644
--- a/control-ui/components/TokenBudgetForm/index.tsx
+++ b/control-ui/components/TokenBudgetForm/index.tsx
@@ -108,15 +108,22 @@ export function TokenBudgetForm({
)
}
if (hosts.status === 'fulfilled') {
- setHostOptions(
- (hosts.value.items ?? [])
- .map(h => h.metadata?.name)
- .filter((n): n is string => Boolean(n))
- .map(n => ({ value: n, label: n }))
- )
+ const hostNames = [
+ ...new Set(
+ (hosts.value.items ?? [])
+ .map(h => h.metadata?.name)
+ .filter((n): n is string => Boolean(n))
+ ),
+ ]
+ setHostOptions(hostNames.map(n => ({ value: n, label: n })))
}
if (secrets.status === 'fulfilled') {
- setSecretOptions((secrets.value.items ?? []).map(s => ({ value: s.name, label: s.name })))
+ const secretNames = [
+ ...new Set(
+ (secrets.value.items ?? []).map(s => s.name).filter((n): n is string => Boolean(n))
+ ),
+ ]
+ setSecretOptions(secretNames.map(n => ({ value: n, label: n })))
}
}
void loadOptions()
diff --git a/control-ui/components/__tests__/HostApprovalSection.test.tsx b/control-ui/components/__tests__/HostApprovalSection.test.tsx
index 3484d0677..36418ce64 100644
--- a/control-ui/components/__tests__/HostApprovalSection.test.tsx
+++ b/control-ui/components/__tests__/HostApprovalSection.test.tsx
@@ -176,6 +176,7 @@ describe('HostApprovalSection — component', () => {
)
expect(screen.getByText(/no per-tool overrides configured/i)).toBeInTheDocument()
expect(screen.getByRole('button', { name: /edit/i })).toBeInTheDocument()
+ expect(screen.queryByText('Per-tool approval')).not.toBeInTheDocument()
})
it('hides the Edit button when canWrite=false', () => {
@@ -300,6 +301,9 @@ describe('HostApprovalSection — component', () => {
fireEvent.click(screen.getByRole('button', { name: /edit/i }))
const saveBtn = screen.getByRole('button', { name: /^save/i })
expect(saveBtn).toBeDisabled()
+ const actions = saveBtn.closest('.cu-host-approval-section__actions')
+ expect(actions).not.toBeNull()
+ expect(actions?.previousElementSibling).toHaveClass('cu-host-approval-section__content')
// Change http_request to Skip
const httpSelect = screen.getByLabelText(/http_request/i) as HTMLSelectElement
@@ -400,7 +404,7 @@ describe('HostApprovalSection — component', () => {
expect(failingSave).toHaveBeenCalled()
const httpSelect = screen.getByLabelText(/http_request/i) as HTMLSelectElement
expect(httpSelect.value).toBe('skip')
- // Save / Cancel bar still present (still in edit mode).
+ // Sticky Save / Cancel toolbar remains present (still in edit mode).
expect(screen.getByRole('button', { name: /^save/i })).toBeInTheDocument()
expect(screen.getByRole('button', { name: /cancel/i })).toBeInTheDocument()
})
diff --git a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
index e0a647680..0935a0898 100644
--- a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
+++ b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
@@ -98,11 +98,12 @@ describe('HostDetailsPage identity integration', () => {
it('renders the Identity section tab with the current host name', async () => {
mockParams = { name: 'foo', tab: 'identity' }
- render(<HostDetailsPage />)
+ const { container } = render(<HostDetailsPage />)
expect(await screen.findByTestId('identity-tab')).toHaveTextContent('Identity editor for foo')
+ expect(container.querySelector('.cu-agent-detail-card')).toBeNull()
})
- it('places Identity as the second agent detail tab', async () => {
+ it('renders the agent detail tabs in order', async () => {
render(<HostDetailsPage />)
const tabs = await screen.findAllByRole('tab')
@@ -110,26 +111,72 @@ describe('HostDetailsPage identity integration', () => {
expect(tabs.map(tab => tab.textContent)).toEqual([
'Overview',
'Identity',
- 'Contexts',
- 'Env vars',
+ 'Models & creds',
+ 'Context',
'Member access',
'Team access',
+ 'Per-tool approval',
+ 'Env vars',
])
})
- it('preserves personalization when saving overview changes', async () => {
- render(<HostDetailsPage />)
+ it('puts Allowed models in place of Model name and spells out Secret reference', async () => {
+ mockParams = { name: 'foo', tab: 'model' }
+ const { container } = render(<HostDetailsPage />)
+
+ expect(await screen.findByText('Allowed models')).toBeInTheDocument()
+ expect(screen.queryByText('Model name')).not.toBeInTheDocument()
+ expect(screen.getByText('Secret reference')).toBeInTheDocument()
+ expect(container.querySelector('.cu-agent-detail-card')).toBeNull()
+ expect(container.querySelector('.cu-agent-detail-heading')).not.toBeNull()
+ expect(container.querySelector('.cu-agent-detail-toolbar')).toBeNull()
+
+ fireEvent.click(screen.getByRole('button', { name: 'Edit' }))
+
+ expect(
+ screen.getByLabelText('Allowed models · OpenAI', { selector: '#llm-allowed-openai' })
+ ).toBeInTheDocument()
+ expect(screen.queryByLabelText('Model', { selector: '#llm-primary-model' })).toBeNull()
+ expect(screen.getByLabelText('Secret reference')).toBeInTheDocument()
+ expect(
+ screen.getByRole('button', { name: 'Save' }).closest('.cu-agent-detail-toolbar')
+ ).not.toBeNull()
+ expect(container.querySelector('.cu-agent-detail-card .cu-agent-detail-scroll')).not.toBeNull()
+ })
+
+ it('keeps Per-tool approval actions in the top toolbar without a duplicate title', async () => {
+ mockParams = { name: 'foo', tab: 'approvals' }
+ const { container } = render(<HostDetailsPage />)
+
+ expect(await screen.findByLabelText('http_request')).toBeInTheDocument()
+ expect(
+ screen.getByRole('button', { name: 'Save' }).closest('.cu-host-approval-section__actions')
+ ).not.toBeNull()
+ expect(container.querySelector('.cu-host-approval-section .cu-section-title')).toBeNull()
+ })
+
+ it('shows editable Name and Type in Overview without Display ID and preserves personalization', async () => {
+ const { container } = render(<HostDetailsPage />)
+ expect(await screen.findByText('Name')).toBeInTheDocument()
+ expect(await screen.findByText('Type')).toBeInTheDocument()
+ expect(screen.queryByText('Display ID')).not.toBeInTheDocument()
+ expect(container.querySelector('.cu-agent-detail-card')).toBeNull()
+ expect(container.querySelector('.cu-agent-detail-heading')).not.toBeNull()
+ expect(container.querySelector('.cu-agent-detail-toolbar')).toBeNull()
+
const [overviewEditButton] = await screen.findAllByRole('button', { name: 'Edit' })
await waitFor(() => expect(overviewEditButton).toBeEnabled())
fireEvent.click(overviewEditButton)
- fireEvent.change(screen.getByLabelText('Display ID'), { target: { value: 'foo-updated' } })
+ expect(screen.getByLabelText('Name')).toHaveValue('foo')
+ fireEvent.change(screen.getByLabelText('Name'), { target: { value: 'foo' } })
+ fireEvent.change(screen.getByLabelText('Type'), { target: { value: 'stateless' } })
fireEvent.click(screen.getByRole('button', { name: 'Save' }))
await waitFor(() =>
expect(api.apiSend).toHaveBeenCalledWith('PUT', '/api/v1/admin/hosts/foo', expect.any(Object))
)
const payload = (api.apiSend as unknown as ReturnType<typeof vi.fn>).mock.calls[0][2]
- expect(payload.spec.host).toBe('foo-updated')
+ expect(payload.spec.lifecycle).toEqual({ stateless: true })
expect(payload.spec.personalization).toEqual(host.spec.personalization)
expect(payload.spec.approval).toEqual(host.spec.approval)
})
diff --git a/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsx b/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsx
index 22fb2e9ca..830d31846 100644
--- a/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsx
+++ b/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsx
@@ -180,7 +180,7 @@ describe('HostDetailsPage stateless lifecycle', () => {
expect(screen.queryByText(/^Lifecycle:/)).not.toBeInTheDocument()
})
- it('loads spec.lifecycle.stateless=true into the Agent type field', async () => {
+ it('loads spec.lifecycle.stateless=true into the Type field', async () => {
setupApiMocks(statelessHost)
render(<HostDetailsPage />)
@@ -214,15 +214,14 @@ describe('HostDetailsPage stateless lifecycle', () => {
expect(screen.queryByText(/SuspendBlocked: activeCronSchedules/)).not.toBeInTheDocument()
})
- it('echoes spec.lifecycle when saving an unrelated field (full-replace safety)', async () => {
+ it('echoes spec.lifecycle when saving Overview unchanged (full-replace safety)', async () => {
setupApiMocks(statelessHost)
render(<HostDetailsPage />)
await openOverviewEdit()
- fireEvent.change(screen.getByLabelText('Display ID'), { target: { value: 'foo-updated' } })
const payload = await saveOverviewAndGetPayload()
- expect(payload.spec.host).toBe('foo-updated')
+ expect(payload.spec.host).toBe('foo-display')
expect(payload.spec.lifecycle).toEqual({ stateless: true })
expect(payload.spec.approval).toEqual(baseSpec.approval)
})
@@ -232,7 +231,6 @@ describe('HostDetailsPage stateless lifecycle', () => {
render(<HostDetailsPage />)
await openOverviewEdit()
- fireEvent.change(screen.getByLabelText('Display ID'), { target: { value: 'foo-updated' } })
const payload = await saveOverviewAndGetPayload()
expect('lifecycle' in payload.spec).toBe(false)
@@ -246,7 +244,6 @@ describe('HostDetailsPage stateless lifecycle', () => {
render(<HostDetailsPage />)
await openOverviewEdit()
- fireEvent.change(screen.getByLabelText('Display ID'), { target: { value: 'foo-updated' } })
const payload = await saveOverviewAndGetPayload()
expect(payload.spec.workflowControl).toEqual({
@@ -265,7 +262,7 @@ describe('HostDetailsPage stateless lifecycle', () => {
render(<HostDetailsPage />)
await openOverviewEdit()
- fireEvent.change(screen.getByLabelText('Agent type'), { target: { value: 'stateless' } })
+ fireEvent.change(screen.getByLabelText('Type'), { target: { value: 'stateless' } })
const payload = await saveOverviewAndGetPayload()
expect(payload.spec.lifecycle).toEqual({ stateless: true })
@@ -276,7 +273,7 @@ describe('HostDetailsPage stateless lifecycle', () => {
render(<HostDetailsPage />)
await openOverviewEdit()
- fireEvent.change(screen.getByLabelText('Agent type'), { target: { value: 'stateful' } })
+ fireEvent.change(screen.getByLabelText('Type'), { target: { value: 'stateful' } })
const payload = await saveOverviewAndGetPayload()
expect(payload.spec.lifecycle).toEqual({ stateless: false })
diff --git a/control-ui/components/__tests__/HostWizard.test.tsx b/control-ui/components/__tests__/HostWizard.test.tsx
index 8386a4ab6..dd64995f1 100644
--- a/control-ui/components/__tests__/HostWizard.test.tsx
+++ b/control-ui/components/__tests__/HostWizard.test.tsx
@@ -466,6 +466,25 @@ describe('HostWizard — baseline render', () => {
await renderWizard()
expect(screen.getByPlaceholderText(/agent-name/i)).toBeInTheDocument()
})
+
+ it('shows Default model without Allowed models in Model & Credentials', async () => {
+ await renderWizard()
+
+ fireEvent.change(screen.getByPlaceholderText(/agent-name/i), {
+ target: { value: 'default-model-agent' },
+ })
+ fireEvent.click(screen.getByRole('button', { name: 'Next' }))
+ fireEvent.click(screen.getByLabelText(/Create new context/i))
+ fireEvent.change(screen.getByPlaceholderText(/context-name/i), {
+ target: { value: 'ctx1' },
+ })
+ fireEvent.click(screen.getByRole('button', { name: 'Next' }))
+
+ expect(
+ screen.getByLabelText('Default model', { selector: '#llm-primary-model' })
+ ).toBeInTheDocument()
+ expect(screen.queryByText(/Allowed models/)).not.toBeInTheDocument()
+ })
})
describe('HostWizard — Agent type (stateless lifecycle)', () => {
diff --git a/control-ui/components/__tests__/LlmProviderConfig.test.tsx b/control-ui/components/__tests__/LlmProviderConfig.test.tsx
index b72d065e3..fc9e53202 100644
--- a/control-ui/components/__tests__/LlmProviderConfig.test.tsx
+++ b/control-ui/components/__tests__/LlmProviderConfig.test.tsx
@@ -20,7 +20,7 @@ function Harness({
initialAllowed = [],
withCredentials = true,
existingKeys,
- inlinePrimaryCredential = false,
+ replacePrimaryModelWithAllowedModels = false,
}: {
initialProvider?: LlmProvider
initialModel?: string
@@ -28,7 +28,7 @@ function Harness({
initialAllowed?: HostAllowedModel[]
withCredentials?: boolean
existingKeys?: string[]
- inlinePrimaryCredential?: boolean
+ replacePrimaryModelWithAllowedModels?: boolean
}) {
const [provider, setProvider] = useState<LlmProvider>(initialProvider)
const [model, setModel] = useState(initialModel)
@@ -57,7 +57,7 @@ function Harness({
}
: undefined
}
- inlinePrimaryCredential={inlinePrimaryCredential}
+ replacePrimaryModelWithAllowedModels={replacePrimaryModelWithAllowedModels}
secretKeys={existingKeys}
/>
)
@@ -82,15 +82,48 @@ describe('LlmProviderConfig (spec Topic 1b — domain projection + usable gate)'
expect(within(primary).queryByText(/Add the OpenAI credential/i)).not.toBeInTheDocument()
})
- it('places the primary credential beside Provider and Model in the create layout', () => {
- render(<Harness inlinePrimaryCredential />)
+ it('keeps the primary credential below Provider, Model, and Allowed models', () => {
+ render(<Harness />)
const row = screen
.getByLabelText('Provider', { selector: '#llm-primary-provider' })
.closest('.cu-llm-config__model-row')
expect(row).not.toBeNull()
- expect(row).toHaveClass('cu-llm-config__model-row--with-credential')
- expect(within(row as HTMLElement).getByLabelText(/OpenAI API key/i)).toBeInTheDocument()
+ expect(within(row as HTMLElement).queryByLabelText(/OpenAI API key/i)).not.toBeInTheDocument()
+
+ const allowedModels = screen.getByText('Allowed models · OpenAI').closest('.cu-field')
+ const credentials = screen.getByLabelText('OpenAI credentials')
+ expect(allowedModels).not.toBeNull()
+ expect(allowedModels?.compareDocumentPosition(credentials)).toBe(
+ Node.DOCUMENT_POSITION_FOLLOWING
+ )
+ })
+
+ it('scopes the provider icon treatment to the provider selector', () => {
+ render(<Harness />)
+
+ const providerSelect = screen
+ .getByLabelText('Provider', { selector: '#llm-primary-provider' })
+ .closest('.cu-selection-dropdown')
+ const modelSelect = screen
+ .getByLabelText('Model', { selector: '#llm-primary-model' })
+ .closest('.cu-selection-dropdown')
+
+ expect(providerSelect).toHaveClass('cu-llm-config__provider-select')
+ expect(modelSelect).not.toHaveClass('cu-llm-config__provider-select')
+ })
+
+ it('replaces Model with Allowed models in the existing-agent layout', () => {
+ render(<Harness replacePrimaryModelWithAllowedModels />)
+
+ const row = screen
+ .getByLabelText('Provider', { selector: '#llm-primary-provider' })
+ .closest('.cu-llm-config__model-row')
+ expect(row).not.toBeNull()
+ expect(within(row as HTMLElement).getByText('Allowed models · OpenAI')).toBeInTheDocument()
+ expect(
+ screen.queryByLabelText('Model', { selector: '#llm-primary-model' })
+ ).not.toBeInTheDocument()
})
it('treats a stored key (existingKeys) as usable without re-entry (edit mode)', () => {
diff --git a/control-ui/components/__tests__/RegistryCatalog.test.tsx b/control-ui/components/__tests__/RegistryCatalog.test.tsx
index f84d87937..e7d06be37 100644
--- a/control-ui/components/__tests__/RegistryCatalog.test.tsx
+++ b/control-ui/components/__tests__/RegistryCatalog.test.tsx
@@ -173,6 +173,16 @@ describe('RegistryCatalog tabs and columns', () => {
'/marketplace/plugins'
)
})
+
+ it('links entry names to their shareable detail routes', async () => {
+ mockApiSuccess()
+ render(<RegistryCatalog />)
+
+ expect(await screen.findByRole('link', { name: 'brave-search' })).toHaveAttribute(
+ 'href',
+ '/marketplace/entries/brave-search/1.0.0'
+ )
+ })
})
describe('RegistryCatalog expansion and actions', () => {
diff --git a/control-ui/e2e/host-approval-tools-e2e.spec.ts b/control-ui/e2e/host-approval-tools-e2e.spec.ts
index f56822e22..472cf2dee 100644
--- a/control-ui/e2e/host-approval-tools-e2e.spec.ts
+++ b/control-ui/e2e/host-approval-tools-e2e.spec.ts
@@ -2,10 +2,8 @@
* E2E -- HostApprovalSection editor flow
*
* Validates the per-tool approval override UI on the host detail page:
- * Scenario 1: Toggle http_request → Skip → Save → override persists
- * in read-only summary; warning icon visible at edit time.
- * Scenario 2: Toggle http_request back to Default → Save → section
- * returns to empty state.
+ * Scenario 1: Toggle http_request → Skip → Save → override persists.
+ * Scenario 2: Toggle http_request back to Default → Save → override clears.
* Scenario 3: Cancel discards the in-flight shell_exec change.
*
* Prerequisites:
@@ -61,26 +59,20 @@ async function login(page: Page) {
}
/**
- * Click the Edit button in the "Per-tool approval" section header.
- * The button lives in the same flex-row div as the section title <p>.
- * We find the closest ancestor div that directly contains both elements.
+ * Enter edit mode when the embedding surface did not open it by default.
*/
async function clickSectionEdit(page: Page) {
- // The flex-row container is the div that directly wraps the <p> and <button>.
- // All ancestor divs also satisfy `:has(p.cu-section-title)`, so we use .last()
- // to get the deepest (most specific) match — the flex-row div itself.
- const flexRow = page
- .locator('div')
- .filter({ has: page.locator('p.cu-section-title:has-text("Per-tool approval")') })
- .last()
- await flexRow.locator('button:has-text("Edit")').click()
+ if ((await page.locator('#approval-http_request').count()) > 0) return
+ await page
+ .locator('.cu-host-approval-section__actions')
+ .locator('button:has-text("Edit")')
+ .click()
}
/** Navigate to the host detail page and wait for the Per-tool approval section to load. */
async function gotoHostDetails(page: Page) {
- await page.goto(`${BASE_UI}/hosts/${encodeURIComponent(HOST_NAME)}`)
- // The HostApprovalSection renders after `!initialLoading`, wait for the section header.
- await page.waitForSelector('text=Per-tool approval', { timeout: 20_000 })
+ await page.goto(`${BASE_UI}/hosts/${encodeURIComponent(HOST_NAME)}/approvals`)
+ await page.waitForSelector('.cu-host-approval-section', { timeout: 20_000 })
}
/**
@@ -135,7 +127,7 @@ test.describe('HostApprovalSection E2E -- per-tool override editor flow', () =>
// ── HAT1. Toggle http_request → Skip → Save ─────────────────────────────
- test('HAT1. Toggle http_request to Skip, Save — override persists in read-only summary with warning icon', async () => {
+ test('HAT1. Toggle http_request to Skip, Save — override persists with warning icon', async () => {
test.skip(!token, 'Login failed — skipping')
// Start from clean slate
@@ -143,9 +135,6 @@ test.describe('HostApprovalSection E2E -- per-tool override editor flow', () =>
await gotoHostDetails(page)
- // Click Edit in the Per-tool approval section.
- // The flex-row div that holds the section title also holds the Edit button.
- // We locate it as the div directly containing both the <p> title and the <button>.
await clickSectionEdit(page)
// Wait for the edit-mode selects to appear
@@ -172,19 +161,10 @@ test.describe('HostApprovalSection E2E -- per-tool override editor flow', () =>
.last()
await saveBtn.click()
- // Wait for the section to return to read-only mode (Edit button reappears)
- await page.waitForSelector('p.cu-section-title:has-text("Per-tool approval")', {
- timeout: 15_000,
- })
- // Give the page time to re-render after loadData() completes
- await page.waitForTimeout(2_000)
-
- // Read-only mode: verify http_request → Skip row is visible
- const readOnlySummary = page.locator('.cu-access-row')
- const rowTexts = await readOnlySummary.allTextContents()
- const httpRequestRow = rowTexts.find(t => t.includes('http_request'))
- expect(httpRequestRow).toBeTruthy()
- expect(httpRequestRow).toContain('Skip')
+ await expect(page.locator('#approval-http_request')).toHaveValue('skip')
+ await expect(
+ page.locator('.cu-host-approval-section__actions button:has-text("Save")')
+ ).toBeDisabled()
// Bonus: verify via API that the CRD was patched
const { status, data } = await api(token, 'GET', `/api/v1/admin/hosts/${HOST_NAME}`)
@@ -200,7 +180,7 @@ test.describe('HostApprovalSection E2E -- per-tool override editor flow', () =>
// ── HAT2. Toggle back to Default → Save → empty state ───────────────────
- test('HAT2. Toggle http_request back to Default, Save — section shows empty state', async () => {
+ test('HAT2. Toggle http_request back to Default, Save — override clears', async () => {
test.skip(!token, 'Login failed — skipping')
await gotoHostDetails(page)
@@ -230,21 +210,7 @@ test.describe('HostApprovalSection E2E -- per-tool override editor flow', () =>
// Wait for re-render
await page.waitForTimeout(2_000)
- // Section should now show the empty state (no overrides)
- const emptyState = page.locator('.cu-empty:has-text("No per-tool overrides")')
- // Allow for the possibility the cluster still has other overrides in flight;
- // what matters is that http_request is NOT in the summary anymore.
- const readOnlyRows = page.locator('.cu-access-row')
- const rowCount = await readOnlyRows.count()
- if (rowCount === 0) {
- // Ideal: the empty state banner is visible
- expect(await emptyState.count()).toBeGreaterThan(0)
- } else {
- // Some other override exists — confirm http_request is not in the list
- const texts = await readOnlyRows.allTextContents()
- const hasHttpRequest = texts.some(t => t.includes('http_request'))
- expect(hasHttpRequest).toBe(false)
- }
+ await expect(page.locator('#approval-http_request')).toHaveValue('default')
// API verification
const { status, data } = await api(token, 'GET', `/api/v1/admin/hosts/${HOST_NAME}`)
@@ -267,14 +233,9 @@ test.describe('HostApprovalSection E2E -- per-tool override editor flow', () =>
await clearApprovalTools(token)
await gotoHostDetails(page)
- // Record the current read-only state (expected: empty state or previous overrides)
- const readOnlyRowsBefore = page.locator('.cu-access-row')
- const countBefore = await readOnlyRowsBefore.count()
- const textsBefore = await readOnlyRowsBefore.allTextContents()
-
- // Click Edit
await clickSectionEdit(page)
await page.waitForSelector('#approval-shell_exec', { timeout: 10_000 })
+ const valueBefore = await page.locator('#approval-shell_exec').inputValue()
// Change shell_exec to Skip (a dirty change)
await page.selectOption('#approval-shell_exec', 'skip')
@@ -282,30 +243,9 @@ test.describe('HostApprovalSection E2E -- per-tool override editor flow', () =>
// Click Cancel
await page.locator('button:has-text("Cancel")').last().click()
- // The section should revert to read-only mode immediately — no Save dialog
- await page.waitForSelector('p.cu-section-title:has-text("Per-tool approval")', {
- timeout: 10_000,
- })
- await page.waitForTimeout(500)
-
- // Edit button should be visible again (back in read-only mode)
- const flexRowAfter = page
- .locator('div')
- .filter({ has: page.locator('p.cu-section-title:has-text("Per-tool approval")') })
- .last()
- const editBtnAfter = flexRowAfter.locator('button:has-text("Edit")')
- expect(await editBtnAfter.count()).toBeGreaterThan(0)
-
- // The read-only rows should be the same as before the edit
- const readOnlyRowsAfter = page.locator('.cu-access-row')
- const countAfter = await readOnlyRowsAfter.count()
- const textsAfter = await readOnlyRowsAfter.allTextContents()
-
- expect(countAfter).toBe(countBefore)
- expect(textsAfter).toEqual(textsBefore)
-
- // shell_exec must NOT appear in the read-only summary (was only in draft)
- const hasShellExecAfter = textsAfter.some(t => t.includes('shell_exec'))
- expect(hasShellExecAfter).toBe(false)
+ await expect(page.locator('#approval-shell_exec')).toHaveValue(valueBefore)
+ await expect(
+ page.locator('.cu-host-approval-section__actions button:has-text("Save")')
+ ).toBeDisabled()
})
})
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 0df8e963d..432434e56 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.349",
+ "version": "0.1.350",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.349",
+ "version": "0.1.350",
"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.json
index 4c28374c7..592f34f03 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.349",
+ "version": "0.1.350",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/desktop-app/169 b/desktop-app/169
deleted file mode 100644
index e69de29bb..000000000
diff --git a/desktop-app/NEXT_IGNORE_INCORRECT_LOCKFILE=1 b/desktop-app/NEXT_IGNORE_INCORRECT_LOCKFILE=1
deleted file mode 100644
index e69de29bb..000000000
diff --git a/desktop-app/[email protected] b/desktop-app/[email protected]
deleted file mode 100644
index e69de29bb..000000000
diff --git a/desktop-app/package-lock.json b/desktop-app/package-lock.json
index 4d8260240..3fbb72e4d 100644
--- a/desktop-app/package-lock.json
+++ b/desktop-app/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "evenfire",
- "version": "0.1.316",
+ "version": "0.1.317",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "evenfire",
- "version": "0.1.316",
+ "version": "0.1.317",
"license": "MPL-2.0",
"dependencies": {
"@tanstack/react-query": "5.100.10",
diff --git a/desktop-app/package.json b/desktop-app/package.json
index b1139fe31..81ab5c880 100644
--- a/desktop-app/package.json
+++ b/desktop-app/package.json
@@ -1,7 +1,7 @@
{
"name": "evenfire",
"productName": "Evenfire",
- "version": "0.1.316",
+ "version": "0.1.317",
"private": true,
"license": "MPL-2.0",
"description": "Evenfire desktop client for secure agent and workflow access",
diff --git a/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx b/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
index e288aab36..fa1d9c2a4 100644
--- a/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
+++ b/desktop-app/ui/src/components/AppHeader/__tests__/notifications.test.tsx
@@ -2,19 +2,13 @@
import React from 'react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
+import type { AppNotification } from '@/uiTypes'
import { AppHeader } from '../index'
const notificationMocks = vi.hoisted(() => ({
clear: vi.fn(),
markRead: vi.fn(),
- notifications: [] as Array<{
- id: string
- kind: 'assistant_reply'
- agentName: string
- text: string
- timestamp: number
- read: boolean
- }>,
+ notifications: [] as AppNotification[],
open: vi.fn(),
remove: vi.fn(),
refresh: vi.fn(async () => undefined),
@@ -102,6 +96,55 @@ describe('AppHeader notification tray presentation', () => {
expect(screen.queryByRole('dialog', { name: 'Notifications and approvals' })).toBeNull()
})
+ it('opens a clickable notification card with the keyboard', () => {
+ const notification = {
+ id: 'notification-1',
+ kind: 'assistant_reply' as const,
+ agentName: 'Research agent',
+ text: 'Your answer is ready.',
+ timestamp: Date.now(),
+ read: true,
+ }
+ notificationMocks.notifications.push(notification)
+
+ render(<AppHeader />)
+ fireEvent.click(screen.getByRole('button', { name: 'Notifications and approvals' }))
+ const card = screen.getByTestId('notification-menu-item')
+
+ expect(card.getAttribute('role')).toBe('button')
+ expect(card.getAttribute('tabindex')).toBe('0')
+ fireEvent.keyDown(card, { key: 'Enter' })
+
+ expect(notificationMocks.open).toHaveBeenCalledWith(notification)
+ })
+
+ it('keeps approval-required notification cards non-clickable', () => {
+ const notification = {
+ id: 'approval-1',
+ kind: 'approval_required' as const,
+ agentName: 'Workflow agent',
+ text: 'Deploy needs your approval.',
+ timestamp: Date.now(),
+ read: false,
+ approval: {
+ taskId: 'task-1',
+ requestId: 'request-1',
+ displayName: 'Deploy',
+ },
+ }
+ notificationMocks.notifications.push(notification)
+
+ render(<AppHeader />)
+ fireEvent.click(screen.getByRole('button', { name: 'Notifications and approvals' }))
+ const card = screen.getByTestId('notification-menu-item')
+
+ expect(card.getAttribute('role')).toBeNull()
+ expect(card.getAttribute('tabindex')).toBeNull()
+ fireEvent.click(card)
+
+ expect(notificationMocks.open).not.toHaveBeenCalled()
+ })
+
it('does not open a notification when its delete button is clicked', () => {
const notification = {
id: 'notification-1',
diff --git a/desktop-app/ui/src/components/AppHeader/index.tsx b/desktop-app/ui/src/components/AppHeader/index.tsx
index 2109ef39b..856379a01 100644
--- a/desktop-app/ui/src/components/AppHeader/index.tsx
+++ b/desktop-app/ui/src/components/AppHeader/index.tsx
@@ -197,17 +197,32 @@ export const AppHeader = React.memo(function AppHeader({
void onOpenNotification(notification)
}
+ const isNestedNotificationAction = (event: React.SyntheticEvent<HTMLDivElement>) => {
+ const target = event.target
+ if (!(target instanceof Element)) return false
+ const interactiveTarget = target.closest(
+ 'button, a, input, select, textarea, [role="button"], [role="link"]'
+ )
+ return interactiveTarget !== null && interactiveTarget !== event.currentTarget
+ }
+
const handleNotificationCardClick = (
event: React.MouseEvent<HTMLDivElement>,
notification: (typeof notifications)[number]
) => {
if (notification.kind === 'approval_required') return
+ if (isNestedNotificationAction(event)) return
+ openNotification(notification)
+ }
- const target = event.target as Element
- if (target.closest('button, a, input, select, textarea, [role="button"], [role="link"]')) {
- return
- }
-
+ const handleNotificationCardKeyDown = (
+ event: React.KeyboardEvent<HTMLDivElement>,
+ notification: (typeof notifications)[number]
+ ) => {
+ if (notification.kind === 'approval_required') return
+ if (event.key !== 'Enter' && event.key !== ' ') return
+ if (isNestedNotificationAction(event)) return
+ event.preventDefault()
openNotification(notification)
}
@@ -878,6 +893,9 @@ export const AppHeader = React.memo(function AppHeader({
notification.kind === 'approval_required' ? '' : ' is-clickable'
}${notification.read ? '' : ' unread'}`}
onClick={event => handleNotificationCardClick(event, notification)}
+ onKeyDown={event => handleNotificationCardKeyDown(event, notification)}
+ role={notification.kind === 'approval_required' ? undefined : 'button'}
+ tabIndex={notification.kind === 'approval_required' ? undefined : 0}
>
<div className="notification-menu-item-header">
<p className="notification-menu-agent">{notification.agentName}</p>
diff --git a/desktop-app/ui/src/lib/__tests__/notifications.test.ts b/desktop-app/ui/src/lib/__tests__/notifications.test.ts
index 8f3bbec5e..523043b50 100644
--- a/desktop-app/ui/src/lib/__tests__/notifications.test.ts
+++ b/desktop-app/ui/src/lib/__tests__/notifications.test.ts
@@ -1,6 +1,5 @@
import { describe, expect, it } from 'vitest'
import {
- notificationInboxDescription,
notificationKindLabel,
notificationPreviewText,
sanitizeNotificationSettings,
@@ -74,19 +73,4 @@ describe('notification settings helpers', () => {
expect(notificationKindLabel('sdk_notification')).toBe('Plugin notification')
expect(notificationKindLabel('assistant_reply')).toBe('Agent reply')
})
-
- it('describes the inbox content without exposing runtime jargon', () => {
- expect(notificationInboxDescription(true, true)).toBe(
- 'Pending approvals and updates from agents, workflows, and plugins.'
- )
- expect(notificationInboxDescription(true, false)).toBe(
- 'Workflow requests that are waiting on you.'
- )
- expect(notificationInboxDescription(false, true)).toBe(
- 'Updates from agents, workflows, and plugins.'
- )
- expect(notificationInboxDescription(false, false)).toBe(
- 'No notifications or pending approvals right now.'
- )
- })
})
diff --git a/desktop-app/ui/src/lib/notifications.ts b/desktop-app/ui/src/lib/notifications.ts
index 5cbfe5879..e84f7e6d8 100644
--- a/desktop-app/ui/src/lib/notifications.ts
+++ b/desktop-app/ui/src/lib/notifications.ts
@@ -74,19 +74,3 @@ export function notificationKindLabel(kind: AppNotificationKind): string {
if (kind === 'sdk_notification') return 'Plugin notification'
return 'Agent reply'
}
-
-export function notificationInboxDescription(
- hasPendingApprovals: boolean,
- hasNotifications: boolean
-): string {
- if (hasPendingApprovals && hasNotifications) {
- return 'Pending approvals and updates from agents, workflows, and plugins.'
- }
- if (hasPendingApprovals) {
- return 'Workflow requests that are waiting on you.'
- }
- if (hasNotifications) {
- return 'Updates from agents, workflows, and plugins.'
- }
- return 'No notifications or pending approvals right now.'
-}
diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.css
index 609941452..d1826f7c9 100644
--- a/desktop-app/ui/src/styles.css
+++ b/desktop-app/ui/src/styles.css
@@ -584,6 +584,12 @@ h3 {
background: var(--surface-hover);
}
+.notification-menu-item.is-clickable:focus-visible {
+ outline: none;
+ border-color: rgba(var(--focus-rgb), 0.6);
+ box-shadow: 0 0 0 var(--space-0-5) rgba(var(--focus-rgb), 0.24);
+}
+
.notification-menu-item.unread {
border-color: rgba(var(--accent-rgb), 0.42);
background: var(--bg-elev-2);