Skip to content

feat(android): add opt-in dp coordinate unit - #5284

Merged
thymikee merged 16 commits into
callstack:mainfrom
satya164:@satya164/android-dp-coordinates
Dec 2, 2026
Merged

thymikee merged 16 commits into
callstack:mainfrom
satya164:@satya164/android-dp-coordinates

Conversation

@satya164

@satya164 satya164 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Android geometry is physical pixels. This adds an opt-in coordinateUnit: 'dp', on the client config or per call; native stays the default.

  • The daemon converts at the router: dp input becomes whole pixels before dispatch, and results come back in dp with a coordinates label. Handlers and .ad scripts keep pixels.
  • Density comes from the request's own capture, else the device's read (wm density, or mobile: deviceInfo on WebDriver hubs), else the caller's coordinateDensity. Nothing is kept between requests.
  • Without a density, a dp request with geometry is refused before dispatch (coordinate_unit_density_unknown).

Before / after

const client = createAgentDeviceClient({ coordinateUnit: 'dp' });
await client.capture.snapshot();
// before: viewport { width: 1080, height: 2400 }
// after:  viewport { width: 411.43, height: 914.29 }, coordinates { unit: 'dp', pixelDensity: 2.625 }
await client.interactions.press({ x: 200, y: 450 });
// before: taps (200, 450); after: taps (525, 1181)

Validation

Hosted runs at 5e1ed75c71, with dp and no coordinateDensity. Every session was released.

Provider Device Density Result
Limrun Android emulator 1.75 press hit target
BrowserStack Pixel 8, Android 14 2.625 press hit target
Revyl Android emulator none refused, dispatched: no
Sauce Labs Pixel 7 emulator 420 dpi raw hub check
TestMu AI — — unit tests only

CI owns the gates. Risk: TestMu AI has no live run.

A request with `meta.coordinateUnit: 'dp'` (client config default or a
per-call override, like `responseLevel`) gets Android geometry in
density-independent pixels. Inside each admitted request, batch steps
included, the router reads the request's points, deltas, distances,
`--pixels`, and `--jitter-px` by shape and turns them into whole pixels
before dispatch, so handlers and `.ad` recordings keep physical pixels. The
response's and an error's geometry, `open --foreground`'s initial snapshot
included, is converted by field name to fractional dp under a `coordinates`
label. Commands that carry geometry say so with the registry's
`carriesScreenGeometry` trait. Replay and Maestro steps never inherit the
unit.

The density is the one the device's last snapshot reported (remembered per
daemon runtime; a snapshot without one, a fold, a boot, and a shutdown forget
it), else the one a WebDriver provider read from its Appium session
capabilities, else one local `wm density` read. On a device with no density,
a dp request that sends geometry is refused before dispatch with
`coordinate_unit_density_unknown`; reads answer in pixels labeled `px`. Apple
targets are labeled `pt`. The daemon advertises `android-dp-coordinates`, and
the client refuses a dp request to a daemon without it before sending.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

Copy link
Copy Markdown
Member

Thanks for the work on this opt-in unit; at 99f9854, one high-priority gap remains: the new Android path has no live run behind it.

The answers to these questions decide whether the change fits the project:

  • Which client or use case needs this, and why is converting with the already-published androidSnapshot.pixelDensity not enough?
  • Would always publishing pixelDensity on Android snapshot/open responses and session info (from the helper, WebDriver capabilities, or wm density) cover the "no usable snapshot content" case without request-side conversion?
  • CLI and MCP cannot set coordinateUnit. Is the Node client the only intended user, and has any user asked for it?
  • Would you narrow this PR to density reporting first, and revisit daemon-side conversion if demand appears?

Could this report the density and not convert? Geometry would stay native. Every Android snapshot and open response, and session/device info, would publish pixelDensity from the helper, else WebDriver pixelRatio/deviceScreenDensity, else one wm density read that is remembered. Callers would multiply and divide, as snapshots.md already documents. This keeps the Android density read and the WebDriver capability parsing, roughly 60-100 production lines. It drops the request meta, daemon capability, client asserts, registry trait, 365-line response rewriter, schema widening and handler guards. This first needs maintainer agreement on whether dp conversion belongs in the daemon at all. If it does, could the descriptor contract (responseDataTransform or a typed geometry-field declaration) first declare each command's geometry paths, so the converter applies only declared fields?

Under dp, the daemon rewrites the tap, gesture and scroll coordinates sent to Android. The PR also adds a wm density read in readPixelDensity and a WebDriver capability density source. The description says nothing ran on a device or emulator, and the WebDriver density was not checked on a live hub. The unit tests use a fake owner and a hand-set density. So nothing shows that wm density parsing, the density remembered from a snapshot, or the rounded taps hit the intended element on a real display, which is the main user value. Each density source and coordinate conversion kept in scope needs live proof.

This evidence is required before merge: one live Android emulator run through the Node client with coordinateUnit: 'dp' on a fresh daemon.

  1. Before any snapshot, press a dp point inside a known element. Show that the element was hit, the response coordinates: {unit:'dp', pixelDensity}, and the pixel tap the daemon sent (diagnostics or trace). This exercises the wm density path.
  2. Take a snapshot and show the dp viewport and rects next to that label.
  3. Record with --save-script and show that the .ad line holds pixels.

If WebDriver density stays in scope, also show one BrowserStack or TestMu AI session where the label's pixelDensity came from pixelRatio or deviceScreenDensity.

Not verified here: no tests or device runs were performed, and the router-level tests were only read. It was also not checked whether live BrowserStack, TestMu AI or AWS Device Farm hubs return those capabilities, or confirmed in provider code that Revyl reports no density. Not every response field of every flagged command was checked against the screen-length field rules; no concrete wrong conversion was found in press, gesture, scroll, screenshot overlay, or snapshot viewport and keyboard frame.

CI is green, with none of the 2 reported checks failing. The PR is a draft, so device lanes did not run, and CI did not exercise the changed Android dispatch paths on a device. The live run above is needed before merge.

thymikee and others added 2 commits November 30, 2026 20:28
The dp conversion rounds every point, distance, and pixel amount to whole
pixels before dispatch, so handlers only ever see integers. Widening the
`jitterPx`, `pixels`, and fling `distance` schemas to numbers then needed
new native-only integer guards in the scroll and gesture handlers to keep
the old contract. Restore the integer schemas and drop the guards: native
requests behave exactly as before, and dp amounts convert at the edge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…shot

The density lived in a second, process-wide cache keyed by device id, kept
fresh by forget calls in the snapshot, fold, boot, and shutdown paths. The
session already stores the density every capture measures
(`snapshot.rectUnitsPerDp`), and that state is cleared when a session opens.

Make the density state machine one pure function in the coordinate-unit
owner, with no cache of its own:

1. measured: the session's latest capture (or, for a capture without a
   session, the density its own response reports);
