Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(control-ui): put each Teams command in the step that tells you to run it

Jose Ramirez7fb4b4048bb9
diff --git a/control-ui/app/communication-channels/new/page.tsx b/control-ui/app/communication-channels/new/page.tsx
index e1bd6b46f..0a16b83ae 100644
--- a/control-ui/app/communication-channels/new/page.tsx
+++ b/control-ui/app/communication-channels/new/page.tsx
@@ -220,6 +220,13 @@ export default function CreateCommunicationChannelPage() {
endpoint: teamsPlaceholderEndpoint(teamsWebhookUrl),
})
}, [draft.teamsAppName, teamsWebhookUrl])
+ // Substituted with CLIENT_ID once it is pasted, which on a teams-managed bot IS
+ // the app id (the Teams App ID, Bot ID and CLIENT_ID are one UUID). Before that
+ // it renders the <appId> placeholder, so the command is readable either way.
+ const teamsSupportsFilesCommand = useMemo(
+ () => buildTeamsSupportsFilesCommand(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
@@ -373,6 +380,16 @@ export default function CreateCommunicationChannelPage() {
)
}
+ async function copyTeamsSupportsFilesCommand() {
+ const copied = await copyTextToClipboard(teamsSupportsFilesCommand)
+ showToast(
+ copied
+ ? 'Teams file support command copied.'
+ : 'Could not copy to clipboard. Select the command and copy it manually.',
+ { tone: copied ? 'success' : 'error' }
+ )
+ }
+
async function copySlackAppManifest() {
if (!slackManifest) return
const copied = await copyTextToClipboard(slackManifest)
@@ -752,73 +769,58 @@ export default function CreateCommunicationChannelPage() {
invalid={Boolean(draft.teamsAppName) && Boolean(teamsBotNameError)}
/>
</Field>
+ {/*
+ Each step that has a command carries it directly, rather than
+ the list narrating three steps and the commands landing after
+ it: "run this" has to sit next to the thing it means, and step
+ 3's command is a different one from step 1's.
+ */}
<ol className="cu-teams-setup__instructions">
<li>
Run this from any directory. The command writes CLIENT_ID, TENANT_ID and
CLIENT_SECRET into .env in whichever directory you run it from.
+ {teamsAppCreateCommand ? (
+ <CommandBlock
+ command={teamsAppCreateCommand}
+ onCopy={copyTeamsAppCreateCommand}
+ copyDisabled={saving || Boolean(teamsBotNameError)}
+ copyLabel="Copy Teams bot create command"
+ />
+ ) : (
+ <>
+ <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 && (
+ <CommandBlock
+ command={teamsAppCreatePlaceholderCommand}
+ onCopy={copyTeamsAppCreatePlaceholderCommand}
+ copyDisabled={saving || Boolean(teamsBotNameError)}
+ copyLabel="Copy Teams bot create command"
+ />
+ )}
+ </>
+ )}
</li>
<li>Paste CLIENT_ID, TENANT_ID, and CLIENT_SECRET below.</li>
<li>
- To deliver workflow files, enable them on the manifest with{' '}
- <code>{buildTeamsSupportsFilesCommand()}</code>. 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. 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.
+ <CommandBlock
+ command={teamsSupportsFilesCommand}
+ onCopy={copyTeamsSupportsFilesCommand}
+ copyDisabled={saving}
+ copyLabel="Copy Teams file support command"
+ />
</li>
</ol>
- {teamsAppCreateCommand ? (
- <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={copyTeamsAppCreateCommand}
- disabled={saving || Boolean(teamsBotNameError)}
- aria-label="Copy Teams bot create command"
- >
- <IconCopy width={15} height={15} />
- Copy
- </Button>
- </div>
- <pre className="cu-command-block__pre">
- <code>{teamsAppCreateCommand}</code>
- </pre>
- </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 || Boolean(teamsBotNameError)}
- 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>
<Field
description="CLIENT_ID from the generated .env file."
@@ -912,6 +914,44 @@ export default function CreateCommunicationChannelPage() {
)
}
+// One shape for every copyable command on this page. Local on purpose: the same
+// markup also appears on the edit page, and lifting it into components/ is a
+// wider change than the ordering fix this belongs to.
+function CommandBlock({
+ command,
+ copyDisabled,
+ copyLabel,
+ onCopy,
+}: {
+ command: string
+ copyDisabled?: boolean
+ copyLabel: string
+ onCopy: () => void
+}) {
+ return (
+ <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={onCopy}
+ disabled={copyDisabled}
+ aria-label={copyLabel}
+ >
+ <IconCopy width={15} height={15} />
+ Copy
+ </Button>
+ </div>
+ <pre className="cu-command-block__pre">
+ <code>{command}</code>
+ </pre>
+ </div>
+ )
+}
+
function ProviderPanel({
checked,
children,
diff --git a/control-ui/app/globals.css b/control-ui/app/globals.css
index 1081565ce..eb2ac1e89 100644
--- a/control-ui/app/globals.css
+++ b/control-ui/app/globals.css
@@ -9750,6 +9750,11 @@ textarea.cu-input {
.cu-teams-setup__instructions {
display: grid;
+ /* minmax(0, 1fr) rather than the implicit 1fr: a grid column's default minimum
+ is its content, and these steps carry command blocks whose single-line
+ commands are far wider than the card. Without this the column grows to the
+ longest command and takes the card and its prose with it. */
+ grid-template-columns: minmax(0, 1fr);
gap: var(--cu-space-1);
margin: 0;
padding-left: var(--cu-space-5);
@@ -9757,6 +9762,15 @@ textarea.cu-input {
font-size: 0.8125rem;
}
+/* Same reason, one level down. A command block sitting directly in .cu-teams-setup
+ is a grid item whose overflow:hidden already zeroes its automatic minimum size;
+ nested in a list item, the li is the grid item and its overflow is visible, so
+ the minimum has to be set here for the block's own overflow-x to do the
+ scrolling. */
+.cu-teams-setup__instructions > li {
+ min-width: 0;
+}
+
.cu-teams-setup__instructions code {
padding: 0.05rem 0.3rem;
border: 1px solid var(--cu-border-subtle);
@@ -9766,6 +9780,23 @@ textarea.cu-input {
font-size: 0.78rem;
}
+/* A step owns its command block, so the block needs to read as part of that step
+ rather than as a sibling of the list. */
+.cu-teams-setup__instructions .cu-command-block {
+ margin: var(--cu-space-2) 0;
+}
+
+/* The inline-code rule above is for prose chips. Inside a command block the code
+ already sits on the block's own surface, so re-applying the chip border,
+ background and smaller size would double-frame it. */
+.cu-teams-setup__instructions .cu-command-block__pre code {
+ padding: 0;
+ border: 0;
+ border-radius: 0;
+ background: none;
+ font-size: inherit;
+}
+
.cu-command-block {
overflow: hidden;
border: 1px solid var(--cu-border);
diff --git a/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx b/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx
index 4367e99c7..d52bc4eac 100644
--- a/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx
+++ b/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx
@@ -273,6 +273,60 @@ describe('CreateCommunicationChannelPage — provider setup', () => {
expect(screen.getByRole('button', { name: 'Copy Teams bot create command' })).toBeEnabled()
})
+ // The list used to narrate three steps and then drop both commands after it, so
+ // "run this" in step 1 pointed past step 3 at a block that was not even the
+ // command step 3 talked about. Each command now sits in the step that means it.
+ it('puts each Teams command inside the step that tells you to run it', 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' } })
+
+ 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[0].querySelector('pre')).toHaveTextContent('teams app create')
+ expect(items[1].querySelector('pre')).toBeNull()
+ expect(items[2].querySelector('pre')).toHaveTextContent(
+ "teams app manifest update <appId> --set-json 'bots[0].supportsFiles=true' --yes"
+ )
+ })
+
+ // Inline <code> is not copyable, and this command is the one with the trap in it.
+ it('makes the file support command copyable and fills in CLIENT_ID once pasted', 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' }))
+
+ expect(
+ screen.getByRole('button', { name: 'Copy Teams file support command' })
+ ).toBeInTheDocument()
+
+ // On a teams-managed bot the app id IS CLIENT_ID, so the placeholder resolves
+ // to a command that can be run as copied.
+ fireEvent.change(screen.getByLabelText(/^CLIENT_ID/), {
+ target: { value: '11111111-2222-3333-4444-555555555555' },
+ })
+ expect(
+ screen.getByText(
+ "teams app manifest update 11111111-2222-3333-4444-555555555555 --set-json 'bots[0].supportsFiles=true' --yes"
+ )
+ ).toBeInTheDocument()
+ })
+
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
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 51480167a..042b36d76 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.424",
+ "version": "0.1.426",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.424",
+ "version": "0.1.426",
"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.json
index 180be428b..0edfb7234 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.424",
+ "version": "0.1.426",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",