From 4bc3147d2a21f29928d143dfef6179f67ad4755b Mon Sep 17 00:00:00 2001 From: PJ Date: Sun, 31 May 2026 15:22:40 +0530 Subject: [PATCH] feat(sidecar): add snapshot default on DriverBackend Default impl calls hierarchy() then screenshot(). The service layer wraps the call in a mutex so concurrent runners observe a serialized pair. --- .../kotlin/dev/sanderling/sidecar/DriverBackend.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sidecar/src/main/kotlin/dev/sanderling/sidecar/DriverBackend.kt b/sidecar/src/main/kotlin/dev/sanderling/sidecar/DriverBackend.kt index 6fb5ca1..1f8c5d1 100644 --- a/sidecar/src/main/kotlin/dev/sanderling/sidecar/DriverBackend.kt +++ b/sidecar/src/main/kotlin/dev/sanderling/sidecar/DriverBackend.kt @@ -14,8 +14,19 @@ interface DriverBackend { fun waitForIdle(durationMillis: Long) fun healthy(): Boolean fun metrics(bundleId: String): MetricsSample + + // snapshot captures hierarchy then screenshot back-to-back. The service + // layer holds a mutex around the call so concurrent callers observe a + // serialized pair from the same on-device frame. Backends may override + // to fuse the two reads more tightly when their native API allows. + fun snapshot(): SnapshotSample = SnapshotSample(hierarchy(), screenshot()) } +data class SnapshotSample( + val hierarchyJson: String, + val screenshot: Triple, +) + // STABILITY_POLL_INTERVAL_MILLIS is set wide enough that UiAutomation / // Maestro's contentDescriptor doesn't get hammered: tighter intervals were // observed to back the sidecar gRPC stream up under fuzz load to the point