Skip to content

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

TypeScript

fix(control-ui,docs): address review findings on the Slack setup flow

Jose Ramirez1aebc3ff1dfa
diff --git a/control-ui/app/communication-channels/new/page.tsx b/control-ui/app/communication-channels/new/page.tsx
index 1ee4cce6c..4b7c132be 100644
--- a/control-ui/app/communication-channels/new/page.tsx
+++ b/control-ui/app/communication-channels/new/page.tsx
@@ -17,6 +17,7 @@ import { useToast } from '@components/Toast'
import { IconCopy } from '@components/icons'
import { Button, Field, TextInput } from '@components/ui'
import { CONTROL_ROUTES } from '@constants/routes'
+import { SLACK_NEW_APP_URL } from '@constants/slack'
import { apiGet, apiSend } from '@lib/api'
import type { ChannelType } from '@lib/channelTypes'
import { copyTextToClipboard } from '@lib/clipboard'
@@ -59,9 +60,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 LOCAL_TEAMS_ENDPOINT_ORIGIN = 'https://<public-webhook-origin>'
-
-/** Slack's "Create an app" chooser, where "From an app manifest" is one of the options. */
-const SLACK_NEW_APP_URL = 'https://api.slack.com/apps?new_app=1'
const STEPS = ['Channel', 'Provider'] as const
const STEP_DETAILS = [
@@ -683,6 +681,17 @@ export default function CreateCommunicationChannelPage() {
channel has to be created under that name.
</span>
</div>
+ ) : draft.slackBotHandle.trim() && normalizedChannelName ? (
+ // Named and ready, but no absolute URL resolved: a manifest with a
+ // relative request_url is invalid to Slack. Say so rather than render
+ // nothing -- the operator is following a guide that promises a manifest
+ // here, and silence gives them no cause to chase.
+ <div className="cu-banner cu-banner--warning">
+ No app manifest: this deployment has no public webhook address, so the
+ Request URL would be a path Slack cannot reach. Expose the webhook proxy
+ publicly and set NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL to that
+ address, then reload this page.
+ </div>
) : null}
<ChannelCredentialsPanel
ccName={channelName.trim()}
diff --git a/control-ui/app/constants/slack.ts b/control-ui/app/constants/slack.ts
new file mode 100644
index 000000000..3b662cf55
--- /dev/null
+++ b/control-ui/app/constants/slack.ts
@@ -0,0 +1,7 @@
+/**
+ * Slack's "Create an app" chooser, where "From an app manifest" is one of the
+ * options. Configuration rather than copy: it is an external service address,
+ * and the edit page renders the same manifest block, so it belongs somewhere
+ * both pages can reach instead of inline in one of them.
+ */
+export const SLACK_NEW_APP_URL = 'https://api.slack.com/apps?new_app=1'
diff --git a/control-ui/components/ChannelCredentialsPanel/index.tsx b/control-ui/components/ChannelCredentialsPanel/index.tsx
index 2306e9fe1..095ef2559 100644
--- a/control-ui/components/ChannelCredentialsPanel/index.tsx
+++ b/control-ui/components/ChannelCredentialsPanel/index.tsx
@@ -30,15 +30,14 @@ const UNKNOWN_PLACEHOLDER = 'Stored value unknown'
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
- * Secret is filed next to a Client Secret on a page the dialog never links to,
- * so both wrong values are the easy ones to grab.
- */
-/**
- * Only the "ignore these" half. Where each value lives now sits on the field that
- * asks for it, which is where someone hunting for it is actually looking -- this
- * note is a paragraph under both inputs and is easy to skip.
+ * Slack offers four secrets and this platform uses two of them, with the "app is
+ * ready" dialog putting the App-Level Token right next to the bot token — so the
+ * wrong value is the easy one to grab.
+ *
+ * This note carries only that "ignore these" half. WHERE each value lives is on
+ * the field that asks for it (see CHANNEL_CREDENTIAL_FIELDS), because that is
+ * where someone hunting for it is looking; a paragraph under both inputs is easy
+ * to skip.
*/
const SLACK_CREDENTIAL_NOTE =
'You do not need the App-Level Token (xapp-) or the Client Secret. Slack offers the xapp- token right beside the xoxb- one, so it is easy to copy the wrong value.'
diff --git a/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx b/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx
index 531f91b6a..574fad4eb 100644
--- a/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx
+++ b/control-ui/components/__tests__/CreateCommunicationChannelPage.test.tsx
@@ -545,6 +545,30 @@ describe('CreateCommunicationChannelPage — Slack app manifest', () => {
expect(link.getAttribute('rel') ?? '').toMatch(/noreferrer|noopener/)
})
+ it('explains itself when the deployment has no public webhook address', async () => {
+ // Minikube and localhost: no env var and a non-app.* hostname, so
+ // webhookUrlForPath returns a bare path and no manifest can be generated. The
+ // edit page shows a warning naming the missing variable; rendering nothing
+ // here leaves the operator following a doc that promises a manifest, with no
+ // cause shown anywhere. jsdom's hostname is localhost, so simply not stubbing
+ // the env reproduces it.
+ render(
+ <ToastProvider>
+ <CreateCommunicationChannelPage />
+ </ToastProvider>
+ )
+ await goToSlackProviderStep('support-bot')
+ fireEvent.change(document.getElementById('slack-bot-handle')!, {
+ target: { value: 'Evenfire' },
+ })
+
+ expect(screen.queryByText(/display_information:/)).not.toBeInTheDocument()
+ const panel = document.querySelector('.cu-channel-provider-panel')
+ expect(panel?.textContent ?? '').toMatch(
+ /NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL|no public webhook address/i
+ )
+ })
+
it('offers no manifest until the Slack App Name is set', async () => {
// The app name is the manifest's display_information.name. Emitting one with a
// placeholder would install an app under a name the operator never chose.
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 237030c69..047434771 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.412",
+ "version": "0.1.413",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.412",
+ "version": "0.1.413",
"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 21eff9373..d692775df 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.412",
+ "version": "0.1.413",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/docs/how-to/connect-slack.md b/docs/how-to/connect-slack.md
index 9c11767e4..af37276b8 100644
--- a/docs/how-to/connect-slack.md
+++ b/docs/how-to/connect-slack.md
@@ -48,24 +48,18 @@ send to link your account.
8. In Slack, invite the app to the channel you want it in (`/invite @YourApp`),
or open a DM with it.
-**Do not build the app by hand.** The Control UI generates a manifest carrying
-all of this, both Request URLs already filled in, and you get it before the
-channel exists. Skip to [In the Control UI](#in-the-control-ui) and come back
-here only if you want to know what the manifest contains or you are building an
-app without the Control UI.
-
-The generated manifest looks like this:
+For reference, the manifest the Control UI generates looks like this:
```yaml
display_information:
- name: Evenfire
+ name: "Evenfire"
features:
app_home:
home_tab_enabled: false
messages_tab_enabled: true
messages_tab_read_only_enabled: false
bot_user:
- display_name: Evenfire
+ display_name: "Evenfire"
always_online: false
oauth_config:
scopes:
@@ -187,11 +181,14 @@ Two Slack-side traps when pasting it:
- **The field truncates on screen**, often exactly where two channels' URLs
diverge. Press `End` in the field to see the tail before saving.
-Slack does not prompt for a reinstall after you subscribe to the bot events
-above, because the manifest already granted the scopes those events need. That
-is expected, not a failure. If you want one anyway: **Settings → Install App →
-Reinstall to Workspace**, then re-check the bot token, since a reinstall can
-issue a new one.
+Whether Slack prompts for a reinstall after you subscribe to the bot events
+depends on how the app was built. An app installed from the generated manifest
+already holds the scopes those events need, so no prompt appears and that is
+expected. An app built by hand **does** need the matching `*:history` scopes
+granted, and without a reinstall the subscription is accepted while no message
+event ever arrives. If you are repairing such an app, reinstall deliberately
+rather than waiting to be asked: **Settings → Install App → Reinstall to
+Workspace**, then re-check the bot token, since a reinstall can issue a new one.
## On minikube (quickstart stack)
@@ -199,18 +196,30 @@ Complete the [Quickstart](../get-started/quickstart.md) first so the platform
runs.
There is no `.env` shortcut for Slack. `CLERUM_SLACK_BOT_TOKEN` is read only by
-`channel-reader`'s dev-mode resolver when the process runs outside the cluster,
-and is ignored in-cluster, where credentials come from
-`spec.credentialsSecretRef` only. It changes where the token is read from and
-nothing else: Slack is webhook-driven either way, and no code path polls it.
+`channel-reader`'s `DevCredentialsResolver`, and the switch is
+**`CLERUM_DEV_MODE=true`**, not whether the process runs in a cluster
+(`channel-reader/src/credentials.ts`). Setting dev mode on an in-cluster
+deployment therefore does resolve every CommunicationChannel to the same
+env-supplied token. It also only supplies the bot token — there is no
+`CLERUM_SLACK_SIGNING_SECRET`, so the dev path cannot verify a single inbound
+Slack request, which is why real use always comes from
+`spec.credentialsSecretRef`.
The bigger constraint is reachability. `webhook-proxy` runs in the
`webhook-ingress` namespace on port 8095, and the base manifests ship no
Ingress for it (production fronts it with cloudflared). A local minikube is not
reachable from Slack, so expose the proxy through a public tunnel and use
-`<your-public-base>/webhooks/slack/<targetId>` as the Request URL. The Control
-UI only prints the path when `NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL` is
-unset, so prefix it with your own public base.
+`<your-public-base>/webhooks/slack/<targetId>` as the Request URL.
+
+The Control UI resolves that base in two steps: it uses
+`NEXT_PUBLIC_WORKFLOW_APPROVAL_READER_BASE_URL` when set, and otherwise derives
+`webhook.<domain>` from the page's own hostname when that hostname starts with
+`app.`. Only when **neither** applies — the usual minikube and `localhost` case
+— does it fall back to a bare path, and then the Slack panel shows a warning
+instead of a manifest, because a relative `request_url` is invalid to Slack.
+That is the case where you prefix the path with your own public base by hand.
+On an `app.<domain>` deployment the URL is already absolute; prefixing it again
+produces a Request URL Slack cannot verify.
Without that, the Slack app installs fine and the channel saves fine, but no
message ever arrives.