feat(slack): add Slack integration with @mention-based task submission#42
feat(slack): add Slack integration with @mention-based task submission#42isadeks wants to merge 1 commit intoaws-samples:mainfrom
Conversation
aef74c1 to
833c770
Compare
Adds full Slack integration enabling users to submit coding tasks by mentioning @shoof in any channel or DM, with real-time emoji reactions and threaded notifications showing task progress. Key features: - @mention task submission with natural language repo extraction - Emoji reaction progression: 👀 → ⌛ → ✅ - Threaded notifications (created, started, completed/failed) - Cancel button with instant feedback - DM support for private task submissions - OAuth multi-workspace install flow - `bgagent slack setup` CLI wizard for zero-friction onboarding - Account linking via /bgagent link New files: - CDK constructs: SlackIntegration, SlackInstallationTable, SlackUserMappingTable - Lambda handlers: events, commands, command-processor, interactions, oauth-callback, link, notify - Shared utilities: slack-verify, slack-blocks - CLI: slack.ts (setup, link commands) - Docs: SLACK_SETUP_GUIDE.md with screenshots
|
Thank you @isadeks ! Great addition From a first pass review: What's Done Well
The inbound path (task creation) is well-architected. The existing createTaskCore() function is a genuinely clean seam — it accepts a TaskCreationContext with a channelSource tag and My architectural problem: This PR hardwires Slack as the only notification consumer, bypassing the opportunity to build a proper event fan-out layer. Today on main, the TaskEventsTable is a pull-only audit log — no streams, no push notifications. When this PR adds stream: dynamodb.StreamViewType.NEW_IMAGE to the events table, it's
The current slack-notify.ts (333 lines) mixes three concerns that should be separated: Event routing, Message rendering, and Delivery + state management. If you separate the routing concern, each future adapter only needs to implement rendering + delivery. The slack-notify.ts handler currently does all three, which means the next adapter would duplicate the routing and deduplication logic. ALso, the opaque bag pattern (channel_metadata: Record<string, string>) works because each adapter writes and reads its own keys. But it means the task record accumulates state for the active channel's notification lifecycle (message timestamps, thread context). This couples the task record to the notification system. A cleaner approach would store notification state in a separate table or in the channel adapter's own state, not in the task's channel_metadata. I don't want to block the PR for the notification architecture alone since this is the first channel we are adding, so premature abstractions is a real risk. What I would like to see in the current PR:
Some captured issues in the current code, please revise once the recommendations above are implemented to see if they are still relevant:
Thank you ! Also, @scoropeza since you are working on the related task, could you please have a look to see if this is aligned with your work ? Thank you ! |
…triage
Hands-on testing against the deployed stack revealed two UX gaps in the
default ``bgagent status`` compact snapshot:
1. A ``pr_review`` task renders indistinguishably from a ``new_task``,
so a user checking status on a review submission has no default-
view confirmation the task_type was set as intended.
2. A FAILED / CANCELLED / TIMED_OUT task shows the terminal status
but not *why*. Users had to either re-run with ``--wait`` (which
blocks), switch to ``--output json``, or grep ``bgagent events``
to recover the error classification that the API already returns.
Both fields are already present on the ``TaskDetail`` payload that
``formatStatusSnapshot`` receives — the previous template just did not
render them. This is pure render-layer plumbing; no new API calls, no
backend changes.
Changes in ``cli/src/format.ts::formatStatusSnapshot``:
- Renders ``Type: pr_iteration (PR aws-samples#42)`` / ``Type: pr_review (PR aws-samples#7)``
after ``Repo:`` when ``task_type !== 'new_task'``. Matches the
``formatTaskDetail`` treatment (``Type:`` line at format.ts:29-31)
so the compact and detailed views agree. Omits the ``(PR #N)``
suffix defensively if ``pr_number`` is null.
- Renders ``Reason: <category>: <title>`` after ``Cost:`` for
non-COMPLETED terminal statuses, prefering
``error_classification.{category, title}`` from the server's
classifier and falling back to a trimmed ``error_message`` if no
structured classification is available. Emits nothing when neither
is populated, or when the task is still running or COMPLETED —
so the line never appears as a dangling ``Reason:`` with no value.
Example (before → after):
Before (FAILED task, user had to chase error in events):
Task 01KQ… — FAILED (3m 12s total)
Repo: scoropeza/agent-plugins
Turn: 8 / 20
Last milestone: agent_execution_complete (2s ago)
Current: task failed
Cost: $0.18 / budget $0.05
Last event: 2026-05-04T21:25:04Z
After:
Task 01KQ… — FAILED (3m 12s total)
Repo: scoropeza/agent-plugins
Turn: 8 / 20
Last milestone: agent_execution_complete (2s ago)
Current: task failed
Cost: $0.18 / budget $0.05
Reason: compute: Exceeded max budget
Last event: 2026-05-04T21:25:04Z
Tests: +10 regression tests covering Type line for pr_iteration /
pr_review / new_task / missing-pr-number, Reason line for
classification / fallback-message / neither / CANCELLED / TIMED_OUT /
COMPLETED-never-emits / RUNNING-never-emits. CLI suite: 181 passing
(was 171).
Refs: PR aws-samples#52 hands-on testing feedback
Summary
@Shoofmentions or DMs, receive threaded notifications with emoji reaction progressbgagent slack setupCLI wizard for zero-friction onboarding/bgagent linkslash commandWhat's included
CDK Constructs: SlackIntegration, SlackInstallationTable, SlackUserMappingTable
Lambda Handlers: slack-events, slack-commands, slack-command-processor, slack-interactions, slack-oauth-callback, slack-link, slack-notify
Shared Utilities: slack-verify (HMAC signature verification), slack-blocks (Block Kit renderer)
CLI:
bgagent slack setup(interactive wizard),bgagent slack link <code>(account linking)Docs: SLACK_SETUP_GUIDE.md with screenshots, Developer Guide updated
UX Flow
@Shoof fix the bug in org/repo#42Other changes (non-Slack)
cdk deploy -c blueprintRepo=org/repoorBLUEPRINT_REPO=org/repo— no longer requires editingagent.tsdirectly. Developer Guide updated with the new method.UpdateTraceSegmentDestinationsetup that blocks first-time deploys. Disabled to unblock new users; re-enable once the prerequisite is documented more clearly.Test plan
bgagent slack setup— full flow from scratch (deploy, create app, credentials, install, link)@Shoofmention in channel — happy path with reactions and threaded notifications/bgagent helpand/bgagent link-c blueprintRepo=org/repodeploys with custom repo onboarded