Skip to content

feat(snapshots): Emit diff_threshold in snapshot sidecar (EME-1055)#1158

Merged
runningcode merged 3 commits intomainfrom
no/eme-1055-diff-threshold-sidecar
Apr 21, 2026
Merged

feat(snapshots): Emit diff_threshold in snapshot sidecar (EME-1055)#1158
runningcode merged 3 commits intomainfrom
no/eme-1055-diff-threshold-sidecar

Conversation

@runningcode
Copy link
Copy Markdown
Contributor

@runningcode runningcode commented Apr 21, 2026

Summary

Finishes EME-1055 (follow-up to #1154) by wiring the @SentrySnapshot(diffThreshold = ...) runtime annotation into the per-snapshot sidecar JSON emitted by the generated Paparazzi test.

  • The generated test's writeSidecarMetadata now reflects on preview.declaringClass / preview.methodName to read @SentrySnapshot.diffThreshold. The value is written as diff_threshold only when the annotation is present and the threshold is non-default (!= 0f), matching the existing "omit when default" pattern used for font_scale, api_level, etc.
  • The reflective lookup uses Class.forName for the annotation class and is wrapped in runCatching, so a missing runtime jar or a class-loading failure silently skips the field rather than failing the test.

Scope

  • Touches only the runtime-generated sidecar. ExportPreviewMetadataTask's build-time preview-metadata.json is intentionally left alone.
  • No changes to PreviewScanner ASM machinery; detection is fully at test runtime.

#skip-changelog

🤖 Generated with Claude Code

@linear-code
Copy link
Copy Markdown

linear-code Bot commented Apr 21, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against fea28a3

Base automatically changed from no/eme-1055-sentry-snapshot-annotation to main April 21, 2026 10:42
The generated Paparazzi test now reflects on each @Preview to read an
optional @SentrySnapshot(diffThreshold) annotation and writes the value
as "diff_threshold" in the per-snapshot sidecar JSON, but only when the
annotation is present and the threshold differs from the 0f default.

Changes SentrySnapshot's retention from BINARY to RUNTIME so the JVM
retains it for reflection. Java's Method.getAnnotation cannot see
CLASS/BINARY-retained annotations.

The lookup is guarded by runCatching so a missing runtime jar or a
class-loading failure degrades to "field omitted" rather than a test
failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@runningcode runningcode force-pushed the no/eme-1055-diff-threshold-sidecar branch from ec8a132 to 4d31af2 Compare April 21, 2026 10:45
Drop the runCatching around the @SentrySnapshot lookup. The previous
guard silently swallowed ClassNotFoundException when
sentry-snapshots-runtime is absent from the test runtime classpath, so
a misconfigured consumer would see "diff_threshold" quietly omitted
with no indication of why. Letting exceptions propagate surfaces the
misconfiguration loudly at test runtime.

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

if (info.showSystemUi) metadata["show_system_ui"] = true
if (info.showBackground) metadata["show_background"] = true

val diffThreshold: Float? = runCatching {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This catches all errors here in scanning since we are using reflection.

@runningcode runningcode merged commit 7072874 into main Apr 21, 2026
19 of 21 checks passed
@runningcode runningcode deleted the no/eme-1055-diff-threshold-sidecar branch April 21, 2026 13:44
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