From f5ee8d75b1844067c32867e3b752d2077e141252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Mon, 9 Nov 2026 13:07:17 +0000 Subject: [PATCH] Screenshots as previews: no endless animation, no fetches; tests named as they start The first run of the new shots did not finish within ten minutes. In inspection mode the writing dots stand still and pictures are not fetched; Gradle now names each test as it starts and gives up after 20 minutes. Co-Authored-By: Claude Opus 5.5 --- app/build.gradle.kts | 6 +++++ .../java/eu/llembas/android/ui/ModelAvatar.kt | 4 +++- .../eu/llembas/android/ui/chat/Transcript.kt | 23 +++++++++++++------ .../java/eu/llembas/android/shots/Shoot.kt | 3 +++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 11e3063..66873df 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -114,6 +114,12 @@ android { test.systemProperty("roborazzi.test.record", "true") test.systemProperty("robolectric.pixelCopyRenderMode", "hardware") test.maxHeapSize = "3g" + // Name each test as it starts, so a run that stops in one says which. + test.testLogging { + events("started", "passed", "failed", "skipped") + exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL + } + test.timeout.set(java.time.Duration.ofMinutes(20)) } } diff --git a/app/src/main/java/eu/llembas/android/ui/ModelAvatar.kt b/app/src/main/java/eu/llembas/android/ui/ModelAvatar.kt index e5e63d0..3a3e80b 100644 --- a/app/src/main/java/eu/llembas/android/ui/ModelAvatar.kt +++ b/app/src/main/java/eu/llembas/android/ui/ModelAvatar.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp @@ -77,8 +78,9 @@ fun ModelAvatar(model: ModelInfo?, fallbackName: String, size: Dp = 24.dp, modif val palette = LocalPalette.current val path = model?.image var image by remember(path) { mutableStateOf(path?.let { ModelImages.cached(it) }) } + val still = LocalInspectionMode.current LaunchedEffect(path) { - if (path != null && image == null) image = ModelImages.load(context, path) + if (path != null && image == null && !still) image = ModelImages.load(context, path) } Box(modifier.size(size).clip(CircleShape).background(palette.accentSoft), contentAlignment = Alignment.Center) { val shown = image diff --git a/app/src/main/java/eu/llembas/android/ui/chat/Transcript.kt b/app/src/main/java/eu/llembas/android/ui/chat/Transcript.kt index a2dad48..84806e5 100644 --- a/app/src/main/java/eu/llembas/android/ui/chat/Transcript.kt +++ b/app/src/main/java/eu/llembas/android/ui/chat/Transcript.kt @@ -70,6 +70,7 @@ import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.style.TextOverflow @@ -287,15 +288,22 @@ private fun footLine(message: Message): String? { @Composable fun Writing(modifier: Modifier = Modifier, withLine: Boolean = false) { val palette = LocalPalette.current + // Still in a preview or a screenshot, where an animation that never ends never lets the + // picture be taken. + val still = LocalInspectionMode.current val pulse = rememberInfiniteTransition(label = "writing") Row(modifier.heightIn(min = 32.dp), verticalAlignment = Alignment.CenterVertically) { repeat(3) { i -> - val alpha by pulse.animateFloat( - initialValue = 0.25f, - targetValue = 1f, - animationSpec = infiniteRepeatable(tween(600, delayMillis = i * 150), RepeatMode.Reverse), - label = "dot$i", - ) + val alpha = if (still) { + listOf(1f, 0.6f, 0.3f)[i] + } else { + pulse.animateFloat( + initialValue = 0.25f, + targetValue = 1f, + animationSpec = infiniteRepeatable(tween(600, delayMillis = i * 150), RepeatMode.Reverse), + label = "dot$i", + ).value + } Box(Modifier.padding(end = 4.dp).size(8.dp).alpha(alpha).clip(CircleShape).background(palette.accent)) } if (withLine) { @@ -531,7 +539,8 @@ fun AttachmentTile(attachment: Attachment, side: Dp, modifier: Modifier = Modifi Box(modifier.size(side).clip(Block).background(palette.surfaceRaised).border(1.dp, palette.border, Block), contentAlignment = Alignment.Center) { if (attachment.image) { var image by remember(attachment.id) { mutableStateOf(Thumbnails.cached(attachment.id)) } - LaunchedEffect(attachment.id) { if (image == null) image = Thumbnails.load(context, attachment.id) } + val still = LocalInspectionMode.current + LaunchedEffect(attachment.id) { if (image == null && !still) image = Thumbnails.load(context, attachment.id) } val shown = image if (shown != null) { Image(shown, contentDescription = attachment.name, contentScale = ContentScale.Crop, modifier = Modifier.fillMaxSize()) diff --git a/app/src/test/java/eu/llembas/android/shots/Shoot.kt b/app/src/test/java/eu/llembas/android/shots/Shoot.kt index cab1aba..9010617 100644 --- a/app/src/test/java/eu/llembas/android/shots/Shoot.kt +++ b/app/src/test/java/eu/llembas/android/shots/Shoot.kt @@ -10,6 +10,7 @@ import com.github.takahirom.roborazzi.ExperimentalRoborazziApi import com.github.takahirom.roborazzi.RoborazziComposeOptions import com.github.takahirom.roborazzi.captureRoboImage import com.github.takahirom.roborazzi.fontScale +import com.github.takahirom.roborazzi.inspectionMode import com.github.takahirom.roborazzi.size import eu.llembas.android.ui.theme.LembasTheme @@ -32,6 +33,8 @@ fun shoot(name: String, phone: Phone = Phone.Large, fontScale: Float = 1f, conte filePath = "build/screenshots/${phone.tag}-$name-$theme$font.png", roborazziComposeOptions = RoborazziComposeOptions { size(phone.widthDp, phone.heightDp) + // As a preview: no endless animation, no pictures fetched from an instance. + inspectionMode(true) if (fontScale != 1f) fontScale(fontScale) }, ) {