Skip to content

feat(snapshots): Restructure sidecar JSON to match ingestion schema#1162

Merged
runningcode merged 2 commits intomainfrom
no/snapshot-sidecar-schema
Apr 24, 2026
Merged

feat(snapshots): Restructure sidecar JSON to match ingestion schema#1162
runningcode merged 2 commits intomainfrom
no/snapshot-sidecar-schema

Conversation

@runningcode
Copy link
Copy Markdown
Contributor

@runningcode runningcode commented Apr 23, 2026

Summary

Aligns the per-snapshot sidecar JSON with the ingestion JSON Schema by organizing fields into the defined buckets:

  • Top level: display_name, group, diff_threshold
  • tags (appearance / render inputs): preview_name, locale, device, font_scale, api_level, width_dp, height_dp, show_system_ui, show_background, ui_mode
  • context (preview identity / location): image_file_name, class_name, method_name

Notable behavior changes:

  • The old night_mode boolean is gone. Dark/light state is now emitted as a ui_mode tag, only when the @Preview(uiMode = …) bits explicitly set UI_MODE_NIGHT_YES"dark" or UI_MODE_NIGHT_NO"light". The common UI_MODE_NIGHT_UNDEFINED case (the default for unannotated previews) yields no ui_mode tag.
  • preview_name (the @Preview(name = …) label) moves from top level into tags.
  • tags is omitted when empty; context is always present.

Implementation notes:

  • The sidecar writer is emitted as a string literal inside the generated Paparazzi test (GenerateSnapshotTestsTask.kt), so the change lives in that template.
  • The hand-rolled JSON writer is replaced with a tiny recursive renderJson(value, indentLevel) that handles String, Number, Boolean, and Map<*,*> — no new dependencies.

Example output:

{
  "display_name": "FooPreview",
  "group": "main",
  "tags": { "preview_name": "Dark", "locale": "en", "font_scale": 1.5, "ui_mode": "dark" },
  "context": {
    "image_file_name": "com.example.FooPreview",
    "class_name": "com.example.Foo",
    "method_name": "FooPreview"
  }
}

#skip-changelog

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2026

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

Generated by 🚫 dangerJS against 67d6904

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

when (info.uiMode and UI_MODE_NIGHT_MASK) {
UI_MODE_NIGHT_YES -> metadata["color_mode"] = "dark"
Copy link
Copy Markdown
Member

@rbro112 rbro112 Apr 23, 2026

Choose a reason for hiding this comment

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

Make sure to pass this through as uiMode in context

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 6acdeab. Configure here.

runningcode and others added 2 commits April 24, 2026 11:18
Bucket appearance inputs (locale, device, font_scale, api_level,
width_dp, height_dp, show_system_ui, show_background, preview_name)
under `tags`; move preview identity (class_name, method_name,
image_file_name) under `context`; replace the `night_mode` boolean
with a `color_mode` enum that is emitted only when `uiMode` explicitly
sets `UI_MODE_NIGHT_YES` or `UI_MODE_NIGHT_NO`.

The serializer is extended with a small recursive `renderJson`
helper so the template can emit nested objects without pulling in a
JSON library.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Relocate the uiMode → light/dark mapping from the top-level
metadata field `color_mode` into the `tags` map, keyed as
`ui_mode`. This aligns the field with the other appearance
inputs (locale, device, font_scale, etc.) and matches the
ingestion schema's expectation that preview configuration
travels as tags rather than first-class metadata.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@runningcode runningcode force-pushed the no/snapshot-sidecar-schema branch from 6acdeab to 67d6904 Compare April 24, 2026 09:19
@runningcode runningcode merged commit 7938856 into main Apr 24, 2026
19 of 21 checks passed
@runningcode runningcode deleted the no/snapshot-sidecar-schema branch April 24, 2026 11:57
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