Skip to content

Commit 6acdeab

Browse files
runningcodeclaude
andcommitted
feat(snapshots): Move ui_mode into sidecar tags block
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>
1 parent e81b819 commit 6acdeab

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

plugin-build/src/main/kotlin/io/sentry/android/gradle/snapshot/GenerateSnapshotTestsTask.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@ class $CLASS_NAME(
370370
if (info.heightDp > 0) tags["height_dp"] = info.heightDp
371371
if (info.showSystemUi) tags["show_system_ui"] = true
372372
if (info.showBackground) tags["show_background"] = true
373+
when (info.uiMode and UI_MODE_NIGHT_MASK) {
374+
UI_MODE_NIGHT_YES -> tags["ui_mode"] = "dark"
375+
UI_MODE_NIGHT_NO -> tags["ui_mode"] = "light"
376+
}
373377
374378
val context = linkedMapOf<String, Any>(
375379
"image_file_name" to screenshotId,
@@ -382,11 +386,6 @@ class $CLASS_NAME(
382386
)
383387
if (info.group.isNotBlank()) metadata["group"] = info.group
384388
385-
when (info.uiMode and UI_MODE_NIGHT_MASK) {
386-
UI_MODE_NIGHT_YES -> metadata["color_mode"] = "dark"
387-
UI_MODE_NIGHT_NO -> metadata["color_mode"] = "light"
388-
}
389-
390389
val diffThreshold: Float? = runCatching {
391390
val declaring = Class.forName(preview.declaringClass)
392391
val method = declaring.declaredMethods.firstOrNull { it.name == preview.methodName }

plugin-build/src/test/kotlin/io/sentry/android/gradle/snapshot/GenerateSnapshotTestsTaskTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ class GenerateSnapshotTestsTaskTest {
175175
}
176176

177177
@Test
178-
fun `generated sidecar maps night mode to color_mode enum`() {
178+
fun `generated sidecar places ui_mode in tags block`() {
179179
val content = generateAndRead(packageTrees = listOf("com.example"))
180180

181181
assertTrue(content.contains("when (info.uiMode and UI_MODE_NIGHT_MASK) {"))
182-
assertTrue(content.contains("UI_MODE_NIGHT_YES -> metadata[\"color_mode\"] = \"dark\""))
183-
assertTrue(content.contains("UI_MODE_NIGHT_NO -> metadata[\"color_mode\"] = \"light\""))
182+
assertTrue(content.contains("UI_MODE_NIGHT_YES -> tags[\"ui_mode\"] = \"dark\""))
183+
assertTrue(content.contains("UI_MODE_NIGHT_NO -> tags[\"ui_mode\"] = \"light\""))
184184
}
185185

186186
@Test

0 commit comments

Comments
 (0)