2. provider: the density the Appium session reported at creation;
3. device: one `wm density` read on a device local adb reaches, not kept.

dp read from a snapshot now converts back with the density that snapshot
measured. The Android adapter's `readPixelDensity` becomes a stateless
`wm density` read, and the fold, readiness, shutdown, and snapshot paths
lose their cache hooks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

thymikee commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Hi @satya164, thanks for this. The need is clear, and the shape you picked (one meta option, converted at the router edge, handlers and .ad scripts stay in pixels, and a coordinates label on every converted answer) is the right one. I pushed follow-up commits on top of yours. Your commit is unchanged. Updated for 5eb6e6647c. This comment replaces the earlier versions.

Where it landed, compared with your commit

  1. No density is carried from one request to the next. Each attempt to keep a density across requests (a device-keyed cache, then the session's snapshot, then a name-and-boot binding) produced a new edge case: fold, a reused serial, a missing boot id, a reboot during a session. Now each request finds its own density:

    • If the request captured (snapshot, find, a cropped screenshot, --settle), its result converts with the density its own capture measured. The boundary runs dispatch inside an async-local density scope (AndroidObservationAdapter.openDensityScope). Every routed request opens its own scope at that boundary, whether native, dp, a batch step, or a nested request such as the click or fill of a dp find. Every parsed helper reply records into the scope of the request that made it, even a reply whose tree is then rejected. So neither overlapping requests nor a nested native request can change the density a dp request converts with. A capture outside any scope records nothing.
    • Otherwise, the request makes one wm density read. A request that sends coordinates makes this read before it dispatches.

    So a fold, a reboot, another emulator on the same serial, or a wm density change takes effect on the next request, with no lifecycle code. The cache, the fold, boot and shutdown hooks, and the boot-id probe are all gone. The cost is one wm density adb call (about 20 ms) on a dp request that sends coordinates. When no density can be read before dispatch, coordinate_unit_density_unknown says to send native pixels. The client guide's snapshot-to-press example names its prerequisite: a local Android device where the daemon can run adb shell wm density.

  2. No Appium capability density. There was no live hub run to prove pixelRatio or deviceScreenDensity, so that source is dropped. On a device that local adb does not reach (Limrun, WebDriver, Revyl), a dp request that sends geometry is refused with coordinate_unit_density_unknown. A capture on such a device that measures a density still reports its geometry in dp.

  3. Fractional amounts. With coordinateUnit: 'dp', jitterPx, scroll pixels and fling distance may carry a fraction on every platform, batch steps included. On Android they convert and round. Elsewhere dp is the native unit, so they only round. Without dp, these amounts must be whole numbers, and a fraction is refused before dispatch with INVALID_ARGS and details.field. A native batch is checked whole before its first step runs (details.step), so a fraction in a later step never follows a step that already touched the device. A dp batch needs no preflight.

There is still no CLI flag or MCP field, and the capability name is unchanged. On iOS, dp is the native unit and is labeled pt.

Live run at 50c5dcd8f8: an Android 15 emulator at 420 dpi (2.625), the Node client and CLI from this branch, and a fresh daemon.

  • agent-device devices --platform android --json lists {"id":"emulator-5570","name":"ReactNative API 35","kind":"emulator","model":"sdk_gphone64_arm64","osVersion":"15","booted":true}, with no extra fields.
  • A native snapshot of Settings puts the "Battery" row at {x:189, y:1752, w:168, h:71} px. A native scroll({pixels: 120.5}) is refused with INVALID_ARGS, {field:'pixels', dispatched:'no'}.
  • In a dp session, with no snapshot yet, press({x:104, y:680.952380952381}) opened the Battery page. That y is the row centre, 1787.5 / 2.625; the earlier version of this comment shortened it to 680.95, which made the rounding look wrong. The response was {x:104, y:681.14, coordinates:{unit:'dp', pixelDensity:2.625}}. The pixel point sent, from the saved .ad script, was press 273 1788: round(104 × 2.625) = 273 and round(1787.5) = 1788.
  • The dp snapshot that followed: viewport {411.43 × 914.29} and coordinates {unit:'dp', pixelDensity:2.625}, matching androidSnapshot.pixelDensity 2.625.
  • A dp batch.run of [press {x:20, y:20}, scroll {pixels:120.5}] was recorded as press 53 53, and the scroll reported pixels: 120.38 dp. Both steps were labeled dp.
  • A native batch.run of [press, scroll {pixels:12.5}] was refused with INVALID_ARGS, {field:'pixels', step:2, dispatched:'no'}.

Scope check at 5eb6e6647c, counting adb processes per request in the daemon's debug request log, in one session:

  • A native snapshot made 0 adb calls, and a dp snapshot also made 0. The dp snapshot was labeled {unit:'dp', pixelDensity:2.625} with viewport 411.43 × 914.29, so its density came from its own capture, not from an extra wm density read.
  • A dp press({x:200, y:450}) made exactly 1 adb call, its wm density read before dispatch. It answered y: 449.90, which is the dispatched 1181 px ÷ 2.625.

Not covered live: a physical Android device, and a fold, because this image is not foldable. With no state kept across requests, neither has a separate code path. CI is running on the new head.

@thymikee

Copy link
Copy Markdown
Member

Thanks for the follow-up work.

At 7313250, the code still needs fixes. Since the earlier findings, the 2026-11-30 live emulator run closes the Android part of the required evidence: the wm density press before a snapshot, the dp snapshot label, and the pixel .ad line. The WebDriver density source is still open, and the other problems are listed below.

The WebDriver capability density still has no live proof, and the posted run says it does not cover it. androidDensityFromWebDriverCapabilities sets the density from pixelRatio, else deviceScreenDensity / 160, and resolvePixelDensity uses it for every dp point and response on BrowserStack, TestMu AI and AWS Device Farm. If a hub value differs from the real display density, taps hit the wrong pixel and rects get wrong dp values without any sign. Only a unit test with hand-written capabilities covers this. Before merge, one of two things is required. One option is a BrowserStack or TestMu AI Android session through the Node client with coordinateUnit: 'dp' and no snapshot, showing the create-session capabilities, a press response whose coordinates.pixelDensity equals that value, and the intended element being hit. The other is to remove this density source, so these devices are refused until a snapshot measures the density, like Limrun.

A second independent pass found that fractional dp fling distances may fail in the Node client. At 2.5 px/dp, fling or gesture with distance: 12.5 reaches the integer reader before transport and throws INVALID_ARGS, although the daemon would convert it to 31 px. Batch gesture steps use the same reader, and the raw daemon test skips client preparation. Can every client-side call of readGestureInput, including nested batch steps, receive the effective unit and accept a finite fractional distance for dp, while the daemon reader stays integer after conversion?

A second independent pass found the same problem for batch scroll: a dp client.batch.run step with pixels: 12.5 throws during step validation, while a direct Node scroll forwards it. Can every batch step read through metadata.readInput use the effective batch unit and accept finite fractional pixels for dp, while the native schema stays integer?

A second independent pass also found it for jitterPx: a dp batch press or click with jitterPx: 2.5 is rejected before sending, although it converts to 6 px and direct calls keep the fraction. Can every command that uses repeatedFields accept finite fractional jitter for an inherited dp unit, with the native bounds applied to the converted pixels at dispatch?

A second independent pass found that the density resolver may keep the old ratio after fold. After a snapshot at 2 px/dp and a fold to a 3 px/dp display, a dp press at (100, 100) goes to (200, 200) instead of (300, 300), because the outdated snapshot is retained. The same applies if the posture change happens and the command then times out. Can any fold that may have been dispatched make the stored snapshot unusable as density evidence, so that dp input uses a fresh measurement or the existing fallback, or is refused?

A second independent pass found that an empty ref-scoped snapshot can report a ratio that the next press does not use. If density changes from 2 to 3 and the @ref target has left the screen, the response uses 3 but the session keeps the old tree and 2, so a 100 dp point is sent as 200 px. Can every capture that reports a new ratio also record it, or invalidate the old one, while the retained tree and its geometry evidence stay intact?

A second independent pass found that a dp cropped screenshot may use stale density. The crop takes a fresh snapshot, but its density is not in the result, so after a change from 2 to 3 px/dp a 300 px crop reports logicalWidth: 150 instead of 100. Can the density measured by the crop capture reach the coordinate conversion for that request and take priority there?

A second independent pass found that a sessionless Limrun find may drop its measured density. A dp find list on a lease without an app session can capture rects at 3 px/dp, but there is no session to store the ratio and the ADB read is skipped for the provider, so the rects are labeled px. Can every result take its density from the capture that produced its rects, before the session, provider or ADB fallbacks?

Not verified here: the live emulator run was not reproduced and was accepted from its posted output, which matches wm density 420 and the code path. It implies, but does not state, that it ran at this commit. Tests were read, not run. A device reboot inside an open session, and whether Revyl or Limrun captures publish androidSnapshot.pixelDensity, were not checked.

The 2 checks that ran pass. The PR is a draft, so the device lanes did not run, and CI did not exercise the Android dispatch path or the WebDriver provider path on a real device.

Before merge, the problems above need fixes or answers. The WebDriver density source also needs the live dp session proof described above, or it needs to be removed.

…fractional dp lengths

Review of 7313250 showed that the session's stored snapshot is not a full
record of what the device measured. A cropped screenshot, a sessionless
find, and an empty ref-scoped snapshot all capture without storing a tree,
and a fold left the stored density in place. This reverts the
session-snapshot lookup and the integer schema revert, then:

- Moves the measured density into one platform-android owner,
  `display-density.ts`, with two named transitions:
  `recordAndroidDisplayDensity` for every helper capture and `wm density`
  read, and `forgetAndroidDisplayDensity` for a fold, a boot, and a
  shutdown. A fold now forgets the density before it dispatches and again
  when it settles, so a fold that times out after it reached the device
  cannot leave the old density behind.
- Converts a result with the density its capture recorded. The density the
  request read is the fallback.
- Drops the Appium capability density source (`pixelRatio`,
  `deviceScreenDensity`), which has no live proof. A device that local adb
  does not reach has a density only after a helper capture measures one.
- Lets dp lengths carry a fraction in client preparation, batch steps
  included (`jitterPx`, scroll `pixels`, fling `distance`). The coordinate
  boundary rounds them to whole pixels. In the native unit, the same
  boundary refuses a fraction before dispatch with `INVALID_ARGS`. This one
  check replaces the two handler guards.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

Copy link
Copy Markdown
Member

Thanks for the follow-up work.

At d7d0046, the problems from the earlier review are fixed: the unproven WebDriver density source is removed, fractional dp amounts now pass the Node client and batch steps, and the stale or missing density cases for fold, empty ref snapshots, cropped screenshots and sessionless Limrun find are closed. The code still needs the fixes below.

A second independent pass found that a native batch can now change the device before it refuses a fraction. In a Node batch, take a valid first press, then a scroll with pixels: 12.5, a press or click with jitterPx: 2.5, or a fling with distance: 12.5. At the base, the integer readers checked the whole batch before sending it. Now the readers accept these steps, the whole-pixel check is skipped for the batch request, and the first press is dispatched before the second step fails. Can the same whole-pixel check run on every normalized step of a native batch before the first step is invoked, while standalone requests keep the current check and Android dp steps still round at the router?

A second independent pass found that a measured density can be lost when its tree is rejected. With 2 px/dp recorded, change the display to 3 px/dp and take a snapshot while the accessibility window gives no usable tree. The helper can reply with density 3 and rootPresent false, but the reply is rejected and the retries throw before the density is recorded, so a 100 dp press still sends 200 px. Can every parsed helper reply record or clear the density before its accessibility content is classified, with the current retry and failure behavior unchanged?

A second independent pass found that a replacement emulator may inherit the old density. Measure 2 px/dp on AVD A at emulator-5554, close its app session without shutdown, let A exit on its own, and boot a 3 px/dp AVD B on the same serial before the first open. Open skips readiness for the booted device, so A's value is used before wm density can run, and a 100 dp press can land at 200 px instead of 300 px. Can a serial-keyed density be reused only after it is matched to the current emulator and boot, and be forgotten otherwise?

A second independent pass found that the client guide promises something web does not do. It says dp lengths may carry a fraction and that the web target refuses nothing, but client.interactions.scroll on web with coordinateUnit: 'dp', direction: 'down' and pixels: 12.5 now returns INVALID_ARGS from the non-Android check before dispatch. Can the guide limit fractional rounding to Android, and state that a non-Android dp request uses its native unit and its whole-number rules?

The 2 checks that ran pass. The PR is a draft, so the Android device lanes did not run, and CI did not exercise the density recording from helper captures or the fold clear on a real device.

Not verified here: the 2026-11-30 live emulator run predates this commit and was not repeated. It was judged to still apply, together with the unit tests, because dispatch and capture did not change in the way density is now sourced. Tests were read, not run. The match between a Limrun capture's device id and the bound device id was traced in code only.

Before merge, the four problems above need fixes or answers.

…nsity gaps

- A batch whose steps stay in the native unit is checked whole at the
  coordinate boundary before its first step runs. A fractional `pixels`,
  `jitterPx`, or `distance` in a later step can no longer follow a step
  that already changed the device. The refusal names the step. Android dp
  batches still convert step by step.
- Every parsed helper reply records or clears the density before its
  content is classified. A reply whose tree is then rejected still updates
  the density. Retry and failure behavior are unchanged.
- A stored density answers only the device it was measured on: the same
  name (the AVD, for an emulator) and the same boot. The inventory probe
  reads the kernel boot id on the same adb shell as its properties, as the
  internal `DeviceInfo.bootId`, which public device projections strip.
  Another emulator or a later boot on a reused serial forgets the entry.
- The client guide limits fractional dp rounding to Android. On other
  platforms, a dp request uses the native unit and its whole-number rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

Copy link
Copy Markdown
Member

Thanks for the follow-up work.

At 18b8034, the batch refusal, rejected-tree density and client guide problems from the earlier review are fixed for the reported routes, but the replacement-emulator fix does not hold without a boot ID, and the code still needs the fixes below.

A second independent pass found that a failed boot ID read can hide a running device's properties. The props probe now ends with cat, so its exit code becomes the shell's exit code. If getprop prints sys.boot_completed=1, the model and the OS version, and cat then fails, all of that output is discarded. The device appears unbooted and loses its model and OS version, even in native mode. Can the boot ID read be optional inside the same shell fragment, for example by printing an empty line when cat fails, while an adb transport failure is handled as it is now?

A second independent pass found that a replacement emulator can still inherit the old density. Measure 2 px/dp, close the session without shutdown, and restart the same AVD externally at 3 px/dp on the same serial. If neither inventory read supplied a boot ID, the identity is the same name and null for both boots, so the stored value is reused and a 100 dp press is sent at 200 px. Can a stored density be reused only with positive evidence of the same boot, with a fresh read or the current capture's own density otherwise?

A second independent pass found that an open session can keep density from an earlier boot. Record density 2, reboot the device externally, bring the app back to the foreground, change density to 3, and send a dp press. The saved device info is reused and passed to the density reader, which returns the stored value before it reads the device, so a 100 dp point still becomes 200 px. Can every use of a stored density first match its boot ID against a current read from the bound device, and get a fresh density or refuse the dp geometry when the boot changed or cannot be verified?

A second independent pass found that some native batches can still change the device before refusing a fraction. Without a session, send a dp batch that opens an iOS app and then scrolls with pixels: 12.5. The whole-batch check is skipped, the app opens, and only then is the scroll refused. A batch that starts on Android, closes that session and opens iOS does the same, although the client guide promises refusal before step 1. Can the effective platform of each geometry step, including after a declared open or close and reopen, be resolved before execution, and every step that will use the native unit be checked before step 1?

A second independent pass found the reverse case, where a valid Android step is refused. Start a named iOS session, then send a dp batch that closes it, opens an Android app under the same session name, and scrolls with pixels: 12.5. The preflight treats the whole plan as iOS and refuses step 3, but each step resolves its session again and the same-name replacement route exists. At density 2.5, that scroll should become 31 px. Can the preflight follow each step's effective platform, so Android dp steps keep their fraction until conversion?

Both reported checks pass at this commit.

The PR is a draft, so the Android device lanes did not run the changed props probe or the helper-capture density record on an emulator.

Not verified here: whether the boot ID read can fail for the adb shell user on any production Android device, and the route from the probe to the session device was traced in code only. Tests were read, not run.

Before merge, the problems above need fixes or answers, and a live run on a booted Android emulator is required at the updated head, ideally also on one physical device, because the last live run predates the changes to the discovery command and the capture-time density record. The run needs to show that agent-device devices --platform android --json lists the device with booted: true, its AVD name and no bootId field. It also needs an app opened with coordinateUnit dp, a snapshot showing coordinates: {unit: 'dp', pixelDensity}, and a dp press whose output shows a pixel point equal to round(dp * density).

Binding a stored density to a device's name and boot kept producing edge
cases: a missing boot id, a session that outlived a reboot, and a probe
whose exit code could hide device properties. Each request now finds its
own density, and nothing is reused:

- A capture during the request answers. Every parsed helper reply records
  the density it measured with a monotonic instant, and the boundary reads
  only what was measured since the request started.
- Otherwise one `wm density` read is made for the request. A request that
  sends coordinates makes the read before dispatch.

This removes the boot id (inventory probe, `DeviceInfo.bootId`, public
strip), the fold, readiness, and shutdown hooks, and the forget/identity
transitions. A fold, a reboot, a replacement emulator, or a `wm density`
change takes effect on the next request with no lifecycle code.

dp lengths may now carry a fraction on every platform: Android converts
and rounds, and elsewhere dp is the native unit, so the amount only
rounds. A dp batch therefore needs no per-step platform preflight. A native
batch is still checked whole before its first step runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

Copy link
Copy Markdown
Member

Thanks for the follow-up work.

At 683381e, the boot ID probe, stored density and both dp batch problems from the earlier review are fixed, the stored density ones for sequential requests, but the code still needs the three fixes below.

The coordinate_unit_density_unknown hint still says that a snapshot on a local Android device reads the density. Each request now accepts only measurements taken after it started, so on a local device this refusal means that wm density failed or did not parse. A caller that follows the hint takes a successful snapshot, resends the dp press and is refused again, and the hint hides the action that works: sending native pixels. Please make the hint, the error reason docs and the client guide describe only what works now, for example: "Send this request with coordinateUnit native and physical pixels; the density is read for each request, and a device that local adb does not reach has none before dispatch."

A second independent pass found that overlapping requests can scale a snapshot with another request's density. With one selectable Android device and no open session, two snapshots from different workspaces, without a device selector or explicit session, get different session locks and no device lock. The first captures at 2 px/dp and then waits for a sparse fallback screenshot after a presentation failure. If the density changes during that wait, the second records 3 px/dp for the device, and the first request accepts it and divides its 300 px viewport width by 3 instead of 2. Each routed request or batch step must read only a helper density that it measured itself, keyed by device, before it falls back to its own wm density result; this applies to every place that records or reads a measured density.

A second independent pass found that the snapshot-to-press example fails on Limrun Android. With an open session, its helper capture can return coordinates.unit = 'dp', so the example enters the press branch. The press then has no earlier measurement to use and no local wm density read, and is refused with coordinate_unit_density_unknown. The example's prerequisites must limit it to where it works: local Android where the daemon can run adb shell wm density. The documented provider behavior can stay.

Both reported checks pass at this commit. The PR is a draft, so the Android device lanes did not run. The posted live emulator run covers the changed density path, but its y pixel, 1788, does not match the stated input of 680.95 dp at 2.625 px/dp, which rounds to 1787.

Not verified here: the live run was not reproduced, tests were read and not run locally, and it was not traced again whether a Limrun or other provider helper capture records density under the same device ID that the request binds.

Before merge, the hint that still tells callers a snapshot supplies density for a later request needs a fix, along with the overlap and the client guide example.

- A helper capture now records its density into the async-local scope of
  the request, or batch step, that runs it (`openDensityScope`). Overlapping
  requests on one device each read only what their own captures measured,
  and a capture outside a scope records nothing. This replaces the shared,
  timestamped record. `readPixelDensity` goes back to one stateless
  `wm density` read.
- The `coordinate_unit_density_unknown` message and hint no longer say a
  snapshot supplies the density. They point to native pixels instead, and
  `error-reasons.md` and the client guide match.
- The client guide's snapshot-to-press example now names its prerequisite:
  a local Android device where the daemon can run `adb shell wm density`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

Thanks for the update. All three problems from the earlier review at 683381e are fixed at 50c5dcd, but one likely defect remains: a nested native click or fill can overwrite the density of its parent dp find request.

On that defect, a second independent pass found this route. A dp find click with flags.settle=true on an open local Android session measures 2 px/dp, with the match center at x=300 px. The handler builds a new click request that keeps settle but has no coordinateUnit (click request, settle copy), and the router re-enters handleRequest. That native dispatch keeps the parent's async density store. If the display changes to 3 px/dp during the click's settle capture (observation), the snapshot writes 3 into the find's map. Find still publishes the pre-click center, but the conversion then divides it by 3 (first site, second site) and returns 100 dp instead of 150 dp. Find fill has the same leak: it invokes a new native fill and returns its result, with a touch point from the pre-resolved target (fill, response). Both also leak when run as a dp batch step. Please reset the ambient density store on every native dispatch at the router boundary, including native commands invoked from a dp handler, so each dp frame's map stays private to its routed request.

CI is green at this commit: 2 checks reported and none failing. Android device lanes did not run because the PR is a draft.

Not verified here: tests were read and not run locally. The posted live emulator run predates this commit, and no live run shows the dp snapshot label through the new request scope. The router test uses a fake scope, so propagation through the real daemon to the capture was only traced by reading.

Before merge, the nested density leak needs a fix, and the PR needs to leave draft.

A native request that a dp request starts, such as the click or fill of a
dp `find`, or a step of a dp batch, re-enters the router. It ran inside
the parent's async-local density scope, so its settle capture could write
a new density into the parent's map, and the parent then converted its
own result with that density.

The coordinate boundary now opens a fresh density scope for every routed
request, whether native, dp, batch, or nested, and dispatches inside it.
A capture records only for the request that made it, so each dp frame
reads only its own measurement.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

Thanks for the fix. The nested density leak from the earlier review at 50c5dcd is fixed at 5eb6e66, and no blocking problem remains in the code: every routed request, including nested clicks, fills and batch steps, now dispatches inside its own density scope.

CI is green at this commit: 2 checks reported and none failing. Android device lanes did not run because the PR is a draft.

Not verified here: tests were read and not run locally. The nested find click and fill isolation was only traced by reading the code, because no test drives a nested capture through the real router and no live emulator run covers this commit. The one-time cost of now loading the Android observation module on the first request of any platform was not measured.

Before merge, the PR needs to leave draft.

@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

@satya164 the latest review at 5eb6e66 came back clean, with the independent cross-check passing too. Two small asks before merge:

  1. Could you mark the PR ready for review when you're happy with the changes on top of your commit? It can't be approved while it's a draft.
  2. If you have access to BrowserStack (or another cloud device farm), could you run one dp snapshot and one dp press on an Android device there and paste the output? The current design reads density per request with wm density or from the request's own capture, and reading it from Appium capabilities was removed because it couldn't be verified. A cloud run would show whether dp coordinates work end to end for your use case, or whether that source should come back.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 54 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread website/docs/docs/error-reasons.md Resolved
Comment thread test/wire-compat/surface.ts Resolved
Comment thread packages/daemon-client/src/index.ts Resolved
Comment thread website/docs/docs/client-api.md Resolved
Comment thread website/docs/docs/error-reasons.md Resolved
Comment thread website/docs/docs/snapshots.md Resolved
@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 1, 2026
@satya164

satya164 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Claude, an AI assistant, wrote this review at the PR author's request against 5eb6e6647c, with the findings checked against the code and not run on a device.

Thanks for all the work here: it didn't find a blocking bug on local Android devices, and the per-request density scope holds for concurrent and nested requests.

Important

  1. dp input doesn't work on provider Android devices (Limrun, BrowserStack, TestMu AI, Revyl). readDensity doesn't return a density there, so every dp request with a point is refused. On Limrun, snapshots pass snapshot.coordinates?.unit === 'dp' in the client guide example, then press fails with coordinate_unit_density_unknown. Hosted devices are where the author needs dp, so could callers send pixelDensity from an earlier coordinates label to keep the daemon stateless (and at minimum match the example guard to where press works)?

  2. A dp batch on those devices fails partway through. Preflight is skipped for dp, so [fill @e1 "a", press 100 200] runs the fill then fails the press, and the error becomes dispatched: 'unknown'. Since the provider device and step geometry are known up front, could preflight refuse it before step 1 like native fractions?

  3. The wm density read doesn't pass a timeout or abort signal. Other adb reads there pass timeoutMs, and every dp point request runs this, so a stalled adb call holds the session lock indefinitely. Passing a timeout and request signal would bound it.

  4. apps.open({ foreground: true }) drops the unit label (author's original commit). The daemon sets coordinates on the outer response, but the Node client doesn't copy it into AppOpenResult. Copying it lets callers tell converted snapshots from pixel ones.

  5. Native mode changed for callers who don't opt in (author's original commit). client.interactions.scroll({ direction: 'down', pixels: 12.5 }) previously rounded to 13 px and is now refused with INVALID_ARGS. The MCP schema lists number for pixels though MCP can't send coordinateUnit, giving a hint suggesting dp (also sent on pre-session dp refusals). Keep native rounding, or keep the refusal while stating "whole number unless coordinateUnit: 'dp'" in field descriptions and dropping the dp hint on dp requests?

  6. A new client with an older daemon can run half a native batch. Previously the client refused [press, fling distance 12.5] up front, whereas now an older daemon runs the press then rejects the fling. Unlikely in practice, though checking native fractions after merging config and per-call units keeps the old behavior.

Nits

  1. Every routed request awaits openDensityScope(), which loads the Android observation module on first request even on iOS or web daemons. display-density.ts only imports node:async_hooks, so a direct import makes openDensityScope synchronous.

  2. Every dp request that doesn't capture runs wm density (before dispatch for points, after for others). A 10-press batch makes 10 reads (the stated design), though one read per batch could help if cost shows up.

  3. Retained-node responses use current density instead of capture density. After a density change (like folding), get attrs @ref or a nested find … fill error with an older rect uses the wrong ratio. Only matters mid-session, though storing capture density on the node avoids it.

  4. On Apple with dp, jitterPx: -0.1 rounds to 0 and passes the 0..100 check. Checking the lower bound before rounding rejects it.

  5. Native batch preflight normalizes with no step limit, so a fraction in step 2 beats batchMaxSteps and steps normalize twice. Running it in runBatch after the limit check avoids both.

Unchecked: didn't run on a device or provider, and didn't run the full gate.

@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

Thanks, the review at 5eb6e66 holds on two blocking points, both confirmed in the code: dp points are refused on every hosted Android device because readDensity returns no density for provider devices (coordinate-unit.ts:437), and callers who never opt in now get INVALID_ARGS for fractional native pixels that used to round. A dp batch on a hosted device also needs the preflight refusal before step 1, and the wm density read needs the request timeout and signal. Because hosted devices are the main target for dp, this goes back to work before merge.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 1, 2026
…read

Addresses the author review at 5eb6e66.

- Hosted Android devices (Limrun, BrowserStack, TestMu AI, Revyl) have no
  `wm density` read, so every dp point was refused. A caller can now pass
  `coordinateDensity` (client config or per call, request meta), the
  `pixelDensity` of an earlier `coordinates` label. The daemon converts
  with it only when it measures no density itself, so it stays stateless.
  Replay never inherits it.
- A dp batch on a hosted session without `coordinateDensity` is refused
  with `coordinate_unit_density_unknown` and the step number before its
  first step runs, instead of failing partway.
- The `wm density` read is bounded by the request deadline (at most 5 s)
  and canceled with the request signal. A canceled request stays canceled.
- Native behavior is restored for callers who do not opt in. A fractional
  `pixels`, `jitterPx`, or fling `distance` rounds to a whole number of
  native units in every mode, as `pixels` did before. The native
  whole-number refusal, its batch preflight, and the dp hint are removed.
  A negative amount stays as sent, so the handler still refuses it.
- `apps.open` copies the `coordinates` label into `AppOpenResult`.
- `openDensityScope` imports only the dependency-free scope module, so it
  no longer loads Android observation code on every daemon.
- The client guide example passes the snapshot's density, so it works
  wherever the snapshot was labeled dp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

@satya164 thanks for the review. c9cb0256d3 addresses it:

  1. Hosted devices. Pass coordinateDensity (client config or per call), set to the pixelDensity of an earlier coordinates label. The daemon converts with it only when it cannot measure a density itself, so it keeps no state. The client guide example now passes snapshot.coordinates.pixelDensity this way, so press works wherever the snapshot was labeled dp. Replay never inherits the value.
  2. dp batch on a hosted session. Without coordinateDensity, the batch is now refused with coordinate_unit_density_unknown and details.step before step 1, instead of failing partway with dispatched: 'unknown'.
  3. wm density read. It now uses the request deadline (capped at 5 s) as its timeout and stops when the request is canceled. A canceled request stays canceled instead of turning into a density refusal.
  4. Native behavior. Callers who don't opt in see no new INVALID_ARGS. A fractional pixels, jitterPx or fling distance rounds to a whole number of native units in every mode, as pixels did before. The native refusal, its batch preflight and the dp hint are gone. A negative amount is not rounded, so -0.1 is still refused.
  5. AppOpenResult now carries coordinates.
  6. Nit 7. openDensityScope loads only the small scope module, so iOS and web daemons no longer load the Android observation code.

Live on a local Android 15 emulator at 2.625:

  • A native scroll({pixels: 120.5}) scrolled 121 px.
  • A dp apps.open({foreground: true}) returned coordinates: {unit: 'dp', pixelDensity: 2.625}.
  • A dp press with that coordinateDensity answered labeled dp.

The hosted path is covered by router tests only, because no hosted device was available.

@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

Thanks for the follow-up. At c9cb025, the earlier pre-session fractional-amount refusal is fixed, but the following issues remain.

The hosted snapshot-to-action workflow has no density source for BrowserStack, TestMu AI, or Revyl: their capture paths do not supply density, and provider ADB is skipped before and after the command. A new caller following the guide receives a px snapshot and skips the press; a dp point without an externally supplied density returns coordinate_unit_density_unknown. Please expose a request-scoped display-density read or capture fact through each Android provider runtime, use it at the coordinate boundary, and retain the caller override as a fallback. Coordinate boundary

Native scroll distances such as 0.25 now round to zero and fail, although the previous planner accepted them as one pixel. Positive dp distances that scale below 0.5 fail too. Please keep native scroll pixels on their existing planner and preserve a one-pixel minimum for positive Android dp scroll distances, while still rejecting zero and negative values. Conversion

A native batch containing a valid press followed by a fractional fling can now reach an older daemon, which dispatches the press before rejecting the fling; the previous client rejected the batch before dispatch. Please retain native fling integer validation during batch preparation after the effective configuration and per-call unit are known, while allowing fractional dp input when the client requires a capable daemon. Batch preparation

Native press jitter and fling distances are now rounded before their previous validation. For example, jitterPx:100.4 can execute a randomized press despite exceeding the previous ceiling. Please preserve native jitter and fling validation and apply fractional conversion only in opted-in mode, while keeping the existing native scroll path. Conversion

The reported Android 15 emulator run and router tests do not establish the hosted snapshot-to-action path or a no-mutation refusal through an actual provider. Before merge, please record current-head Node transport runs through Limrun, BrowserStack, TestMu AI, and Revyl, showing the initial snapshot and density source, a dp press with observable target confirmation, and a no-density geometry batch with its step number, dispatched:no, and unchanged UI. Client guide

The open threads on pre-send disposition, density fixture, wire compatibility, replay cleanup, and overlay coordinates still apply, as do two lower-priority threads. The sessionless conversion thread no longer applies because actions require a session; the structured input thread does not apply because the assertion reads the correct property; the fling transport thread does not apply because fling uses the structured gesture writer; the pre-session amount thread is fixed at head.

The prose and link checks and coverage checks overlap the changed documentation and code, so they may be related; the Apple runner build appears unrelated to the changed inputs. Not verified here: the causes of the failing checks, because failed-step logs were not supplied. No conflicts are known. Before merge, provide the density sources, preserve native behavior and batch preflight, document the live provider evidence, and resolve or attribute the failing required checks.

… in host-kit

Addresses the review at c9cb025 and the CI failures on that head.

- Native requests go to their handlers as sent again. Scroll `pixels` keeps
  its planner, so 0.25 still scrolls one pixel. Press `jitterPx` keeps its
  0..100 integer check. A fractional fling `distance` is refused with
  "Expected distance to be an integer." as before. dp on a platform other
  than Android, where it is the native unit, also goes as sent.
- An Android dp amount converts to whole pixels, and a positive one to at
  least one pixel, so a small positive scroll no longer rounds to zero.
- A native client batch refuses a fractional `jitterPx`, `pixels`, or
  `distance` before it sends any step, as it did before. The check runs
  once the configured and per-call unit are merged, so a dp batch can
  still send fractions.
- The per-request density scope moves from the Android observation adapter
  to `@agent-device/host-kit/display-density-scope`. The daemon opens it
  synchronously, so every routed request gets one without an adapter call.
  This fixes the compositions whose adapter has no scope, where every
  request failed. The Android capture imports the module lazily, which
  keeps the mechanics eager closure at its base.
- `error-reasons.md` is regenerated from the reason table.
- The client guide states the native rules and which hosted devices label
  dp: Limrun snapshots report a density, and WebDriver and Revyl snapshots
  do not.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The dp capability refusal now runs inside the cleanup-managed send, so a
  one-shot daemon still retires when the client refuses a dp request.
- The reason table wording says what each refusal means for the caller.
  `coordinate_unit_density_unknown` covers all dp geometry and dispatched
  nothing; `dp_coordinates_unsupported` is a client refusal before the send.
  `error-reasons.md` is regenerated from it.
- The wire surface also tracks `readResponseCoordinates`, the parser
  clients use for the label.
- `CaptureScreenshotResult.coordinates` names what it covers: overlay node
  rects, while `overlayRect` and `center` stay in image pixels.
- snapshots.md qualifies its Android pixel statement with "By default".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

Follow-up at 92f5e9b36e (with 99c9e7e03e):

  • Native behavior is unchanged again. Native requests reach their handlers as sent. Scroll pixels keeps its planner, so 0.25 still scrolls 1 px. jitterPx keeps its 0–100 integer check, so 100.4 is refused. A fractional fling distance is refused with "Expected distance to be an integer.", as before. dp on iOS or the web is the native unit, so it also goes as sent.
  • Android dp amounts. They convert to whole pixels, and any positive amount becomes at least 1 px.
  • Native batches. The client refuses a fractional jitterPx, pixels or distance before it sends any step, as it did before. The check uses the configured unit merged with the per-call one, so a dp batch can still send fractions.
  • Density scope. It moved out of the Android adapter into @agent-device/host-kit/display-density-scope. The daemon now opens it without an adapter call, which fixes the host, composition and Limrun HTTP tests that failed at c9cb025. The capture imports it lazily, which fixes the eager-closure budget failure.
  • Generated reasons page. error-reasons.md is regenerated, which fixes the docs check. The open inline threads are answered and resolved.

Still open, and I'd rather not guess:

  • A density read through each hosted provider's runtime would mean a new runtime operation per provider. On Limrun, a helper snapshot already labels its result with the density, and that pixelDensity can go back as coordinateDensity. WebDriver and Revyl snapshots report no density, so the guide now says their geometry stays px and dp input needs a density from elsewhere.
  • Live runs on Limrun, BrowserStack, TestMu AI and Revyl need provider accounts I don't have here. The hosted path is covered by router tests only.

thymikee and others added 2 commits December 1, 2026 19:59
Hosted Android devices had no density source before dispatch, so every dp
point was refused unless the caller passed `coordinateDensity`. Add one
optional operation to the gesture runtime family, `readDisplayDensity`,
next to `gestureViewport`, backed by an optional interactor method:

- The Android interactor runs `adb shell wm density` through the device's
  adb route, bounded at 5 s and canceled with the request. This covers
  local devices and Limrun, whose interactor routes adb through its own
  session.
- The WebDriver interactor reads `displayDensity` from UiAutomator2's
  `mobile: deviceInfo` (BrowserStack, TestMu AI, Sauce Labs, AWS Device
  Farm). Android only; XCUITest has no dp.
- Owners declare it like any other fact. Local Android, Limrun, and
  WebDriver Android declare it; everything else reports the gesture
  family's denial.

The coordinate boundary reads the density through this operation for
every Android device, before dispatch for input and after dispatch only
when no capture of the request measured one. `coordinateDensity` stays the
fallback. The observation adapter's `readPixelDensity` and the
provider-device special case are gone. A dp batch on an Android session
reads once and is refused before its first step only when no density
answers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The client guide lists where each request's density comes from: its own
capture, else the device's read (`wm density` locally and on Limrun,
`mobile: deviceInfo` on WebDriver hubs), else `coordinateDensity`. Revyl
answers no read. The example no longer passes a density by hand. The
`coordinate_unit_density_unknown` reason and hint say the device answered
no read, and `error-reasons.md` is regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

