feat(slack): native Sim app trigger mode via the preview-gated slack_v2 block#5892
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Trigger config — The Slack credential field accepts OAuth accounts and custom bots ( Deploy ( Tests — New coverage for custom-bot routing, cross-workspace rejection, invalid bot/OAuth paths, unsupported Sim-app events, successful OAuth Reviewed by Cursor Bugbot for commit b59d165. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryAdds native Sim Slack-app trigger deployment alongside reusable custom bots.
Confidence Score: 5/5The pull request appears safe to merge. No blocking failure remains. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Slack trigger deployment] --> B{Credential resolves as custom bot?}
B -->|Yes| C[Validate workflow workspace]
C --> D[Route through slack by credential ID]
B -->|No| E[Resolve OAuth credential in workflow workspace]
E --> F[Validate shared-app event]
F --> G[Resolve credential owner's token]
G --> H[Call Slack auth.test]
H --> I[Route through slack_app by team ID]
Reviews (2): Last reviewed commit: "fix(slack): address review — set credent..." | Re-trigger Greptile |
…ck_v2 block Restore the native Sim Slack app mode for the slack_oauth trigger using a single-credential-picker design. The trigger is only reachable through the preview-gated slack_v2 block, so the mode inherits that gate — no separate env flag. - Re-add SIM_SUBSCRIBED_EVENTS / SLACK_SIM_EVENT_OPTIONS derived exports. - Merge the trigger credential picker (credentialKind: 'any') so it lists Sim OAuth accounts and reusable custom bots together, mirroring the slack_v2 block. - Event dropdown narrows to the Sim app's subscribed events when an OAuth account is selected, all events for a custom bot (resolved client-side from the warmed credential list). - Deploy branch discriminates by the RESOLVED credential, not a UI field: a bot credential routes by credential id (custom app); otherwise validate the event against SIM_SUBSCRIBED_EVENTS, resolve the credential owner's token, derive routingKey from Slack team_id (auth.test), and route on the shared Sim app. - The ingest endpoint and team_id fan-out routing already existed on staging. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018asmKsWQ5Vi7T7wD9uHofz
…rkspace, drop event narrowing Review round 1 (Greptile 4/5 + Cursor Bugbot): - deploy.ts: the native Sim-app (OAuth) branch now sets providerConfig.credentialId (runtime token resolution in the slack provider and credential-disconnect cleanup both key slack_app rows on it — without it, file downloads / reaction text fail and disconnect leaves the webhook active). - deploy.ts: resolve the OAuth credential through resolveTriggerCredentialId (workspace- and oauth-scoped) so a pasted foreign/other-tenant credential id can't bind to the workflow; use the resolved canonical id for token owner lookup + routing. - deploy.ts: a deleted/secretless custom bot credential (getSlackBotCredential → null but a service_account row exists) now returns the "reconnect the bot" error instead of the misleading "connected Slack account" message. - oauth.ts: drop the credential-based event-option narrowing. The shared dropdown framework doesn't revalidate a stored value when its dependency changes, so switching a custom bot → Sim account left an orphaned event that failed deploy with a 400. The event picker now offers all events; the deploy path is the authoritative gate. - tests: add broken-bot and workspace-not-resolvable cases; assert credentialId is set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018asmKsWQ5Vi7T7wD9uHofz
0a6c39e to
b59d165
Compare
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit b59d165. Configure here.
What
Restores the native Sim Slack app mode for the
slack_oauthtrigger using the single-credential-picker design (not the oldappTypedropdown from #5323).The trigger is only reachable through the preview-gated
slack_v2block, so the native mode inherits that gate — no separate env flag needed. (The original brief called forNEXT_PUBLIC_SLACK_SIM_APP_ENABLED; we dropped it since the slack_v2 preview already provides the staging-only gating.)The official-app ingest endpoint and
team_idfan-out routing already existed and are live on staging (PR #5323 backend survived #5800). This PR re-wires the picker + deploy path to reach them.Changes
triggers/slack/shared.ts— re-add theSIM_SUBSCRIBED_EVENTSandSLACK_SIM_EVENT_OPTIONSderived exports (removed by improvement(slack): merge slack_v2 auth into one credential picker for accounts and custom bots #5800).triggers/slack/oauth.ts— single credential picker (credentialKind: 'any') lists Sim OAuth accounts and reusable custom bots together, mirroring the slack_v2 block. The event dropdown resolves the selected credential's kind client-side (from the warmed credential list) and offersSLACK_SIM_EVENT_OPTIONSfor an OAuth account,SLACK_ALL_EVENT_OPTIONSfor a custom bot.lib/webhooks/deploy.ts— theslack_oauthdeploy branch discriminates by the resolved credential, not a UI field:getSlackBotCredentialsucceeds → custom bot path (route by credential id), unchanged.eventType ∈ SIM_SUBSCRIBED_EVENTS(400), resolve the credential owner's token (not the deploying actor's), deriveroutingKeyfrom Slackteam_idviaauth.test, route onslack_appwith no path.lib/webhooks/deploy.test.ts— exportresolveWebhookConfigForBlockand add coverage for: custom-bot routing, cross-workspace bot rejection, non-simSubscribedevent → 400, OAuth account →team_idrouting (owner's token), and token-resolution failure → 400.Checks
bunx vitest run lib/webhooks triggers/slack— 518 passedbun run type-check— no new errors (5 pre-existing better-auth errors unchanged)bun run lint:check— cleanbun run apps/sim/scripts/check-block-registry.ts origin/staging— passcheck:api-validation/check:client-boundary— pass🤖 Generated with Claude Code
https://claude.ai/code/session_018asmKsWQ5Vi7T7wD9uHofz