Skip to content

Commit 1edb276

Browse files
thymikeeclaude
andcommitted
fix(revyl): replay only unreachable or transient requests, and fix the docs
A timed-out or canceled request is no longer replayed, and the replay reads the request's own route. The iOS docs name the accessibility tree and say back is Android-only, and the cloud page keeps Limrun's allocating commands apart from Revyl's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fb603fa commit 1edb276

7 files changed

Lines changed: 54 additions & 17 deletions

File tree

‎packages/provider-revyl/src/device.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type RevylPlatform = 'ios' | 'android';
66

77
export const REVYL_PROVIDER = 'revyl';
88

9-
/** How the service names itself to a user, in every message and display name this package writes. */
9+
/** The service name the connect report and a device's display name carry. */
1010
export const REVYL_SERVICE = 'Revyl';
1111

1212
/** Revyl picks the device from the platform, an optional model and OS version, and an app URL. */

‎packages/provider-revyl/src/facts-runtime.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { audioProbeRuntimeOperationFacts } from '@agent-device/contracts/audio-p
1111
import { perfRuntimeOperationFacts } from '@agent-device/contracts/perf-runtime';
1212
import { isSupportedRevylRuntimeDevice } from './device.ts';
1313
import {
14+
available,
1415
liveSessionUnavailable,
1516
revylInteractionOperationFacts,
1617
revylNavigationOperationFacts,
@@ -19,8 +20,6 @@ import {
1920
REVYL_TELEPHONY_UNAVAILABLE,
2021
} from './interaction-operations.ts';
2122

22-
const available = Object.freeze({ available: true } as const);
23-
2423
/** Revyl installs the app it is given when the session starts; the worker's install action takes a URL. */
2524
const installUnavailable = unavailableFact(
2625
'unsupported-provider-mode',

‎packages/provider-revyl/src/interaction-operations.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
} from '@agent-device/contracts/platform-runtime';
3838
import type { DeviceInfo } from '@agent-device/kernel/device';
3939

40-
const available = Object.freeze({ available: true } as const);
40+
export const available = Object.freeze({ available: true } as const);
4141

4242
/**
4343
* Revyl's text entry takes the field's coordinates, and no action injects text into whatever the

‎packages/provider-revyl/src/revyl-client.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,35 @@ test('a refusal is told from a verdict that never came back', async () => {
357357
);
358358
});
359359

360+
test('a read that never reached Revyl is replayed, and a canceled one is not', async () => {
361+
const unreachableCalls: Request[] = [];
362+
const flaky = clientResponding((call) => {
363+
if (call === 0) throw new TypeError('fetch failed');
364+
return new Response('[]', { status: 200, headers: { 'content-type': 'application/json' } });
365+
}, unreachableCalls);
366+
assert.equal(await flaky.getWorkerHierarchy('run-1'), '[]');
367+
assert.equal(unreachableCalls.length, 2);
368+
369+
const canceledCalls: Request[] = [];
370+
const controller = new AbortController();
371+
const hanging = clientResponding(
372+
(call) =>
373+
new Promise<Response>((_, reject) => {
374+
const request = canceledCalls[call]!;
375+
request.signal.addEventListener('abort', () => reject(request.signal.reason), {
376+
once: true,
377+
});
378+
controller.abort();
379+
}),
380+
canceledCalls,
381+
);
382+
await assert.rejects(
383+
async () => await hanging.getWorkerHierarchy('run-1', controller.signal),
384+
(error: unknown) => error instanceof AppError && error.details?.reason === 'request_canceled',
385+
);
386+
assert.equal(canceledCalls.length, 1, 'the canceled read is sent once');
387+
});
388+
360389
/** A client whose every answer comes from `reply`, recording each request it makes. */
361390
function clientResponding(
362391
reply: (call: number) => Response | Promise<Response>,

‎packages/provider-revyl/src/revyl-client.ts‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ type RevylRequest = Readonly<{
4646
path: string;
4747
body?: unknown;
4848
timeoutMs?: number;
49-
/** Defaults to true for GET and false for POST: a side-effecting action is never replayed. */
49+
/**
50+
* Defaults to true for GET and false for POST. A POST opts in only when Revyl documents it as
51+
* idempotent, which `/stop` and `/status/cancel` are; a device action is never replayed.
52+
*/
5053
retry?: boolean;
5154
/** A device-proxy action carries the agent header; an execution-API call does not. */
5255
workerAction?: boolean;
@@ -100,7 +103,7 @@ export function createRevylClient(options: RevylClientOptions): RevylClient {
100103
const attempts = retry ? RETRY_DELAYS_MS.length + 1 : 1;
101104
for (let attempt = 1; ; attempt += 1) {
102105
const outcome = await sendOnce(backendUrl, fetchImpl, baseHeaders, request);
103-
if (!isRetryable(outcome) || attempt >= attempts || request.signal?.aborted) {
106+
if (!isRetryable(request, outcome) || attempt >= attempts || request.signal?.aborted) {
104107
if (outcome instanceof Error) throw outcome;
105108
return outcome;
106109
}
@@ -122,9 +125,7 @@ export function createRevylClient(options: RevylClientOptions): RevylClient {
122125
/** A successful call whose body is raw text or bytes; a binary action still reports errors as JSON. */
123126
async function body(request: RevylRequest): Promise<Uint8Array> {
124127
const response = await send(request);
125-
if (response.status < 200 || response.status >= 300) {
126-
assertSuccess(request, response);
127-
}
128+
assertSuccess(request, response);
128129
return response.body;
129130
}
130131

@@ -256,8 +257,16 @@ async function sendOnce(
256257
}
257258
}
258259

259-
function isRetryable(outcome: RevylResponse | Error): boolean {
260-
return outcome instanceof Error || revylFailure('general', outcome.status).retryable;
260+
/**
261+
* Only a request that never reached Revyl, or a status Revyl marks transient, is replayed. A
262+
* cancellation is the caller's own answer, and a timeout has already spent the request's budget, so
263+
* neither is sent again.
264+
*/
265+
function isRetryable(request: RevylRequest, outcome: RevylResponse | Error): boolean {
266+
if (outcome instanceof Error) {
267+
return outcome instanceof AppError && outcome.details?.reason === 'provider-unreachable';
268+
}
269+
return revylFailure(request.route ?? 'general', outcome.status).retryable;
261270
}
262271

263272
function requestCanceled(request: RevylRequest, cause: unknown): AppError {

‎website/docs/docs/device-clouds.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Use a device cloud or farm when an agent needs to drive a hosted mobile device w
2626

2727
## Shared workflow
2828

29-
Every provider runs through the local `agent-device` daemon. `connect` checks your credentials and configuration, then saves non-secret connection state; it does not allocate a device. BrowserStack, AWS Device Farm, and TestMu AI allocate a hosted session on `open`. Limrun and Revyl allocate an instance on the first device command, such as `snapshot` or `open`.
29+
Every provider runs through the local `agent-device` daemon. `connect` checks your credentials and configuration, then saves non-secret connection state; it does not allocate a device. BrowserStack, AWS Device Farm, and TestMu AI allocate a hosted session on `open`. Limrun allocates an instance on the first device command, such as `install` or `open`. Revyl allocates a device on the first device command, usually `open`.
3030

3131
Every provider follows the same steps:
3232

‎website/docs/docs/revyl.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ the device is returned. Revyl also releases an idle session on its own after its
5959

6060
A Revyl session runs the commands that reach a device through Revyl's device actions:
6161

62-
- `snapshot` and `screenshot`. iOS reads Revyl's XCUITest-style tree and Android reads its uiautomator
63-
dump, so `snapshot -i`, `--json`, and label and selector targeting work the same way they do on a
64-
local device.
62+
- `snapshot` and `screenshot`. iOS reads the simulator's accessibility tree and Android reads its
63+
uiautomator dump, so `snapshot -i`, `--json`, and label and selector targeting work the same way they
64+
do on a local device.
6565
- `click`, `press`, `double tap`, `longpress`, and `fill` by point or by snapshot reference, and
6666
`scroll` by direction. `scroll` sends one drag of the planned finger path, so `--pixels` and
6767
`--amount` mean the same distance they mean on a local device. Revyl's drag takes endpoints only, so
6868
`scroll --duration-ms` refuses with that reason rather than running the drag at a speed nobody chose;
6969
`fill --delay-ms` is paced by typing one character per pause.
70-
- `open` (the session's app), `open` with a deep link or URL, and `close`.
71-
- `back`, and `home`.
70+
- `open` (the session's app), `open` with a deep link or URL, and `close` for the app the session opened.
71+
- `home`, and `back` on Android. iOS has no system back button; click the app's own back control.
7272

7373
The plugin refuses every other command with a reason that names the substitute. It does not
7474
report a refused command as a success:

0 commit comments

Comments
 (0)