Hosted-device density at 5e1ed75c71:

  • One new provider operation. readDisplayDensity sits in the gesture runtime family next to gestureViewport, backed by an optional interactor method. The Android interactor runs wm density through the device's adb route, so it works locally and on Limrun, which routes adb through its own session; the read is bounded at 5 s and stops when the request is canceled. The WebDriver interactor reads displayDensity from UiAutomator2's mobile: deviceInfo, which covers BrowserStack, TestMu AI and AWS Device Farm. Revyl declares no read. There are no new flags.
  • How the coordinate boundary uses it. It reads the density through this operation for every Android device. The order is: the request's own capture, then the owner's read, then coordinateDensity. The daemon keeps nothing between requests. A dp batch reads once, and is refused before its first step only when nothing answers. The observation adapter's readPixelDensity and the provider-device special case are gone.
  • Live runs. Limrun (1.75) and BrowserStack on a Pixel 8 (2.625): each dp snapshot was labeled dp, and each dp press hit its target. Revyl: snapshots are labeled px, and a dp press and a dp batch were refused with dispatched: no and the UI unchanged. Sauce Labs: a raw Appium check returned displayDensity 420. agent-device has no Sauce Labs provider. TestMu AI: unit tests only, because there were no credentials. Details are in the PR body, and every session opened was released.

