Skip to content

feat: reply with the outcome in the slack bot thread (CM-1841) - #4924

Merged
ulemons merged 2 commits into
mainfrom
feat/CM-1841-bot-thread-replies
Oct 13, 2026
Merged

ulemons merged 2 commits into
mainfrom
feat/CM-1841-bot-thread-replies

Conversation

@ulemons

@ulemons ulemons commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Last PR of the onboarding-core sequence (after #4916, #4918, #4919): every outcome of a request made through the Slack bot is posted back in the thread where the bot was mentioned.

  • @crowd/slack: parseSlackPermalink(url) extracts channel, ts and parent thread from the permalink stored as sourceUrl (honours ?thread_ts= when the mention was already inside a thread); replyInSlackThread(sourceUrl, text) posts with the bot token.
  • @crowd/project-onboarding: botThreadReply.ts holds the reply texts (skipped, review, auto-apply disabled, onboarded, error) with mrkdwn escaping and reason truncation. buildInsightsProjectUrl replaces the duplicated Insights URL constant in the onboarding worker.
  • Evaluation worker: for slack-bot rows a skip (routing or LLM) replies in the thread instead of the webhook alert; after the review card is posted the thread gets "needs a human review"; with CROWD_ONBOARDING_AUTO_APPLY=false the removed row gets "automatic onboarding is disabled". GitHub discussion rows keep the webhook alerts.
  • Onboarding worker: onboarded replies with the Insights link (or "connected to its existing project" for create_integration / update_integration), error replies with the reason, and a new notifySkippedBotRequest activity re-reads the row and replies with its skipReason. All replies run as notify activities with a single attempt (see CM-1791).
  • Backend: a reject from the review channel replies in the bot thread with the reason. Approve does not reply, the onboarding worker does once it finishes.

Deployment note

automatic_onboarding_worker only used incoming webhooks so far: it now needs CROWD_SLACK_BOT_TOKEN to post thread replies. Backend and projects_evaluation_worker already have it.

Test plan

  • Unit tests: permalink parsing and thread reply, reply builders, immediate onboarding plan, review decision reject reply
  • pnpm lint --deny-warnings, pnpm format, pnpm tsc-check
  • Staging: mention the bot with a known LF repo, reject the card, check the thread; mention a non-LF repo with auto-apply on, check the onboarded reply

Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 07:52
@cursor

cursor Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Adds bot-token thread posts across evaluation, onboarding, and review paths; mis-parsed permalinks or missing CROWD_SLACK_BOT_TOKEN on automatic_onboarding_worker would silently skip user-facing feedback but should not corrupt catalog state.

Overview
Slack-bot project catalog requests now get outcome replies in the original mention thread (via stored sourceUrl), instead of relying only on review-channel webhooks for human-visible feedback.

New plumbing: @crowd/slack adds permalink parsing and replyInSlackThread; @crowd/project-onboarding centralizes reply copy (skipped, review, auto-apply off, onboarded, error) with escaping/truncation and buildInsightsProjectUrl.

Evaluation worker routes slack-bot skips, “posted to review,” and auto-apply-disabled removals to the thread; GitHub discussion rows still use skip/onboard alerts. Immediate-onboarding refs carry sourceUrl so disabled auto-apply can notify after row deletion (including retry/idempotency when the row was already removed).

Onboarding worker threads onboarded/success, errors, and newly skipped outcomes (notifySkippedBotRequest); distinguishes already-skipped from fresh skipped so only new skips trigger replies. Backend review reject also replies in the thread (approve still waits for onboarding worker).

Failed thread posts are logged and must not fail the surrounding Temporal batch.

Reviewed by Cursor Bugbot for commit c755a2d. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Concurrent onboarding runs can send duplicate skipped-outcome replies for the same request.

1 open finding
What changed in this PR

Adds Slack thread replies for onboarding outcomes across evaluation, onboarding, and review flows.

Changes:

  • Parses Slack permalinks and posts threaded replies.
  • Adds standardized outcome messages and Insights links.
  • Connects evaluation, onboarding, and rejection outcomes to Slack notifications.
File Description
services/​libs/​slack/​src/​threadReply.ts Adds permalink parsing and threaded replies.
services/​libs/​slack/​src/​threadReply.test.ts Tests parsing and posting behavior.
services/​libs/​slack/​src/​index.ts Exports thread-reply utilities.
services/​libs/​project-onboarding/​src/​index.ts Exports reply builders.
services/​libs/​project-onboarding/​src/​botThreadReply.ts Builds standardized outcome messages.
services/​libs/​project-onboarding/​src/​botThreadReply.test.ts Tests message construction.
services/​apps/​projects_evaluation_worker/​src/​workflows/​evaluateProjects.ts Notifies requests removed when auto-apply is disabled.
services/​apps/​projects_evaluation_worker/​src/​types.ts Adds notification data to onboarding references.
services/​apps/​projects_evaluation_worker/​src/​activities/​immediateOnboarding.ts Preserves source permalinks in plans.
services/​apps/​projects_evaluation_worker/​src/​activities/​immediateOnboarding.test.ts Updates expected plan references.
services/​apps/​projects_evaluation_worker/​src/​activities/​activities.ts Sends skip, review, and disabled replies.
services/​apps/​automatic_onboarding_worker/​src/​workflows/​onboardProjects.ts Dispatches skipped-request replies.
services/​apps/​automatic_onboarding_worker/​src/​activities/​discussionRequestAlert.ts Reuses the shared Insights URL builder.
services/​apps/​automatic_onboarding_worker/​src/​activities/​discussionRequestAlert.test.ts Removes obsolete provenance tests.
services/​apps/​automatic_onboarding_worker/​src/​activities/​activities.ts Sends onboarding outcome replies.
backend/​src/​services/​slack/​reviewDecisionCommand.ts Replies when review requests are rejected.
backend/​src/​services/​slack/​reviewDecisionCommand.test.ts Tests rejection and approval notifications.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +83 to +85
if (outcome === 'skipped') {
try {
await notifyActivities.notifySkippedBotRequest(project)

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@ulemons ulemons self-assigned this Oct 13, 2026
…cross retries (CM-1841)

Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
@ulemons

ulemons commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Addressed both findings in the follow-up commit: onboardAndUpdateProject now returns already-skipped when another run recorded the skip, so only the run that applied it replies in the thread; applyImmediateOnboarding counts a row that no longer exists as removed by an earlier attempt, so a retried activity still returns it and the auto-apply reply is posted.

Copilot AI balanced review requested due to automatic review settings October 13, 2026 08:15

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c755a2d. Configure here.

if (current?.action === 'skip') {
log.info({ id: project.id, repoUrl: project.repoUrl }, 'Project already skipped.')
return 'skipped'
return 'already-skipped'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retry drops skipped thread reply

Medium Severity

resolveUnclaimedOutcome returns already-skipped whenever action is already skip, including when an earlier attempt of this same activity wrote that skip and then failed before Temporal stored the result. onboardProjects posts the thread reply only for skipped, and onboardAndUpdateProject is allowed a second attempt, so that retry never sends the outcome.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c755a2d. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An activity retry can suppress a required skip reply, and embedded code fences can break reason formatting.

2 open findings
Previously missed (1)

In code that hasn't changed since last review

Medium severity Embedded backticks break skip reason formatting

services/​libs/​project-onboarding/​src/​botThreadReply.ts:23

A reason containing an embedded triple-backtick closes this code block early, so the remainder is rendered as mrkdwn instead of as the quoted reason. This is plausible for LLM-generated skip reasons and breaks the reply formatting; neutralize embedded fences before wrapping the text.

🧠 Review effort: Balanced

@ulemons

ulemons commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Both follow-up findings describe the same case: a worker crash between the skip commit and the activity result being recorded, on the onboarding worker's only skip path (deleted Insights project). Telling that retry apart from a competing run needs a notification marker on the row; without it the choice is between a lost reply and a duplicate one, and the pipeline already prefers a lost notification (CM-1791). Leaving it as is for now, a marker column can follow in a separate ticket if it shows up in practice.

@ulemons
ulemons merged commit 653fd33 into main Oct 13, 2026
14 checks passed
@ulemons
ulemons deleted the feat/CM-1841-bot-thread-replies branch October 13, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants