feat(incidents): Add skip-paging option for self-handled P0/P1 incidents#254
feat(incidents): Add skip-paging option for self-handled P0/P1 incidents#254rgibert wants to merge 5 commits into
Conversation
Adds a "Skip paging on-call responders" checkbox to the /inc new modal that appears (and defaults to checked) when severity is P0 or P1. When selected, both PagerDuty paging and on-call channel invites are skipped. The flag is transient -- it threads from the Slack modal through serializer context to the incident hooks at creation time, with no model changes. The severity select now uses dispatch_action to dynamically show/hide the skip-paging option via views.update when the user changes severity. Closes RELENG-833 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/_VGnoulIKkldtN9n9qeKgA1BrEzRNdYIUxYb9B11C2o
The serializer test expected on_incident_created(incident) without the new skip_paging kwarg. The two new handler tests needed HOOKS_ENABLED=True to reach the on_incident_created call path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/uOhBQs8tSIs_BIgGrBMKGlxijRPYmS3xP0YXebZtObc
When a user changes severity in the modal, handle_severity_action now reads the current options_block selections from view state and threads them through to _build_options_block so initial_options reflects the user's prior choices (e.g. private) rather than resetting them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/08Y9vY0PBATSmZuY5L6EAGyLKxFKk0sRIBUBbK-jk5U
When a user first selects P0/P1, skip_paging was not in the prior selections (it did not exist at the previous severity), so _build_options_block received an empty set and skipped the default-on branch. Now handle_severity_action injects skip_paging into the selected values when the new severity is high and skip_paging is not already present, ensuring it renders checked on first appearance. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/ADzF8zl8QmltQGscnYCK808rg5r0ERyZGJtS2FN9m4M
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3f893ef. Configure here.
| selected_values = {opt.get("value") for opt in prior_selections} | ||
|
|
||
| if severity in HIGH_SEVERITIES and "skip_paging" not in selected_values: | ||
| selected_values.add("skip_paging") |
There was a problem hiding this comment.
Severity change rechecks skip paging
Medium Severity
In handle_severity_action, when severity is P0/P1 the code adds skip_paging to selected_values whenever it is missing. That runs on every severity change, so a user who unchecked “Skip paging on-call responders” to allow paging can have the option forced back on when they switch between high severities, suppressing PagerDuty and on-call invites contrary to their choice.
Reviewed by Cursor Bugbot for commit 3f893ef. Configure here.
| if severity in HIGH_SEVERITIES and "skip_paging" not in selected_values: | ||
| selected_values.add("skip_paging") |
There was a problem hiding this comment.
Bug: The "Skip paging" checkbox is incorrectly re-checked if a user unchecks it, changes to a non-high severity, and then changes back to a high severity.
Severity: MEDIUM
Suggested Fix
Modify the handle_severity_action handler to preserve the user's choice for skip_paging across severity changes. The logic should not automatically re-add the skip_paging default if the user has previously interacted with the incident creation form. This could involve checking the prior state more carefully before injecting default values.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/firetower/slack_app/handlers/new_incident.py#L276-L277
Potential issue: When a user creates a high-severity incident (P0/P1), explicitly
unchecks the "Skip paging on-call responders" option, changes the severity to a non-high
level (e.g., P2), and then changes it back to a high severity, the "Skip paging" option
is incorrectly re-checked. This happens because the logic at `handle_severity_action`
re-injects the `skip_paging` default when it's not found in the view's state. The state
is cleared of this option when switching to a non-high severity, causing the system to
forget the user's explicit choice to uncheck the box, leading to unwanted PagerDuty
pages.
Did we get this right? 👍 / 👎 to inform future reviews.
handle_severity_action now extracts user_id from the action body and passes it to _build_new_incident_modal so the captain block retains its initial_user when views.update rebuilds the modal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/Qeq8_btcFr1qAGYpHcYenuDZuFQwAdU2EoYfA3V5dnI


Summary
/inc newSlack modal, grouped with the private incident toggle in a single Options blockviews.updateon severity change) and defaults to checkedAgent transcript: https://claudescope.sentry.dev/share/eReflyKHOjlxj3XHUR_WogKuafhwOofLe6_a9YdDSIA