@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

Thanks for the updates. Review of 59a928b found four remaining issues. Native scroll and jitter conversion, native batch preflight, and daemon fling rejection are fixed; the previous live evidence gap is partially closed.

The batch preflight discards the density it reads, so a later step can fail to read density after an earlier step has modified the device. Carry the preflight density as batch-local driver density for admitted steps on that device, keep each step's capture density first for labeling results, and discard the value after the batch.

The WebDriver density read has neither the request signal nor a probe budget. A stalled hub can hold the session lock for roughly a minute after cancellation or deadline expiry. Pass the binding signal to the read-script transport and bound the whole density read across attempts.

The fling projection now lets a native fractional distance reach session lookup before rejection, so Node and CLI callers can receive a session error or contact a daemon for invalid input. Keep integer validation in the shared native projection and native positional parser, allow fractions only in the Node projection with effective dp opt-in, and retain strict daemon validation after conversion.

The TestMu AI route still lacks the requested live Node transport evidence. The BrowserStack receipt and TestMu AI stub do not show that the TestMu AI hub returns usable density. Before merge, record a production-equivalent run without coordinateDensity that shows density in a dp snapshot and an observable target change after a dp press.

The earlier session thread does not apply because coordinate actions require a session: #5284 (comment). The client refusal documentation is fixed: #5284 (comment). Capture scope is fixed: #5284 (comment). Wire compatibility tracking is fixed: #5284 (comment). The structured input test is correct: #5284 (comment). Fling distance is in structured input: #5284 (comment). Capability refusal now has cleanup: #5284 (comment). Overlay and screenshot coordinates are distinguished: #5284 (comment). The earlier pre-session amount rejection is removed: #5284 (comment). The dp geometry error documentation is fixed: #5284 (comment). The snapshot documentation is fixed: #5284 (comment). No lower-priority threads still apply.

