feat(preprod): Add post-on-added/removed PR comment toggles (EME-1046)#114130
Open
runningcode wants to merge 3 commits intomasterfrom
Open
feat(preprod): Add post-on-added/removed PR comment toggles (EME-1046)#114130runningcode wants to merge 3 commits intomasterfrom
runningcode wants to merge 3 commits intomasterfrom
Conversation
…046) Adds a nested "Only post when there are changes" sub-toggle to the snapshot PR comments setting. The sub-toggle is only shown when the parent toggle is enabled and persists to the new preprodSnapshotPrCommentsOnlyIfDiff project option. Depends on the backend serializer change that exposes the preprodSnapshotPrCommentsOnlyIfDiff field on the project resource.
eaf348a to
5f7fddf
Compare
…1046) Surface dedicated PR-comment toggles for treating added/removed snapshots as diffs worth posting. These appear nested under "Only post when there are changes" since they only affect that gate. Decoupled from the snapshot status-check fail-on-added/removed options on the backend (#114302), so projects can tune PR comments independently of red/green status check semantics.
…1046) The only-if-diff option is collapsed into the main PR comments toggle on the backend (#114302). Drop the nested toggle from the settings panel and surface the post-on-added/post-on-removed sub-toggles directly under the main switch.
| </Flex> | ||
| <Flex align="center" justify="between"> | ||
| <Stack gap="xs"> | ||
| <Text bold>{t('Post on Removed Snapshots')}</Text> |
Contributor
There was a problem hiding this comment.
Bug: Rapidly clicking the snapshot comment toggle switches can send two identical requests due to a stale closure, preventing the setting from being toggled back.
Severity: MEDIUM
Suggested Fix
Introduce local state within the SnapshotPrCommentsToggle component to manage the checked state of the switches optimistically. Update this local state immediately on click to provide instant visual feedback and use this state to calculate the payload for the update mutation. This decouples the UI from the asynchronous propagation of the project prop.
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: static/app/views/settings/project/preprod/snapshotPrCommentsToggle.tsx#L97
Potential issue: The `Switch` components for toggling snapshot pull request comments are
fully controlled by props from the `project` object. When a switch is clicked, an
asynchronous update is triggered, but the component does not re-render synchronously. If
a user clicks the switch again before the asynchronous state update completes, the
`onClick` handler's closure captures a stale value for the setting. This causes the
toggle logic (e.g., `!postOnAdded`) to compute the same result for both clicks, sending
two identical requests instead of toggling the setting back.
runningcode
added a commit
that referenced
this pull request
May 5, 2026
…E-1046) (#114302) Gives snapshot PR comments the same granular controls as snapshot status checks. Previously PR comments shared the status-check options for deciding what counts as a diff; now they have their own independent set. Here's a link to where these settings will eventually go: https://sentry.sentry.io/settings/projects/hackernews-android/snapshots/ This is just the backend for now though **Drop only-if-diff toggle** The `sentry:preprod_snapshot_pr_comments_only_if_diff` option is removed. Enabling PR comments now always implies "post only when there are changes" — commenting on every build regardless of diffs is no longer possible. **Dedicated post-on options** Four independent project options control which snapshot change types trigger a PR comment: | Option | Default | |--------|---------| | `post_on_added` | `False` | | `post_on_removed` | `True` | | `post_on_changed` | `True` | | `post_on_renamed` | `False` | Defaults match the status-check equivalents so no project sees a behavior change from this decoupling. The task no longer imports from the status-check module. The frontend changes (surfacing these toggles in the settings UI) are in #114130. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
cleptric
pushed a commit
that referenced
this pull request
May 5, 2026
…E-1046) (#114302) Gives snapshot PR comments the same granular controls as snapshot status checks. Previously PR comments shared the status-check options for deciding what counts as a diff; now they have their own independent set. Here's a link to where these settings will eventually go: https://sentry.sentry.io/settings/projects/hackernews-android/snapshots/ This is just the backend for now though **Drop only-if-diff toggle** The `sentry:preprod_snapshot_pr_comments_only_if_diff` option is removed. Enabling PR comments now always implies "post only when there are changes" — commenting on every build regardless of diffs is no longer possible. **Dedicated post-on options** Four independent project options control which snapshot change types trigger a PR comment: | Option | Default | |--------|---------| | `post_on_added` | `False` | | `post_on_removed` | `True` | | `post_on_changed` | `True` | | `post_on_renamed` | `False` | Defaults match the status-check equivalents so no project sees a behavior change from this decoupling. The task no longer imports from the status-check module. The frontend changes (surfacing these toggles in the settings UI) are in #114130. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the only-if-diff sub-toggle with explicit "Post on Added" / "Post on Removed" toggles under the main PR comments switch:
preprodSnapshotPrCommentsEnabled) now governs whether comments post at all. Enabling it always means "post when there are changes" — the prior always-post mode is gone.preprodSnapshotPrCommentsPostOnAdded, default off) — treat newly added snapshots as a change worth posting.preprodSnapshotPrCommentsPostOnRemoved, default on) — treat removed snapshots as a change worth posting.Backend support is in #114302 — must land first.
EME-1046