Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): render per-key credential state instead of masking everything
Jose Ramirez7c252fd09d61
diff --git a/control-ui/app/communication-channels/[name]/edit/page.tsx b/control-ui/app/communication-channels/[name]/edit/page.tsxindex afccbf37e..c59d8b978 100644--- a/control-ui/app/communication-channels/[name]/edit/page.tsx+++ b/control-ui/app/communication-channels/[name]/edit/page.tsx@@ -70,6 +70,18 @@ function extractChannel(response: unknown, name: string): CommunicationChannelItreturn list.items?.find(item => item.metadata?.name === name) ?? null}+/**+ * Key names from `GET .../credentials`, or `undefined` when the answer is not+ * usable. Undefined keeps the credentials panel in its pending state: a read+ * that failed or came back malformed is "unknown", never "nothing stored".+ */+function extractCredentialKeys(response: unknown): string[] | undefined {+ if (!response || typeof response !== 'object') return undefined+ const keys = (response as { keys?: unknown }).keys+ if (!Array.isArray(keys)) return undefined+ return keys.filter((key): key is string => typeof key === 'string')+}+function conversationsForProvider(provider: ChannelProvider,draft: DraftState@@ -93,6 +105,9 @@ export default function EditCommunicationChannelPage() {const [draft, setDraft] = useState<DraftState | null>(null)const [activeTab, setActiveTab] = useState<ChannelProvider>('telegram')const [hosts, setHosts] = useState<HostItem[]>([])+ // Which credential keys the channel's Secret actually holds. Undefined until+ // the read lands, so the panel renders pending instead of "nothing stored".+ const [storedCredentialKeys, setStoredCredentialKeys] = useState<string[] | undefined>(undefined)const [loading, setLoading] = useState(true)const [loadError, setLoadError] = useState('')const [saving, setSaving] = useState(false)@@ -108,7 +123,7 @@ export default function EditCommunicationChannelPage() {setLoading(true)setLoadError('')try {- const [channelResponse, hostsResponse] = await Promise.all([+ const [channelResponse, hostsResponse, credentialsResponse] = await Promise.all([apiGet(`/api/v1/admin/communication-channels/${encodeURIComponent(name)}`).catch(async error => {if (isSilentApiError(error)) return null@@ -116,6 +131,12 @@ export default function EditCommunicationChannelPage() {}),apiGet('/api/v1/admin/hosts') as Promise<HostsResponse | HostItem[]>,+ // Key names only — the API never returns values. A failure here must+ // not take the whole page down, and must not be read as "no+ // credentials": null leaves the panel's stored state unknown.+ apiGet(+ `/api/v1/admin/communication-channels/${encodeURIComponent(name)}/credentials`+ ).catch(() => null),])if (cancelled || channelResponse === null) returnconst nextItem = extractChannel(channelResponse, name)@@ -130,6 +151,7 @@ export default function EditCommunicationChannelPage() {setDraft(createCommunicationChannelDraft(nextItem))setActiveTab(communicationChannelInitialTab(nextItem))setHosts(nextHosts)+ setStoredCredentialKeys(extractCredentialKeys(credentialsResponse))} catch (error) {if (isSilentApiError(error)) returnif (!cancelled) {@@ -626,7 +648,7 @@ export default function EditCommunicationChannelPage() {<ChannelCredentialsPanelccName={item.metadata?.name || name}visibleChannelTypes={visibleChannelTypes}- hasStoredCredentials={!!draft.credentialsSecretRef?.name}+ storedKeys={storedCredentialKeys}/></section>diff --git a/control-ui/components/ChannelCredentialsPanel/index.tsx b/control-ui/components/ChannelCredentialsPanel/index.tsxindex 80f4909b6..b405bf6b4 100644--- a/control-ui/components/ChannelCredentialsPanel/index.tsx+++ b/control-ui/components/ChannelCredentialsPanel/index.tsx@@ -14,6 +14,12 @@ function emptyDraft(): CredentialDraft {type SaveStatus = 'idle' | 'saved' | 'error'+/** Stand-in for a stored value. The API never returns values, only key names. */+const MASKED_VALUE = '**********'+/** Shown while `storedKeys` is unknown. Distinct from the per-field placeholder+ * so a page load cannot flash "nothing stored" before the answer arrives. */+const PENDING_PLACEHOLDER = 'Checking stored credentials…'+/*** Per-CommunicationChannel provider credential form.*@@ -26,12 +32,17 @@ type SaveStatus = 'idle' | 'saved' | 'error'* Empty fields are NOT sent on rotation: a partial update of just the* Telegram token must not clobber the stored Slack token. Only non-empty* trimmed values make it into the request body.+ *+ * Stored state is per key (`storedKeys`), never per channel: a field renders+ * masked only when the Secret holds that field's own key. The panel used to+ * take one boolean for the whole channel, so a Telegram-only Secret made every+ * Slack field look populated.*/export function ChannelCredentialsPanel({ccName,pending,onPendingChange,- hasStoredCredentials = false,+ storedKeys,presentation = 'panel',readOnly = false,visibleChannelTypes,@@ -47,6 +58,10 @@ export function ChannelCredentialsPanel({const [deletedKeys, setDeletedKeys] = useState<Partial<Record<keyof CredentialDraft, boolean>>>({})+ // Keys this panel stored itself since the parent last read the Secret. Without+ // it a freshly saved credential would render empty until the page reloaded,+ // which is the same lie in the other direction.+ const [savedKeys, setSavedKeys] = useState<Partial<Record<keyof CredentialDraft, boolean>>>({})// Monotonic id to drop stale async responses when `ccName` changes mid-flight.const requestId = useRef(0)@@ -63,16 +78,35 @@ export function ChannelCredentialsPanel({// eslint-disable-next-line react-hooks/exhaustive-deps}, [visibleSignature])+ // Stable signature of the stored key list. `null` means "not known yet".+ // Effects key on this string, never on the array: parents hand over a fresh+ // array on most renders, and keying on identity would reset the panel+ // mid-typing and silently discard what the operator entered.+ const storedSignature = storedKeys ? [...storedKeys].sort().join('|') : null+ const storedKeySet = useMemo(+ () => new Set<string>(storedKeys ?? []),+ // storedSignature stands in for storedKeys — see comment above.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ [storedSignature]+ )+ // Nothing is known about the Secret yet. Create flows have no Secret to read,+ // so they are never pending.+ const keysPending = !pending && storedSignature === null+// Reset local state when the target CC changes so values typed for CC A// are not saved against CC B if the parent swaps `ccName` without unmounting.+ // Also on a re-read of the Secret: the stored keys are the source of truth the+ // fields render, so local edit/delete marks made against the previous answer+ // no longer describe anything.useEffect(() => {setDraft(emptyDraft())setError('')setStatus('idle')setEditingKeys({})setDeletedKeys({})+ setSavedKeys({})requestId.current += 1- }, [ccName, hasStoredCredentials])+ }, [ccName, storedSignature])// Prune draft values for channel types that are no longer visible. Prevents// a stale token (e.g., user typed Slack creds then removed the Slack row)@@ -146,6 +180,7 @@ export function ChannelCredentialsPanel({setDraft(prev => ({ ...prev, [key]: '' }))setEditingKeys(prev => ({ ...prev, [key]: false }))setDeletedKeys(prev => ({ ...prev, [key]: false }))+ setSavedKeys(prev => ({ ...prev, [key]: true }))setStatus('saved')showToast('Channel credential saved.', { tone: 'success' })} catch (e) {@@ -177,6 +212,7 @@ export function ChannelCredentialsPanel({setDraft(prev => ({ ...prev, [key]: '' }))setEditingKeys(prev => ({ ...prev, [key]: false }))setDeletedKeys(prev => ({ ...prev, [key]: true }))+ setSavedKeys(prev => ({ ...prev, [key]: false }))setStatus('saved')showToast('Channel credential deleted.', { tone: 'success' })} catch (e) {@@ -192,6 +228,16 @@ export function ChannelCredentialsPanel({const fieldsDisabled = disabled || (!pending && !ccName)const isInline = presentation === 'inline'+ /** True when the Secret holds this exact key, as far as the panel knows.+ * A key deleted here is gone even if the parent's list still lists it; a key+ * saved here exists even if the parent's list predates the save. */+ function isKeyStored(key: keyof CredentialDraft): boolean {+ if (pending || keysPending) return false+ if (deletedKeys[key]) return false+ if (savedKeys[key]) return true+ return storedKeySet.has(key)+ }+return (<div className={cn('cu-channel-credentials', isInline && 'cu-channel-credentials--inline')}>{!isInline && (@@ -204,9 +250,10 @@ export function ChannelCredentialsPanel({Provider credentials for this channel's channel-reader. Stored as a KubernetesSecret<code> cc-{ccName || '<channel>'}-credentials </code>- in the <code>channels</code> namespace. Values are write-only — fields render blank and- existing secrets are never returned. The Secret is created on first save and follows the- CC if you change <code>hostRef</code>.+ in the <code>channels</code> namespace. Values are write-only — a key the Secret holds+ renders masked, every other field renders blank, and stored values are never returned.+ The Secret is created on first save and follows the CC if you change{' '}+ <code>hostRef</code>.</p></>)}@@ -225,71 +272,73 @@ export function ChannelCredentialsPanel({</div>) : (<div className="cu-form-stack">- {fields.map(field => (- <div key={field.key} className="cu-field cu-field--compact">- <label htmlFor={`channel-cred-${field.key}`}>{field.label}</label>- <div className="cu-credential-field">- <input- id={`channel-cred-${field.key}`}- type="password"- autoComplete="off"- value={- !pending &&- hasStoredCredentials &&- !deletedKeys[field.key] &&- !editingKeys[field.key]- ? '**********'- : draft[field.key] || ''- }- onChange={e => updateField(field.key, e.target.value)}- placeholder={- !pending && hasStoredCredentials && !deletedKeys[field.key]- ? undefined- : field.placeholder- }- disabled={fieldsDisabled || readOnly || (!pending && !editingKeys[field.key])}- />- {!pending && !readOnly ? (- <div className="cu-credential-field__actions">- {editingKeys[field.key] ? (- <button- type="button"- className="cu-btn cu-btn--icon cu-btn--sm"- onClick={() => void saveField(field.key)}- disabled={saving || !(draft[field.key] || '').trim()}- aria-label={`Save ${field.label}`}- title={`Save ${field.label}`}- >- <IconCheck width={16} height={16} />- </button>- ) : (+ {fields.map(field => {+ const stored = isKeyStored(field.key)+ return (+ <div key={field.key} className="cu-field cu-field--compact">+ <label htmlFor={`channel-cred-${field.key}`}>{field.label}</label>+ <div className="cu-credential-field">+ <input+ id={`channel-cred-${field.key}`}+ type="password"+ autoComplete="off"+ value={+ stored && !editingKeys[field.key] ? MASKED_VALUE : draft[field.key] || ''+ }+ onChange={e => updateField(field.key, e.target.value)}+ placeholder={+ keysPending ? PENDING_PLACEHOLDER : stored ? undefined : field.placeholder+ }+ aria-busy={keysPending || undefined}+ disabled={+ fieldsDisabled ||+ readOnly ||+ keysPending ||+ (!pending && !editingKeys[field.key])+ }+ />+ {!pending && !readOnly ? (+ <div className="cu-credential-field__actions">+ {editingKeys[field.key] ? (+ <button+ type="button"+ className="cu-btn cu-btn--icon cu-btn--sm"+ onClick={() => void saveField(field.key)}+ disabled={saving || !(draft[field.key] || '').trim()}+ aria-label={`Save ${field.label}`}+ title={`Save ${field.label}`}+ >+ <IconCheck width={16} height={16} />+ </button>+ ) : (+ <button+ type="button"+ className="cu-btn cu-btn--icon cu-btn--sm"+ onClick={() => editField(field.key)}+ disabled={saving || keysPending}+ aria-label={`Edit ${field.label}`}+ title={`Edit ${field.label}`}+ >+ <IconPencil width={16} height={16} />+ </button>+ )}<buttontype="button"- className="cu-btn cu-btn--icon cu-btn--sm"- onClick={() => editField(field.key)}- disabled={saving}- aria-label={`Edit ${field.label}`}- title={`Edit ${field.label}`}+ className="cu-btn cu-btn--icon cu-btn--danger-icon cu-btn--sm"+ onClick={() => void deleteField(field.key)}+ disabled={saving || keysPending || !stored}+ aria-label={`Delete ${field.label}`}+ title={`Delete ${field.label}`}>- <IconPencil width={16} height={16} />+ <IconTrash width={16} height={16} /></button>- )}- <button- type="button"- className="cu-btn cu-btn--icon cu-btn--danger-icon cu-btn--sm"- onClick={() => void deleteField(field.key)}- disabled={saving || !hasStoredCredentials || !!deletedKeys[field.key]}- aria-label={`Delete ${field.label}`}- title={`Delete ${field.label}`}- >- <IconTrash width={16} height={16} />- </button>- </div>- ) : null}+ </div>+ ) : null}+ </div>+ {field.helpText ? <div className="cu-field__hint">{field.helpText}</div> : null}</div>- {field.helpText ? <div className="cu-field__hint">{field.helpText}</div> : null}- </div>- ))}+ )+ })}</div>)}</>diff --git a/control-ui/components/ChannelCredentialsPanel/types.ts b/control-ui/components/ChannelCredentialsPanel/types.tsindex cd495b47c..959c898e5 100644--- a/control-ui/components/ChannelCredentialsPanel/types.ts+++ b/control-ui/components/ChannelCredentialsPanel/types.ts@@ -58,8 +58,18 @@ export type ChannelCredentialsPanelProps = {* When set, draft values for hidden types are pruned so they cannot leak* into the POST body after a user removes the corresponding channel row. */visibleChannelTypes?: ChannelType[]- /** True when the backing Secret exists. Values stay write-only and render masked. */- hasStoredCredentials?: boolean+ /** Credential key NAMES the backing Secret actually holds, from+ * `GET /api/v1/admin/communication-channels/:name/credentials`. Values are+ * never returned — only a key's presence is knowable, and only that key+ * renders masked.+ * - `undefined` → not known yet (the read is in flight or failed): fields+ * render a pending state, distinct from "nothing stored"+ * - `[]` → the Secret holds nothing: every field renders empty+ * - `['telegram-bot-token']` → only Telegram renders masked+ * This replaced a single `hasStoredCredentials` boolean, which masked every+ * field whenever the channel had any Secret at all, so a Telegram-only+ * channel reported a configured Slack Signing Secret it did not have. */+ storedKeys?: string[]/** Render masked provider fields without rotation/delete controls. */readOnly?: boolean}diff --git a/control-ui/components/__tests__/ChannelCredentialsPanel.test.tsx b/control-ui/components/__tests__/ChannelCredentialsPanel.test.tsxindex 91d76db25..84280325a 100644--- a/control-ui/components/__tests__/ChannelCredentialsPanel.test.tsx+++ b/control-ui/components/__tests__/ChannelCredentialsPanel.test.tsx@@ -1,6 +1,6 @@import React from 'react'import { afterEach, describe, expect, it, vi } from 'vitest'-import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'+import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import { ChannelCredentialsPanel } from '../ChannelCredentialsPanel'import type { CredentialDraft } from '../ChannelCredentialsPanel/types'import { ToastProvider } from '../Toast'@@ -9,7 +9,20 @@ vi.mock('../../lib/api', () => ({apiSend: vi.fn().mockResolvedValue({}),}))-afterEach(() => cleanup())+afterEach(() => {+ cleanup()+ vi.clearAllMocks()+})++/** What a field with a stored value renders. Copied from the panel, not imported,+ * so a change to the mask has to be looked at here too. */+const MASKED = '**********'+/** Placeholder shown while the stored-key list is unknown (GET in flight). */+const PENDING_PLACEHOLDER = 'Checking stored credentials…'++function credentialInput(label: string): HTMLInputElement {+ return screen.getByLabelText(label) as HTMLInputElement+}function renderPanel(props: Parameters<typeof ChannelCredentialsPanel>[0] = { ccName: 'cc-x' }) {return render(@@ -91,3 +104,192 @@ describe('ChannelCredentialsPanel — credential field filtering', () => {expect(onPendingChange).toHaveBeenLastCalledWith({})})})++describe('ChannelCredentialsPanel — per-key stored state', () => {+ const TELEGRAM_AND_SLACK: Parameters<typeof ChannelCredentialsPanel>[0] = {+ ccName: 'jose-tg',+ visibleChannelTypes: ['telegram', 'slack'],+ }++ it('masks only the keys the Secret actually holds', () => {+ // The regression: a Telegram-only Secret used to mask every field, so an+ // operator read "Slack is configured here" off a channel that had no Slack+ // credential at all.+ renderPanel({ ...TELEGRAM_AND_SLACK, storedKeys: ['telegram-bot-token'] })++ expect(credentialInput('Telegram Bot Token').value).toBe(MASKED)++ const signingSecret = credentialInput('Slack Signing Secret')+ expect(signingSecret.value).not.toBe(MASKED)+ expect(signingSecret.value).toBe('')+ expect(signingSecret.placeholder).toBe('signing secret')++ const botToken = credentialInput('Slack Bot User OAuth Token')+ expect(botToken.value).not.toBe(MASKED)+ expect(botToken.value).toBe('')+ expect(botToken.placeholder).toBe('xoxb-…')+ })++ it('renders every field empty and rotatable when the Secret holds nothing', () => {+ renderPanel({ ...TELEGRAM_AND_SLACK, storedKeys: [] })++ for (const [label, placeholder] of [+ ['Telegram Bot Token', '123456789:ABCDEF…'],+ ['Slack Signing Secret', 'signing secret'],+ ['Slack Bot User OAuth Token', 'xoxb-…'],+ ] as const) {+ const input = credentialInput(label)+ expect(input.value).toBe('')+ expect(input.placeholder).toBe(placeholder)+ expect(input.getAttribute('aria-busy')).toBe(null)+ expect(screen.getByLabelText(`Edit ${label}`)).not.toBeDisabled()+ // Nothing stored under this key, so there is nothing to delete.+ expect(screen.getByLabelText(`Delete ${label}`)).toBeDisabled()+ }+ })++ it('renders a pending state, not the empty state, while the key list is unknown', () => {+ renderPanel({ ...TELEGRAM_AND_SLACK, storedKeys: undefined })++ for (const label of [+ 'Telegram Bot Token',+ 'Slack Signing Secret',+ 'Slack Bot User OAuth Token',+ ]) {+ const input = credentialInput(label)+ expect(input.getAttribute('aria-busy')).toBe('true')+ expect(input.placeholder).toBe(PENDING_PLACEHOLDER)+ expect(input.value).toBe('')+ // Editing a field whose stored state is unknown would be discarded the+ // moment the answer lands, so the controls stay closed until it does.+ expect(screen.getByLabelText(`Edit ${label}`)).toBeDisabled()+ expect(screen.getByLabelText(`Delete ${label}`)).toBeDisabled()+ }+ // The empty state's own placeholders must not appear while pending.+ expect(credentialInput('Slack Signing Secret').placeholder).not.toBe('signing secret')+ })++ it('re-syncs a field when a rotation adds its key to the stored list', () => {+ const { rerender } = render(+ <ToastProvider>+ <ChannelCredentialsPanel+ ccName="jose-tg"+ visibleChannelTypes={['telegram', 'slack']}+ storedKeys={['telegram-bot-token']}+ />+ </ToastProvider>+ )++ // Operator opens the Slack bot token for editing and types a value.+ act(() => {+ fireEvent.click(screen.getByLabelText('Edit Slack Bot User OAuth Token'))+ })+ act(() => {+ fireEvent.change(credentialInput('Slack Bot User OAuth Token'), {+ target: { value: 'xoxb-typed-but-never-saved' },+ })+ })+ expect(credentialInput('Slack Bot User OAuth Token').value).toBe('xoxb-typed-but-never-saved')++ // The parent re-reads the Secret and the key now exists (rotated elsewhere).+ rerender(+ <ToastProvider>+ <ChannelCredentialsPanel+ ccName="jose-tg"+ visibleChannelTypes={['telegram', 'slack']}+ storedKeys={['telegram-bot-token', 'slack-bot-token']}+ />+ </ToastProvider>+ )++ expect(credentialInput('Slack Bot User OAuth Token').value).toBe(MASKED)+ expect(credentialInput('Telegram Bot Token').value).toBe(MASKED)+ expect(credentialInput('Slack Signing Secret').value).toBe('')+ })++ it('keeps a typed value when the parent passes an equal key list in a new array', () => {+ // The parent re-renders for unrelated reasons and hands over a fresh array+ // with the same contents. Keying the reset on array identity would wipe+ // what the operator is halfway through typing.+ const { rerender } = render(+ <ToastProvider>+ <ChannelCredentialsPanel+ ccName="jose-tg"+ visibleChannelTypes={['slack']}+ storedKeys={['slack-signing-secret', 'telegram-bot-token']}+ />+ </ToastProvider>+ )++ act(() => {+ fireEvent.click(screen.getByLabelText('Edit Slack Bot User OAuth Token'))+ })+ act(() => {+ fireEvent.change(credentialInput('Slack Bot User OAuth Token'), {+ target: { value: 'xoxb-half-typed' },+ })+ })++ rerender(+ <ToastProvider>+ <ChannelCredentialsPanel+ ccName="jose-tg"+ visibleChannelTypes={['slack']}+ storedKeys={['telegram-bot-token', 'slack-signing-secret']}+ />+ </ToastProvider>+ )++ expect(credentialInput('Slack Bot User OAuth Token').value).toBe('xoxb-half-typed')+ })++ it('masks a key it just saved even though the parent list is now stale', () => {+ renderPanel({ ...TELEGRAM_AND_SLACK, storedKeys: ['telegram-bot-token'] })++ act(() => {+ fireEvent.click(screen.getByLabelText('Edit Slack Signing Secret'))+ })+ act(() => {+ fireEvent.change(credentialInput('Slack Signing Secret'), {+ target: { value: 'signing-secret-value' },+ })+ })+ act(() => {+ fireEvent.click(screen.getByLabelText('Save Slack Signing Secret'))+ })++ return waitFor(() => {+ expect(credentialInput('Slack Signing Secret').value).toBe(MASKED)+ })+ })++ it('renders masked read-only fields only for keys that exist', () => {+ renderPanel({+ ...TELEGRAM_AND_SLACK,+ readOnly: true,+ storedKeys: ['slack-bot-token'],+ })++ expect(credentialInput('Slack Bot User OAuth Token').value).toBe(MASKED)+ expect(credentialInput('Slack Signing Secret').value).toBe('')+ expect(credentialInput('Telegram Bot Token').value).toBe('')+ expect(screen.queryByLabelText('Edit Slack Bot User OAuth Token')).not.toBeInTheDocument()+ expect(screen.queryByLabelText('Delete Slack Bot User OAuth Token')).not.toBeInTheDocument()+ })++ it('ignores storedKeys in pending (create) mode', () => {+ // A CC that does not exist yet has no Secret to report on; the panel must+ // stay a plain editable form even if a caller passes a list.+ renderPanel({+ ccName: 'cc-new',+ pending: true,+ visibleChannelTypes: ['slack'],+ storedKeys: ['slack-signing-secret'],+ })++ const signingSecret = credentialInput('Slack Signing Secret')+ expect(signingSecret.value).toBe('')+ expect(signingSecret.placeholder).toBe('signing secret')+ expect(signingSecret).not.toBeDisabled()+ })+})diff --git a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsxindex eb7196788..fe6c5d3df 100644--- a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx+++ b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx@@ -144,6 +144,102 @@ describe('EditCommunicationChannelPage', () => {})})+describe('EditCommunicationChannelPage channel credentials', () => {+ const TELEGRAM_ONLY_CHANNEL = 'jose-tg'+ const TELEGRAM_ONLY_SPEC: ChannelSpec = {+ credentialsSecretRef: { name: 'cc-jose-tg-credentials' },+ telegramSettings: { botHandle: '@ops_bot' },+ }++ /** Like mockChannel, but also answers the per-channel credentials read.+ * Pass an Error to make that read fail. */+ function mockChannelCredentials(name: string, spec: ChannelSpec, credentials: unknown) {+ navigation.params = { name }+ vi.mocked(api.apiGet).mockImplementation(async path => {+ if (path === '/api/v1/admin/hosts') {+ return { items: [{ metadata: { name: 'agent-a' } }] }+ }+ if (path === `/api/v1/admin/communication-channels/${name}/credentials`) {+ if (credentials instanceof Error) throw credentials+ return credentials+ }+ if (path === `/api/v1/admin/communication-channels/${name}`) {+ return {+ item: {+ metadata: { name, namespace: 'channels' },+ spec: { access: { users: [], teams: [] }, hostRef: 'agent-a', ...spec },+ },+ }+ }+ return { items: [] }+ })+ }++ it('masks only the keys the channel Secret holds, not every field', async () => {+ // The channel has a Secret, but it holds a Telegram token only. Inferring+ // per-field state from the Secret's existence rendered both Slack fields as+ // populated, so a half-configured channel read as configured.+ mockChannelCredentials(TELEGRAM_ONLY_CHANNEL, TELEGRAM_ONLY_SPEC, {+ name: TELEGRAM_ONLY_CHANNEL,+ secretName: 'cc-jose-tg-credentials',+ namespace: 'channels',+ keys: ['telegram-bot-token'],+ })+ await renderLoadedPage()++ await waitFor(() => {+ expect(screen.getByLabelText('Telegram Bot Token')).toHaveValue('**********')+ })++ fireEvent.click(screen.getByRole('radio', { name: 'Slack' }))+ const signingSecret = screen.getByLabelText('Slack Signing Secret') as HTMLInputElement+ expect(signingSecret.value).not.toBe('**********')+ expect(signingSecret.value).toBe('')+ expect(signingSecret.placeholder).toBe('signing secret')+ const botToken = screen.getByLabelText('Slack Bot User OAuth Token') as HTMLInputElement+ expect(botToken.value).toBe('')+ expect(botToken.placeholder).toBe('xoxb-…')+ })++ it('renders no credentials as empty when the Secret holds nothing', async () => {+ mockChannelCredentials(TELEGRAM_ONLY_CHANNEL, TELEGRAM_ONLY_SPEC, {+ name: TELEGRAM_ONLY_CHANNEL,+ secretName: 'cc-jose-tg-credentials',+ namespace: 'channels',+ keys: [],+ })+ await renderLoadedPage()++ await waitFor(() => {+ expect(screen.getByLabelText('Edit Telegram Bot Token')).toBeEnabled()+ })+ const telegramToken = screen.getByLabelText('Telegram Bot Token') as HTMLInputElement+ expect(telegramToken.value).toBe('')+ expect(telegramToken.placeholder).toBe('123456789:ABCDEF…')+ })++ it('leaves the fields unknown, not empty, when the credentials read fails', async () => {+ // A denied or failed read says nothing about what is stored. Rendering the+ // empty state here would report "no credentials" on a channel that has them.+ mockChannelCredentials(+ TELEGRAM_ONLY_CHANNEL,+ TELEGRAM_ONLY_SPEC,+ new Error('secrets is forbidden')+ )+ await renderLoadedPage()++ await waitFor(() => {+ expect(screen.getByLabelText('Telegram Bot Token')).toBeInTheDocument()+ })+ const telegramToken = screen.getByLabelText('Telegram Bot Token') as HTMLInputElement+ expect(telegramToken.getAttribute('aria-busy')).toBe('true')+ expect(telegramToken.value).toBe('')+ expect(telegramToken.placeholder).toBe('Checking stored credentials…')+ // The page itself still loaded: the read failure is scoped to the panel.+ expect(screen.getByLabelText(/Telegram bot handle/)).toHaveValue('@ops_bot')+ })+})+describe('EditCommunicationChannelPage Slack app manifest', () => {it('renders the manifest with both request URLs when the webhook is publicly reachable', async () => {vi.stubEnv('NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL', 'https://webhook.example.com')diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 1e14c7564..84c97e1af 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.401",+ "version": "0.1.402","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.401",+ "version": "0.1.402","dependencies": {"@clerum/llm-providers": "file:../packages/llm-providers","@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",diff --git a/control-ui/package.json b/control-ui/package.jsonindex ba70147ac..7c16d87fa 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.401",+ "version": "0.1.402","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",