Skip to content

Example preview test that causes record to hang - #814

Open
takahirom wants to merge 1 commit into
takahirom:mainfrom
burntcookie90:vr/preview-test-hang
Open

Example preview test that causes record to hang#814
takahirom wants to merge 1 commit into
takahirom:mainfrom
burntcookie90:vr/preview-test-hang

Conversation

@takahirom

@takahirom takahirom commented Mar 28, 2026

Copy link
Copy Markdown
Owner
I've added an example Preview function containing a dialog and text with inline content that causes roborazzi's record to hang.

Just to confirm: the IDE preview window does render a preview.

Summary by CodeRabbit

  • New Features

    • Added a new preview demonstrating text display with inline icon content, including Material3 alert dialog support with advanced annotated string formatting and placeholder configuration.
  • Style

    • Improved code formatting and readability in existing preview components.
  • Chores

    • Added string resources to support preview testing scenarios.

I've added an example Preview function containing a dialog and text with inline content that causes roborazzi's record to hang.

Just to confirm: the IDE preview window does render a preview.
@coderabbitai

coderabbitai Bot commented Mar 28, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Added a new preview composable for testing inline content in Material3 BasicAlertDialog with AnnotatedString and icon placeholders. Reformatted an existing preview function's modifier expression to multiline style. Added supporting string resources for preview tests.

Changes

Cohort / File(s) Summary
Preview Composables
sample-generate-preview-tests/src/main/java/com/github/takahirom/preview/tests/Previews.kt
Added PreviewTextWithInlineContent composable that renders an AlertDialog with Text using AnnotatedString and inline content support for a "linkIcon" placeholder with a Material Add icon. Reformatted modifier expression in PreviewFocusGroupLaunchedEffectMinimal from single-line to chained multiline sequence without behavior changes.
String Resources
sample-generate-preview-tests/src/main/res/values/strings.xml
Added two new string resources: testing_inline_content ("Testing inline content") and for_preview_tests ("for preview tests").

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Inline content blooms in dialogs bright,
With icons placed just right,
A text that flows with placeholders true,
Preview magic, tested anew! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main purpose of the PR—adding an example preview test that demonstrates a hang issue in roborazzi's record functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@sample-generate-preview-tests/src/main/java/com/github/takahirom/preview/tests/Previews.kt`:
- Around line 550-583: The PreviewTextWithInlineContent composable hangs during
recording because InlineTextContent triggers animated timing; add the
Robolectric preview annotation to disable auto-advance by annotating the
PreviewTextWithInlineContent function with
`@RoboComposePreviewOptions`(manualClockOptions = [ManualClockOptions()]) (ensure
the annotation is placed alongside `@OptIn` and `@Preview` and import
ManualClockOptions/RoboComposePreviewOptions if missing) so the preview uses a
manual clock and won't hang during recording.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d87a86c7-23ed-4ee6-ba5f-8f696c1438de

📥 Commits

Reviewing files that changed from the base of the PR and between eb3901a and 5422a12.

📒 Files selected for processing (2)
  • sample-generate-preview-tests/src/main/java/com/github/takahirom/preview/tests/Previews.kt
  • sample-generate-preview-tests/src/main/res/values/strings.xml

