Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): add Teams annotation carve-out for request URL gate
Jose Ramirez69dd334e5916
diff --git a/control-ui/app/communication-channels/[name]/edit/page.tsx b/control-ui/app/communication-channels/[name]/edit/page.tsxindex 47153802b..0248423ca 100644--- a/control-ui/app/communication-channels/[name]/edit/page.tsx+++ b/control-ui/app/communication-channels/[name]/edit/page.tsx@@ -28,7 +28,7 @@ import {communicationChannelInitialTab,createCommunicationChannelDraft,hasSlackConfigForRequestUrl,- hasTeamsConfig,+ hasTeamsConfigForRequestUrl,} from '@lib/communicationChannelEdit'import {COMMUNICATION_CHANNEL_PROVIDERS,@@ -232,7 +232,7 @@ export default function EditCommunicationChannelPage() {// step it describes. The URL depends only on namespace/name, both fixed at// create time, and the reader resolves that id regardless of teamsSettings.const teamsRequestUrl =- draft && hasTeamsConfig(draft)+ draft && hasTeamsConfigForRequestUrl(draft)? teamsWebhookUrlForChannelName(item?.metadata?.name?.trim() || name,item?.metadata?.namespace@@ -634,7 +634,14 @@ export default function EditCommunicationChannelPage() {value={draft.teamsAppName}onChange={event =>setDraft(current =>- current ? { ...current, teamsAppName: event.target.value } : current+ current+ ? {+ ...current,+ teamsAppName: event.target.value,+ // Typed, so no longer just an inherited label.+ teamsAppNameFromAnnotation: false,+ }+ : current)}placeholder="Your Teams Bot"diff --git a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsxindex 202dfa12b..f3cba4880 100644--- a/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx+++ b/control-ui/components/__tests__/EditCommunicationChannelPage.test.tsx@@ -512,8 +512,53 @@ describe('EditCommunicationChannelPage Teams request URL', () => {const user = userEvent.setup()await user.click(await screen.findByRole('radio', { name: /microsoft teams/i }))++ // Before typing, the URL should show Unavailable+ expect(screen.getByText('Unavailable')).toBeInTheDocument()+ expect(screen.queryByText(/\/webhooks\/teams\/teams%3A/)).not.toBeInTheDocument()+await user.type(screen.getByLabelText(/name/i), 'evenfire-bot')+ // After typing into the bot name field, the URL should appear+ expect(screen.queryByText('Unavailable')).not.toBeInTheDocument()+ expect(await screen.findByText(/\/webhooks\/teams\/teams%3A/)).toBeInTheDocument()+ })++ it('does not render a Teams request URL for a channel with only the stale teams-app-name annotation', async () => {+ mockChannel(+ 'telegram-channel',+ { telegramSettings: { botHandle: '@ops_bot' } },+ {+ 'clerum.io/teams-app-name': 'Stale Teams Name',+ }+ )+ await renderLoadedPage()++ const user = userEvent.setup()+ await user.click(await screen.findByRole('radio', { name: /microsoft teams/i }))++ expect(screen.getByText('Unavailable')).toBeInTheDocument()+ expect(screen.queryByText(/\/webhooks\/teams\/teams%3A/)).not.toBeInTheDocument()+ })++ it('shows the Teams request URL once an App Name is typed over a stale annotation', async () => {+ mockChannel(+ 'telegram-channel',+ { telegramSettings: { botHandle: '@ops_bot' } },+ {+ 'clerum.io/teams-app-name': 'Stale Teams Name',+ }+ )+ await renderLoadedPage()++ const user = userEvent.setup()+ await user.click(await screen.findByRole('radio', { name: /microsoft teams/i }))++ expect(screen.getByText('Unavailable')).toBeInTheDocument()++ await user.type(screen.getByLabelText(/name/i), 'New Bot Name')++ expect(screen.queryByText('Unavailable')).not.toBeInTheDocument()expect(await screen.findByText(/\/webhooks\/teams\/teams%3A/)).toBeInTheDocument()})})diff --git a/control-ui/lib/communicationChannelEdit.ts b/control-ui/lib/communicationChannelEdit.tsindex 617f754e5..321a355c9 100644--- a/control-ui/lib/communicationChannelEdit.ts+++ b/control-ui/lib/communicationChannelEdit.ts@@ -20,6 +20,13 @@ export type CommunicationChannelDraftState = {slackWorkspaceId: stringteams: CommunicationChannelGroup[]teamsAppName: string+ /**+ * True when `teamsAppName` was seeded from the `clerum.io/teams-app-name`+ * annotation rather than from `spec.teamsSettings` or from typing. Absent+ * means "not from the annotation": a hand-built draft has no annotation+ * history, and anything the operator types clears the flag.+ */+ teamsAppNameFromAnnotation?: booleanteamsAppId: stringteamsTenantId: stringteamsReplyOnlyWhenMentioned: boolean@@ -108,12 +115,45 @@ export function hasTeamsConfig()}+/**+ * Gate for the Teams Request URL, and for nothing else.+ *+ * `hasTeamsConfig` counts a `teamsAppName` seeded from the+ * `clerum.io/teams-app-name` annotation, which is how a Telegram-only channel+ * carrying a stale label rendered a copyable Request URL for a Teams bot that+ * does not exist. An annotation is a leftover label, not a declaration that this+ * channel has a Teams provider.+ *+ * Everything else keeps reading `hasTeamsConfig`: the annotation still fills the+ * visible App Name field, still decides which tab the edit page opens on, and+ * still reaches the saved spec. Only the copyable URL waits for a real Teams+ * provider, whether persisted or typed into the open draft.+ */+export function hasTeamsConfigForRequestUrl(+ draft: Pick<+ CommunicationChannelDraftState,+ | 'teams'+ | 'teamsAppName'+ | 'teamsAppNameFromAnnotation'+ | 'teamsAppId'+ | 'teamsTenantId'+ | 'teamsReplyOnlyWhenMentioned'+ >+): boolean {+ return hasTeamsConfig({+ ...draft,+ teamsAppName: draft.teamsAppNameFromAnnotation ? '' : draft.teamsAppName,+ })+}+export function createCommunicationChannelDraft(item: CommunicationChannelItem): CommunicationChannelDraftState {const spec = item.spec || {}const slackBotHandleFromSpec = spec.slackSettings?.botHandle || ''const slackBotHandleFromLabel = annotationValue(item, ['clerum.io/slack-bot-label'])+ const teamsAppNameFromSpec = spec.teamsSettings?.appName || ''+ const teamsAppNameFromAnnotation = annotationValue(item, ['clerum.io/teams-app-name'])return {accessTeamIds: spec.access?.teams || [],accessUserIds: spec.access?.users || [],@@ -128,8 +168,8 @@ export function createCommunicationChannelDraft(slackReplyInThreads: spec.slackSettings?.replyInThreads === true,slackWorkspaceId: spec.slackSettings?.workspaceId || '',teams: spec.teams || [],- teamsAppName:- spec.teamsSettings?.appName || annotationValue(item, ['clerum.io/teams-app-name']),+ teamsAppName: teamsAppNameFromSpec || teamsAppNameFromAnnotation,+ teamsAppNameFromAnnotation: !teamsAppNameFromSpec && Boolean(teamsAppNameFromAnnotation),teamsAppId: spec.teamsSettings?.appId || '',teamsTenantId: spec.teamsSettings?.tenantId || '',teamsReplyOnlyWhenMentioned: spec.teamsSettings?.replyOnlyWhenMentioned === true,diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 9791393c8..9fa4b3bac 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.414",+ "version": "0.1.415","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.414",+ "version": "0.1.415","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 7505209d4..2bc2f3c7b 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.414",+ "version": "0.1.415","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",