Body rules likely fails because the supplied PR body exceeds the prose limit; Coverage overlaps the changed code, but its failing substep and cause are unclear without logs. No conflicts are known. Not verified here: tests, gates, or device actions were not run; the review was static. The hosted receipts cover production-equivalent 5e1ed75, with only a later layering test export change. Preserve early native fling validation, make preflight density govern batch execution, bound and cancel the density probe, provide the TestMu AI receipt, and resolve or attribute both failing checks before merge.

…ck native fling early

- A dp batch's preflight density read now governs its steps. It is kept
  batch-local, the steps on that device convert with it instead of reading
  again, each step's own capture still labels its results, and it ends
  with the batch.
- The WebDriver density read takes the binding's signal and one 5 s budget
  across resends. `executeReadScript` accepts a signal and a timeout, and
  the interactor's `readDisplayDensity` receives the binding signal.
- The client's gesture projection refuses a fractional fling distance
  unless the effective unit is dp, so native Node and CLI callers fail
  before any session lookup. A dp batch step carries its unit into that
  projection. The daemon still checks whole pixels after conversion.
- `gesture-runtime.test.ts` covers the new `readDisplayDensity` fact.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

Follow-up at 16ff9ac017:

  • Batch preflight density. A dp batch now converts its steps with the density its preflight read for that device, instead of reading again per step. Each step's own capture still labels its results, and the value ends with the batch. The router test covers a device that answers only the first read.
  • WebDriver density read. It now receives the binding signal and has one 5 s budget across resends, so cancelling the request or hitting its deadline stops it.
  • Native fling. The client refuses a fractional distance before sending unless the effective unit is dp, so native Node and CLI callers no longer reach a session lookup. A dp batch step carries its unit into the check, and the daemon still checks whole pixels after converting.
  • Failing checks. Coverage failed on gesture-runtime.test.ts, which pins the gesture fact catalog; it now includes readDisplayDensity. Body rules failed on length, so the body is shorter and passes the checker locally.
  • TestMu AI. Still unit tests only: no TestMu or LambdaTest credentials are available here. The read is the same UiAutomator2 mobile: deviceInfo call that returned 420 dpi on BrowserStack and Sauce Labs. A live run needs credentials or a maintainer waiver.