Comment on lines +550 to +583
@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
fun PreviewTextWithInlineContent() {
BasicAlertDialog(onDismissRequest = {}) {

val text = buildAnnotatedString {
append(stringResource(R.string.testing_inline_content))
append(" ")
appendInlineContent("linkIcon", "[linkIcon]")
append(" ")
append(stringResource(R.string.for_preview_tests))
}

Text(
modifier = Modifier.fillMaxWidth(),
text = text,
style = MaterialTheme.typography.bodySmall,
textAlign = TextAlign.Center,
inlineContent = mapOf(
"linkIcon" to InlineTextContent(
placeholder = Placeholder(20.sp, 20.sp, PlaceholderVerticalAlign.Center),
children = {
Icon(
modifier = Modifier.fillMaxSize(),
imageVector = Icons.Default.Add,
contentDescription = null,
)
},
),
),
)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Inspect available options on RoboComposePreviewOptions to find exclusion/gating knobs.
rg -n --type=kt -C4 'annotation class RoboComposePreviewOptions|class RoboComposePreviewOptions'

# 2) Inspect current usages to mirror an existing exclusion pattern (if any).
rg -n --type=kt -C3 '@RoboComposePreviewOptions|RoboComposePreviewOptions\('

# 3) Confirm this new preview currently has no gating annotation besides `@Preview`.
rg -n --type=kt -C3 'fun PreviewTextWithInlineContent|@Preview|@OptIn\(ExperimentalMaterial3Api::class\)'

Repository: takahirom/roborazzi

Length of output: 89


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Find RoboComposePreviewOptions definition
echo "=== Searching for RoboComposePreviewOptions definition ==="
rg -n 'annotation class RoboComposePreviewOptions|class RoboComposePreviewOptions' -A 10

# 2) Find usages of RoboComposePreviewOptions
echo -e "\n=== Searching for RoboComposePreviewOptions usages ==="
rg -n '@RoboComposePreviewOptions|RoboComposePreviewOptions(' -B 2 -A 2

# 3) Verify current annotations on PreviewTextWithInlineContent
echo -e "\n=== Current annotations on PreviewTextWithInlineContent ==="
rg -n 'fun PreviewTextWithInlineContent' -B 5

# 4) Check if there are any exclusion/recording-related annotations in the codebase
echo -e "\n=== Searching for exclusion or recording-related patterns ==="
rg -n 'record|exclude|skipRecord|Recorder' -i --max-count=20

Repository: takahirom/roborazzi

Length of output: 1905


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Get full RoboComposePreviewOptions.kt definition
echo "=== Full RoboComposePreviewOptions definition ==="
cat roborazzi-annotations/src/main/java/com/github/takahirom/roborazzi/annotations/RoboComposePreviewOptions.kt

# 2) Find usages (with escaped parenthesis)
echo -e "\n=== Searching for `@RoboComposePreviewOptions` usages ==="
rg -n '@RoboComposePreviewOptions' -B 2 -A 5

# 3) Verify PreviewTextWithInlineContent annotations
echo -e "\n=== Current annotations on PreviewTextWithInlineContent ==="
rg -n 'PreviewTextWithInlineContent' -B 10

# 4) Look for any skip/exclude recording patterns
echo -e "\n=== Searching for recording exclusion patterns ==="
rg -n 'skipRecord|excludeRecord|skip.*[Rr]ecord|exclude.*[Rr]ecord'

Repository: takahirom/roborazzi

Length of output: 4890


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Check README and docs for recording exclusion guidance
echo "=== Searching docs for recording/exclusion guidance ==="
rg -n 'record|exclude|skip' README.md docs/ -i -B 2 -A 2 | head -80

# 2) Look for PR context or TODO comments about hanging previews
echo -e "\n=== Searching for hanging/issue context ==="
rg -n 'hang|inline.*content|deadlock' -i -B 2 -A 2 | head -50

# 3) Check the PR or related files to understand the PR objective
echo -e "\n=== Searching for PR context or objectives ==="
rg -n 'record.*hang|hang.*record|inline.*content.*hang' -i

# 4) List other preview annotations/patterns to find alternative gating
echo -e "\n=== Other `@Preview` patterns in test file ==="
rg -n '@Preview' sample-generate-preview-tests/src/main/java/com/github/takahirom/preview/tests/Previews.kt -B 3 | head -60

Repository: takahirom/roborazzi

Length of output: 11209


🏁 Script executed:

#!/bin/bash
set -euso pipefail

# 1) Search for issue `#768` mentions or comments
echo "=== Searching for issue 768 context ==="
rg -n '768|inline.*content.*hang|hang.*preview' -i

# 2) Look for TODO or FIXME about skipping/excluding previews
echo -e "\n=== Looking for TODOs about recording exclusion ==="
rg -n 'TODO|FIXME' -B 1 -A 1 | grep -i -E 'skip|record|exclude|preview|inline|hang' -A 2 -B 2

# 3) Search for any configuration or annotation that might control recording
echo -e "\n=== Searching for skip/ignore patterns ==="
rg -n 'ignore|skip|exclude' -i -A 2 | head -60

# 4) Check if there's a way to exclude tests from running
echo -e "\n=== Searching for test exclusion patterns ==="
rg -n '@Ignore|Ignore\(|skip.*=.*true' -i -B 1 -A 1

Repository: takahirom/roborazzi

Length of output: 8625


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check the RoborazziPreviewScannerSupport.kt file around issue 768 reference
echo "=== RoborazziPreviewScannerSupport.kt around issue 768 ==="
rg -n 'See.*768' roborazzi-compose-preview-scanner-support/src/main/java/com/github/takahirom/roborazzi/RoborazziPreviewScannerSupport.kt -B 10 -A 10

# Also check if there's a mechanism to filter/exclude previews
echo -e "\n=== Preview filtering logic ==="
rg -n 'filter|exclude|skip' roborazzi-compose-preview-scanner-support/src/main/java/com/github/takahirom/roborazzi/RoborazziPreviewScannerSupport.kt -B 2 -A 2

# Check the full file to understand the structure
echo -e "\n=== File structure ==="
wc -l roborazzi-compose-preview-scanner-support/src/main/java/com/github/takahirom/roborazzi/RoborazziPreviewScannerSupport.kt

Repository: takahirom/roborazzi

Length of output: 1788


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check how ManualClockOptions is used and when it disables autoAdvance
echo "=== How manualClockOptions affects autoAdvance ==="
rg -n 'autoAdvance|manualClockOptions' roborazzi-compose-preview-scanner-support/src/main/java/ -B 3 -A 3

# Check the actual implementation in the test rule
echo -e "\n=== Looking for composeTestRule implementation ==="
rg -n 'class.*ComposeTestRule|mainClock.*autoAdvance' -B 2 -A 2 | head -60

# Verify what happens when manualClockOptions is empty vs populated
echo -e "\n=== PreviewWithEmptyOptions to see if it needs special handling ==="
rg -n 'PreviewWithEmptyOptions' -A 8

Repository: takahirom/roborazzi

Length of output: 12643


Add @RoboComposePreviewOptions to prevent hanging during recording.

This preview uses InlineTextContent with animations that can cause recording to hang (issue #768). Gate it with @RoboComposePreviewOptions(manualClockOptions = [ManualClockOptions()]) to disable auto-advance timing, matching the pattern used in PreviewWithEmptyOptions:

Applied change
`@OptIn`(ExperimentalMaterial3Api::class)
`@RoboComposePreviewOptions`(manualClockOptions = [ManualClockOptions()])
`@Preview`
`@Composable`
fun PreviewTextWithInlineContent() {
  // ... rest of implementation
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@sample-generate-preview-tests/src/main/java/com/github/takahirom/preview/tests/Previews.kt`
around lines 550 - 583, The PreviewTextWithInlineContent composable hangs during
recording because InlineTextContent triggers animated timing; add the
Robolectric preview annotation to disable auto-advance by annotating the
PreviewTextWithInlineContent function with
`@RoboComposePreviewOptions`(manualClockOptions = [ManualClockOptions()]) (ensure
the annotation is placed alongside `@OptIn` and `@Preview` and import
ManualClockOptions/RoboComposePreviewOptions if missing) so the preview uses a
manual clock and won't hang during recording.

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