Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix: final-review fix wave for Teams channel setup UX (7 findings)
Jose Ramirez72b9611e7a0d
diff --git a/channel-reader/package-lock.json b/channel-reader/package-lock.jsonindex c574d5571..20b18560b 100644--- a/channel-reader/package-lock.json+++ b/channel-reader/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-channel-reader",- "version": "0.1.97",+ "version": "0.1.98","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-channel-reader",- "version": "0.1.97",+ "version": "0.1.98","license": "SEE LICENSE IN LICENSE","dependencies": {"@kubernetes/client-node": "^1.0.0",diff --git a/channel-reader/package.json b/channel-reader/package.jsonindex 1f07627a3..e9b26d2d9 100644--- a/channel-reader/package.json+++ b/channel-reader/package.json@@ -1,6 +1,6 @@{"name": "clerum-channel-reader",- "version": "0.1.97",+ "version": "0.1.98","description": "Watches CommunicationChannel CRDs and fetches messages from Telegram, Email, and Slack","main": "dist/main.js","engines": {diff --git a/channel-reader/src/main.ts b/channel-reader/src/main.tsindex 30fbe0c19..01b04cd98 100644--- a/channel-reader/src/main.ts+++ b/channel-reader/src/main.ts@@ -1592,7 +1592,16 @@ export class ChannelReader {const conversationId = identity?.providerChannelId?.trim() || channelIdconst key = `${workspaceId}:${userId}:${conversationId}`if (this.unresolvedNoticesSent.has(key)) return- if (this.unresolvedNoticesSent.size >= UNRESOLVED_NOTICE_GLOBAL_CAP) return+ if (this.unresolvedNoticesSent.size >= UNRESOLVED_NOTICE_GLOBAL_CAP) {+ // Not deduplicated on purpose: a repeated line is the signal that this is+ // an ongoing condition, not a one-off, while every provider goes silent+ // for unresolved senders until the TTL sweep frees a slot.+ console.warn(+ `[Main] Unresolved-sender notice cap (${UNRESOLVED_NOTICE_GLOBAL_CAP}) reached; ` ++ `suppressing notice to ${userId} in ${channelId}.`+ )+ return+ }// Record on ATTEMPT, not on success: a conversation Slack keeps rejecting// must not produce one outbound call per inbound message.this.unresolvedNoticesSent.set(key, { seenAt: Date.now() })@@ -1615,8 +1624,12 @@ export class ChannelReader {// produce a top-level post in a shared channel.await adapter.sendMessage(channelId, content, msg.messageId)} else if (msg.channelType === 'telegram') {- // No reply id: unlike Teams, Telegram has no channel-wide audience for a- // top-level post to leak this notice to.+ // No reply id: the spec fixes this as sendMessage(channelId, content) for+ // Telegram, with no threading. Group and supergroup chats do have a+ // channel-wide audience (see telegramOperationalMessage.ts), so this is+ // not a threading-is-pointless argument; the copy itself is deliberately+ // terse so a top-level post leaks nothing meaningful, and threading here+ // is a possible follow-up.await adapter.sendMessage(channelId, content)} else {if (!adapter.sendEphemeral) returndiff --git a/channel-reader/src/progressFormatter.ts b/channel-reader/src/progressFormatter.tsindex 0204d6407..3007643f9 100644--- a/channel-reader/src/progressFormatter.ts+++ b/channel-reader/src/progressFormatter.ts@@ -24,7 +24,13 @@ function formatDuration(ms: number): string {export function describeToolError(errorSummary: string | undefined): string {const raw = (errorSummary ?? '').toLowerCase()if (!raw) return 'unavailable.'- if (/auth|credential|unauthorized|forbidden|401|403/.test(raw)) {+ // Anchored so this does not fire on "author" (bare auth) or a millisecond+ // count that happens to contain "401"/"403" (bare digits).+ if (+ /unauthoriz|unauthenticat|authentication|authorization|credential|forbidden|\b401\b|\b403\b/.test(+ raw+ )+ ) {return 'unavailable (authentication problem). Ask your administrator.'}if (/timed out|timeout|etimedout|deadline/.test(raw)) return 'unavailable (timed out).'diff --git a/channel-reader/test/progressFormatter.test.ts b/channel-reader/test/progressFormatter.test.tsindex 86f5d8d82..f50117e01 100644--- a/channel-reader/test/progressFormatter.test.ts+++ b/channel-reader/test/progressFormatter.test.ts@@ -13,6 +13,19 @@ describe('describeToolError', () => {expect(describeToolError('request timed out after 30000ms')).toBe('unavailable (timed out).')})+ it('does not misclassify "author" as an authentication problem', () => {+ // Bare `auth` matched inside "author"; anchoring on unauthoriz/authenticat/etc+ // must not catch it.+ expect(describeToolError('search_issues failed: no results for author:jose')).toBe(+ 'unavailable.'+ )+ })++ it('does not let a millisecond count containing 401/403 win over a real timeout', () => {+ // Bare `401`/`403` matched inside "4031ms"; \b401\b and \b403\b must not.+ expect(describeToolError('request timed out after 4031ms')).toBe('unavailable (timed out).')+ })+it('falls back to generic for anything unrecognised', () => {expect(describeToolError('kaboom {"secret":"hunter2"}')).toBe('unavailable.')})diff --git a/channel-reader/test/unresolvedSenderNotice.test.ts b/channel-reader/test/unresolvedSenderNotice.test.tsindex cefb6b66d..9179881cc 100644--- a/channel-reader/test/unresolvedSenderNotice.test.ts+++ b/channel-reader/test/unresolvedSenderNotice.test.ts@@ -94,7 +94,7 @@ describe('authorizeProviderMessage response shape', () => {interface BuildReaderOptions {/** Omit the key entirely for the default; pass `undefined` for "no reason at all". */reason?: 'unresolved' | 'error'- medium?: 'slack' | 'telegram' | 'teams'+ medium?: 'slack' | 'telegram' | 'teams' | 'email'ephemeralThrows?: booleanprofileUiUrl?: string}@@ -338,10 +338,14 @@ describe('unresolved sender notice', () => {expect(sendEphemeral).not.toHaveBeenCalled()})- it('never sends for a non-Slack medium', async () => {- const { deliver, sendEphemeral } = buildReader({ medium: 'telegram' })+ it('never sends for email, the one medium the guard excludes', async () => {+ // Slack, Teams, and Telegram all send now (Telegram via sendMessage, asserted+ // below), so this can no longer be phrased as "non-Slack" -- email is the+ // only medium sendUnresolvedSenderNotice's top guard still drops.+ const { deliver, sendEphemeral, sendMessage } = buildReader({ medium: 'email' })await deliver('C1', 'U1')expect(sendEphemeral).not.toHaveBeenCalled()+ expect(sendMessage).not.toHaveBeenCalled()})})@@ -440,6 +444,26 @@ describe('unresolved notice global cap', () => {expect(sendMessage).toHaveBeenCalledTimes(UNRESOLVED_NOTICE_GLOBAL_CAP)})++ it('warns once per blocked send once the cap is reached, without deduplicating', async () => {+ const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined)+ const { deliverBatch, buildMessage } = buildReader({ medium: 'teams' })++ const messages = Array.from({ length: UNRESOLVED_NOTICE_GLOBAL_CAP + 5 }, (_, i) =>+ buildMessage('C1', `U${i}`, 'T1')+ )+ await deliverBatch(messages)++ const capWarnings = warnSpy.mock.calls.filter(call =>+ String(call[0]).includes('Unresolved-sender notice cap')+ )+ // One line per blocked send (5 excess messages), not one line total: a+ // repeated line is the signal that this is an ongoing condition.+ expect(capWarnings).toHaveLength(5)+ expect(String(capWarnings[0][0])).toContain(String(UNRESOLVED_NOTICE_GLOBAL_CAP))++ warnSpy.mockRestore()+ })})describe('unresolved notice link', () => {diff --git a/control-ui/app/communication-channels/[name]/edit/page.tsx b/control-ui/app/communication-channels/[name]/edit/page.tsxindex aa660983c..a48480d3f 100644--- a/control-ui/app/communication-channels/[name]/edit/page.tsx+++ b/control-ui/app/communication-channels/[name]/edit/page.tsx@@ -46,6 +46,7 @@ import {LOCAL_TEAMS_ENDPOINT_ORIGIN,buildTeamsAppCreateCommand,canGenerateTeamsCommand,+ isValidTeamsBotName,} from '@lib/teamsSetup'type ChannelProvider = CommunicationChannelProvider@@ -250,11 +251,12 @@ export default function EditCommunicationChannelPage() {slackRequestUrl && canGenerateSlackAppManifest(slackRequestUrl)? slackAppManifest(draft?.slackBotHandle.trim() || DEFAULT_SLACK_APP_NAME, slackRequestUrl): null- // Same reasoning as the Slack manifest above: a relative endpoint would point- // the Teams CLI at a host that does not exist, so warn instead of handing over- // a command built from a placeholder. This is also the repair path when a- // channel is recreated under a new name: retyping the Name field alone is- // enough to regenerate this command.+ // A relative endpoint would point the Teams CLI at a host that does not+ // exist, so a deployment with no public webhook origin falls back to+ // teamsAppCreatePlaceholderCommand below instead of a command built from+ // that relative path. This is also the repair path when a channel is+ // recreated under a new name: retyping the Name field alone is enough to+ // regenerate this command.const teamsAppCreateCommand =teamsRequestUrl && canGenerateTeamsCommand(teamsRequestUrl)? buildTeamsAppCreateCommand({@@ -262,6 +264,23 @@ export default function EditCommunicationChannelPage() {endpoint: teamsRequestUrl,}): null+ // The minikube case: no public origin to build a real command from. Still+ // render a runnable-looking command rather than nothing, using the marker+ // origin LOCAL_TEAMS_ENDPOINT_ORIGIN, because substituting a real origin by+ // hand for that marker is the documented self-hosted workflow.+ const teamsAppCreatePlaceholderCommand =+ teamsRequestUrl && !canGenerateTeamsCommand(teamsRequestUrl)+ ? buildTeamsAppCreateCommand({+ botName: draft?.teamsAppName || '',+ endpoint: `${LOCAL_TEAMS_ENDPOINT_ORIGIN}${teamsRequestUrl}`,+ })+ : null+ // hasTeamsConfigForRequestUrl is satisfied by CLIENT_ID or TENANT_ID alone,+ // so teamsAppCreateCommand can render with a blank Name -- which+ // buildTeamsAppCreateCommand fills with the literal placeholder <bot-name>.+ // Gate Copy on a valid name the same way the create page does, so that+ // placeholder is never handed over as if it were runnable.+ const teamsBotNameIsValid = isValidTeamsBotName(draft?.teamsAppName || '')async function persistDraft(nextDraft: DraftState, successMessage: string) {setSaving(true)@@ -357,6 +376,17 @@ export default function EditCommunicationChannelPage() {)}+ async function copyTeamsAppCreatePlaceholderCommand() {+ if (!teamsAppCreatePlaceholderCommand) return+ const copied = await copyTextToClipboard(teamsAppCreatePlaceholderCommand)+ showToast(+ copied+ ? 'Teams bot command copied.'+ : 'Could not copy to clipboard. Select the command and copy it manually.',+ { tone: copied ? 'success' : 'error' }+ )+ }+return (<AuthGate><DashboardLayout isDetailPage>@@ -735,7 +765,9 @@ export default function EditCommunicationChannelPage() {</button></div><span className="cu-field__hint">- Use this URL as the Messaging endpoint for the Teams bot app.+ {teamsRequestUrl+ ? 'Use this URL as the Messaging endpoint for the Teams bot app.'+ : 'Enter the Name above and this channel gets its Teams Request URL.'}</span></div>{teamsRequestUrl ? (@@ -751,7 +783,7 @@ export default function EditCommunicationChannelPage() {size="sm"className="cu-command-block__copy"onClick={copyTeamsAppCreateCommand}- disabled={saving}+ disabled={saving || !teamsBotNameIsValid}aria-label="Copy Teams bot create command"><IconCopy width={15} height={15} />@@ -769,12 +801,36 @@ export default function EditCommunicationChannelPage() {</span></div>) : (- <div className="cu-banner cu-banner--warning">- This deployment has no public webhook origin, so the command below cannot- be generated. Set{' '}- <code>NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL</code>, or substitute- your own public origin for <code>{LOCAL_TEAMS_ENDPOINT_ORIGIN}</code>{' '}- before running it.+ <div className="cu-field">+ <div className="cu-banner cu-banner--warning">+ This deployment has no public webhook origin. The command below uses the+ placeholder origin <code>{LOCAL_TEAMS_ENDPOINT_ORIGIN}</code>, which+ must be replaced before running it, or set{' '}+ <code>NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL</code> to have it+ filled in automatically.+ </div>+ {teamsAppCreatePlaceholderCommand && (+ <div className="cu-command-block">+ <div className="cu-command-block__toolbar">+ <span>Bash</span>+ <Button+ type="button"+ variant="secondary"+ size="sm"+ className="cu-command-block__copy"+ onClick={copyTeamsAppCreatePlaceholderCommand}+ disabled={saving || !teamsBotNameIsValid}+ aria-label="Copy Teams bot create command"+ >+ <IconCopy width={15} height={15} />+ Copy+ </Button>+ </div>+ <pre className="cu-command-block__pre">+ <code>{teamsAppCreatePlaceholderCommand}</code>+ </pre>+ </div>+ )}</div>)) : null}diff --git a/control-ui/app/communication-channels/new/page.tsx b/control-ui/app/communication-channels/new/page.tsxindex d00d481a0..54d086fd4 100644--- a/control-ui/app/communication-channels/new/page.tsx+++ b/control-ui/app/communication-channels/new/page.tsx@@ -39,6 +39,7 @@ import {LOCAL_TEAMS_ENDPOINT_ORIGIN,buildTeamsAppCreateCommand,canGenerateTeamsCommand,+ isValidTeamsBotName,} from '@lib/teamsSetup'type HostItem = {@@ -63,7 +64,6 @@ type DraftState = {}const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i-const TEAMS_BOT_NAME_RE = /^[a-z][a-z0-9-]{1,62}[a-z0-9]$/const STEPS = ['Channel', 'Provider'] as constconst STEP_DETAILS = [@@ -104,10 +104,6 @@ function toTeamsBotNameInput(value: string): string {return toKebabInput(value).slice(0, 64)}-function isValidTeamsBotName(value: string): boolean {- return TEAMS_BOT_NAME_RE.test(value.trim())-}-function providerSettings(provider: ChannelProvider, draft: DraftState) {if (provider === 'telegram') {return {@@ -206,12 +202,24 @@ export default function CreateCommunicationChannelPage() {[canUseBrowserWebhookOrigin, normalizedChannelName])// A relative endpoint would register a Teams bot pointing at a host that does- // not exist, so a deployment with no public webhook origin warns instead of- // handing over a command built from a placeholder.+ // not exist, so a deployment with no public webhook origin falls back to+ // teamsAppCreatePlaceholderCommand below instead of a command built from+ // that relative path.const teamsAppCreateCommand = useMemo(() => {if (!teamsWebhookUrl || !canGenerateTeamsCommand(teamsWebhookUrl)) return nullreturn buildTeamsAppCreateCommand({ botName: draft.teamsAppName, endpoint: teamsWebhookUrl })}, [draft.teamsAppName, teamsWebhookUrl])+ // The minikube case: no public origin to build a real command from. Still+ // render a runnable-looking command rather than nothing, using the marker+ // origin LOCAL_TEAMS_ENDPOINT_ORIGIN, because substituting a real origin by+ // hand for that marker is the documented self-hosted workflow.+ const teamsAppCreatePlaceholderCommand = useMemo(() => {+ if (!teamsWebhookUrl || canGenerateTeamsCommand(teamsWebhookUrl)) return null+ return buildTeamsAppCreateCommand({+ botName: draft.teamsAppName,+ endpoint: `${LOCAL_TEAMS_ENDPOINT_ORIGIN}${teamsWebhookUrl}`,+ })+ }, [draft.teamsAppName, teamsWebhookUrl])// Slack's order is manifest first, credentials second: the bot token only exists// after the app is installed, so a manifest offered only once the channel is saved// arrives after the step it describes. The Request URL encodes namespace and name@@ -354,6 +362,17 @@ export default function CreateCommunicationChannelPage() {)}+ async function copyTeamsAppCreatePlaceholderCommand() {+ if (!teamsAppCreatePlaceholderCommand) return+ const copied = await copyTextToClipboard(teamsAppCreatePlaceholderCommand)+ showToast(+ copied+ ? 'Teams bot command copied.'+ : 'Could not copy to clipboard. Select the command and copy it manually.',+ { tone: copied ? 'success' : 'error' }+ )+ }+async function copySlackAppManifest() {if (!slackManifest) returnconst copied = await copyTextToClipboard(slackManifest)@@ -764,13 +783,37 @@ export default function CreateCommunicationChannelPage() {</pre></div>) : (- <div className="cu-banner cu-banner--warning">- This deployment has no public webhook origin, so the command below- cannot be generated. Set{' '}- <code>NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL</code>, or- substitute your own public origin for{' '}- <code>{LOCAL_TEAMS_ENDPOINT_ORIGIN}</code> before running it.- </div>+ <>+ <div className="cu-banner cu-banner--warning">+ This deployment has no public webhook origin. The command below uses+ the placeholder origin <code>{LOCAL_TEAMS_ENDPOINT_ORIGIN}</code>,+ which must be replaced before running it, or set{' '}+ <code>NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL</code> to have it+ filled in automatically.+ </div>+ {teamsAppCreatePlaceholderCommand && (+ <div className="cu-command-block">+ <div className="cu-command-block__toolbar">+ <span>Bash</span>+ <Button+ type="button"+ variant="secondary"+ size="sm"+ className="cu-command-block__copy"+ onClick={copyTeamsAppCreatePlaceholderCommand}+ disabled={saving || !teamsBotNameIsValid}+ aria-label="Copy Teams bot create command"+ >+ <IconCopy width={15} height={15} />+ Copy+ </Button>+ </div>+ <pre className="cu-command-block__pre">+ <code>{teamsAppCreatePlaceholderCommand}</code>+ </pre>+ </div>+ )}+ </>)}</section><Fielddiff --git a/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx b/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsxindex 8d973e70d..d15b92b0b 100644--- a/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx+++ b/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx@@ -263,12 +263,14 @@ describe('CreateCommunicationChannelPage — provider setup', () => {expect(screen.getByRole('button', { name: 'Copy Teams bot create command' })).toBeEnabled()})- it('warns instead of showing a command when the deployment has no public webhook origin', async () => {+ it('warns and still renders a placeholder-origin command when the deployment has no public webhook origin', async () => {// No NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL and jsdom's hostname is// localhost (not app.*), which is the minikube case. The endpoint the CLI- // would need is a bare path here, and registering a Teams bot against a bare- // path points it at a host that does not exist -- warn instead of handing- // over a command built from a placeholder origin.+ // would need is a bare path here, and registering a Teams bot against a+ // bare path points it at a host that does not exist -- but leaving the+ // operator with nothing to run is worse: the documented minikube workflow+ // is to substitute a real origin for the placeholder by hand, so the+ // command still renders, built from the marker origin.render(<ToastProvider><CreateCommunicationChannelPage />@@ -281,14 +283,17 @@ describe('CreateCommunicationChannelPage — provider setup', () => {target: { value: 'Evenfire Bot!' },})- expect(screen.queryByText(/teams app create/)).not.toBeInTheDocument()- expect(- screen.queryByRole('button', { name: 'Copy Teams bot create command' })- ).not.toBeInTheDocument()const panel = document.querySelector('.cu-channel-provider-panel')expect(panel?.textContent ?? '').toMatch(/NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL|no public webhook origin/i)++ const command = screen.getByText(/teams app create/).closest('pre')+ expect(command).toHaveTextContent('--name "evenfire-bot"')+ // Pin the literal placeholder origin: this is what the operator is being+ // told to replace by hand.+ expect(command).toHaveTextContent('--endpoint "https://<public-webhook-origin>/webhooks/teams/')+ expect(screen.getByRole('button', { name: 'Copy Teams bot create command' })).toBeEnabled()})it('validates Teams CLIENT_ID and TENANT_ID before submission', async () => {diff --git a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsxindex 06229e56c..a7f4365b1 100644--- a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx+++ b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx@@ -139,7 +139,10 @@ describe('EditCommunicationChannelPage', () => {})expect(screen.getByText('Teams Request URL')).toBeInTheDocument()- expect(screen.getByText(/\/webhooks\/teams\//)).toBeInTheDocument()+ // Scoped to the readonly value field: the placeholder command block below+ // also renders this same path as part of its (marker-origin) endpoint.+ const requestUrlValue = document.querySelector('.cu-readonly-field.cu-copy-field__value')+ expect(requestUrlValue?.textContent ?? '').toMatch(/\/webhooks\/teams\//)expect(screen.getByText('General')).toBeInTheDocument()expect(screen.getByText('Channel')).toBeInTheDocument()})@@ -519,9 +522,42 @@ describe('EditCommunicationChannelPage Teams request URL', () => {await user.type(screen.getByLabelText(/name/i), 'evenfire-bot')- // After typing into the bot name field, the URL should appear+ // After typing into the bot name field, the URL should appear. Scoped to+ // the readonly value field: the placeholder command block below also+ // renders this same path as part of its (marker-origin) endpoint.expect(screen.queryByText('Unavailable')).not.toBeInTheDocument()- expect(await screen.findByText(/\/webhooks\/teams\/teams%3A/)).toBeInTheDocument()+ await waitFor(() => {+ const requestUrlValue = document.querySelector('.cu-readonly-field.cu-copy-field__value')+ expect(requestUrlValue?.textContent ?? '').toMatch(/\/webhooks\/teams\/teams%3A/)+ })+ })++ it('makes the Messaging endpoint hint conditional on the URL being available', async () => {+ // Slack makes the equivalent hint conditional; the Teams hint stayed+ // unconditional and kept telling the operator to use a URL that was not+ // there whenever the field renders Unavailable.+ mockChannel('teams-support', { hostRef: 'agentjose' })+ await renderLoadedPage()++ const user = userEvent.setup()+ await user.click(await screen.findByRole('radio', { name: /microsoft teams/i }))++ expect(screen.getByText('Unavailable')).toBeInTheDocument()+ expect(+ screen.getByText('Enter the Name above and this channel gets its Teams Request URL.')+ ).toBeInTheDocument()+ expect(+ screen.queryByText('Use this URL as the Messaging endpoint for the Teams bot app.')+ ).not.toBeInTheDocument()++ await user.type(screen.getByLabelText(/name/i), 'evenfire-bot')++ expect(+ screen.getByText('Use this URL as the Messaging endpoint for the Teams bot app.')+ ).toBeInTheDocument()+ expect(+ screen.queryByText('Enter the Name above and this channel gets its Teams Request URL.')+ ).not.toBeInTheDocument()})it('does not render a Teams request URL for a channel with only the stale teams-app-name annotation', async () => {@@ -558,8 +594,13 @@ describe('EditCommunicationChannelPage Teams request URL', () => {await user.type(screen.getByLabelText(/name/i), 'New Bot Name')+ // Scoped to the readonly value field: the placeholder command block below+ // also renders this same path as part of its (marker-origin) endpoint.expect(screen.queryByText('Unavailable')).not.toBeInTheDocument()- expect(await screen.findByText(/\/webhooks\/teams\/teams%3A/)).toBeInTheDocument()+ await waitFor(() => {+ const requestUrlValue = document.querySelector('.cu-readonly-field.cu-copy-field__value')+ expect(requestUrlValue?.textContent ?? '').toMatch(/\/webhooks\/teams\/teams%3A/)+ })})})@@ -596,12 +637,14 @@ describe('EditCommunicationChannelPage Teams setup command', () => {expect(updatedCommand).toHaveTextContent('--name "evenfire-bot-2"')})- it('warns instead of showing a command when the deployment has no public webhook origin', async () => {+ it('warns and still renders a placeholder-origin command when the deployment has no public webhook origin', async () => {// No NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL and jsdom's hostname is// localhost, which is the minikube case: the Teams Request URL above renders// as a bare path, and registering a bot against that path would point the- // CLI at a host that does not exist. Warn instead of handing over a command- // built from a placeholder origin.+ // CLI at a host that does not exist -- but leaving the operator with+ // nothing to run is worse: the documented minikube workflow is to+ // substitute a real origin for the placeholder by hand, so the command+ // still renders, built from the marker origin.mockChannel('teams-channel', {teamsSettings: { appName: 'evenfire', appId: '', tenantId: '' },})@@ -610,14 +653,39 @@ describe('EditCommunicationChannelPage Teams setup command', () => {const user = userEvent.setup()await user.click(await screen.findByRole('radio', { name: /microsoft teams/i }))- expect(screen.queryByText('Create the Teams bot')).not.toBeInTheDocument()- expect(screen.queryByText(/teams app create/)).not.toBeInTheDocument()- expect(- screen.queryByRole('button', { name: 'Copy Teams bot create command' })- ).not.toBeInTheDocument()const warning = document.querySelector('.cu-banner--warning')expect(warning?.textContent ?? '').toMatch(/no public webhook origin/)expect(screen.getByText('NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL')).toBeInTheDocument()++ const command = screen.getByText(/teams app create/).closest('pre')+ expect(command).toHaveTextContent('--name "evenfire"')+ // Pin the literal placeholder origin: this is what the operator is being+ // told to replace by hand.+ expect(command).toHaveTextContent('--endpoint "https://<public-webhook-origin>/webhooks/teams/')+ expect(screen.getByRole('button', { name: 'Copy Teams bot create command' })).toBeEnabled()+ })++ it('disables Copy on a command with a blank bot name, matching the create page', async () => {+ // hasTeamsConfigForRequestUrl is satisfied by CLIENT_ID or TENANT_ID alone,+ // so a channel with credentials but a blank Name still renders a command --+ // one that buildTeamsAppCreateCommand fills with the literal placeholder+ // <bot-name>. That placeholder must not look copyable and runnable.+ vi.stubEnv('NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL', 'https://webhook.example.com')+ mockChannel('teams-channel', {+ teamsSettings: { appName: '', appId: '7e9cdb6c-87e8-4b1e-b291-76f7b8bdbe82', tenantId: '' },+ })+ await renderLoadedPage()++ const user = userEvent.setup()+ await user.click(await screen.findByRole('radio', { name: /microsoft teams/i }))++ const command = screen.getByText(/teams app create/).closest('pre')+ expect(command).toHaveTextContent('--name "<bot-name>"')+ expect(screen.getByRole('button', { name: 'Copy Teams bot create command' })).toBeDisabled()++ await user.type(screen.getByLabelText(/name/i), 'evenfire-bot')++ expect(screen.getByRole('button', { name: 'Copy Teams bot create command' })).toBeEnabled()})it('renders neither the command nor the warning until this channel has Teams config', async () => {diff --git a/control-ui/lib/teamsSetup.ts b/control-ui/lib/teamsSetup.tsindex da222b185..55a4fd08d 100644--- a/control-ui/lib/teamsSetup.ts+++ b/control-ui/lib/teamsSetup.ts@@ -1,11 +1,23 @@/**- * Placeholder origin shown in guidance copy when the deployment has no public- * webhook address to substitute. Never used to build a real command: a- * generated command either carries a real absolute endpoint or is not- * generated at all.+ * Placeholder origin shown in guidance copy, and used to build a placeholder+ * command, when the deployment has no public webhook address to substitute.+ * Substituting it by hand for a real origin is the documented workflow for a+ * self-hosted (minikube) deployment, so a command built from this placeholder+ * is deliberately still rendered rather than withheld.*/export const LOCAL_TEAMS_ENDPOINT_ORIGIN = 'https://<public-webhook-origin>'+const TEAMS_BOT_NAME_RE = /^[a-z][a-z0-9-]{1,62}[a-z0-9]$/++/**+ * Teams CLI `--name` constraint: lowercase letters, numbers, and hyphens,+ * starting with a letter. Shared by the create and edit pages so both gate+ * Copy on the same rule instead of one silently drifting from the other.+ */+export function isValidTeamsBotName(value: string): boolean {+ return TEAMS_BOT_NAME_RE.test(value.trim())+}+/*** The Teams CLI needs an absolute endpoint. A deployment with no* NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL and a hostname that does notdiff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex fbf9c3b74..ab8072fa4 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.418",+ "version": "0.1.419","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.418",+ "version": "0.1.419","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 7726c4e73..99ef197e9 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.418",+ "version": "0.1.419","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",