Skip to content

feat(slack): Add list command to show active and mitigated incidents#194

Open
rgibert wants to merge 17 commits into
mainfrom
rgibert/slack-list-command
Open

feat(slack): Add list command to show active and mitigated incidents#194
rgibert wants to merge 17 commits into
mainfrom
rgibert/slack-list-command

Conversation

@rgibert
Copy link
Copy Markdown
Member

@rgibert rgibert commented May 13, 2026

Add a /ft list (alias /ft ls) slash command that shows all non-private active and mitigated incidents grouped by status. Usable from any channel or DM -- unlike other /ft subcommands, this is a read-only cross-cutting query rather than an action on a specific incident channel.

Output is grouped into Active then Mitigated sections, newest first within each group. Each line shows severity, incident number, title, captain, and a link to the Slack channel.

The query uses select_related("captain") and prefetch_related("external_links") to avoid N+1 queries. Private incidents are excluded entirely since Slack command context does not carry an authenticated Django user.

Agent transcript: https://claudescope.sentry.dev/share/LMXluTDxc8O5rC063_tQKM7h_nJvlTD5Ei9Ype98AyE

rgibert added 2 commits May 13, 2026 15:32
Add handle_list_command that responds with active and mitigated
incidents grouped by status, excluding private and terminal-state
incidents. Includes 8 test cases covering empty state, grouping,
ordering, privacy filtering, and link formatting.

Co-Authored-By: Claude <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/rvyzwlSQ329ffIavjmsM6NVgHwtd802c79Fm0rGkXQ4
Wire handle_list_command into the command dispatcher for both "list"
and "ls" subcommands, add them to KNOWN_SUBCOMMANDS for metrics
tracking, and include the command in help output.

Co-Authored-By: Claude <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/DjJ6t8ZO_sqbk6IHmrGQiPmWd6h3xiPjb_UJw1ZZOYs
Comment thread src/firetower/slack_app/handlers/list_incidents.py Outdated
Calls users.info to check is_restricted/is_ultra_restricted before
returning incident data. Fails open on API errors to avoid blocking
legitimate users.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/xcbdzP6-Bc8Zwpwt0cbJLk-Ux2yggnJtRBcgrkBPa2A
Comment thread src/firetower/slack_app/handlers/list_incidents.py Outdated
Title and captain name are interpolated into Slack mrkdwn without
escaping, allowing crafted titles like <http://evil|click> to inject
clickable links. Uses the existing escape_slack_text helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/RQcgU1pYf87GRjczZdGrgFmHpHz6XbChAMuHshP78PY
Comment thread src/firetower/slack_app/handlers/list_incidents.py Outdated
Comment thread src/firetower/slack_app/handlers/list_incidents.py Outdated
Comment thread src/firetower/slack_app/handlers/list_incidents.py Outdated
@rgibert rgibert self-assigned this May 22, 2026
@rgibert rgibert marked this pull request as ready for review May 22, 2026 18:20
@rgibert rgibert requested a review from a team as a code owner May 22, 2026 18:20
Comment thread src/firetower/slack_app/handlers/list_incidents.py Outdated
rgibert added 3 commits May 22, 2026 14:46
…al responses

Captain displays as a Slack mention (<@SLACK_ID>) when the user has a
Slack external profile, and falls back to the plain name otherwise.
Incident number (INC-XXXX) links to the incident's Slack channel.
All responses are now ephemeral (only visible to the requesting user).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/A8PX9kGW-TK67VAjrWjl2sgD3Kywk09wP5ETMV5xX58
The incident number is already a clickable link to the Slack channel,
so the separate "Slack" link is unnecessary.

Co-Authored-By: Claude <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/ZS6pf4OC9_5JcyynSS5fkTZ_GVpLQv7gVNYnmuilA_Y
Comment thread src/firetower/slack_app/handlers/list_incidents.py Outdated
@rgibert rgibert changed the title feat(slack): Add /ft list command to show active and mitigated incidents feat(slack): Add list command to show active and mitigated incidents May 22, 2026
Comment thread src/firetower/slack_app/handlers/list_incidents.py Outdated
ack()

user_id = body.get("user_id", "")
if client and user_id and _is_slack_guest(client, user_id):
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.

how did you even think of this edge case?? 😂 I would have missed this 10 times out of 10

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All the bots and I are like this 🤞🏻

Copy link
Copy Markdown
Contributor

@spalmurray spalmurray left a comment

Choose a reason for hiding this comment

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

lgtm, one nit

rgibert and others added 3 commits May 22, 2026 15:40
Move is_slack_guest to slack service module, use get_full_name() for
captain display fallback instead of manual name concatenation, and add
proper None guards for captain_id and captain lookups.

Co-Authored-By: Claude <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/UW4oiAwxt8AaiqmO0WMGbIp1yE6uAKyOQCUH3ZF6Lu4
… name

Condense the incident list display to a more scannable format using
lowercase incident tags, bracketed severity, and IC label for captain.

Co-Authored-By: Claude <noreply@anthropic.com>
… name

Condense the incident list display to a more scannable format using
lowercase incident tags, bracketed severity, and IC label for captain.

Co-Authored-By: Claude <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/CbeokUpMjZnvEAgxv5ACiHS8oyvqzOrXPb-EmOkopEU
Comment thread src/firetower/integrations/services/slack.py
rgibert added 4 commits May 22, 2026 15:58
Replace plain-text space-aligned help output with Slack Block Kit
section fields for proper two-column layout in proportional fonts.

Co-Authored-By: Claude <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/uI4hHgeuAXoTs7IgBuaTGHgLwMRifvSF3JBOdMzbD4w
Comment thread src/firetower/integrations/services/slack.py
Comment thread src/firetower/integrations/services/slack.py Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 80aaf1f. Configure here.

Comment thread src/firetower/integrations/services/slack.py Outdated
Return False instead of True when the Slack API is unreachable so
non-guest users are not blocked by transient API failures.

Co-Authored-By: Claude <noreply@anthropic.com>

Agent transcript: https://claudescope.sentry.dev/share/XVBZMCxvTAN6rXml1HFtCbw8mT8Y5zeZIwy3GcO80Gs
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