Skip to content

feat(slack): add ignoreOtherMentions channel config#53467

Merged
steipete merged 2 commits into
openclaw:mainfrom
hanamizuki:slack-ignore-other-mentions
Jul 5, 2026
Merged

feat(slack): add ignoreOtherMentions channel config#53467
steipete merged 2 commits into
openclaw:mainfrom
hanamizuki:slack-ignore-other-mentions

Conversation

@hanamizuki

@hanamizuki hanamizuki commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

In busy Slack rooms where requireMention is disabled, OpenClaw can respond to messages explicitly directed at another user or user group. This adds an opt-in per-channel filter for #89625 without changing default behavior.

Why This Change Was Made

  • Add channels.slack.channels.<id>.ignoreOtherMentions, matching the existing Discord configuration concept.
  • Keep the decision in Slack's inbound owner, where native user and user-group mentions and the authenticated bot user ID are available.
  • Treat Slack thread participation differently from Discord: participation is broad and does not count as an explicit bot mention for this filter.
  • Preserve suppressed messages as pending channel history so later bot-directed turns retain useful context.
  • Fail open when the bot user ID is unavailable rather than misclassifying a native mention.
  • Keep TypeScript types, Zod schema, resolved channel config, generated metadata, config baselines, and Slack docs aligned.

User Impact

The new option defaults to false. When enabled for a Slack channel or private channel, messages that mention another user or user group but not the bot are stored as pending context and are not handled. Bot-directed messages, ordinary unmentioned messages, DMs, and group DMs keep their existing behavior.

Evidence

  • node scripts/run-vitest.mjs extensions/slack/src/monitor/message-handler/prepare.test.ts — 100 tests passed.
  • Generated metadata and docs baseline checks passed.
  • Fresh full-branch autoreview: no accepted/actionable findings; best bounded fix, confidence 0.94.
  • Blacksmith Testbox tbx_01kwqracphtj8m49be5xmhpyxy — broad changed gate passed in 10m16s: core/extension production and test types, lint, import cycles, state/storage guards, config guards, and changed-surface checks.
  • Contributor live Slack proof: coworker-only mentions stopped triggering the bot inside a bot-participated thread; explicit bot mentions still triggered it.

Closes #89625.

@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack size: XS labels Mar 24, 2026
@greptile-apps

greptile-apps Bot commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds an ignoreOtherMentions option to Slack channel configuration, mirroring the existing Discord feature. When enabled, messages that mention another user (<@U...>) but do not explicitly mention the bot are dropped — including inside bot-participated threads. The Slack implementation intentionally omits the !implicitMention guard present in Discord because Slack's thread-participation implicit mention fires for every message in a bot thread, which would make the feature ineffective.

Key changes:

  • src/config/types.slack.ts and zod-schema.providers-core.ts: New ignoreOtherMentions?: boolean field with matching Zod validation
  • channel-config.ts: Field threaded through resolveSlackChannelConfig via the existing firstDefined cascade (channel-specific → wildcard)
  • prepare.ts: Drop gate inserted after the control-command block and before the requireMention gate — condition isRoom && ignoreOtherMentions && hasAnyMention && !wasMentioned with a recordPendingHistoryEntryIfEnabled call matching the requireMention pattern

The only gap is test coverage: the Discord counterpart has dedicated unit tests for this path (message-handler.preflight.test.ts lines 620–658), but no equivalent test cases were added on the Slack side.

Confidence Score: 5/5

  • Safe to merge; the logic is correct and consistent with the Discord equivalent. The missing tests are a follow-up nicety, not a blocker.
  • All four changed files are tightly scoped and follow existing patterns. The condition in prepare.ts handles all relevant edge cases correctly (DMs excluded by isRoom, bot-mentioned messages excluded by !wasMentioned, messages with no mentions pass through because hasAnyMention is false). The deliberate omission of the !implicitMention guard is well-documented in comments and the PR description. The only gap is that no new unit tests cover the new branch, but the existing 236 tests confirm no regressions and the feature was manually verified on a live workspace.
  • No files require special attention.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/slack/src/monitor/message-handler/prepare.ts
Line: 472-497

Comment:
**No test coverage for `ignoreOtherMentions`**

The Discord counterpart (`extensions/discord/src/monitor/message-handler.preflight.test.ts`) has dedicated test cases for this feature (e.g. `"drops guild messages that mention another user when ignoreOtherMentions=true"`, `"does not drop @everyone messages when ignoreOtherMentions=true"`), but no equivalent tests were added for the Slack implementation.

