Skip to content

Sync #core channel topic with on-call assignee#8

Merged
ewels merged 3 commits into
mainfrom
claude/slack-topic-automation-x2Lc2
May 18, 2026
Merged

Sync #core channel topic with on-call assignee#8
ewels merged 3 commits into
mainfrom
claude/slack-topic-automation-x2Lc2

Conversation

@ewels
Copy link
Copy Markdown
Member

@ewels ewels commented May 18, 2026

Summary

Add automatic synchronization of the #core channel topic to reflect the current week's on-call assignee. The topic is updated whenever the on-call roster changes (via /nf-core on-call switch or /nf-core on-call reboot) and on scheduler startup, with deduplication to avoid spamming the channel with system messages.

Changes

  • New function sync_oncall_topic() in scheduler/oncall_jobs.py:

    • Fetches the current week's roster entry and formats the topic as "On call: <@USER_ID>" or clears it if unassigned
    • Reads the current channel topic via conversations_info and only calls conversations_setTopic if the topic differs
    • Gracefully handles missing channel resolution, API failures, and permission errors with logging
    • All exceptions are swallowed so callers (scheduler, switch, reboot) never fail due to topic-update issues
  • Integration points:

    • Called on scheduler startup in run_oncall_scheduler()
    • Called after roster changes in _send_channel_announcement() (weekly Monday job)
    • Called after manual switch in handle_oncall_switch()
    • Called after reboot in handle_oncall_reboot()
  • Comprehensive test coverage in TestSyncOncallTopic and TestSyncOncallTopicNoChannel:

    • Topic update when different
    • Deduplication when topic already matches
    • Topic clearing when no assignee or no roster entry
    • No-op when topic already empty and unassigned
    • Graceful handling of conversations_info and conversations_setTopic failures
    • No-op when channel cannot be resolved

Implementation Details

  • Uses current_week_start() helper to determine the active week
  • Imports get_roster_entry from db/oncall to fetch the current assignee
  • Deduplication logic prevents redundant Slack system messages on every scheduler tick or restart
  • Best-effort approach: topic sync failures are logged but never propagate to callers

https://claude.ai/code/session_012pZCGBLwNVz4WHGWMaErHD

claude added 3 commits May 18, 2026 09:21
Adds sync_oncall_topic() that sets the #core topic to
"On call: <@user>" via conversations.setTopic. Hooked into the Monday
announcement, switch, reboot, and scheduler startup so the topic
tracks the roster without manual intervention. Diffs against the
current topic before setting to avoid Slack's "X set the channel
topic" system message spamming the channel on every restart.

Requires the bot token to have the groups:write.topic scope.
Previously set the topic to "On call: (no one assigned)" on
unassigned weeks; now clears it entirely so the channel topic is
empty when there's nothing to announce.
- Replace inline monday_of_week(today).isoformat() with existing
  current_week_start() helper.
- Replace list_roster + filter with direct get_roster_entry point
  lookup (one DynamoDB GetItem instead of querying all future weeks).
- Drop the try/except around sync_oncall_topic() at scheduler startup
  since the helper already swallows and logs all exceptions.
@ewels ewels merged commit aa10498 into main May 18, 2026
3 checks passed
@ewels ewels deleted the claude/slack-topic-automation-x2Lc2 branch May 18, 2026 09:54
ewels added a commit that referenced this pull request May 26, 2026
…topic sync

The on-call Monday announcement (added March) and channel topic sync (added
in #8) both depend on conversations.list / setTopic, which require channel
scopes that were never documented. The bot has been silently failing both
since the announcement feature shipped.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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