Skip to content

Add best-effort layout tree source hints#22

Merged
static-var merged 5 commits into
mainfrom
layout-tree-source-hints
May 25, 2026
Merged

Add best-effort layout tree source hints#22
static-var merged 5 commits into
mainfrom
layout-tree-source-hints

Conversation

@static-var
Copy link
Copy Markdown
Owner

Summary

  • add nullable best-effort source hint fields to experimental layoutTree nodes:
    • sourceName
    • sourceFile
    • sourceLine
    • sourceHintKind
  • preserve existing componentHint and layout tree structure
  • enrich layout tree nodes in the forked Robolectric renderer using Compose tooling data when available
  • correlate tooling groups to runtime LayoutNodes by identity plus bounded app-source/preorder fallback
  • keep source hint extraction optional and non-fatal
  • document best-effort behavior and CMP fallback caveat in snapshot schema docs

Notes

  • source hints are additive and nullable; schemaVersion remains 2
  • sourceHintKind indicates confidence/source, e.g. tooling-nearest-app-ancestor or preview-entrypoint-fallback
  • CMP Android-target sample currently falls back to preview-entrypoint hints when tooling data is unavailable

Verification

  • build-brief ./gradlew spotlessCheck detekt :plugin:test :preview-scanner:test
  • ANDROID_HOME=$HOME/Library/Android/sdk build-brief ./gradlew -p samples/android-compose-app :app:captureComposePreviews --configuration-cache
  • ANDROID_HOME=$HOME/Library/Android/sdk build-brief ./gradlew -p samples/cmp-compose-app :composeApp:captureComposePreviews --configuration-cache

Android sample source-hint check

Inspected generated snapshots and found 70 useful non-fallback tooling hints, for example:

layout-2 Surface LoginPreview.kt 36 tooling-nearest-app-ancestor
layout-3 Column LoginPreview.kt 37 tooling-nearest-app-ancestor
layout-4 Text LoginPreview.kt 41 tooling-nearest-app-ancestor
layout-5 Spacer LoginPreview.kt 42 tooling-nearest-app-ancestor
layout-6 Box LoginPreview.kt 43 tooling-nearest-app-ancestor

Review

  • Implementation delegated to subagent
  • Multiple review/fix cycles addressed fallback-only output and framework/internal source names
  • Final review subagent approved with no findings

@static-var static-var merged commit ceaa37c into main May 25, 2026
1 check passed
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.

1 participant