Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(control-ui): hand over a clickable Teams install link, not a command
Jose Ramirez9e4cb68c2d6a
diff --git a/control-ui/app/communication-channels/new/page.tsx b/control-ui/app/communication-channels/new/page.tsxindex 481e6a3af..7ae2cf97b 100644--- a/control-ui/app/communication-channels/new/page.tsx+++ b/control-ui/app/communication-channels/new/page.tsx@@ -40,9 +40,11 @@ import {LOCAL_TEAMS_ENDPOINT_ORIGIN,TEAMS_APP_NAME_MAX_LENGTH,buildTeamsAppCreateCommand,+ buildTeamsPackageDownloadCommand,buildTeamsSupportsFilesCommand,canGenerateTeamsCommand,teamsAppNameError,+ teamsInstallUrl,teamsPlaceholderEndpoint,} from '@lib/teamsSetup'@@ -228,6 +230,16 @@ export default function CreateCommunicationChannelPage() {() => buildTeamsSupportsFilesCommand(draft.teamsAppId),[draft.teamsAppId])+ // Built from the two ids the operator has already pasted, so the deep link is+ // handed over without a CLI round trip. Null until both are real UUIDs.+ const teamsInstallLink = useMemo(+ () => teamsInstallUrl(draft.teamsAppId, draft.teamsTenantId),+ [draft.teamsAppId, draft.teamsTenantId]+ )+ const teamsPackageDownloadCommand = useMemo(+ () => buildTeamsPackageDownloadCommand(draft.teamsAppId),+ [draft.teamsAppId]+ )// 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@@ -391,6 +403,16 @@ export default function CreateCommunicationChannelPage() {)}+ async function copyTeamsPackageDownloadCommand() {+ const copied = await copyTextToClipboard(teamsPackageDownloadCommand)+ showToast(+ copied+ ? 'Teams package download 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)@@ -808,14 +830,14 @@ export default function CreateCommunicationChannelPage() {</>)}</li>- <li>Paste CLIENT_ID, TENANT_ID, and CLIENT_SECRET below.</li><li>- To deliver workflow files, enable them on the manifest. Paste CLIENT_ID- above first and this command fills itself in: the Teams App ID, the Bot- ID and CLIENT_ID are all the same value, written to <code>.env</code> by- the command above. The <code>--yes</code> is required; without it the- command changes nothing and still looks like it worked. File delivery- works in a direct chat only, not in a channel.+ To deliver workflow files, enable them on the manifest{' '}+ <strong>before you install the app in Teams</strong>. An installed app+ keeps the manifest it was installed with, so doing this afterwards means+ reinstalling. The <code>--yes</code> is required; without it the command+ changes nothing and still looks like it worked. File delivery works in a+ direct chat only, not in a channel. The app id is the CLIENT_ID from{' '}+ <code>.env</code>, so pasting it below fills this command in.<CommandBlockcommand={teamsSupportsFilesCommand}onCopy={copyTeamsSupportsFilesCommand}@@ -823,6 +845,37 @@ export default function CreateCommunicationChannelPage() {copyLabel="Copy Teams file support command"/></li>+ <li>Paste CLIENT_ID, TENANT_ID, and CLIENT_SECRET below.</li>+ <li>+ Install the app in Teams. The link below appears once CLIENT_ID and+ TENANT_ID are filled in, because it is built from exactly those two+ values.+ {teamsInstallLink ? (+ <>+ <a+ className="cu-btn cu-btn--secondary cu-btn--sm cu-teams-setup__install"+ href={teamsInstallLink}+ target="_blank"+ rel="noopener noreferrer"+ >+ Install in Teams+ </a>+ <span className="cu-muted">+ Pick the channel during install rather than adding it afterwards.+ If it says the app cannot be found, the Teams app catalog has not+ caught up yet: wait a few minutes and retry, or upload the package+ by hand with the command below and Apps > Manage your apps >+ Upload an app.+ </span>+ <CommandBlock+ command={teamsPackageDownloadCommand}+ onCopy={copyTeamsPackageDownloadCommand}+ copyDisabled={saving}+ copyLabel="Copy Teams package download command"+ />+ </>+ ) : null}+ </li></ol></section><Fielddiff --git a/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx b/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsxindex a8b6d045e..6045a4c1b 100644--- a/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx+++ b/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx@@ -290,15 +290,21 @@ describe('CreateCommunicationChannelPage — provider setup', () => {const steps = screen.getByText(/Run this from any directory/i).closest('ol')const items = Array.from(steps?.querySelectorAll(':scope > li') ?? [])- expect(items).toHaveLength(3)+ expect(items).toHaveLength(4)expect(items[0].querySelector('pre')).toHaveTextContent('teams app create')- expect(items[1].querySelector('pre')).toBeNull()+ // File support comes BEFORE install: an installed app keeps the manifest it+ // was installed with, so enabling it afterwards means reinstalling.// Named placeholder, never `<appId>`: angle brackets are a redirect in sh and// zsh, so pasting the command unedited fails with "no such file or directory".- expect(items[2].querySelector('pre')).toHaveTextContent(+ expect(items[1].querySelector('pre')).toHaveTextContent("teams app manifest update YOUR_CLIENT_ID --set-json 'bots[0].supportsFiles=true' --yes")+ expect(items[2].querySelector('pre')).toBeNull()+ // The install step carries no command until both ids are filled in, at which+ // point it renders a link rather than something to paste into a terminal.+ expect(items[3].textContent ?? '').toMatch(/install the app in Teams/i)+ expect(items[3].querySelector('a')).toBeNull()})// Inline <code> is not copyable, and this command is the one with the trap in it.@@ -842,3 +848,41 @@ describe('CreateCommunicationChannelPage — Teams prerequisites', () => {expect(screen.queryByRole('link', { name: /Teams setup guide/i })).not.toBeInTheDocument()})})++describe('CreateCommunicationChannelPage — Teams install link', () => {+ afterEach(() => {+ vi.unstubAllEnvs()+ })++ it('offers no install link until both ids are present, then builds it from them', async () => {+ vi.stubEnv('NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL', 'https://webhook.example.com')+ render(+ <ToastProvider>+ <CreateCommunicationChannelPage />+ </ToastProvider>+ )++ await fillStep1AndContinue()+ fireEvent.click(screen.getByRole('radio', { name: 'Microsoft Teams' }))+ fireEvent.change(screen.getByLabelText(/^Name/), { target: { value: 'Evenfire Bot' } })++ // A link built from half the values fails as "app cannot be found", which is+ // indistinguishable from catalog lag, so none is offered until both are real.+ expect(screen.queryByRole('link', { name: 'Install in Teams' })).not.toBeInTheDocument()++ const appId = '0cd0e1e6-adf7-40f4-952f-79006d320a05'+ const tenantId = '18517e81-9d09-4c73-88f3-e84a6c90c3d9'+ fireEvent.change(screen.getByLabelText(/^CLIENT_ID/), { target: { value: appId } })+ expect(screen.queryByRole('link', { name: 'Install in Teams' })).not.toBeInTheDocument()++ fireEvent.change(screen.getByLabelText(/^TENANT_ID/), { target: { value: tenantId } })++ const link = screen.getByRole('link', { name: 'Install in Teams' })+ expect(link).toHaveAttribute(+ 'href',+ `https://teams.microsoft.com/l/app/${appId}?installAppPackage=true&appTenantId=${tenantId}`+ )+ expect(link).toHaveAttribute('target', '_blank')+ expect(link).toHaveAttribute('rel', expect.stringContaining('noopener'))+ })+})diff --git a/control-ui/lib/__tests__/teamsSetup.test.ts b/control-ui/lib/__tests__/teamsSetup.test.tsindex 6b52ffd43..ebcbc90cd 100644--- a/control-ui/lib/__tests__/teamsSetup.test.ts+++ b/control-ui/lib/__tests__/teamsSetup.test.ts@@ -6,6 +6,7 @@ import {buildTeamsSupportsFilesCommand,canGenerateTeamsCommand,teamsAppNameError,+ teamsInstallUrl,teamsPlaceholderEndpoint,} from '../teamsSetup'@@ -120,3 +121,25 @@ describe('buildTeamsSupportsFilesCommand', () => {expect(cmd).not.toContain('>')})})++describe('teamsInstallUrl', () => {+ const APP = '0cd0e1e6-adf7-40f4-952f-79006d320a05'+ const TENANT = '18517e81-9d09-4c73-88f3-e84a6c90c3d9'++ it('builds the deep link from the two ids already on the form', () => {+ expect(teamsInstallUrl(APP, TENANT)).toBe(+ `https://teams.microsoft.com/l/app/${APP}?installAppPackage=true&appTenantId=${TENANT}`+ )+ })++ it('returns null until both ids are real UUIDs, so no half-built link is offered', () => {+ expect(teamsInstallUrl('', TENANT)).toBeNull()+ expect(teamsInstallUrl(APP, '')).toBeNull()+ expect(teamsInstallUrl('not-a-uuid', TENANT)).toBeNull()+ expect(teamsInstallUrl(APP, 'not-a-uuid')).toBeNull()+ })++ it('trims, since pasted ids often carry whitespace', () => {+ expect(teamsInstallUrl(` ${APP} `, ` ${TENANT} `)).toContain(APP)+ })+})diff --git a/control-ui/lib/teamsSetup.ts b/control-ui/lib/teamsSetup.tsindex ac62ba1b8..8ed43e094 100644--- a/control-ui/lib/teamsSetup.ts+++ b/control-ui/lib/teamsSetup.ts@@ -109,3 +109,28 @@ export function buildTeamsSupportsFilesCommand(appId?: string): string {const id = appId?.trim() || 'YOUR_CLIENT_ID'return `teams app manifest update ${id} --set-json 'bots[0].supportsFiles=true' --yes`}++const TEAMS_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i++/**+ * The Teams install deep link, which is fully determined by the app id and the+ * tenant id. Both are already on this form, so the operator never needs to run+ * `teams app get --install-link` to be handed the same string.+ *+ * Returns null unless both ids are real UUIDs. A half-built link looks clickable+ * and fails as "This app cannot be found", which is indistinguishable from the+ * catalog-propagation failure below and would send someone debugging the wrong+ * thing.+ */+export function teamsInstallUrl(appId: string, tenantId: string): string | null {+ const app = appId.trim()+ const tenant = tenantId.trim()+ if (!TEAMS_UUID_RE.test(app) || !TEAMS_UUID_RE.test(tenant)) return null+ return `https://teams.microsoft.com/l/app/${app}?installAppPackage=true&appTenantId=${tenant}`+}++/** Fallback when the deep link 404s because the Teams app catalog has not caught+ * up with the Developer Portal yet. Produces a package to upload by hand. */+export function buildTeamsPackageDownloadCommand(appId?: string): string {+ return `teams app package download ${appId?.trim() || 'YOUR_CLIENT_ID'}`+}diff --git a/control-ui/next-env.d.ts b/control-ui/next-env.d.tsindex 9edff1c7c..c4b7818fb 100644--- a/control-ui/next-env.d.ts+++ b/control-ui/next-env.d.ts@@ -1,6 +1,6 @@/// <reference types="next" />/// <reference types="next/image-types/global" />-import "./.next/types/routes.d.ts";+import "./.next/dev/types/routes.d.ts";// NOTE: This file should not be edited// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 8a0d6564b..c2b2a3a63 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.427",+ "version": "0.1.428","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.427",+ "version": "0.1.428","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 7024d9f74..4703e9431 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.427",+ "version": "0.1.428","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",