@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

Thanks for the updates. At 16ff9ac, the catalog mismatch is covered by the changed assertions, but the findings below remain.

Could positional fling parsing require an integer distance for every CLI and native replay step before dispatch? A malformed replay step can currently trigger Android dialog readiness, close and relaunch the app, or return a dialog error before INVALID_ARGS. Keep fractional distances in the effective-dp structured projection and retain the whole-pixel daemon guard.

The existing TestMu AI production-path evidence requirement remains open. Shared WebDriver code, a stub, and another hub’s receipt do not establish usable TestMu AI density or an observable dp press. Before merge, record the maintainer’s decision on the pending receipt or waiver; the requested receipt must use production Node transport without coordinateDensity, show a dp-labeled snapshot, and show a target change after a dp press.

Repo Guards failed on the changed coordinate-unit code: Fallow reports cyclomatic complexity 17 and cognitive complexity 16 for runInCoordinateUnit. Body rules was cancelled after the PR body changed, so it has no passing result. Coverage no longer appears among the nonpassing checks. No conflicts are known.

Before merge, restore positional validation, reduce the reported complexity, and obtain a green Body rules run; the TestMu AI evidence decision remains with the maintainer. Not verified here: tests, gates, and device actions were not run. The WebDriver test observes a stub, and the older provider receipts do not validate the retry budget or batch carry path on a live device.

