Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/research/layout-tree-source-names-spike.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ Avoid replacing existing `componentHint`. Add nullable, best-effort fields under
"sourceLine": 42,
"sourceColumn": null,
"sourcePackageHash": 123456,
"sourceNameConfidence": "tooling-ancestor-node-identity"
"sourceHintKind": "tooling-nearest-app-ancestor"
}
```

Recommended semantics:

- `sourceName`: nullable composable/tooling group name nearest to the layout node.
- `sourceName`: nullable composable/tooling group name correlated to the layout node, preferring app/source-file groups over Compose runtime internals.
- `sourceFile`, `sourceLine`, `sourceColumn`, `sourcePackageHash`: nullable source location parts from `SourceLocation`.
- `sourceNameConfidence`: optional nullable diagnostic enum/string such as `tooling-node-identity`, `tooling-ancestor-node-identity`, `tooling-bounds-preorder`, or `absent`.
- `sourceHintKind`: optional nullable diagnostic enum/string such as `tooling-node-identity`, `tooling-nearest-app-ancestor`, `tooling-sibling-preorder-app`, `tooling-useful-framework-ancestor`, `tooling-framework-ancestor`, or `preview-entrypoint-fallback`.

Do not require these fields for consumers. Do not fail snapshot extraction when tooling data is unavailable.
Do not require these fields for consumers. Tooling hints may still fall back to framework/internal groups when no app group can be correlated within ancestry/preorder/bounds constraints; CMP Android-target captures may remain preview-entrypoint-fallback-only when composition tooling data is unavailable. Do not fail snapshot extraction when tooling data is unavailable.

## Production recommendation

Expand Down
8 changes: 8 additions & 0 deletions docs/snapshot-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ Version 2 adds preview parameter metadata, optional layout tree data, and option
"boundsPx": { "x": 0, "y": 0, "width": 393, "height": 852 },
"boundsDp": { "x": 0.0, "y": 0.0, "width": 393.0, "height": 852.0 },
"componentHint": "androidx.compose.foundation.layout.Column",
"sourceName": "LoginCard",
"sourceFile": "LoginPreview.kt",
"sourceLine": 24,
"sourceHintKind": "tooling-nearest-app-ancestor",
"modifierHint": "androidx.compose.ui.Modifier",
"classHint": "androidx.compose.ui.node.LayoutNode",
"semanticsId": "7",
Expand Down Expand Up @@ -94,3 +98,7 @@ Future desktop and web renderers should use separate platform-specific viewport
## Semantics and Layout Tree

Fake renderer snapshots emit an empty `nodes` list because no real Compose semantics tree is available. Production renderer snapshots populate `nodes` from Compose semantics when available and may include `layoutTree` entries derived from the rendered Compose layout hierarchy.

`layoutTree` entries always keep `componentHint` as the implementation-level fallback. Production Android rendering may also add nullable best-effort source hints from Compose tooling data: `sourceName`, `sourceFile`, `sourceLine`, and `sourceHintKind`. The correlation prefers app/preview source files over Compose runtime internals such as `ReusableComposeNode`, `Layout.kt`, `Composer.kt`, and `Composables.kt`; if no app group can be correlated within ancestry/preorder/bounds constraints, the hint may be a useful framework composable or a framework/internal fallback. Current hint kinds include `tooling-node-identity`, `tooling-nearest-app-ancestor`, `tooling-sibling-preorder-app`, `tooling-useful-framework-ancestor`, `tooling-framework-node-identity`, `tooling-framework-ancestor`, `tooling-sibling-preorder-framework`, and `preview-entrypoint-fallback`.

These fields are optional, depend on Compose tooling/source information being available at render time, and are omitted if enrichment fails. `sourceLine` is emitted only when an actual positive source line is available; preview-entrypoint fallback hints may include `sourceName` and `sourceFile` with `sourceLine` omitted. Compose Multiplatform Android-target captures may currently emit only `preview-entrypoint-fallback` layout source hints when tooling composition data is unavailable for the rendered common source.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class AgentPreviewPlugin : Plugin<Project> {
project,
project.configurations.detachedConfiguration(
project.dependencies.create("androidx.compose.ui:ui-tooling:1.11.2"),
project.dependencies.create("androidx.compose.ui:ui-tooling-data:1.11.2"),
),
)

Expand All @@ -117,6 +118,7 @@ class AgentPreviewPlugin : Plugin<Project> {
project,
project.configurations.detachedConfiguration(
project.dependencies.create("androidx.compose.ui:ui-tooling:1.11.2"),
project.dependencies.create("androidx.compose.ui:ui-tooling-data:1.11.2"),
project.dependencies.create("androidx.test:core:1.7.0"),
project.dependencies.create("androidx.test:monitor:1.8.0"),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ data class SnapshotLayoutNode(
val boundsPx: Bounds,
val boundsDp: DpBounds,
val componentHint: String? = null,
val sourceName: String? = null,
val sourceFile: String? = null,
val sourceLine: Int? = null,
val sourceHintKind: String? = null,
val modifierHint: String? = null,
val classHint: String? = null,
val semanticsId: String? = null,
Expand Down
Loading
Loading