Consider adding cases in `prepare.test.ts` or a sibling file covering at least:
- A channel message with `<@U456>` and `ignoreOtherMentions: true` → expect `null`
- A channel message with `<@UBOT> <@U456>` (bot explicitly mentioned) and `ignoreOtherMentions: true` → expect non-null
- A DM with `<@U456>` and `ignoreOtherMentions: true` → expect non-null (DMs are excluded by the `isRoom` guard)
- A channel message with no user mentions and `ignoreOtherMentions: true` → expect non-null

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "feat(slack): add ignoreOtherMentions cha..." | Re-trigger Greptile

Re-review progress:

Comment thread extensions/slack/src/monitor/message-handler/prepare.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9bc878f821

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/slack/src/monitor/message-handler/prepare.ts Outdated
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Mar 24, 2026
@hanamizuki
hanamizuki force-pushed the slack-ignore-other-mentions branch 2 times, most recently from 4ecaa5b to 42c72fa Compare March 26, 2026 14:37
@hanamizuki

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42c72fa87e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/slack/src/monitor/message-handler/prepare.ts Outdated
@hanamizuki
hanamizuki force-pushed the slack-ignore-other-mentions branch from 42c72fa to 8aacf0b Compare March 29, 2026 12:58
@hanamizuki

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8aacf0b0ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/.generated/config-baseline.jsonl Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d28b0c2cb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/slack/src/monitor/message-handler/prepare.ts Outdated
@hanamizuki

Copy link
Copy Markdown
Contributor Author

The 3 failing checks (checks-windows-node-test-1, checks-windows-node-test-4, checks-windows-node-test-6) are Windows CI flaky timeouts — unrelated to this PR's changes.

Errors are Hook timed out in 60000ms in channel-server.test.ts and Test timed out in 120000ms in supervisor.test.ts. All Linux checks pass. Could a maintainer re-run the failed jobs?

@hanamizuki
hanamizuki force-pushed the slack-ignore-other-mentions branch from de5481e to 0337e5d Compare March 31, 2026 11:16

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0337e5d7a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/.generated/config-baseline.jsonl Outdated
@hanamizuki
hanamizuki force-pushed the slack-ignore-other-mentions branch from 0337e5d to f2c0875 Compare March 31, 2026 11:31

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2c0875146

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/.generated/config-baseline.jsonl Outdated
@hanamizuki
hanamizuki force-pushed the slack-ignore-other-mentions branch from c082e1f to 2e37d7f Compare April 1, 2026 04:27
@hanamizuki

Copy link
Copy Markdown
Contributor Author

Rebased on latest upstream/main and regenerated baseline artifacts (config:channels:gen + config:docs:gen).

The two remaining CI failures are pre-existing on upstream/main — unrelated to this PR:

  1. checks-node-test-1channel-import-guardrails.test.ts: fails because extensions/matrix/src/matrix/monitor/ack-config.ts imports via openclaw/plugin-sdk/… instead of a local API barrel. Same failure on upstream/main.
  2. lint:plugins:no-extension-test-core-importsextensions/amazon-bedrock/index.test.ts imports src/plugins/types.js directly. Same failure on upstream/main (introduced by feat(amazon-bedrock): add Bedrock Guardrails support #58588).

Both reproduce locally on a clean checkout of upstream/main.

@hanamizuki
hanamizuki force-pushed the slack-ignore-other-mentions branch 2 times, most recently from 5c23a9c to 0ad297d Compare April 1, 2026 14:12

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ad297d28f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/slack/src/monitor/message-handler/prepare.ts Outdated
@hanamizuki
hanamizuki force-pushed the slack-ignore-other-mentions branch from 715d740 to 0fa84e3 Compare June 5, 2026 16:23
hanamizuki added a commit to hanamizuki/openclaw that referenced this pull request Jun 5, 2026
Cherry-pick from upstream PR openclaw#53467 (0fa84e3).
Mirrors Discord ignoreOtherMentions for Slack channels — drops messages
that mention another user but not the bot, even in bot-participated
threads. Regenerated config baseline and bundled metadata.
@hanamizuki

Copy link
Copy Markdown
Contributor Author

Real behavior proof — tested on a live Slack workspace:

  1. Bot-mentioned message (<@bot> help) → processed ✓
  2. Other-user mention (<@coworker> check this) → dropped ✓
  3. No mention → processed normally ✓
Screenshot 2026-06-07 at 1 21 03 PM

@hanamizuki
hanamizuki force-pushed the slack-ignore-other-mentions branch from 0fa84e3 to 5ec9e3e Compare June 7, 2026 05:23
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 7, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label Jun 7, 2026
@hanamizuki

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@hanamizuki

Copy link
Copy Markdown
Contributor Author

Rebased onto latest upstream/main — the failing checks are pre-existing upstream issues unrelated to this PR:

  • check-additional-runtime-topology-architecture: madge import cycle in src/agents/ (not touched by this PR)
  • check-test-types: TS2345 in extensions/memory-core/doctor-contract-api.test.ts (not touched)
  • check-lint: oxlint unnecessary-assertion warnings in other extensions (not touched)
  • build-artifacts: cascading failure from the above

All Slack-related checks (channels, contracts, boundary tests) pass.

@hanamizuki
hanamizuki force-pushed the slack-ignore-other-mentions branch from 5ec9e3e to 183a3e1 Compare June 7, 2026 08:21
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Jun 7, 2026
@hanamizuki

Copy link
Copy Markdown
Contributor Author

Addressed ClawSweeper review findings:

[P2] Native bot-id certainty — fixed.
Changed the drop guard from canDetectMention (which is true when mention regexes exist, even without botUserId) to Boolean(ctx.botUserId). The gate now only fires when native Slack bot identity is available, preventing false drops in degraded-identity states. Added a regression test covering the botUserId empty + mention regexes present scenario.

[P2] MPIM scope alignment — fixed.
Updated docs (slack.md) and type comment (types.slack.ts) to say "channel/group contexts (not DMs or MPIMs)" — matching the actual runtime behavior where channelConfig is only resolved for isRoom.

[P3] CHANGELOG entry — intentionally kept.
The project has 8000+ Thanks @contributor changelog entries; this is the established convention for contributor PRs. Keeping ours consistent.

@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 7, 2026
hanamizuki and others added 2 commits July 4, 2026 19:56
Mirrors the existing Discord `ignoreOtherMentions` option for Slack
channels. When set on a channel entry, drop channel/group/MPIM messages
that mention another user or subteam but not this bot — the inverse of
`requireMention`. Useful in busy channels where the bot would otherwise
reply to side conversations.

Implementation lives in `prepareSlackMessage` right after the
`allowBots: "mentions"` bot-drop gate and before the `shouldRequireMention`
non-mention drop, so it integrates with the new `messageIngress` ingress
pipeline. The gate is conditional on `canDetectMention` (botUserId
resolvable via `auth.test` or explicit mention regexes configured) to
avoid false drops when we have no reliable way to tell bot vs non-bot
mentions apart.

Slack implicit mentions (thread participation) are intentionally NOT
respected here — they fire for every message in a bot-participated
thread, so honoring them would defeat the feature in any active thread.
The gate matches on `wasMentioned` (explicit) and `hasAnyMention`, with
the existing `shouldBypassMention` override (e.g. authorized commands)
also respected.

Includes config types, zod schema, channel-config resolution,
prepare-message implementation, full test coverage in
`prepare.test.ts`, regenerated channel + docs baselines, and Slack
docs entry.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f03fe0716

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Thread participation is broad on Slack; only an explicit bot mention escapes this gate.
// Native bot identity distinguishes bot pings from other Slack mentions.
const ignoreOtherMentions = channelConfig?.ignoreOtherMentions ?? false;
if (isRoom && ignoreOtherMentions && Boolean(ctx.botUserId) && hasAnyMention && !wasMentioned) {

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.

P2 Badge Apply other-mention filtering to relay activations

In Slack relay mode this condition never fires for routed events because relay-source marks every forwarded event as wasMentioned: true (extensions/slack/src/monitor/relay-source.ts:243-245), including channel_default routes. With channels.slack.mode="relay" and ignoreOtherMentions enabled, a forwarded channel message like <@U456> hey reaches this gate with hasAnyMention=true but wasMentioned=true, so the new filter is bypassed and the bot still handles coworker mentions; base this check on actual bot-mention evidence rather than the relay activation flag.

Useful? React with 👍 / 👎.

@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. triage: dirty-candidate Candidate: broad unrelated surfaces; may need splitting or cleanup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support ignoreOtherMentions config option for Slack channels

2 participants