Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): say the credentials read failed instead of freezing the panel
Jose Ramireze73279b06ed5
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex 7a68d2d8d..c47b8b39f 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.440",+ "version": "0.1.441","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.440",+ "version": "0.1.441","dependencies": {"@clerum/image-policy": "file:../packages/image-policy","@clerum/llm-providers": "file:../packages/llm-providers",diff --git a/control-api/package.json b/control-api/package.jsonindex caddbdcb8..6c2fdadf9 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.440",+ "version": "0.1.441","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/test/routes.communicationChannelCredentialsGet.test.ts b/control-api/test/routes.communicationChannelCredentialsGet.test.tsindex d15f18f08..81615a745 100644--- a/control-api/test/routes.communicationChannelCredentialsGet.test.ts+++ b/control-api/test/routes.communicationChannelCredentialsGet.test.ts@@ -64,6 +64,38 @@ describe('GET /admin/communication-channels/:name/credentials — names only', (})})+ it('reads the Secret the channel points at, not the conventional name', async () => {+ // Every other fixture sets credentialsSecretRef to `cc-<name>-credentials`,+ // which is byte-identical to the fallback — so the ref lookup, the whole+ // reason this route reads the CC at all, was never exercised. A channel+ // pointing at an operator-supplied Secret would report the keys of a+ // `cc-foo-credentials` that does not exist, which is the same lie about+ // what is configured that this endpoint was added to kill.+ gatewayMock.getResource.mockResolvedValue({+ metadata: { name: 'foo', namespace: 'channels' },+ spec: { hostRef: 'h1', credentialsSecretRef: { name: 'ops-shared-slack' } },+ })+ gatewayMock.getSecret.mockResolvedValue({+ metadata: { name: 'ops-shared-slack', namespace: 'channels' },+ data: { 'slack-bot-token': Buffer.from('xoxb-shared').toString('base64') },+ })++ const res = await request(makeApp()).get('/admin/communication-channels/foo/credentials')++ expect(res.status).toBe(200)+ expect(res.body).toEqual({+ name: 'foo',+ secretName: 'ops-shared-slack',+ namespace: 'channels',+ keys: ['slack-bot-token'],+ })+ // The call ARGUMENTS are the point. Asserting only the body leaves a route+ // that never reads the CC, or reads the right Secret out of the wrong+ // namespace, passing: both can still produce a plausible-looking answer.+ expect(gatewayMock.getResource).toHaveBeenCalledWith('communicationchannels', 'foo', 'channels')+ expect(gatewayMock.getSecret).toHaveBeenCalledWith('ops-shared-slack', 'channels')+ })+it('returns 200 with keys: [] when the channel has no Secret yet', async () => {gatewayMock.getResource.mockResolvedValue({metadata: { name: 'foo', namespace: 'channels' },diff --git a/control-ui/app/communication-channels/[name]/edit/page.tsx b/control-ui/app/communication-channels/[name]/edit/page.tsxindex 98e7ad333..5c0488c94 100644--- a/control-ui/app/communication-channels/[name]/edit/page.tsx+++ b/control-ui/app/communication-channels/[name]/edit/page.tsx@@ -1,6 +1,6 @@'use client'-import React, { useEffect, useMemo, useState } from 'react'+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'import { useParams, useRouter } from 'next/navigation'import { AuthGate } from '@components/AuthGate'import { FormSectionsSkeleton } from '@components/BodyLoadingSkeleton'@@ -70,10 +70,16 @@ function extractChannel(response: unknown, name: string): CommunicationChannelItreturn list.items?.find(item => item.metadata?.name === name) ?? null}+/** Detail shown under the panel's read-failed banner when the request itself+ * succeeded but the body did not carry a usable key list. */+const CREDENTIALS_SHAPE_ERROR = 'The credentials response did not list the stored keys.'+/** Same, when the request threw something that is not an Error. */+const CREDENTIALS_REQUEST_ERROR = 'The credentials request failed.'+/*** 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".+ * usable. Undefined is never "nothing stored": callers turn it into the panel's+ * read-failed state, which says so and offers a retry.*/function extractCredentialKeys(response: unknown): string[] | undefined {if (!response || typeof response !== 'object') return undefined@@ -108,6 +114,13 @@ export default function EditCommunicationChannelPage() {// 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)+ // Why that read failed, when it did. Undefined keys ALONE cannot say whether+ // the read is still running or is over and broken, and the panel disables+ // itself while it believes a read is in flight — so swallowing the error left+ // every credential control dead until a page reload, with no way to tell.+ const [credentialKeysError, setCredentialKeysError] = useState('')+ // Drops a stale credentials response when the read is retried or `name` changes.+ const credentialsRequestId = useRef(0)const [loading, setLoading] = useState(true)const [loadError, setLoadError] = useState('')const [saving, setSaving] = useState(false)@@ -117,13 +130,40 @@ export default function EditCommunicationChannelPage() {router.push(CONTROL_ROUTES.externalChannels.root)}+ // Key names only — the API never returns values. A failure here must not take+ // the whole page down, must not be read as "no credentials", and must not be+ // read as "still loading" either: it is its own state, with a retry.+ const loadCredentialKeys = useCallback(async (channelName: string) => {+ if (!channelName) return+ const id = ++credentialsRequestId.current+ setStoredCredentialKeys(undefined)+ setCredentialKeysError('')+ try {+ const response = await apiGet(+ `/api/v1/admin/communication-channels/${encodeURIComponent(channelName)}/credentials`+ )+ if (id !== credentialsRequestId.current) return+ const keys = extractCredentialKeys(response)+ if (!keys) {+ setCredentialKeysError(CREDENTIALS_SHAPE_ERROR)+ return+ }+ setStoredCredentialKeys(keys)+ } catch (error) {+ // A silent error is an expired session: the app is already redirecting,+ // so a banner about credentials would just be noise on the way out.+ if (id !== credentialsRequestId.current || isSilentApiError(error)) return+ setCredentialKeysError(error instanceof Error ? error.message : CREDENTIALS_REQUEST_ERROR)+ }+ }, [])+useEffect(() => {let cancelled = falseasync function load() {setLoading(true)setLoadError('')try {- const [channelResponse, hostsResponse, credentialsResponse] = await Promise.all([+ const [channelResponse, hostsResponse] = await Promise.all([apiGet(`/api/v1/admin/communication-channels/${encodeURIComponent(name)}`).catch(async error => {if (isSilentApiError(error)) return null@@ -131,12 +171,9 @@ 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),+ // Runs alongside the other two, but owns its own state: a credentials+ // failure is reported in the panel, not by failing the page load.+ loadCredentialKeys(name),])if (cancelled || channelResponse === null) returnconst nextItem = extractChannel(channelResponse, name)@@ -151,7 +188,6 @@ export default function EditCommunicationChannelPage() {setDraft(createCommunicationChannelDraft(nextItem))setActiveTab(communicationChannelInitialTab(nextItem))setHosts(nextHosts)- setStoredCredentialKeys(extractCredentialKeys(credentialsResponse))} catch (error) {if (isSilentApiError(error)) returnif (!cancelled) {@@ -167,7 +203,7 @@ export default function EditCommunicationChannelPage() {return () => {cancelled = true}- }, [name])+ }, [name, loadCredentialKeys])const visibleChannelTypes = useMemo<ChannelType[]>(() => [activeTab], [activeTab])const activeConversations = draft ? conversationsForProvider(activeTab, draft) : []@@ -660,6 +696,8 @@ export default function EditCommunicationChannelPage() {ccName={item.metadata?.name || name}visibleChannelTypes={visibleChannelTypes}storedKeys={storedCredentialKeys}+ storedKeysError={credentialKeysError}+ onRetryStoredKeys={() => void loadCredentialKeys(name)}/></section>diff --git a/control-ui/components/ChannelCredentialsPanel/index.tsx b/control-ui/components/ChannelCredentialsPanel/index.tsxindex f6a9879b2..e54a3a3e8 100644--- a/control-ui/components/ChannelCredentialsPanel/index.tsx+++ b/control-ui/components/ChannelCredentialsPanel/index.tsx@@ -4,6 +4,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react'import { IconCheck, IconPencil, IconTrash } from '@components/icons'import { cn } from '@lib/cn'import { apiSend } from '../../lib/api'+import { RetryBanner } from '../PublisherView/RetryBanner'import { useToast } from '../Toast'import { CHANNEL_CREDENTIAL_FIELDS } from './constants'import type { ChannelCredentialsPanelProps, CredentialDraft } from './types'@@ -19,6 +20,15 @@ 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…'+/** Shown per field once the stored-key read has FAILED. The panel knows nothing+ * about this key, and a blank field with its normal placeholder would read as+ * "nothing stored", which is the lie this panel exists to stop. */+const UNKNOWN_PLACEHOLDER = 'Stored value unknown'+/** Banner copy for a failed stored-key read. Rotation is a blind PUT that does+ * not need to know the current state, so it stays available; deleting a key+ * the panel cannot see does not. */+const STORED_KEYS_ERROR =+ 'Could not check which credentials are stored. You can still rotate a value; deleting one needs a successful read.'/*** Slack offers four secrets and this platform uses two of them. The "app is* ready" dialog puts the App-Level Token next to the bot token, and the Signing@@ -45,12 +55,21 @@ const SLACK_CREDENTIAL_NOTE =* 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.+ *+ * That state has three cases, not two: the read is in flight (`storedKeys`+ * undefined, controls closed because the answer landing would discard whatever+ * was typed), the read answered (`storedKeys` set), or the read FAILED+ * (`storedKeysError`). The failed case says so and keeps rotation open —+ * a PUT overwrites whatever is there and needs no knowledge of it — while+ * Delete stays closed, because a key the panel cannot see is not safe to drop.*/export function ChannelCredentialsPanel({ccName,pending,onPendingChange,storedKeys,+ storedKeysError,+ onRetryStoredKeys,presentation = 'panel',readOnly = false,visibleChannelTypes,@@ -97,9 +116,14 @@ export function ChannelCredentialsPanel({// 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+ // The read is over and its answer is unusable. Create flows have no Secret to+ // read, so they never reach this state either.+ const storedKeysReadFailed = !pending && Boolean(storedKeysError)+ // Nothing is known about the Secret YET, i.e. the read is still in flight.+ // Create flows have no Secret to read, so they are never pending. A failed+ // read is not pending: leaving it here disabled the whole panel forever,+ // under a placeholder describing a request that had already finished.+ const keysPending = !pending && storedSignature === null && !storedKeysReadFailed// 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.@@ -268,6 +292,17 @@ export function ChannelCredentialsPanel({{error ? <div className="cu-banner cu-banner--error">{error}</div> : null}+ {storedKeysReadFailed ? (+ <div role="alert">+ {onRetryStoredKeys ? (+ <RetryBanner message={STORED_KEYS_ERROR} onRetry={onRetryStoredKeys} />+ ) : (+ <p className="cu-banner cu-banner--warn">{STORED_KEYS_ERROR}</p>+ )}+ <p className="cu-field__hint cu-channel-credentials__note">{storedKeysError}</p>+ </div>+ ) : null}+{!pending && !ccName ? (<div className="cu-empty">Save the channel first, then return here to set its credentials.@@ -295,7 +330,13 @@ export function ChannelCredentialsPanel({}onChange={e => updateField(field.key, e.target.value)}placeholder={- keysPending ? PENDING_PLACEHOLDER : stored ? undefined : field.placeholder+ keysPending+ ? PENDING_PLACEHOLDER+ : stored+ ? undefined+ : storedKeysReadFailed+ ? UNKNOWN_PLACEHOLDER+ : field.placeholder}aria-busy={keysPending || undefined}disabled={diff --git a/control-ui/components/ChannelCredentialsPanel/types.ts b/control-ui/components/ChannelCredentialsPanel/types.tsindex 959c898e5..6ff89b36d 100644--- a/control-ui/components/ChannelCredentialsPanel/types.ts+++ b/control-ui/components/ChannelCredentialsPanel/types.ts@@ -70,6 +70,18 @@ export type ChannelCredentialsPanelProps = {* 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[]+ /** Why the stored-key read failed, when it did. Non-empty means the read is+ * OVER and its answer is unusable, which is a different state from+ * `storedKeys === undefined` on its own (that also covers "still in+ * flight"). Without it a failed read parked the panel in its pending state+ * forever: every input, Edit and Delete disabled under a "Checking stored+ * credentials…" placeholder for a request that was not running.+ * The panel renders its own explanation; this string is the underlying+ * cause, shown as a detail line. Pass `onRetryStoredKeys` with it. */+ storedKeysError?: string+ /** Re-runs the stored-key read. Only meaningful alongside+ * `storedKeysError` — the panel does not own that request. */+ onRetryStoredKeys?: () => void/** Render masked provider fields without rotation/delete controls. */readOnly?: boolean}diff --git a/control-ui/components/CommunicationChannelConversations/index.tsx b/control-ui/components/CommunicationChannelConversations/index.tsxindex 6ddb416c2..bdc505142 100644--- a/control-ui/components/CommunicationChannelConversations/index.tsx+++ b/control-ui/components/CommunicationChannelConversations/index.tsx@@ -54,7 +54,7 @@ function conversationKey(conversation: CommunicationChannelConversation, index:* page. Saying only "none confirmed" made a working channel read as broken.*/const EMPTY_CONVERSATIONS_LABEL =- 'No conversations confirmed yet. Each user links their own by sending the verify command from their profile page in the conversation they want to link.'+ 'No conversations confirmed yet. Each user links their own by copying the verify command from their profile page and sending it in the conversation they want to link.'export function CommunicationChannelConversationsTable({conversations,diff --git a/control-ui/components/__tests__/ChannelCredentialsPanel.test.tsx b/control-ui/components/__tests__/ChannelCredentialsPanel.test.tsxindex f899fac68..3540b6157 100644--- a/control-ui/components/__tests__/ChannelCredentialsPanel.test.tsx+++ b/control-ui/components/__tests__/ChannelCredentialsPanel.test.tsx@@ -19,6 +19,12 @@ afterEach(() => {const MASKED = '**********'/** Placeholder shown while the stored-key list is unknown (GET in flight). */const PENDING_PLACEHOLDER = 'Checking stored credentials…'+/** Placeholder shown per field once that GET has failed. */+const UNKNOWN_PLACEHOLDER = 'Stored value unknown'+/** Banner copy for a failed stored-key read. Written out, not imported: this+ * copy is the whole fix, so a reworded panel has to fail here. */+const STORED_KEYS_ERROR =+ 'Could not check which credentials are stored. You can still rotate a value; deleting one needs a successful read.'function credentialInput(label: string): HTMLInputElement {return screen.getByLabelText(label) as HTMLInputElement@@ -277,6 +283,28 @@ describe('ChannelCredentialsPanel — per-key stored state', () => {expect(screen.queryByLabelText('Delete Slack Bot User OAuth Token')).not.toBeInTheDocument()})+ it('keeps the create wizard editable when no stored-key list is passed', () => {+ // What the create page actually renders: pending, and no storedKeys at all+ // (there is no Secret to read yet). Without the `!pending` guard on+ // keysPending, every credential input on the create page is disabled under+ // a "checking" placeholder for a request nobody made — and no suite+ // notices, because the test that looks like it covers pending mode passes+ // storedKeys, which makes the guard irrelevant to its assertions.+ renderPanel({ ccName: 'cc-new', pending: true, visibleChannelTypes: ['slack'] })++ const signingSecret = credentialInput('Slack Signing Secret')+ // Asserted on the property, not by typing: fireEvent.change dispatches+ // straight at the node and lands on a disabled input just the same.+ expect(signingSecret.disabled).toBe(false)+ expect(signingSecret.placeholder).toBe('signing secret')+ expect(signingSecret.getAttribute('aria-busy')).toBe(null)++ const botToken = credentialInput('Slack Bot User OAuth Token')+ expect(botToken.disabled).toBe(false)+ expect(botToken.placeholder).toBe('xoxb-…')+ expect(botToken.getAttribute('aria-busy')).toBe(null)+ })+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.@@ -294,6 +322,112 @@ describe('ChannelCredentialsPanel — per-key stored state', () => {})})+describe('ChannelCredentialsPanel — failed stored-key read', () => {+ const TELEGRAM_AND_SLACK: Parameters<typeof ChannelCredentialsPanel>[0] = {+ ccName: 'jose-tg',+ visibleChannelTypes: ['telegram', 'slack'],+ }++ it('says the read failed, keeps rotation open, and keeps delete closed', () => {+ // A failed read is NOT the pending state. Rendering it as pending disabled+ // every input, Edit and Delete permanently, under a placeholder describing+ // a request that had already finished, with nothing on screen saying so and+ // no way out but a page reload.+ const onRetryStoredKeys = vi.fn()+ renderPanel({+ ...TELEGRAM_AND_SLACK,+ storedKeys: undefined,+ storedKeysError: 'secrets is forbidden',+ onRetryStoredKeys,+ })++ expect(screen.getByText(STORED_KEYS_ERROR)).toBeInTheDocument()+ // The cause, not just "something went wrong".+ expect(screen.getByText('secrets is forbidden')).toBeInTheDocument()++ 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(null)+ expect(input.placeholder).toBe(UNKNOWN_PLACEHOLDER)+ expect(input.value).toBe('')+ // Rotation is a blind PUT: it overwrites whatever is there and needs to+ // know nothing about it, so a failed read must not block it.+ expect(screen.getByLabelText(`Edit ${label}`)).not.toBeDisabled()+ // Deleting a key the panel cannot see is a different matter.+ expect(screen.getByLabelText(`Delete ${label}`)).toBeDisabled()+ }+ })++ it('offers a retry that re-runs the read the panel does not own', () => {+ const onRetryStoredKeys = vi.fn()+ renderPanel({+ ...TELEGRAM_AND_SLACK,+ storedKeysError: 'secrets is forbidden',+ onRetryStoredKeys,+ })++ act(() => {+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }))+ })+ expect(onRetryStoredKeys).toHaveBeenCalledTimes(1)+ })++ it('still reports the failure when the caller offers no retry', () => {+ renderPanel({ ...TELEGRAM_AND_SLACK, storedKeysError: 'secrets is forbidden' })++ expect(screen.getByText(STORED_KEYS_ERROR)).toBeInTheDocument()+ expect(screen.queryByRole('button', { name: 'Retry' })).not.toBeInTheDocument()+ })++ it('lets the panel mask a key it saved while the read was failing', () => {+ // The read said nothing, but this panel just wrote this key, so it knows+ // that one exists — and only that one.+ renderPanel({+ ...TELEGRAM_AND_SLACK,+ storedKeysError: 'secrets is forbidden',+ onRetryStoredKeys: vi.fn(),+ })++ 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)+ expect(credentialInput('Slack Bot User OAuth Token').placeholder).toBe(UNKNOWN_PLACEHOLDER)+ })+ })++ it('never shows the read-failed banner in pending (create) mode', () => {+ // A CC that does not exist has no Secret to read, so nothing can have+ // failed to read it.+ renderPanel({+ ccName: 'cc-new',+ pending: true,+ visibleChannelTypes: ['slack'],+ storedKeysError: 'secrets is forbidden',+ onRetryStoredKeys: vi.fn(),+ })++ expect(screen.queryByText(STORED_KEYS_ERROR)).not.toBeInTheDocument()+ const signingSecret = credentialInput('Slack Signing Secret')+ expect(signingSecret.disabled).toBe(false)+ expect(signingSecret.placeholder).toBe('signing secret')+ })+})+/** The Slack note, written out rather than imported: this copy IS the feature,* so a reworded panel must fail here instead of quietly passing. */const SLACK_CREDENTIAL_NOTE =diff --git a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsxindex 5088061f3..82aa7d800 100644--- a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx+++ b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx@@ -151,17 +151,33 @@ describe('EditCommunicationChannelPage channel credentials', () => {telegramSettings: { botHandle: '@ops_bot' },}+ /** The panel's own copy for a stored-key read that failed, written out rather+ * than imported: this copy is the fix, so a reworded panel must fail here. */+ const STORED_KEYS_ERROR =+ 'Could not check which credentials are stored. You can still rotate a value; deleting one needs a successful read.'++ function credentialReadCount(name: string): number {+ return vi+ .mocked(api.apiGet)+ .mock.calls.filter(+ ([path]) => path === `/api/v1/admin/communication-channels/${name}/credentials`+ ).length+ }+/** Like mockChannel, but also answers the per-channel credentials read.- * Pass an Error to make that read fail. */+ * Pass an Error to make that read fail, or an array to answer successive+ * reads in order (the last entry answers every read after it). */function mockChannelCredentials(name: string, spec: ChannelSpec, credentials: unknown) {navigation.params = { name }+ const answers = Array.isArray(credentials) ? [...credentials] : [credentials]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+ const answer = answers.length > 1 ? answers.shift() : answers[0]+ if (answer instanceof Error) throw answer+ return answer}if (path === `/api/v1/admin/communication-channels/${name}`) {return {@@ -218,9 +234,13 @@ describe('EditCommunicationChannelPage channel credentials', () => {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.+ it('says the credentials read failed instead of reporting them as empty or pending', async () => {+ // A denied or failed read says nothing about what is stored, so the empty+ // state would report "no credentials" on a channel that has them. The+ // pending state is just as wrong once the request is over: the panel+ // disables every control while it believes a read is in flight, so+ // swallowing the error left the whole panel dead, silently, until a reload+ // — which repeats the failure whenever the cause is not transient.mockChannelCredentials(TELEGRAM_ONLY_CHANNEL,TELEGRAM_ONLY_SPEC,@@ -229,21 +249,79 @@ describe('EditCommunicationChannelPage channel credentials', () => {await renderLoadedPage()await waitFor(() => {- expect(screen.getByLabelText('Telegram Bot Token')).toBeInTheDocument()+ expect(screen.getByText(STORED_KEYS_ERROR)).toBeInTheDocument()})+ // The cause reaches the operator rather than being discarded with the+ // rejected promise.+ expect(screen.getByText('secrets is forbidden')).toBeInTheDocument()+const telegramToken = screen.getByLabelText('Telegram Bot Token') as HTMLInputElement- expect(telegramToken.getAttribute('aria-busy')).toBe('true')+ expect(telegramToken.getAttribute('aria-busy')).toBe(null)expect(telegramToken.value).toBe('')- expect(telegramToken.placeholder).toBe('Checking stored credentials…')+ expect(telegramToken.placeholder).toBe('Stored value unknown')+ // Rotation still works: a PUT overwrites whatever is there and needs to+ // know nothing about it. Deleting an invisible key does not.+ expect(screen.getByLabelText('Edit Telegram Bot Token')).toBeEnabled()+ expect(screen.getByLabelText('Delete Telegram Bot Token')).toBeDisabled()// The page itself still loaded: the read failure is scoped to the panel.expect(screen.getByLabelText(/Telegram bot handle/)).toHaveValue('@ops_bot')})++ it('retries the credentials read from the panel and recovers', async () => {+ // The failure is reachable from a control-ui newer than control-api (404 on+ // this route, a window on every rolling update) or any transient apiserver+ // failure, so the way out has to be cheaper than a page reload.+ mockChannelCredentials(TELEGRAM_ONLY_CHANNEL, TELEGRAM_ONLY_SPEC, [+ new Error('secrets is forbidden'),+ {+ name: TELEGRAM_ONLY_CHANNEL,+ secretName: 'cc-jose-tg-credentials',+ namespace: 'channels',+ keys: ['telegram-bot-token'],+ },+ ])+ await renderLoadedPage()++ await waitFor(() => {+ expect(screen.getByRole('button', { name: 'Retry' })).toBeInTheDocument()+ })+ expect(credentialReadCount(TELEGRAM_ONLY_CHANNEL)).toBe(1)++ fireEvent.click(screen.getByRole('button', { name: 'Retry' }))++ await waitFor(() => {+ expect(screen.getByLabelText('Telegram Bot Token')).toHaveValue('**********')+ })+ expect(credentialReadCount(TELEGRAM_ONLY_CHANNEL)).toBe(2)+ expect(screen.queryByText(STORED_KEYS_ERROR)).not.toBeInTheDocument()+ expect(screen.queryByRole('button', { name: 'Retry' })).not.toBeInTheDocument()+ })++ it('treats an unusable credentials response as a failed read, not as no credentials', async () => {+ // 200 with a body that carries no key list is exactly as uninformative as a+ // rejection, and parked the panel in the same permanent pending state.+ mockChannelCredentials(TELEGRAM_ONLY_CHANNEL, TELEGRAM_ONLY_SPEC, {+ name: TELEGRAM_ONLY_CHANNEL,+ namespace: 'channels',+ })+ await renderLoadedPage()++ await waitFor(() => {+ expect(screen.getByText(STORED_KEYS_ERROR)).toBeInTheDocument()+ })+ expect(+ screen.getByText('The credentials response did not list the stored keys.')+ ).toBeInTheDocument()+ const telegramToken = screen.getByLabelText('Telegram Bot Token') as HTMLInputElement+ expect(telegramToken.placeholder).toBe('Stored value unknown')+ expect(screen.getByLabelText('Edit Telegram Bot Token')).toBeEnabled()+ })})/** Both strings are written out rather than imported: this copy IS the feature,* so a reworded page must fail here instead of quietly passing. */const EMPTY_CONVERSATIONS_COPY =- 'No conversations confirmed yet. Each user links their own by sending the verify command from their profile page in the conversation they want to link.'+ 'No conversations confirmed yet. Each user links their own by copying the verify command from their profile page and sending it in the conversation they want to link.'const THREAD_MENTION_COPY ='Replies inside a thread still require a mention: even in a thread the app started, a follow-up that does not mention the app is ignored.'diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex fabedfd53..568daba9b 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.403",+ "version": "0.1.404","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.403",+ "version": "0.1.404","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 8de9692d9..16a2a9d7d 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.403",+ "version": "0.1.404","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",