- The positional gesture parser that the CLI and replay share now requires
  a whole-number fling distance before dispatch, so a malformed replay step
  is refused with INVALID_ARGS before any readiness work. Structured dp
  input still allows a fraction, and the daemon still checks whole pixels
  after converting.
- `runInCoordinateUnit` is split into `invalidUnitRequest`,
  `dispatchBatch`, and `dispatchInDp`, which brings it under Fallow's
  complexity limits. Behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

Follow-up at 1aa196bbd3:

  • Positional fling. The gesture parser shared by the CLI and replay now requires a whole-number fling distance before dispatch, so a malformed replay step is refused with INVALID_ARGS before any dialog readiness or relaunch work. Structured dp input still allows a fraction, and the daemon still checks whole pixels after converting.
  • Fallow complexity. runInCoordinateUnit is split into request validation, batch dispatch and dp dispatch. Behavior is unchanged, and fallow audit reports no complexity issues across the changed files.
  • Body rules. The body passes scripts/check-pr-body.ts locally. Its CI run is going on this push; the previous one was cancelled when the body was edited.
  • TestMu AI. Live evidence is still open, because there are no TestMu credentials here. Whether to provide a receipt or waive it is the maintainer's call.

@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member

Thanks for addressing the earlier review. The positional and CI issues are fixed at 1aa196b, with evidence still pending for TestMu AI production Node transport without coordinateDensity.

