Skip to content

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

TypeScript

fix(control-ui): open linked LLM secret editor inline

Miguelon Peluchon691c9532883b
diff --git a/control-ui/app/hosts/[name]/page.tsx b/control-ui/app/hosts/[name]/page.tsx
index f59b197e4..0bed9a4b5 100644
--- a/control-ui/app/hosts/[name]/page.tsx
+++ b/control-ui/app/hosts/[name]/page.tsx
@@ -1,7 +1,6 @@
'use client'
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
-import Link from 'next/link'
import { useParams, useRouter } from 'next/navigation'
import { useConfirmDialog } from '@components/ConfirmDialog'
import { DetailPageShell } from '@components/DetailPageShell'
@@ -14,8 +13,7 @@ import { HostAdvancedTab } from '../../../components/HostAdvancedTab'
import type { HostGuardrails } from '../../../components/HostGuardrailsSection/types'
import { HostIdentityTab } from '../../../components/HostIdentityTab'
import { HostOverviewTab } from '../../../components/HostOverviewTab'
-import { LlmCredentialFields } from '../../../components/LlmCredentialFields'
-import { LlmProviderConfig } from '../../../components/LlmProviderConfig'
+import { LlmSecretUpdateModal } from '../../../components/LlmSecretUpdateModal'
import { RowActionsMenu } from '../../../components/RowActionsMenu'
import { IconRobot } from '../../../components/Sidebar/icons'
import { IconCheck, IconMoreHorizontal, IconPencil, IconX } from '../../../components/icons'
@@ -32,22 +30,15 @@ import { useLlmAllowedModels } from '../../../lib/hooks/useLlmAllowedModels'
import { FIRST_PARTY_CHANNEL_WORKFLOW_CONTROL_SCOPES } from '../../../lib/hostWorkflowControl'
import {
type HostAllowedModel,
- LLM_EMPTY_TRIGGER_ERROR,
type LlmPolicy,
type LlmProvider,
buildAllowedModelsSpec,
- getActiveCredentialKeys,
getModelOptions,
getProviderLabel,
- isProviderUsable,
normalizeAllowedModels,
normalizeLlmPolicy,
normalizeProvider,
- projectCredentialDraft,
- providerForDataKey,
resolveDefaultModel,
- validateLlmPolicy,
- validateLlmSecretData,
} from '../../../lib/llm'
import type { HostTab } from './types'
@@ -200,8 +191,7 @@ export default function HostDetailsPage() {
const [error, setError] = useState('')
const [initialLoading, setInitialLoading] = useState(true)
- const [editingOverview, setEditingOverview] = useState(false)
- const [editingModel, setEditingModel] = useState(false)
+ const [llmSecretModalOpen, setLlmSecretModalOpen] = useState(false)
const [editingContext, setEditingContext] = useState(false)
const [showDeleteAgentConfirm, setShowDeleteAgentConfirm] = useState(false)
const [deletingAgent, setDeletingAgent] = useState(false)
@@ -211,26 +201,11 @@ export default function HostDetailsPage() {
const [hostDisplayDraft, setHostDisplayDraft] = useState('')
const [hostDescription, setHostDescription] = useState('')
const [contextRefDraft, setContextRefDraft] = useState('')
- // Last server-backed snapshot of the Overview-owned fields, captured at every
- // (re)load. Cancel (and re-opening Edit) reverts the whole class of Overview
- // drafts to THIS — the last SAVED state — so a discarded edit (e.g. a Display
- // name typed then cancelled) can never leak into a later saveHost PUT.
- const savedOverviewRef = useRef({
- hostName: routeName,
- hostDisplay: '',
- contextRef: '',
- channels: [] as string[],
- stateless: false,
- })
const [providerDraft, setProviderDraft] = useState<LlmProvider>('openai')
// Model options are the operator allowlist (enabled only). The host's saved
// model is always kept selectable even if it fell out of the allowlist
// (preexisting resources are not interrupted — spec R3.7).
- const {
- models: allowedCatalog,
- loading: modelsLoading,
- error: modelsError,
- } = useLlmAllowedModels()
+ const { models: allowedCatalog } = useLlmAllowedModels()
const [modelNameDraft, setModelNameDraft] = useState('')
const [secretRefDraft, setSecretRefDraft] = useState('')
// Fallback policy (spec §3-R5). `undefined` = the Host has no llmPolicy.
@@ -238,15 +213,6 @@ export default function HostDetailsPage() {
// Per-host model allowlist subset (spec.allowedModels, Topic 3a). Empty = the
// host offers the full global allowlist per provider (back-compat default).
const [allowedModelsDraft, setAllowedModelsDraft] = useState<HostAllowedModel[]>([])
- // Write-only credential rotations for this Host's Secret (spec Topic 1b R5).
- // A blank field leaves the stored key unchanged; a typed value rotates ONLY
- // that dataKey via the merge PUT. Reset on every (re)load.
- const [llmKeyDraft, setLlmKeyDraft] = useState<Record<string, string>>({})
- // Extra fallback slots whose stored key can be retired after their fallback
- // was removed (spec Topic 1b R5: offer to RETIRE via removeKeys). Applied on
- // save unless the operator opts out.
- const [retireCandidates, setRetireCandidates] = useState<string[]>([])
- const [additionalRetireCandidates, setAdditionalRetireCandidates] = useState<string[]>([])
// Data keys present per LLM Secret name, so the fallback credentialSlot
// dropdown can offer extra keys (e.g. `claude-api-key-fb1`) — never free text.
const [secretKeysByName, setSecretKeysByName] = useState<Record<string, string[]>>({})
@@ -284,7 +250,6 @@ export default function HostDetailsPage() {
const [statelessRejectionMessage, setStatelessRejectionMessage] = useState('')
const [availableContexts, setAvailableContexts] = useState<string[]>([])
- const [availableSecrets, setAvailableSecrets] = useState<string[]>([])
const providerModelOptions = useMemo(
() => getModelOptions(allowedCatalog, providerDraft),
@@ -362,7 +327,6 @@ export default function HostDetailsPage() {
// built from it, so it is the correct precondition for the eventual save.
formResourceVersionRef.current = String(host.metadata?.resourceVersion || '')
if (resetDrafts === 'all' || resetDrafts === 'overview') {
- // Snapshot the saved Overview state so Cancel/Edit can revert to it.
const overview = {
hostName: String(host.metadata?.name || routeName),
hostDisplay: String(spec.host || host.metadata?.name || routeName),
@@ -370,7 +334,6 @@ export default function HostDetailsPage() {
channels: Array.isArray(spec.channels) ? spec.channels.map(String).filter(Boolean) : [],
stateless: spec.lifecycle?.stateless === true,
}
- savedOverviewRef.current = overview
setHostNameDraft(overview.hostName)
setHostDisplayDraft(overview.hostDisplay)
setHostDescription(String(spec.description || '').trim())
@@ -449,10 +412,6 @@ export default function HostDetailsPage() {
// Hydrate the per-host model subset from the saved spec (Topic 3a); absent
// → [] = unrestricted (offers the full global allowlist per provider).
setAllowedModelsDraft(normalizeAllowedModels(spec.allowedModels))
- // Write-only surfaces reset only when this tab is reloaded or saved.
- setLlmKeyDraft({})
- setRetireCandidates([])
- setAdditionalRetireCandidates([])
}
const rawTools = (spec.approval as { tools?: Record<string, boolean> } | undefined)?.tools
setApprovalToolsData(rawTools && typeof rawTools === 'object' ? rawTools : undefined)
@@ -481,9 +440,6 @@ export default function HostDetailsPage() {
.map(item => String(item.spec?.contextId || item.metadata?.name || '').trim())
.filter(Boolean)
setAvailableContexts(Array.from(new Set(contextIds)).sort((a, b) => a.localeCompare(b)))
- const secretNames = (secretsList || []).map(item => item.name.trim()).filter(Boolean)
- setAvailableSecrets(Array.from(new Set(secretNames)).sort((a, b) => a.localeCompare(b)))
-
// Map each Secret to its data-key NAMES (never values), already carried by
// the detail bundle. Feeds the fallback credentialSlot dropdown's extra
// keys (e.g. `claude-api-key-fb1`, spec R4.5.6) without a second fetch.
@@ -600,84 +556,6 @@ export default function HostDetailsPage() {
[secretKeysByName, secretRefDraft]
)
- const activeCredentialProviders = useMemo(() => {
- const providers = new Set<LlmProvider>([
- providerDraft,
- ...(llmPolicyDraft?.fallbacks ?? []).map(fallback => fallback.provider),
- ])
- return providers
- }, [llmPolicyDraft, providerDraft])
-
- // The host runtime still selects credentials through the primary/fallback
- // provider domain. Other provider keys can safely live in the same Secret,
- // but they are intentionally shown in a separate additive editor until the
- // operator selects one as a primary or fallback provider.
- const additionalCredentialKeys = useMemo(
- () =>
- currentSecretKeys.filter(key => {
- const owner = providerForDataKey(key)
- return owner !== null && !activeCredentialProviders.has(owner)
- }),
- [activeCredentialProviders, currentSecretKeys]
- )
- const additionalCredentialDraft = useMemo(
- () =>
- Object.fromEntries(
- Object.entries(llmKeyDraft).filter(([key, value]) => {
- const owner = providerForDataKey(key)
- return owner !== null && !activeCredentialProviders.has(owner) && value.trim().length > 0
- })
- ),
- [activeCredentialProviders, llmKeyDraft]
- )
- const credentialSetProviders = useMemo(() => {
- const providers = new Set<LlmProvider>()
- for (const key of currentSecretKeys) {
- const owner = providerForDataKey(key)
- if (owner) providers.add(owner)
- }
- return Array.from(providers)
- .map(provider => ({
- provider,
- usable: isProviderUsable(provider, key => currentSecretKeys.includes(key)),
- }))
- .sort((left, right) =>
- getProviderLabel(left.provider).localeCompare(getProviderLabel(right.provider))
- )
- }, [currentSecretKeys])
- const credentialSetOptions = useMemo(() => {
- const options = availableSecrets.map(secretName => {
- const providers = new Set<LlmProvider>()
- for (const key of secretKeysByName[secretName] ?? []) {
- const owner = providerForDataKey(key)
- if (owner) providers.add(owner)
- }
- const providerNames = Array.from(providers)
- .map(getProviderLabel)
- .sort((left, right) => left.localeCompare(right))
- return {
- value: secretName,
- label: secretName,
- description:
- providerNames.length > 0
- ? `${providerNames.join(', ')} available`
- : 'No recognized provider credentials yet',
- }
- })
- if (secretRefDraft && !availableSecrets.includes(secretRefDraft)) {
- options.push({
- value: secretRefDraft,
- label: secretRefDraft,
- description: 'Selected LLM Secret (details unavailable)',
- })
- }
- return options
- }, [availableSecrets, secretKeysByName, secretRefDraft])
- const pendingCredentialRemovals = useMemo(
- () => Array.from(new Set([...retireCandidates, ...additionalRetireCandidates])),
- [additionalRetireCandidates, retireCandidates]
- )
-
const connectorOptions = useMemo(
() =>
availableConnectorNames
@@ -686,43 +564,10 @@ export default function HostDetailsPage() {
[availableConnectorNames, contextMcpServers]
)
- // Track fallback removals: when a fallback with its OWN stored extra slot is
- // dropped and no remaining entry references that key, offer to retire it
- // (spec Topic 1b R5). Re-adding a fallback that reclaims the key un-offers it.
- function handlePolicyChange(next: LlmPolicy | undefined) {
- const stored = new Set(currentSecretKeys)
- const stillInUse = getActiveCredentialKeys(providerDraft, next)
- const removedExtraSlots = (llmPolicyDraft?.fallbacks ?? [])
- .map(fallback => fallback.credentialSlot)
- .filter((slot): slot is string => Boolean(slot))
- .filter(slot => stored.has(slot) && !stillInUse.has(slot))
- setRetireCandidates(current => {
- const set = new Set(current)
- for (const slot of removedExtraSlots) set.add(slot)
- for (const slot of Array.from(set)) if (stillInUse.has(slot)) set.delete(slot)
- return Array.from(set)
- })
- setLlmPolicyDraft(next)
- }
-
- // Revert every Overview-owned draft to the last SAVED snapshot. Used by Cancel
- // and by Edit-open so an edit session always starts from server-backed values
- // — never a stale draft left behind by a prior discarded edit (any Overview
- // field, not just Display name: the whole class shares this reset).
- function resetOverviewDrafts() {
- const saved = savedOverviewRef.current
- setHostNameDraft(saved.hostName)
- setHostDisplayDraft(saved.hostDisplay)
- // contextRef is written by the Overview save (saveHost), so reset it here to
- // block a stale leak — EXCEPT while the Context tab has a live edit open: it
- // is a legitimate concurrent writer of contextRefDraft (its editingContext
- // session), and reverting an in-progress selection would silently discard it.
- if (!editingContext) setContextRefDraft(saved.contextRef)
- setChannelsDraft(saved.channels)
- setStatelessDraft(saved.stateless)
- }
-
- async function saveHost(nextDisplayName = hostDisplayDraft): Promise<boolean> {
+ async function saveHost(
+ nextDisplayName = hostDisplayDraft,
+ nextStateless = statelessDraft
+ ): Promise<boolean> {
const nextHostName = hostNameDraft.trim()
if (!nextHostName) return false
@@ -746,8 +591,8 @@ export default function HostDetailsPage() {
channels: channelsDraft,
// Echo spec.lifecycle explicitly: the admin facade full-replaces the
// spec, so leaving lifecycle implicit would strip the stateless flag.
- ...(statelessDraft || currentLifecycle
- ? { lifecycle: { ...currentLifecycle, stateless: statelessDraft } }
+ ...(nextStateless || currentLifecycle
+ ? { lifecycle: { ...currentLifecycle, stateless: nextStateless } }
: {}),
...(channelsDraft.length > 0 && currentWorkflowControl === undefined
? { workflowControl: { scopes: [...FIRST_PARTY_CHANNEL_WORKFLOW_CONTROL_SCOPES] } }
@@ -791,160 +636,6 @@ export default function HostDetailsPage() {
}
}
- // 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)
- // Additive provider editing intentionally extends the active routing domain:
- // a provider added to this LLM Secret is persisted now and becomes
- // available for primary/fallback selection without another secret flow.
- const credentialKeysToWrite = new Set(activeCredentialKeys)
- for (const key of Object.keys(llmKeyDraft)) {
- const owner = providerForDataKey(key)
- if (owner && !activeCredentialProviders.has(owner)) credentialKeysToWrite.add(key)
- }
- const rotatedData = projectCredentialDraft(llmKeyDraft, credentialKeysToWrite)
- const removeKeys = pendingCredentialRemovals.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
- // 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,
- })
- // Rotate/retire credentials on the Host's own Secret with merge:true so
- // other providers' stored keys are preserved (spec Topic 1b R5). removeKeys
- // retires the extra slots left behind by removed fallbacks.
- if (secretRefDraft.trim() && (Object.keys(rotatedData).length > 0 || removeKeys.length > 0)) {
- await apiSend('PUT', '/api/v1/admin/secrets', {
- name: secretRefDraft.trim(),
- merge: true,
- ...(Object.keys(rotatedData).length > 0 ? { stringData: rotatedData } : {}),
- ...(removeKeys.length > 0 ? { removeKeys } : {}),
- })
- }
- // Refresh server-backed state and this tab's saved values without
- // clobbering a still-open Overview draft.
- await loadData('model')
- 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 (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 model & credentials')
- }
- return false
- } finally {
- setBusy(false)
- }
- }
-
const persistApprovalTools = useCallback(
async (tools: Record<string, boolean>) => {
setBusy(true)
@@ -1049,11 +740,7 @@ export default function HostDetailsPage() {
subtitle="Configuration and access for this agent."
tabAriaLabel="Agent sections"
tabClassName="cu-tabs--compact"
- contentClassName={
- activeTab === 'advanced' || (activeTab === 'model' && editingModel)
- ? 'cu-agent-detail-card'
- : undefined
- }
+ contentClassName={activeTab === 'advanced' ? 'cu-agent-detail-card' : undefined}
tabs={HOST_TABS.map(tab => ({
value: tab,
label: TAB_LABELS[tab],
@@ -1085,9 +772,17 @@ export default function HostDetailsPage() {
modelProviderLine={
modelNameDraft ? `${getProviderLabel(providerDraft)} · ${modelNameDraft}` : ''
}
+ stateless={statelessDraft}
+ lifecycleState={lifecycleState}
+ lifecycleReason={friendlyLifecycleReason(lifecycleReason)}
+ statelessRejectionMessage={statelessRejectionMessage}
accessSummary={accessSummary}
onNavigate={tab => selectTab(tab)}
onSaveDisplayName={nextDisplayName => saveHost(nextDisplayName)}
+ onSaveLifecycle={nextStateless => {
+ setStatelessDraft(nextStateless)
+ return saveHost(hostDisplayDraft, nextStateless)
+ }}
createdAt={hostCreatedAt}
lastUpdated={hostLastUpdated}
/>
@@ -1097,223 +792,86 @@ export default function HostDetailsPage() {
<>
<div className="cu-agent-detail-heading">
<p className="cu-muted" style={{ fontSize: '0.875rem', margin: 0 }}>
- Provider, allowed models, fallback policy, and credentials for this agent.
+ Provider, current model, allowed models, fallback policy, and credentials for this
+ agent.
</p>
- {!editingModel ? (
- <div className="cu-agent-detail-heading__actions">
- <button
- type="button"
- className="cu-btn cu-btn--ghost cu-btn--sm"
- onClick={() => setEditingModel(true)}
- disabled={busy}
- >
- Edit
- </button>
- </div>
- ) : null}
+ <div className="cu-agent-detail-heading__actions">
+ <button
+ type="button"
+ className="cu-btn cu-btn--ghost cu-btn--sm"
+ onClick={() => setLlmSecretModalOpen(true)}
+ disabled={busy || !secretRefDraft.trim()}
+ >
+ Edit
+ </button>
+ </div>
</div>
- {!editingModel ? (
- <div className="cu-form-stack">
- <div className="cu-field">
- <label htmlFor="model-secret">LLM Secret</label>
- <div className="cu-field__readonly">{secretRefDraft || '-'}</div>
- </div>
- <div className="cu-field">
- <label htmlFor="model-provider">Model provider</label>
- <div className="cu-field__readonly">{getProviderLabel(providerDraft)}</div>
+ <div className="cu-form-stack">
+ <div className="cu-field">
+ <label htmlFor="model-secret">LLM Secret</label>
+ <div id="model-secret" className="cu-field__readonly">
+ {secretRefDraft || '-'}
</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-current">Current model</label>
+ <div id="model-current" className="cu-field__readonly">
+ {modelNameDraft || '-'}
</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 className="cu-field">
+ <label htmlFor="model-provider">Model provider</label>
+ <div id="model-provider" className="cu-field__readonly">
+ {getProviderLabel(providerDraft)}
</div>
</div>
- ) : (
- <>
- {pendingCredentialRemovals.length > 0 ? (
- <div className="cu-banner cu-banner--warning" style={{ marginBottom: '0.75rem' }}>
- <span>
- Removed provider credential(s): {pendingCredentialRemovals.join(', ')}. They
- will be deleted from the LLM Secret when you save.
- </span>
- <button
- type="button"
- className="cu-btn cu-btn--ghost cu-btn--sm"
- onClick={() => {
- setRetireCandidates([])
- setAdditionalRetireCandidates([])
- }}
- disabled={busy}
- >
- Keep them
- </button>
- </div>
- ) : null}
- <section className="cu-agent-credential-set" aria-label="LLM Secret">
- <div className="cu-agent-credential-set__head">
- <div>
- <span className="cu-agent-credential-set__eyebrow">LLM Secret</span>
- <h4 className="cu-agent-credential-set__title">
- {secretRefDraft || 'No LLM Secret linked'}
- </h4>
- <p className="cu-field__hint">
- One LLM Secret can contain credentials for several providers. Changes here
- apply to the Secret and may affect other agents that use it.
- </p>
- </div>
- <Link
- className="cu-btn cu-btn--ghost cu-btn--sm"
- href={CONTROL_ROUTES.secrets.llm}
- >
- Manage LLM Secrets
- </Link>
+ <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 id="model-allowed" className="cu-field__readonly">
+ All models — this agent offers every enabled model for its provider(s).
</div>
- <div className="cu-field">
- <label htmlFor="host-credential-set">Linked LLM Secret</label>
- <SelectionDropdown
- id="host-credential-set"
- value={secretRefDraft ? [secretRefDraft] : []}
- options={credentialSetOptions}
- placeholder="Select an LLM Secret…"
- searchPlaceholder="Search LLM Secrets…"
- selectionLabel="LLM Secret"
- multiple={false}
- showSelectedChips={false}
- disabled={busy}
- onChange={next => {
- const nextSecret = next[0] ?? ''
- if (nextSecret === secretRefDraft) return
- setSecretRefDraft(nextSecret)
- // A write-only draft belongs to the selected set. Never
- // carry a replacement or retirement from set A into set B.
- setLlmKeyDraft({})
- setRetireCandidates([])
- setAdditionalRetireCandidates([])
- }}
- />
- </div>
- <div className="cu-agent-credential-set__providers">
- <span className="cu-agent-credential-set__providers-label">
- Providers in this set
- </span>
- {credentialSetProviders.length > 0 ? (
- <div className="cu-chip-row">
- {credentialSetProviders.map(({ provider, usable }) => (
- <span className="cu-chip" key={provider}>
- {getProviderLabel(provider)} · {usable ? 'configured' : 'incomplete'}
- </span>
- ))}
- </div>
- ) : (
- <span className="cu-field__hint">
- No provider keys are visible yet. Credential values are never exposed here.
- </span>
- )}
- </div>
- </section>
- <LlmProviderConfig
- provider={providerDraft}
- model={modelNameDraft}
- onPrimaryChange={next => {
- setProviderDraft(next.provider)
- setModelNameDraft(next.model)
- }}
- policy={llmPolicyDraft}
- onPolicyChange={handlePolicyChange}
- allowedModels={allowedModelsDraft}
- onAllowedModelsChange={setAllowedModelsDraft}
- catalog={allowedCatalog}
- catalogLoading={modelsLoading}
- catalogError={modelsError}
- replacePrimaryModelWithAllowedModels
- credentials={{
- draft: llmKeyDraft,
- onChange: (dataKey, value) =>
- setLlmKeyDraft(prev => ({ ...prev, [dataKey]: value })),
- existingKeys: currentSecretKeys,
- }}
- secretKeys={currentSecretKeys}
- disabled={busy}
- />
- <section className="cu-llm-config__block cu-agent-additional-credentials">
- <div className="cu-llm-config__block-head">
- <span className="cu-llm-config__block-title">Additional providers</span>
- <span className="cu-llm-config__block-tag cu-llm-config__block-tag--muted">
- Optional
- </span>
+ )}
+ </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 id="model-fallback" className="cu-field__readonly">
+ No fallback configured.
</div>
- <p className="cu-field__hint cu-agent-additional-credentials__intro">
- Add credentials for another provider to this set. They become available to the
- agent when you select that provider as primary or as a fallback.
- </p>
- <LlmCredentialFields
- draft={additionalCredentialDraft}
- onChange={(dataKey, value) =>
- setLlmKeyDraft(prev => ({ ...prev, [dataKey]: value }))
- }
- existingKeys={additionalCredentialKeys}
- excludedProviders={Array.from(activeCredentialProviders)}
- onRemovedKeysChange={next =>
- setAdditionalRetireCandidates(prev =>
- prev.join('\n') === next.join('\n') ? prev : next
- )
- }
- disabled={busy}
- />
- </section>
- <div className="cu-create-actions cu-agent-model-actions">
- <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>
- </div>
- </>
- )}
+ )}
+ </div>
+ </div>
+
+ {llmSecretModalOpen && secretRefDraft.trim() ? (
+ <LlmSecretUpdateModal
+ key={secretRefDraft}
+ secretName={secretRefDraft}
+ existingKeys={currentSecretKeys}
+ onClose={() => setLlmSecretModalOpen(false)}
+ onChanged={async () => {
+ await loadData('none')
+ }}
+ />
+ ) : null}
</>
)}
diff --git a/control-ui/components/HostOverviewTab/index.tsx b/control-ui/components/HostOverviewTab/index.tsx
index 438068a28..d902e4497 100644
--- a/control-ui/components/HostOverviewTab/index.tsx
+++ b/control-ui/components/HostOverviewTab/index.tsx
@@ -90,9 +90,14 @@ export function HostOverviewTab({
contextMcpTotal,
modelPrimary,
modelProviderLine,
+ stateless,
+ lifecycleState,
+ lifecycleReason,
+ statelessRejectionMessage,
accessSummary,
onNavigate,
onSaveDisplayName,
+ onSaveLifecycle,
createdAt,
lastUpdated,
}: HostOverviewTabProps & { createdAt: string; lastUpdated: string }) {
@@ -100,6 +105,9 @@ export function HostOverviewTab({
const [editingName, setEditingName] = React.useState(false)
const [nameDraft, setNameDraft] = React.useState(shownName)
const [savingName, setSavingName] = React.useState(false)
+ const [editingLifecycle, setEditingLifecycle] = React.useState(false)
+ const [lifecycleDraft, setLifecycleDraft] = React.useState(stateless)
+ const [savingLifecycle, setSavingLifecycle] = React.useState(false)
const hasContext = Boolean(contextRef.trim())
const trimmedDescription = description.trim()
const shownDescription = truncateDescription(trimmedDescription) || 'No description provided.'
@@ -108,6 +116,10 @@ export function HostOverviewTab({
if (!editingName) setNameDraft(shownName)
}, [editingName, shownName])
+ React.useEffect(() => {
+ if (!editingLifecycle) setLifecycleDraft(stateless)
+ }, [editingLifecycle, stateless])
+
function startNameEdit() {
setNameDraft(shownName)
setEditingName(true)
@@ -130,209 +142,318 @@ export function HostOverviewTab({
}
}
+ async function saveLifecycle() {
+ if (savingLifecycle) return
+
+ setSavingLifecycle(true)
+ try {
+ if (await onSaveLifecycle(lifecycleDraft)) setEditingLifecycle(false)
+ } finally {
+ setSavingLifecycle(false)
+ }
+ }
+
+ function cancelLifecycleEdit() {
+ setLifecycleDraft(stateless)
+ setEditingLifecycle(false)
+ }
+
return (
- <div className="cu-host-overview">
- <section className="cu-host-overview-identity" aria-label="Agent identity">
- <div className="cu-host-overview-identity__name-row">
- {editingName ? (
- <div className="cu-host-overview-identity__name-editor">
- <span className="cu-host-overview-identity__icon" aria-hidden="true">
- <IconRobot />
- </span>
- <input
- className="cu-input cu-host-overview-identity__name-input"
- value={nameDraft}
- onChange={event => setNameDraft(event.target.value)}
- onKeyDown={event => {
- if (event.key === 'Enter') void saveName()
- if (event.key === 'Escape') cancelNameEdit()
- }}
- aria-label="Agent name"
- disabled={savingName}
- autoFocus
- />
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--toolbar"
- onClick={() => void saveName()}
- disabled={savingName || !nameDraft.trim()}
- aria-label="Save agent name"
- title="Save agent name"
- >
- <IconCheck width={16} height={16} />
- </button>
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--ghost"
- onClick={cancelNameEdit}
- disabled={savingName}
- aria-label="Cancel editing agent name"
- title="Cancel editing agent name"
- >
- <IconX width={16} height={16} />
- </button>
- </div>
- ) : (
- <>
- <div className="cu-host-overview-identity__name">
+ <>
+ {statelessRejectionMessage ? (
+ <div className="cu-banner cu-banner--warning" style={{ marginBottom: '1rem' }}>
+ <strong>Stateless mode rejected:</strong> {statelessRejectionMessage}
+ </div>
+ ) : null}
+ <div className="cu-host-overview">
+ <section className="cu-host-overview-identity" aria-label="Agent identity">
+ <div className="cu-host-overview-identity__name-row">
+ {editingName ? (
+ <div className="cu-host-overview-identity__name-editor">
<span className="cu-host-overview-identity__icon" aria-hidden="true">
<IconRobot />
</span>
- {shownName}
+ <input
+ className="cu-input cu-host-overview-identity__name-input"
+ value={nameDraft}
+ onChange={event => setNameDraft(event.target.value)}
+ onKeyDown={event => {
+ if (event.key === 'Enter') void saveName()
+ if (event.key === 'Escape') cancelNameEdit()
+ }}
+ aria-label="Agent name"
+ disabled={savingName}
+ autoFocus
+ />
+ <button
+ type="button"
+ className="cu-btn cu-btn--icon cu-btn--toolbar"
+ onClick={() => void saveName()}
+ disabled={savingName || !nameDraft.trim()}
+ aria-label="Save agent name"
+ title="Save agent name"
+ >
+ <IconCheck width={16} height={16} />
+ </button>
+ <button
+ type="button"
+ className="cu-btn cu-btn--icon cu-btn--ghost"
+ onClick={cancelNameEdit}
+ disabled={savingName}
+ aria-label="Cancel editing agent name"
+ title="Cancel editing agent name"
+ >
+ <IconX width={16} height={16} />
+ </button>
</div>
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--ghost cu-host-overview-identity__edit"
- onClick={startNameEdit}
- disabled={savingName}
- aria-label="Edit agent name"
- title="Edit agent name"
- >
- <IconPencil width={16} height={16} />
- </button>
- </>
- )}
- </div>
- <div
- className="cu-host-overview-identity__description"
- title={trimmedDescription || undefined}
- >
- {shownDescription}
- </div>
- <div className="cu-host-overview-identity__status">
- <StatusDot tone={statusTone} />
- <span>{statusLabel}</span>
- </div>
+ ) : (
+ <>
+ <div className="cu-host-overview-identity__name">
+ <span className="cu-host-overview-identity__icon" aria-hidden="true">
+ <IconRobot />
+ </span>
+ {shownName}
+ </div>
+ <button
+ type="button"
+ className="cu-btn cu-btn--icon cu-btn--ghost cu-host-overview-identity__edit"
+ onClick={startNameEdit}
+ disabled={savingName}
+ aria-label="Edit agent name"
+ title="Edit agent name"
+ >
+ <IconPencil width={16} height={16} />
+ </button>
+ </>
+ )}
+ </div>
+ <div
+ className="cu-host-overview-identity__description"
+ title={trimmedDescription || undefined}
+ >
+ {shownDescription}
+ </div>
+ <div className="cu-host-overview-identity__status">
+ <StatusDot tone={statusTone} />
+ <span>{statusLabel}</span>
+ </div>
+ {stateless && lifecycleState ? (
+ <span className="cu-chip">
+ {`Lifecycle: ${lifecycleState}${lifecycleReason ? ` — ${lifecycleReason}` : ''}`}
+ </span>
+ ) : null}
- <div className="cu-host-overview-identity__divider" />
+ <div className="cu-host-overview-identity__divider" />
- <NavHeader label="Access" tab="access" onNavigate={onNavigate} />
- <div className="cu-host-overview-identity__counts">
- <div>
- <div className="cu-host-overview-identity__count-value">
- {accessSummary.memberCount}
- </div>
- <div className="cu-host-overview-identity__count-label">
- {accessSummary.memberCount === 1 ? 'member' : 'members'}
+ <NavHeader label="Access" tab="access" onNavigate={onNavigate} />
+ <div className="cu-host-overview-identity__counts">
+ <div>
+ <div className="cu-host-overview-identity__count-value">
+ {accessSummary.memberCount}
+ </div>
+ <div className="cu-host-overview-identity__count-label">
+ {accessSummary.memberCount === 1 ? 'member' : 'members'}
+ </div>
</div>
- </div>
- <div className="cu-host-overview-identity__count-sep" aria-hidden="true" />
- <div>
- <div className="cu-host-overview-identity__count-value">{accessSummary.teamCount}</div>
- <div className="cu-host-overview-identity__count-label">
- {accessSummary.teamCount === 1 ? 'team' : 'teams'}
+ <div className="cu-host-overview-identity__count-sep" aria-hidden="true" />
+ <div>
+ <div className="cu-host-overview-identity__count-value">
+ {accessSummary.teamCount}
+ </div>
+ <div className="cu-host-overview-identity__count-label">
+ {accessSummary.teamCount === 1 ? 'team' : 'teams'}
+ </div>
</div>
</div>
- </div>
- <div className="cu-host-overview-identity__divider" />
+ <div className="cu-host-overview-identity__divider" />
- <NavHeader label="Connectors" tab="connectors" onNavigate={onNavigate} />
- <div className="cu-host-overview-identity__counts">
- <div>
- <div className="cu-host-overview-identity__count-value">{contextMcpServers.length}</div>
- <div className="cu-host-overview-identity__count-label">
- {contextMcpServers.length === 1 ? 'connector' : 'connectors'}
+ <NavHeader label="Connectors" tab="connectors" onNavigate={onNavigate} />
+ <div className="cu-host-overview-identity__counts">
+ <div>
+ <div className="cu-host-overview-identity__count-value">
+ {contextMcpServers.length}
+ </div>
+ <div className="cu-host-overview-identity__count-label">
+ {contextMcpServers.length === 1 ? 'connector' : 'connectors'}
+ </div>
</div>
</div>
- </div>
- <div className="cu-host-overview-identity__divider" />
+ <div className="cu-host-overview-identity__divider" />
- <dl className="cu-host-overview-identity__meta">
- <dt>Created</dt>
- <dd>{formatTimestamp(createdAt) || '—'}</dd>
- <dt>Last updated</dt>
- <dd>{formatTimestamp(lastUpdated) || '—'}</dd>
- </dl>
- </section>
-
- <div className="cu-host-overview-right">
- <section className="cu-card" aria-label="Configuration">
- <div className="cu-card__body">
- <NavHeader label="Configuration" tab="model" onNavigate={onNavigate} />
- <div className="cu-host-overview-config">
- <ConfigRow setting="Primary model" value={modelPrimary} />
- <ConfigRow setting="Provider · Model" value={modelProviderLine} />
- </div>
- </div>
+ <dl className="cu-host-overview-identity__meta">
+ <dt>Created</dt>
+ <dd>{formatTimestamp(createdAt) || '—'}</dd>
+ <dt>Last updated</dt>
+ <dd>{formatTimestamp(lastUpdated) || '—'}</dd>
+ </dl>
</section>
- <section className="cu-card" aria-label="Access summary">
- <div className="cu-card__body">
- <NavHeader label="Access" tab="access" onNavigate={onNavigate} />
-
- <div className="cu-host-overview-access__columns">
- <div className="cu-host-overview-access__group">
- <div className="cu-host-overview-access__head">
- <span className="cu-host-overview-access__head-label">Members</span>
- <span className="cu-host-overview-access__head-count">
- {accessSummary.memberCount}
- </span>
+ <div className="cu-host-overview-right">
+ <section className="cu-card" aria-label="Lifecycle">
+ <div className="cu-card__body">
+ <div
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ gap: '0.75rem',
+ }}
+ >
+ <div>
+ <h3 className="cu-section-title" style={{ margin: 0 }}>
+ Lifecycle
+ </h3>
+ <p className="cu-muted" style={{ margin: '0.35rem 0 0', fontSize: '0.8125rem' }}>
+ Choose whether this agent stays running or suspends when idle.
+ </p>
</div>
- {accessSummary.memberNames.length > 0 ? (
- <ul className="cu-host-overview-access__people">
- {accessSummary.memberNames.map(name => (
- <li key={name} className="cu-host-overview-access__person">
- <span className="cu-host-overview-access__dot" aria-hidden="true" />
- <span className="cu-host-overview-access__person-name">{name}</span>
- </li>
- ))}
- </ul>
+ {!editingLifecycle ? (
+ <button
+ type="button"
+ className="cu-btn cu-btn--ghost cu-btn--sm"
+ onClick={() => {
+ setLifecycleDraft(stateless)
+ setEditingLifecycle(true)
+ }}
+ disabled={savingLifecycle}
+ >
+ Edit lifecycle
+ </button>
+ ) : null}
+ </div>
+ <div className="cu-field" style={{ marginTop: '1rem', marginBottom: 0 }}>
+ <label htmlFor="host-agent-type">Type</label>
+ {editingLifecycle ? (
+ <>
+ <select
+ id="host-agent-type"
+ value={lifecycleDraft ? 'stateless' : 'stateful'}
+ onChange={event => setLifecycleDraft(event.target.value === 'stateless')}
+ disabled={savingLifecycle}
+ >
+ <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 may keep them always-on.
+ </span>
+ <div className="cu-create-actions" style={{ marginTop: '0.75rem' }}>
+ <button
+ type="button"
+ className="cu-btn cu-btn--ghost cu-btn--sm"
+ onClick={cancelLifecycleEdit}
+ disabled={savingLifecycle}
+ >
+ Cancel lifecycle
+ </button>
+ <button
+ type="button"
+ className="cu-btn cu-btn--primary"
+ onClick={() => void saveLifecycle()}
+ disabled={savingLifecycle}
+ >
+ {savingLifecycle ? 'Saving…' : 'Save lifecycle'}
+ </button>
+ </div>
+ </>
) : (
- <p className="cu-host-overview-access__empty">No members yet.</p>
+ <div id="host-agent-type" className="cu-field__readonly">
+ {stateless ? 'Stateless (suspends when idle)' : 'Stateful (always on)'}
+ </div>
)}
</div>
+ </div>
+ </section>
- <div className="cu-host-overview-access__group">
- <div className="cu-host-overview-access__head">
- <span className="cu-host-overview-access__head-label">Teams</span>
- <span className="cu-host-overview-access__head-count">
- {accessSummary.teamCount}
- </span>
+ <section className="cu-card" aria-label="Configuration">
+ <div className="cu-card__body">
+ <NavHeader label="Configuration" tab="model" onNavigate={onNavigate} />
+ <div className="cu-host-overview-config">
+ <ConfigRow setting="Primary model" value={modelPrimary} />
+ <ConfigRow setting="Provider · Model" value={modelProviderLine} />
+ </div>
+ </div>
+ </section>
+
+ <section className="cu-card" aria-label="Access summary">
+ <div className="cu-card__body">
+ <NavHeader label="Access" tab="access" onNavigate={onNavigate} />
+
+ <div className="cu-host-overview-access__columns">
+ <div className="cu-host-overview-access__group">
+ <div className="cu-host-overview-access__head">
+ <span className="cu-host-overview-access__head-label">Members</span>
+ <span className="cu-host-overview-access__head-count">
+ {accessSummary.memberCount}
+ </span>
+ </div>
+ {accessSummary.memberNames.length > 0 ? (
+ <ul className="cu-host-overview-access__people">
+ {accessSummary.memberNames.map(name => (
+ <li key={name} className="cu-host-overview-access__person">
+ <span className="cu-host-overview-access__dot" aria-hidden="true" />
+ <span className="cu-host-overview-access__person-name">{name}</span>
+ </li>
+ ))}
+ </ul>
+ ) : (
+ <p className="cu-host-overview-access__empty">No members yet.</p>
+ )}
+ </div>
+
+ <div className="cu-host-overview-access__group">
+ <div className="cu-host-overview-access__head">
+ <span className="cu-host-overview-access__head-label">Teams</span>
+ <span className="cu-host-overview-access__head-count">
+ {accessSummary.teamCount}
+ </span>
+ </div>
+ {accessSummary.teamNames.length > 0 ? (
+ <ul className="cu-host-overview-access__people">
+ {accessSummary.teamNames.map(name => (
+ <li key={name} className="cu-host-overview-access__person">
+ <span className="cu-host-overview-access__dot" aria-hidden="true" />
+ <span className="cu-host-overview-access__person-name">{name}</span>
+ </li>
+ ))}
+ </ul>
+ ) : (
+ <p className="cu-host-overview-access__empty">No teams yet.</p>
+ )}
</div>
- {accessSummary.teamNames.length > 0 ? (
- <ul className="cu-host-overview-access__people">
- {accessSummary.teamNames.map(name => (
- <li key={name} className="cu-host-overview-access__person">
- <span className="cu-host-overview-access__dot" aria-hidden="true" />
- <span className="cu-host-overview-access__person-name">{name}</span>
- </li>
- ))}
- </ul>
- ) : (
- <p className="cu-host-overview-access__empty">No teams yet.</p>
- )}
</div>
</div>
- </div>
- </section>
+ </section>
- <section className="cu-card" aria-label="Connectors">
- <div className="cu-card__body">
- <NavHeader
- label="Connectors"
- tab="connectors"
- count={contextMcpTotal}
- onNavigate={onNavigate}
- />
- {contextMcpServers.length > 0 ? (
- <ul className="cu-host-overview-mcp__list">
- {contextMcpServers.map(server => (
- <li key={server} className="cu-host-overview-mcp__chip" title={server}>
- <span className="cu-host-overview-mcp__dot" aria-hidden="true" />
- {server}
- </li>
- ))}
- </ul>
- ) : (
- <p className="cu-muted" style={{ margin: '0.5rem 0 0', fontSize: '0.875rem' }}>
- {hasContext ? 'No connectors attached.' : 'No connectors attached yet.'}
- </p>
- )}
- </div>
- </section>
+ <section className="cu-card" aria-label="Connectors">
+ <div className="cu-card__body">
+ <NavHeader
+ label="Connectors"
+ tab="connectors"
+ count={contextMcpTotal}
+ onNavigate={onNavigate}
+ />
+ {contextMcpServers.length > 0 ? (
+ <ul className="cu-host-overview-mcp__list">
+ {contextMcpServers.map(server => (
+ <li key={server} className="cu-host-overview-mcp__chip" title={server}>
+ <span className="cu-host-overview-mcp__dot" aria-hidden="true" />
+ {server}
+ </li>
+ ))}
+ </ul>
+ ) : (
+ <p className="cu-muted" style={{ margin: '0.5rem 0 0', fontSize: '0.875rem' }}>
+ {hasContext ? 'No connectors attached.' : 'No connectors attached yet.'}
+ </p>
+ )}
+ </div>
+ </section>
+ </div>
</div>
- </div>
+ </>
)
}
diff --git a/control-ui/components/HostOverviewTab/types.ts b/control-ui/components/HostOverviewTab/types.ts
index d012d130d..03f4e5031 100644
--- a/control-ui/components/HostOverviewTab/types.ts
+++ b/control-ui/components/HostOverviewTab/types.ts
@@ -18,9 +18,14 @@ export type HostOverviewTabProps = {
contextMcpTotal: number
modelPrimary: string
modelProviderLine: string
+ stateless: boolean
+ lifecycleState: string
+ lifecycleReason: string
+ statelessRejectionMessage: string
accessSummary: HostOverviewAccessSummary
onNavigate: (tab: HostTabKey) => void
onSaveDisplayName: (displayName: string) => Promise<boolean>
+ onSaveLifecycle: (stateless: boolean) => Promise<boolean>
createdAt: string
lastUpdated: string
}
diff --git a/control-ui/components/LlmSecretUpdateModal.tsx b/control-ui/components/LlmSecretUpdateModal.tsx
new file mode 100644
index 000000000..4c28b6891
--- /dev/null
+++ b/control-ui/components/LlmSecretUpdateModal.tsx
@@ -0,0 +1,192 @@
+'use client'
+
+import { useState } from 'react'
+import { apiSend } from '../lib/api'
+import { createEmptyLlmKeyDraft, validateLlmSecretData } from '../lib/llm'
+import { useConfirmDialog } from './ConfirmDialog'
+import { LlmCredentialFields } from './LlmCredentialFields'
+import { useToast } from './Toast'
+import { IconX } from './icons'
+
+export type LlmSecretUpdateModalProps = {
+ secretName: string
+ existingKeys: string[]
+ onClose: () => void
+ onChanged: () => Promise<void>
+}
+
+/**
+ * The single update surface for an LLM Secret.
+ *
+ * Secret values are write-only: existingKeys contains names only, while the
+ * draft contains only values the operator typed during this edit. Keeping the
+ * write and retirement logic here means every entry point gets the same safe
+ * merge semantics and the same provider editor.
+ */
+export function LlmSecretUpdateModal({
+ secretName,
+ existingKeys,
+ onClose,
+ onChanged,
+}: LlmSecretUpdateModalProps) {
+ const { confirm, confirmDialog } = useConfirmDialog()
+ const { showToast } = useToast()
+ const [keyDraft, setKeyDraft] = useState<Record<string, string>>(() => createEmptyLlmKeyDraft())
+ const [removedKeys, setRemovedKeys] = useState<string[]>([])
+ const [saving, setSaving] = useState(false)
+ const [error, setError] = useState('')
+
+ function closeModal() {
+ if (!saving) onClose()
+ }
+
+ async function saveSecret() {
+ const normalizedSecretName = secretName.trim()
+ if (!normalizedSecretName) {
+ setError('Secret name is required.')
+ return
+ }
+
+ const stringData = Object.fromEntries(
+ Object.entries(keyDraft)
+ .map(([key, value]) => [key, value.trim()])
+ .filter(([, value]) => value.length > 0)
+ )
+ // The server resolves a key present in both stringData and removeKeys as
+ // retirement-wins. Keep the editor's write intent safe at the boundary.
+ const removeKeys = removedKeys.filter(key => !(key in stringData))
+
+ if (Object.keys(stringData).length === 0 && removeKeys.length === 0) {
+ setError('Provide at least one API key.')
+ return
+ }
+
+ const survivingKeys = new Set([
+ ...existingKeys.filter(key => !removeKeys.includes(key)),
+ ...Object.keys(stringData),
+ ])
+ if (survivingKeys.size === 0) {
+ setError('Removing every key would leave the secret empty — delete the secret instead.')
+ return
+ }
+
+ const slotErrors = validateLlmSecretData(stringData)
+ if (slotErrors.length > 0) {
+ setError(slotErrors[0])
+ return
+ }
+
+ if (removeKeys.length > 0) {
+ const confirmed = await confirm({
+ title: 'Remove stored keys',
+ message: `Permanently remove ${removeKeys.join(', ')} from secret ${normalizedSecretName}? Their values cannot be recovered.`,
+ confirmLabel: 'Remove and save',
+ tone: 'danger',
+ })
+ if (!confirmed) return
+ }
+
+ setSaving(true)
+ setError('')
+ try {
+ await apiSend('PUT', '/api/v1/admin/secrets', {
+ name: normalizedSecretName,
+ merge: true,
+ stringData,
+ ...(removeKeys.length > 0 ? { removeKeys } : {}),
+ })
+ showToast(`Secret ${normalizedSecretName} updated.`, { tone: 'success' })
+ await onChanged()
+ onClose()
+ } catch (e) {
+ setError(e instanceof Error ? e.message : 'Failed to save secret')
+ } finally {
+ setSaving(false)
+ }
+ }
+
+ return (
+ <>
+ <div
+ style={{
+ position: 'fixed',
+ inset: 0,
+ background: 'var(--cu-overlay)',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ zIndex: 1000,
+ padding: '1rem',
+ }}
+ role="presentation"
+ onClick={event => {
+ if (event.target === event.currentTarget) closeModal()
+ }}
+ >
+ <div
+ className="cu-modal-panel"
+ role="dialog"
+ aria-modal="true"
+ aria-labelledby="llm-secret-title"
+ onClick={event => event.stopPropagation()}
+ >
+ <div className="cu-modal-panel__head">
+ <strong id="llm-secret-title" style={{ fontSize: '1rem', lineHeight: 1.35 }}>
+ Update LLM secret {secretName.trim()}
+ </strong>
+ <button
+ type="button"
+ className="cu-btn cu-btn--icon cu-btn--ghost"
+ onClick={closeModal}
+ disabled={saving}
+ aria-label="Close"
+ >
+ <IconX width={18} height={18} />
+ </button>
+ </div>
+
+ <div className="cu-form-stack" style={{ maxWidth: '100%' }}>
+ <p className="cu-field__hint">
+ Updates the listed keys and deletes the ones you remove here; every other key already
+ stored in this secret is preserved.
+ </p>
+ <LlmCredentialFields
+ draft={keyDraft}
+ onChange={(dataKey, value) => setKeyDraft(prev => ({ ...prev, [dataKey]: value }))}
+ existingKeys={existingKeys}
+ // The editor reports on every change. Keep the parent state
+ // identity-stable so it does not cause an unnecessary rerender.
+ onRemovedKeysChange={next =>
+ setRemovedKeys(prev => (prev.join('\n') === next.join('\n') ? prev : next))
+ }
+ disabled={saving}
+ pickerInline
+ />
+ </div>
+
+ {error ? <div className="cu-banner cu-banner--error">{error}</div> : null}
+
+ <div className="cu-modal-panel__foot">
+ <button
+ type="button"
+ className="cu-btn cu-btn--ghost cu-btn--sm"
+ onClick={closeModal}
+ disabled={saving}
+ >
+ Cancel
+ </button>
+ <button
+ type="button"
+ className="cu-btn cu-btn--primary"
+ onClick={() => void saveSecret()}
+ disabled={saving}
+ >
+ {saving ? 'Saving…' : 'Update secret'}
+ </button>
+ </div>
+ </div>
+ </div>
+ {confirmDialog}
+ </>
+ )
+}
diff --git a/control-ui/components/SecretsTable.tsx b/control-ui/components/SecretsTable.tsx
index e22bab6a6..f47db7407 100644
--- a/control-ui/components/SecretsTable.tsx
+++ b/control-ui/components/SecretsTable.tsx
@@ -11,23 +11,18 @@ import {
getRecipeSecrets,
getRecipes,
} from '../lib/api'
-import {
- createEmptyLlmKeyDraft,
- getProviderLabel,
- getProvidersWithCompleteCredentials,
- validateLlmSecretData,
-} from '../lib/llm'
+import { getProviderLabel, getProvidersWithCompleteCredentials } from '../lib/llm'
import { collectWorkflowRecipeSecretRefs } from '../lib/workflowRecipeSecretRefs'
import { useConfirmDialog } from './ConfirmDialog'
-import { LlmCredentialFields } from './LlmCredentialFields'
import { LlmProviderIcon } from './LlmProviderIcon'
+import { LlmSecretUpdateModal } from './LlmSecretUpdateModal'
import { RowActionsMenu } from './RowActionsMenu'
import { SectionSearchInput } from './SectionSearchInput'
import { IconKey } from './Sidebar/icons'
import { TabBar } from './TabBar'
import { TablePanelHeader } from './TablePanelHeader'
import { useToast } from './Toast'
-import { IconRefresh, IconX } from './icons'
+import { IconRefresh } from './icons'
type SecretItem = {
name?: string
@@ -99,14 +94,6 @@ export function SecretsTable({
// LLM secrets state
const [editingName, setEditingName] = useState('')
- const [editingKeys, setEditingKeys] = useState<string[]>([])
- const [isLlmModalOpen, setIsLlmModalOpen] = useState(false)
- const [keyDraft, setKeyDraft] = useState<Record<string, string>>(createEmptyLlmKeyDraft)
- // Stored data keys the editor queued for retirement (removed or renamed-away
- // extra slots). Sent as `removeKeys` on save — the draft is write-only and a
- // blank value is explicitly NOT a deletion server-side.
- const [removedKeys, setRemovedKeys] = useState<string[]>([])
- const [saving, setSaving] = useState(false)
const [deletingName, setDeletingName] = useState<string | null>(null)
const [error, setError] = useState('')
const [llmSearchQuery, setLlmSearchQuery] = useState('')
@@ -175,100 +162,8 @@ export function SecretsTable({
)
}, [recipeRows, normalizedRecipeSearch])
- function closeLlmModal() {
- setIsLlmModalOpen(false)
- setEditingName('')
- setEditingKeys([])
- setKeyDraft(createEmptyLlmKeyDraft())
- setRemovedKeys([])
- setError('')
- }
-
function openUpdate(name: string) {
setEditingName(name)
- setEditingKeys(keysByName.get(name) ?? [])
- setKeyDraft(createEmptyLlmKeyDraft())
- setRemovedKeys([])
- setError('')
- setIsLlmModalOpen(true)
- }
-
- async function saveSecret() {
- const secretName = editingName.trim()
- if (!secretName) {
- setError('Secret name is required.')
- return
- }
-
- const stringData = Object.fromEntries(
- Object.entries(keyDraft)
- .map(([key, value]) => [key, value.trim()])
- .filter(([, value]) => value.length > 0)
- )
- // Defense in depth: the editor owns this invariant (it never reports a key
- // the draft is writing), and the server resolves "in data AND in
- // removeKeys" as retirement-wins, which would drop the value just typed.
- // The filter stays as a backstop for any future parent wiring the channel.
- const removeKeys = removedKeys.filter(key => !(key in stringData))
- // A retire-only edit is a real edit: `merge: true` accepts `removeKeys`
- // with no data at all, so only an empty-and-nothing-retired save is a
- // no-op worth blocking.
- if (Object.keys(stringData).length === 0 && removeKeys.length === 0) {
- setError('Provide at least one API key.')
- return
- }
- // Retiring every stored key without writing one 400s server-side with
- // "secret must retain at least one key" — a cryptic answer to a question
- // the client can answer itself from the keys it already knows.
- const survivingKeys = new Set([
- ...editingKeys.filter(key => !removeKeys.includes(key)),
- ...Object.keys(stringData),
- ])
- if (survivingKeys.size === 0) {
- setError('Removing every key would leave the secret empty — delete the secret instead.')
- return
- }
- // Slot-aware validation (spec R4.5.3), mirrored server-side in control-api.
- const slotErrors = validateLlmSecretData(stringData)
- if (slotErrors.length > 0) {
- setError(slotErrors[0])
- return
- }
- // Retirement is irreversible — the values are write-only, so a key deleted
- // by mistake cannot be restored from anything the UI holds. Confirm before
- // the write, naming exactly what goes.
- if (removeKeys.length > 0) {
- const confirmed = await confirm({
- title: 'Remove stored keys',
- message: `Permanently remove ${removeKeys.join(', ')} from secret ${secretName}? Their values cannot be recovered.`,
- confirmLabel: 'Remove and save',
- tone: 'danger',
- })
- if (!confirmed) return
- }
-
- setSaving(true)
- setError('')
- try {
- // merge:true → server-side read-then-replace that preserves the keys of
- // other providers stored in this shared LLM secret (spec R4 FIX 2b).
- // `removeKeys` (merge-only) is the deletion half of the same write: keys
- // the editor retired are dropped from the merged data. Omitted entirely
- // when nothing is retired so a plain update stays a pure overlay.
- await apiSend('PUT', '/api/v1/admin/secrets', {
- name: secretName,
- merge: true,
- stringData,
- ...(removeKeys.length > 0 ? { removeKeys } : {}),
- })
- showToast(`Secret ${secretName} updated.`, { tone: 'success' })
- await onChanged()
- closeLlmModal()
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Failed to save secret')
- } finally {
- setSaving(false)
- }
}
async function loadMcpSecretReferences() {
@@ -971,87 +866,15 @@ export function SecretsTable({
) : null}
</div>
- {isLlmModalOpen && (
- <div
- style={{
- position: 'fixed',
- inset: 0,
- background: 'var(--cu-overlay)',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- zIndex: 1000,
- padding: '1rem',
- }}
- role="presentation"
- onClick={e => {
- if (e.target === e.currentTarget && !saving) closeLlmModal()
- }}
- >
- <div
- className="cu-modal-panel"
- role="dialog"
- aria-labelledby="llm-secret-title"
- onClick={e => e.stopPropagation()}
- >
- <div className="cu-modal-panel__head">
- <strong id="llm-secret-title" style={{ fontSize: '1rem', lineHeight: 1.35 }}>
- Update LLM secret {editingName}
- </strong>
- <button
- type="button"
- className="cu-btn cu-btn--icon cu-btn--ghost"
- onClick={closeLlmModal}
- disabled={saving}
- aria-label="Close"
- >
- <IconX width={18} height={18} />
- </button>
- </div>
-
- <div className="cu-form-stack" style={{ maxWidth: '100%' }}>
- <p className="cu-field__hint">
- Updates the listed keys and deletes the ones you remove here; every other key
- already stored in this secret is preserved.
- </p>
- <LlmCredentialFields
- draft={keyDraft}
- onChange={(dataKey, value) => setKeyDraft(prev => ({ ...prev, [dataKey]: value }))}
- existingKeys={editingKeys}
- // Identity-stable update: the editor re-reports on every change,
- // and a fresh array each time would re-render the modal for no
- // reason (and on mount, for an empty set).
- onRemovedKeysChange={next =>
- setRemovedKeys(prev => (prev.join('\n') === next.join('\n') ? prev : next))
- }
- disabled={saving}
- pickerInline
- />
- </div>
-
- {error ? <div className="cu-banner cu-banner--error">{error}</div> : null}
-
- <div className="cu-modal-panel__foot">
- <button
- type="button"
- className="cu-btn cu-btn--ghost cu-btn--sm"
- onClick={closeLlmModal}
- disabled={saving}
- >
- Cancel
- </button>
- <button
- type="button"
- className="cu-btn cu-btn--primary"
- onClick={() => void saveSecret()}
- disabled={saving}
- >
- {saving ? 'Saving…' : 'Update secret'}
- </button>
- </div>
- </div>
- </div>
- )}
+ {editingName ? (
+ <LlmSecretUpdateModal
+ key={editingName}
+ secretName={editingName}
+ existingKeys={keysByName.get(editingName) ?? []}
+ onClose={() => setEditingName('')}
+ onChanged={onChanged}
+ />
+ ) : null}
{confirmDialog}
</>
)
diff --git a/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx b/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx
index 310e6660e..e773431d0 100644
--- a/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx
+++ b/control-ui/components/__tests__/HostDetailsPage.conflict.test.tsx
@@ -87,7 +87,7 @@ function setupApiMocks(bundleHost: TestHost, refetchHost: TestHost = bundleHost)
;(api.getHostDetailBundle as unknown as ReturnType<typeof vi.fn>).mockResolvedValue({
host: bundleHost,
contexts: [{ metadata: { name: 'ctx' }, spec: { contextId: 'ctx' } }],
- secrets: [{ name: 'openai-secret' }],
+ secrets: [{ name: 'openai-secret', keys: ['openai-api-key'] }],
users: [],
teams: [],
agentUsers: [],
@@ -111,7 +111,7 @@ function navigateToTab(view: ReturnType<typeof rtlRender>, tab: 'overview' | 'mo
}
async function openOverviewEdit() {
- const [overviewEditButton] = await screen.findAllByRole('button', { name: 'Edit' })
+ const overviewEditButton = await screen.findByRole('button', { name: 'Edit agent name' })
await waitFor(() => expect(overviewEditButton).toBeEnabled())
fireEvent.click(overviewEditButton)
}
@@ -148,7 +148,7 @@ describe('HostDetailsPage AP-6 save conflict handling', () => {
render(<HostDetailsPage />)
await openOverviewEdit()
- fireEvent.click(screen.getByRole('button', { name: 'Save' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Save agent name' }))
await waitFor(() =>
expect(api.apiSend).toHaveBeenCalledWith('PUT', '/api/v1/admin/hosts/foo', expect.any(Object))
)
@@ -161,7 +161,7 @@ describe('HostDetailsPage AP-6 save conflict handling', () => {
render(<HostDetailsPage />)
await openOverviewEdit()
- fireEvent.click(screen.getByRole('button', { name: 'Save' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Save agent name' }))
await waitFor(() =>
expect(api.apiSend).toHaveBeenCalledWith('PUT', '/api/v1/admin/hosts/foo', expect.any(Object))
)
@@ -174,7 +174,7 @@ describe('HostDetailsPage AP-6 save conflict handling', () => {
render(<HostDetailsPage />)
await openOverviewEdit()
- fireEvent.click(screen.getByRole('button', { name: 'Save' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Save agent name' }))
// The resourceVersion precondition is whole-object, so a 409 cannot tell a
// human edit apart from the agent's own lifecycle tick. The banner must
@@ -189,7 +189,7 @@ describe('HostDetailsPage AP-6 save conflict handling', () => {
// No silent success…
expect(screen.queryByText('Agent configuration saved.')).not.toBeInTheDocument()
// …and the edit form stays open so the operator's draft is preserved.
- expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'Save agent name' })).toBeInTheDocument()
})
it('recovers after a 409: reloading then re-applying the same save succeeds and clears the banner', async () => {
@@ -201,17 +201,17 @@ describe('HostDetailsPage AP-6 save conflict handling', () => {
render(<HostDetailsPage />)
await openOverviewEdit()
- fireEvent.click(screen.getByRole('button', { name: 'Save' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Save agent name' }))
expect(
await screen.findByText(
"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."
)
).toBeInTheDocument()
// Draft survives: the form is still in edit mode after the conflict.
- expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'Save agent name' })).toBeInTheDocument()
// Re-apply the change (the reload+re-apply recovery the banner instructs).
- fireEvent.click(screen.getByRole('button', { name: 'Save' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Save agent name' }))
// The retry succeeds: success toast shows and the conflict banner is gone.
expect(await screen.findByText('Agent configuration saved.')).toBeInTheDocument()
@@ -227,63 +227,58 @@ describe('HostDetailsPage AP-6 save conflict handling', () => {
render(<HostDetailsPage />)
await openOverviewEdit()
- fireEvent.click(screen.getByRole('button', { name: 'Save' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Save agent name' }))
expect(await screen.findByText('boom')).toBeInTheDocument()
- expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'Save agent name' })).toBeInTheDocument()
})
})
-describe('HostDetailsPage cross-tab draft preservation', () => {
+describe('HostDetailsPage current model and credential flow', () => {
beforeEach(() => {
vi.clearAllMocks()
mockParams = { name: 'foo' }
setupApiMocks(formLoadHost, refetchedHost)
})
- it('preserves an open Overview draft when Model & credentials is saved', async () => {
+ it('opens the linked LLM Secret editor without navigating or saving the Host', async () => {
const view = render(<HostDetailsPage />)
- await openOverviewEdit()
- fireEvent.change(screen.getByLabelText('Display name'), {
- target: { value: 'unsaved-overview-name' },
- })
-
navigateToTab(view, 'model')
- expect(
- await screen.findByText(
- 'Provider, allowed models, fallback policy, and credentials for this agent.'
- )
- ).toBeInTheDocument()
+ expect(await screen.findByText('Current model')).toBeInTheDocument()
fireEvent.click(screen.getByRole('button', { name: 'Edit' }))
- fireEvent.change(screen.getByLabelText('Secret reference'), { target: { value: '' } })
- fireEvent.click(screen.getByRole('button', { name: 'Save' }))
- expect(await screen.findByText('Model & credentials saved.')).toBeInTheDocument()
- navigateToTab(view, 'overview')
- expect(await screen.findByDisplayValue('unsaved-overview-name')).toBeInTheDocument()
- expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument()
+ expect(screen.getByRole('dialog')).toBeInTheDocument()
+ expect(screen.getByText('Update LLM secret openai-secret')).toBeInTheDocument()
+ expect(pushMock).not.toHaveBeenCalled()
+ expect(
+ (api.apiSend as unknown as ReturnType<typeof vi.fn>).mock.calls.some(
+ args => args[0] === 'PUT' && args[1] === '/api/v1/admin/hosts/foo'
+ )
+ ).toBe(false)
})
- it('preserves an open Model & credentials draft when Overview is saved', async () => {
+ it('updates the linked Secret without writing Host model configuration', async () => {
const view = render(<HostDetailsPage />)
navigateToTab(view, 'model')
- expect(
- await screen.findByText(
- 'Provider, allowed models, fallback policy, and credentials for this agent.'
- )
- ).toBeInTheDocument()
+ await screen.findByText('Current model')
fireEvent.click(screen.getByRole('button', { name: 'Edit' }))
- fireEvent.change(screen.getByLabelText('Secret reference'), { target: { value: '' } })
-
- navigateToTab(view, 'overview')
- await openOverviewEdit()
- fireEvent.click(screen.getByRole('button', { name: 'Save' }))
- expect(await screen.findByText('Agent configuration saved.')).toBeInTheDocument()
+ fireEvent.click(screen.getByRole('button', { name: 'Replace OpenAI API key' }))
+ fireEvent.change(screen.getByLabelText(/^OpenAI API key/i), {
+ target: { value: 'sk-live' },
+ })
+ fireEvent.click(screen.getByRole('button', { name: 'Update secret' }))
- navigateToTab(view, 'model')
await waitFor(() =>
- expect((screen.getByLabelText('Secret reference') as HTMLSelectElement).value).toBe('')
+ expect(api.apiSend).toHaveBeenCalledWith('PUT', '/api/v1/admin/secrets', {
+ name: 'openai-secret',
+ merge: true,
+ stringData: { 'openai-api-key': 'sk-live' },
+ })
)
- expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument()
+ expect(
+ (api.apiSend as unknown as ReturnType<typeof vi.fn>).mock.calls.some(
+ args => args[0] === 'PUT' && args[1] === '/api/v1/admin/hosts/foo'
+ )
+ ).toBe(false)
})
})
diff --git a/control-ui/components/__tests__/HostDetailsPage.connectors.test.tsx b/control-ui/components/__tests__/HostDetailsPage.connectors.test.tsx
index 50d835ff8..4e9d79dc4 100644
--- a/control-ui/components/__tests__/HostDetailsPage.connectors.test.tsx
+++ b/control-ui/components/__tests__/HostDetailsPage.connectors.test.tsx
@@ -1,6 +1,13 @@
import React from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import { cleanup, fireEvent, render as rtlRender, screen, waitFor } from '@testing-library/react'
+import {
+ cleanup,
+ fireEvent,
+ render as rtlRender,
+ screen,
+ waitFor,
+ within,
+} from '@testing-library/react'
import HostDetailsPage from '../../app/hosts/[name]/page'
import * as api from '../../lib/api'
import { ToastProvider } from '../Toast'
@@ -112,10 +119,12 @@ describe('HostDetailsPage connectors', () => {
expect(await screen.findByText('mcp-existing')).toBeInTheDocument()
expect(screen.queryByText(contextName)).not.toBeInTheDocument()
- fireEvent.click(screen.getByRole('button', { name: 'Add connector', exact: true }))
+ fireEvent.click(screen.getByRole('button', { name: 'Add connector' }))
await waitFor(() => expect(api.getMcpServers).toHaveBeenCalledTimes(1))
fireEvent.click(await screen.findByRole('option', { name: 'mcp-new' }))
- fireEvent.click(screen.getByRole('dialog').getByRole('button', { name: 'Add connector' }))
+ fireEvent.click(
+ within(screen.getByRole('dialog')).getByRole('button', { name: 'Add connector' })
+ )
await waitFor(() => expect(api.updateContext).toHaveBeenCalledTimes(1))
expect(api.updateContext).toHaveBeenCalledWith(
@@ -138,8 +147,8 @@ describe('HostDetailsPage connectors', () => {
name: 'Actions for connector mcp-existing',
})
fireEvent.click(actionsButton)
- fireEvent.click(await screen.findByRole('menuitem', { name: 'Remove connector', exact: true }))
- fireEvent.click(await screen.findByRole('button', { name: 'Remove connector', exact: true }))
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Remove connector' }))
+ fireEvent.click(await screen.findByRole('button', { name: 'Remove connector' }))
await waitFor(() => expect(api.updateContext).toHaveBeenCalledTimes(1))
expect(api.updateContext).toHaveBeenCalledWith(
diff --git a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
index 17a443f6e..607c37795 100644
--- a/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
+++ b/control-ui/components/__tests__/HostDetailsPage.identity.test.tsx
@@ -132,7 +132,7 @@ describe('HostDetailsPage identity integration', () => {
)
})
- it('puts Allowed models in place of Model name and uses LLM Secret language', async () => {
+ it('shows the current model and opens the linked LLM Secret modal inline', async () => {
mockParams = { name: 'foo', tab: 'model' }
const { container } = render(<HostDetailsPage />)
@@ -143,36 +143,36 @@ describe('HostDetailsPage identity integration', () => {
Array.from(container.querySelectorAll('.cu-form-stack > .cu-field label')).map(label =>
label.textContent?.trim()
)
- ).toEqual(['LLM Secret', 'Model provider', 'Allowed models', 'Fallback policy'])
+ ).toEqual([
+ 'LLM Secret',
+ 'Current model',
+ 'Model provider',
+ 'Allowed models',
+ 'Fallback policy',
+ ])
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('LLM Secret')).toBeInTheDocument()
- expect(
- screen.getByRole('button', { name: 'Save' }).closest('.cu-create-actions')
- ).not.toBeNull()
- expect(container.querySelector('.cu-agent-detail-card .cu-agent-detail-scroll')).not.toBeNull()
+ expect(screen.getByRole('dialog')).toBeInTheDocument()
+ expect(screen.getByText('Update LLM secret openai-secret')).toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'Replace OpenAI API key' })).toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'Update secret' })).toBeInTheDocument()
+ expect(pushMock).not.toHaveBeenCalled()
+ expect(container.querySelector('.cu-agent-detail-card')).toBeNull()
})
- it('frames one linked LLM Secret and exposes additive provider credentials', async () => {
+ it('uses the shared LLM Secret editor for additional provider credentials', async () => {
mockParams = { name: 'foo', tab: 'model' }
render(<HostDetailsPage />)
fireEvent.click(await screen.findByRole('button', { name: 'Edit' }))
- expect(screen.getByRole('link', { name: 'Manage LLM Secrets' })).toHaveAttribute(
- 'href',
- '/secrets/llm'
- )
- expect(screen.getByText('OpenAI · configured')).toBeInTheDocument()
- expect(screen.getByText('Additional providers')).toBeInTheDocument()
+ expect(screen.getByText('Update LLM secret openai-secret')).toBeInTheDocument()
+ expect(screen.queryByRole('link', { name: 'Manage LLM Secrets' })).toBeNull()
+ expect(screen.getByRole('button', { name: 'Replace OpenAI API key' })).toBeInTheDocument()
fireEvent.click(screen.getByLabelText('Add provider'))
fireEvent.click(screen.getByRole('option', { name: 'Anthropic' }))
diff --git a/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsx b/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsx
index 9f1073a45..ed0f28e01 100644
--- a/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsx
+++ b/control-ui/components/__tests__/HostDetailsPage.lifecycle.test.tsx
@@ -153,13 +153,13 @@ function render(children: ReactNode) {
}
async function openOverviewEdit() {
- const [overviewEditButton] = await screen.findAllByRole('button', { name: 'Edit' })
+ const overviewEditButton = await screen.findByRole('button', { name: 'Edit lifecycle' })
await waitFor(() => expect(overviewEditButton).toBeEnabled())
fireEvent.click(overviewEditButton)
}
async function saveOverviewAndGetPayload(): Promise<{ spec: Record<string, unknown> }> {
- fireEvent.click(screen.getByRole('button', { name: 'Save' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Save lifecycle' }))
await waitFor(() =>
expect(api.apiSend).toHaveBeenCalledWith('PUT', '/api/v1/admin/hosts/foo', expect.any(Object))
)
@@ -341,7 +341,7 @@ describe('HostDetailsPage stateless lifecycle', () => {
expect(await screen.findByText('Stateless mode rejected:')).toBeInTheDocument()
await openOverviewEdit()
- fireEvent.click(screen.getByRole('button', { name: 'Save' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Save lifecycle' }))
await waitFor(() =>
expect(screen.queryByText('Stateless mode rejected:')).not.toBeInTheDocument()
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 5037093b5..4ac83d4a1 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.449",
+ "version": "0.1.450",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.449",
+ "version": "0.1.450",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/llm-providers": "file:../packages/llm-providers",
diff --git a/control-ui/package.json b/control-ui/package.json
index 40c5592f7..5fef329e3 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.449",
+ "version": "0.1.450",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",