Skip to content

Commit f5446df

Browse files
committed
fix(limrun): batch the iOS double tap so the inter-tap gap stays on-device
Limrun iOS direct sessions issued two independent tap requests for a double tap, putting a network round trip between them. That exceeds the double-tap recognition window, so every double tap registered as two slow single taps. Send both taps in one performActions batch with an 80 ms on-device wait.
1 parent 6dd57d9 commit f5446df

3 files changed

Lines changed: 52 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
unsupported although the SDK exposes the HID primitives; it now holds one touch as a
77
`performActions` batch of `touchDown`, `wait`, `touchUp`, defaulting to the 800 ms the Android
88
and Linux interactors use when no duration is given.
9+
- Fixed (limrun): `press --double-tap` on Limrun iOS direct sessions sends both taps in one
10+
`performActions` batch with an 80 ms on-device pause. The interactor issued two independent `tap`
11+
requests, so a network round trip sat between the taps and iOS recognized them as two slow
12+
single taps.
913
- Added (ios): `type` and `fill` work in the Apple Pay sheet on iOS Simulator instead of failing
1014
with `TEXT_INPUT_NOT_FOCUSED`. `com.apple.PassbookUIService` is served in place like the web
1115
sign-in host (#2438).
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { expect, test, vi } from 'vitest';
2+
import { createLimrunIosInteractor, type LimrunIosSession } from './ios.ts';
3+
4+
function sessionWithClient() {
5+
const client = {
6+
tap: vi.fn(async () => {}),
7+
performActions: vi.fn(async () => ({ results: [] })),
8+
};
9+
const session = {
10+
platform: 'ios',
11+
instanceId: 'limrun-double-tap-instance',
12+
client,
13+
} as unknown as LimrunIosSession;
14+
return { interactor: createLimrunIosInteractor(session), client };
15+
}
16+
17+
test('double tap sends both taps in one batch with the pause enforced on the device', async () => {
18+
const { interactor, client } = sessionWithClient();
19+
20+
await interactor.doubleTap(120, 340);
21+
22+
expect(client.performActions).toHaveBeenCalledTimes(1);
23+
expect(client.performActions).toHaveBeenCalledWith([
24+
{ type: 'tap', x: 120, y: 340 },
25+
{ type: 'wait', durationMs: 80 },
26+
{ type: 'tap', x: 120, y: 340 },
27+
]);
28+
expect(client.tap).not.toHaveBeenCalled();
29+
});
30+
31+
test('a batch the device rejects surfaces as the double tap failure', async () => {
32+
const { interactor, client } = sessionWithClient();
33+
client.performActions.mockRejectedValueOnce(new Error('tap: no foreground application'));
34+
35+
await expect(interactor.doubleTap(120, 340)).rejects.toThrow('tap: no foreground application');
36+
});

‎packages/provider-limrun/src/ios.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,17 @@ class LimrunIosInteractor implements Interactor {
212212
await this.session.client.tapElement(toIosSelector(selector));
213213
}
214214

215+
/**
216+
* Both taps travel in one `performActions` batch so the inter-tap gap is enforced on the
217+
* device. Two separate `tap` requests put a network round trip between the taps, which
218+
* exceeds the double-tap recognition window and registers as two slow single taps.
219+
*/
215220
async doubleTap(x: number, y: number): Promise<void> {
216-
await this.tap(x, y);
217-
await this.tap(x, y);
221+
await this.session.client.performActions([
222+
{ type: 'tap', x, y },
223+
{ type: 'wait', durationMs: DOUBLE_TAP_INTERVAL_MS },
224+
{ type: 'tap', x, y },
225+
]);
218226
}
219227

220228
/** One held touch as HID primitives; the hold runs on the device, not across the wire. */
@@ -412,6 +420,8 @@ const IOS_APP_INVENTORY_RETRY_DELAYS_MS = [0, 250] as const;
412420

413421
/** Hold applied when the caller names no duration; matches the Android and Linux interactors. */
414422
const DEFAULT_LONG_PRESS_DURATION_MS = 800;
423+
/** On-device pause between the two taps of a double tap; well inside the recognizer's window. */
424+
const DOUBLE_TAP_INTERVAL_MS = 80;
415425

416426
function resolveInstalledIosAppId(params: {
417427
resultBundleId?: string;

0 commit comments

Comments
 (0)