Before merge, a maintainer must decide whether to require a TestMu receipt or waive it; a receipt must show a dp-labeled Android snapshot and a visible target change from a dp press in a TestMu session. The packet records neither a receipt nor a waiver.

GitHub reports no failed or pending checks, and Repo Guards & Compatibility, Body rules, Coverage, and Android smoke passed. The earlier Fallow failure overlapped the changed runInCoordinateUnit directly, and the earlier Body rules run was cancelled. No conflicts are known.

The previous and current packets record zero open and eleven resolved threads. The earlier local Android 15 and hosted Limrun, BrowserStack, and Revyl reports do not cover the new malformed-step path, one-read batch carry, or WebDriver retry budget on a live device; this head's Android smoke runs the existing settings replay and is not a dp-specific receipt. Not verified here: local tests or device actions; the pinned Git objects and packet were reviewed, and test validity was checked against the previous parser and merge base. Not verified here: session-release output, the reported local body-check execution, or the older helper omitting density, which were not included.

@thymikee

thymikee commented Dec 2, 2026

Copy link
Copy Markdown
Member

Maintainer decision: the live TestMu AI receipt is waived for this PR. The TestMu AI route uses the same UiAutomator2 mobile: deviceInfo density read that was verified live on BrowserStack and Sauce Labs, and unit tests cover it. A live receipt can follow later.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 2, 2026
@thymikee
thymikee merged commit fb66f50 into callstack:main Dec 2, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants