Skip to content

feat(slack): add opt-in scoped presence events - #108510

Merged
steipete merged 6 commits into
mainfrom
feat/slack-presence-events
Jul 16, 2026
Merged

steipete merged 6 commits into
mainfrom
feat/slack-presence-events

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #108507

What Problem This Solves

Slack agents cannot receive scoped presence changes through the Events API or Socket Mode. Operators who want context-aware return greetings otherwise need separate polling, routing, and deduplication logic, while broad workspace presence notifications would be noisy and invasive.

Why This Change Was Made

Add opt-in off|auto|on presence polling at the Slack account and channel levels, with off as the default. OpenClaw observes only accepted human messages, polls a bounded set of recent eligible participants, routes an away to active transition to that person's latest eligible conversation, and applies a durable eight-hour account/user cooldown.

auto covers recent DMs, MPIMs, and threads with at most eight observed humans. on also covers larger threads and top-level channels. Initial samples only establish a baseline. Enterprise Grid org-wide installs remain excluded.

User Impact

Slack operators can explicitly enable tailored presence greetings without exposing every workspace member's status to the agent. The generated event asks the agent to consult memory/wiki and known timezone context before deciding whether one short greeting is appropriate; silence remains valid.

Existing installations do not start a timer or make presence API calls because the default remains off.

Evidence

  • Blacksmith Testbox tidal-barnacle-2fb9 (tbx_01kxm2avtyv5mc5125t11eq7ww): post-fix Slack lint, extension production/test typechecks, and 34 focused tests passed.
  • Blacksmith Testbox: pnpm build passed in 1m52s after the final implementation change.
  • Full pnpm check:changed passed formatting, generated SDK baseline, dependency/plugin boundaries, all four typecheck lanes, and full core lint. Its only findings were three mechanical Slack lint rules; those were fixed and the touched lint surface was rerun green.
  • Autoreview: full feature pass clean (0.84); post-lint-fix pass clean (0.93).
  • Generated config schema exposes off|auto|on at root, account, root-channel, and account-channel paths.
  • Live Slack read-only proof is blocked: the available bot credential returns invalid_auth. No Slack message was sent.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: slack Channel integration: slack size: L maintainer Maintainer-authored PR labels Jul 16, 2026
@steipete
steipete force-pushed the feat/slack-presence-events branch from 26a6082 to 300ebdf Compare July 16, 2026 00:03
@steipete steipete self-assigned this Jul 16, 2026

@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: 02bbad4f7f

ℹ️ 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".


const pruneTargets = (now: number) => {
for (const [key, target] of targets) {
if (now - target.lastActivityAtMs >= SLACK_PRESENCE_TARGET_TTL_MS) {

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 Prune stale presence participants

When a channel/thread remains active, this expiry only looks at the target's lastActivityAt; individual participants entries never age out even though each stores its own observed timestamp. With presenceEvents.on on a busy top-level channel, or a long-lived thread, anyone who sent one accepted message can stay in candidates indefinitely and later be polled/woken back into a conversation they have not used recently. Prune participants whose observed time is older than SLACK_PRESENCE_TARGET_TTL_MS before building eligibility/candidates.

Useful? React with 👍 / 👎.

@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: 41e5b8adec

ℹ️ 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 on lines +99 to +106
const channelType = prepared.message.channel_type;
const autoEligibleKind = prepared.isDirectMessage
? "direct"
: channelType === "mpim"
? "group"
: threadId
? "thread"
: "channel";

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 Preserve resolved MPIM type for auto presence

When presenceEvents.mode is auto and Slack delivers an MPIM message without channel_type, this reclassifies the prepared message from the raw event only. The prepare path already resolves missing channel types through resolveSlackConversationContext, but that result is not carried here; for G-prefixed MPIMs channelType stays undefined, autoEligibleKind becomes "channel", and the guard below returns null, so the documented auto MPIM polling never starts for those events. Carry the resolved group-DM/channel type (or an isGroupDm flag) into the prepared message before deciding eligibility.

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready.

  • Behavior: Slack presence events are opt-in at account/channel scope; default remains off, so absent config creates no monitor, timer, state store, or Slack presence API calls.
  • Scope/dedupe: auto tracks only recent DMs, MPIMs, and threads with at most eight observed humans; excluded top-level channels never consume target capacity. on is the explicit larger-conversation override. First samples seed silently; away-to-active transitions use an eight-hour durable account/user cooldown.
  • Focused proof on Blacksmith Testbox tbx_01kxm5ap1tqj25wckzy3s7tfe3 (Actions run 29461642541):
    • pnpm format:check extensions/slack/src/monitor/presence-monitor.ts extensions/slack/src/monitor/presence-monitor.test.ts
    • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/slack/src/monitor/presence-monitor.ts extensions/slack/src/monitor/presence-monitor.test.ts
    • pnpm tsgo:extensions
    • pnpm tsgo:extensions:test
    • pnpm test extensions/slack/src/monitor/presence-monitor.test.ts extensions/slack/src/monitor/presence-cooldown-store.test.ts extensions/slack/src/config-schema.test.ts — 35 passed.
  • Broader proof: pnpm deadcode:exports, pnpm docs:map:check, full pnpm build, and full pnpm check:changed passed on Blacksmith Testbox runs. Exact-head GitHub CI run 29461884433 passed; PR checks: 82 passed, 33 skipped, zero failed/pending.
  • Review: native review artifacts validate with zero findings. Autoreview found the excluded-channel capacity issue; fix plus regression rerun clean at 0.95.
  • Known gap: the available Slack bot credential returns invalid_auth, so live away-to-active Slack E2E could not run. No Slack message was sent. Official API/types, generated config, focused behavior, build, and exact-head CI are proven.

@steipete
steipete merged commit 9317aad into main Jul 16, 2026
118 checks passed
@steipete
steipete deleted the feat/slack-presence-events branch July 16, 2026 00:43
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 16, 2026
* feat(slack): add opt-in presence events

* style(slack): satisfy presence lint rules

* chore: keep release changelog centralized

* fix(slack): satisfy presence integration gates

* fix(slack): preserve eligible presence targets
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* feat(slack): add opt-in presence events

* style(slack): satisfy presence lint rules

* chore: keep release changelog centralized

* fix(slack): satisfy presence integration gates

* fix(slack): preserve eligible presence targets
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 maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(slack): add opt-in scoped presence events

1 participant