Repository navigation
feat(slack): add opt-in scoped presence events - #108510
Conversation
26a6082 to
300ebdf
Compare
There was a problem hiding this comment.
💡 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) { |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
💡 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".
| const channelType = prepared.message.channel_type; | ||
| const autoEligibleKind = prepared.isDirectMessage | ||
| ? "direct" | ||
| : channelType === "mpim" | ||
| ? "group" | ||
| : threadId | ||
| ? "thread" | ||
| : "channel"; |
There was a problem hiding this comment.
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 👍 / 👎.
|
Land-ready.
|
|
Merged via squash.
|
* 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
* 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
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|onpresence polling at the Slack account and channel levels, withoffas the default. OpenClaw observes only accepted human messages, polls a bounded set of recent eligible participants, routes anawaytoactivetransition to that person's latest eligible conversation, and applies a durable eight-hour account/user cooldown.autocovers recent DMs, MPIMs, and threads with at most eight observed humans.onalso 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
tidal-barnacle-2fb9(tbx_01kxm2avtyv5mc5125t11eq7ww): post-fix Slack lint, extension production/test typechecks, and 34 focused tests passed.pnpm buildpassed in 1m52s after the final implementation change.pnpm check:changedpassed 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.off|auto|onat root, account, root-channel, and account-channel paths.invalid_auth. No Slack message was sent.