From 0720e2961187550b4a771c18247f15f073bddcfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Sun, 1 Nov 2026 17:22:53 +0100 Subject: [PATCH 1/2] fix(revyl): send drag duration when the worker supports it and retry hierarchy 500s - scroll --duration-ms rides /drag duration_ms when health reports supports_explicit_drag_duration; older workers still refuse it. - Replay a GET answered with 500: Revyl passes the iOS simulator's brief empty accessibility answer through as a 500 on hierarchy. - Docs and help: leave --device/--provider-os-version unset for a warm simulator, and reuse one session instead of reconnecting. Co-Authored-By: Claude Opus 5.5 --- packages/provider-revyl/README.md | 2 +- .../provider-revyl/src/interactor.test.ts | 35 ++++++++++++-- packages/provider-revyl/src/interactor.ts | 47 ++++++++++++------- .../src/revyl-backend.fixtures.ts | 3 ++ .../provider-revyl/src/revyl-client.test.ts | 14 ++++++ packages/provider-revyl/src/revyl-client.ts | 3 ++ packages/provider-revyl/src/revyl-session.ts | 3 ++ packages/provider-revyl/src/revyl-types.ts | 2 + src/commands/schema/cli-help-topics.test.ts | 5 +- src/commands/schema/cli-help.ts | 4 +- website/docs/docs/revyl.md | 17 ++++--- 11 files changed, 102 insertions(+), 33 deletions(-) diff --git a/packages/provider-revyl/README.md b/packages/provider-revyl/README.md index 1ed732c3f8..b046051c10 100644 --- a/packages/provider-revyl/README.md +++ b/packages/provider-revyl/README.md @@ -8,7 +8,7 @@ customers; a partner integration gets one through Revyl's partner program. npm install -g agent-device agent-device plugins add @agent-device/revyl export REVYL_API_KEY=your-api-key -agent-device connect revyl --platform ios --device "iPhone 16" --provider-os-version 18.0 --provider-app https://apps.example.com/MyApp-simulator.zip +agent-device connect revyl --platform ios --provider-app https://apps.example.com/MyApp-simulator.zip agent-device open com.example.app agent-device snapshot -i agent-device close diff --git a/packages/provider-revyl/src/interactor.test.ts b/packages/provider-revyl/src/interactor.test.ts index e6c9926532..bd2fbfbf75 100644 --- a/packages/provider-revyl/src/interactor.test.ts +++ b/packages/provider-revyl/src/interactor.test.ts @@ -302,14 +302,43 @@ test('scroll dispatches the planned finger path as one drag', async () => { }); assert.equal(report.pixels, 300); assert.equal(report.direction, 'down'); - // Revyl's `/drag` body has no duration field, so the report names none: a duration the worker never + // No duration was asked for, so the report names none: a duration the worker never // ran must not appear as though it were honored. assert.equal('durationMs' in report, false); }); +test('a scroll that names a duration sends it when the worker takes one', async () => { + const { fixture, interactor } = await liveInteractor('ios', { dragDuration: true }); + const report = (await interactor.scroll?.('down', { pixels: 300, durationMs: 900 })) as Record< + string, + unknown + >; + + assert.deepEqual(fixture.bodyFor('drag'), { + start_x: 195, + start_y: 572, + end_x: 195, + end_y: 272, + duration_ms: 900, + }); + assert.equal(report.durationMs, 900); +}); + +test('a zero scroll duration is refused before the drag, since Revyl takes at least 1 ms', async () => { + const { fixture, interactor } = await liveInteractor('ios', { dragDuration: true }); + await assert.rejects( + () => interactor.scroll?.('down', { pixels: 300, durationMs: 0 }), + (error: unknown) => error instanceof AppError && error.code === 'INVALID_ARGS', + ); + assert.equal( + fixture.paths().some((request) => request.endsWith('/drag')), + false, + ); +}); + test('a scroll that names a duration is refused rather than run at another speed', async () => { - // The caller asked how fast the finger travels and Revyl's drag cannot be told, so the command is - // answered with that fact. Running the drag at Revyl's speed in silence would drop what was asked for. + // This worker reports no drag duration support, so the command is answered with that fact. Running + // the drag at Revyl's speed in silence would drop what was asked for. const { fixture, interactor } = await liveInteractor('ios'); await assert.rejects( diff --git a/packages/provider-revyl/src/interactor.ts b/packages/provider-revyl/src/interactor.ts index 22ff1c04d7..f69a871c9e 100644 --- a/packages/provider-revyl/src/interactor.ts +++ b/packages/provider-revyl/src/interactor.ts @@ -215,28 +215,17 @@ class RevylInteractor implements Interactor { * `pixels` and endpoints. Revyl's own `/swipe` is not used: it moves the finger a distance the * worker chooses, so `--pixels` and `--amount` would be silently dropped. * - * Revyl's `/drag` body carries endpoints only — no duration field exists — so the worker chooses - * how fast the finger travels and the report names no `durationMs`. `scroll --duration-ms` is therefore - * refused: a drag that ran at Revyl's own speed while reporting the caller's number would be a false - * echo, and one that said nothing would drop what the caller asked for. + * A worker whose `health` reports `supports_explicit_drag_duration` takes `duration_ms` in the + * `/drag` body, so `scroll --duration-ms` rides it and the report echoes it. Any other worker + * chooses how fast the finger travels, so the flag is refused there: a drag that ran at Revyl's own + * speed while reporting the caller's number would be a false echo. */ async scroll( direction: ScrollDirection, options?: ScrollExecutionOptions, ): Promise> { - if (options?.durationMs !== undefined) { - throw new AppError( - 'UNSUPPORTED_OPERATION', - 'Revyl scrolls with one drag and cannot be told how fast the finger travels.', - { - reason: 'unsupported-provider-mode', - command: 'scroll', - flag: '--duration-ms', - runId: this.session.runId, - hint: 'Scroll without --duration-ms; the drag runs at the speed Revyl gives it.', - }, - ); - } + const durationMs = options?.durationMs; + if (durationMs !== undefined) this.requireDragDuration(durationMs); const screen = this.session.screen; if (!screen) { throw new AppError( @@ -262,13 +251,37 @@ class RevylInteractor implements Interactor { start_y: plan.y1, end_x: plan.x2, end_y: plan.y2, + ...(durationMs === undefined ? {} : { duration_ms: durationMs }), }); return { ...plan, + ...(durationMs === undefined ? {} : { durationMs }), backend: 'revyl-device-proxy', }; } + /** Refuses a drag duration this worker cannot honor; Revyl's `duration_ms` starts at 1. */ + private requireDragDuration(durationMs: number): void { + if (!this.session.dragDuration) { + throw new AppError( + 'UNSUPPORTED_OPERATION', + 'This Revyl worker scrolls with one drag and cannot be told how fast the finger travels.', + { + reason: 'unsupported-provider-mode', + command: 'scroll', + flag: '--duration-ms', + runId: this.session.runId, + hint: 'Scroll without --duration-ms; the drag runs at the speed Revyl gives it.', + }, + ); + } + if (durationMs < 1) { + throw new AppError('INVALID_ARGS', 'Revyl drag --duration-ms must be at least 1.', { + flag: '--duration-ms', + }); + } + } + /** * Writes through a temporary file in the same directory and renames it into place, so a caller that * hangs up mid-write or a process that dies leaves either the previous screenshot or none at all, and diff --git a/packages/provider-revyl/src/revyl-backend.fixtures.ts b/packages/provider-revyl/src/revyl-backend.fixtures.ts index 0293b7db35..518ab3b68d 100644 --- a/packages/provider-revyl/src/revyl-backend.fixtures.ts +++ b/packages/provider-revyl/src/revyl-backend.fixtures.ts @@ -35,6 +35,8 @@ export type RevylFixtureOptions = Readonly<{ screen?: Readonly<{ width: number; height: number }>; /** Reports no screen size at all, which is what a health answer without the fields reads as. */ withoutScreen?: boolean; + /** Reports `supports_explicit_drag_duration: true`, which a newer worker does. */ + dragDuration?: boolean; /** The body every `hierarchy` answer carries: iOS JSON or Android XML. */ hierarchy?: string; /** The start response body; a run id is generated when absent. */ @@ -234,6 +236,7 @@ export async function startRevylFixtureBackend( ...(options.withoutScreen ? {} : { screen_width: screen.width, screen_height: screen.height }), + ...(options.dragDuration ? { supports_explicit_drag_duration: true } : {}), }, }; } diff --git a/packages/provider-revyl/src/revyl-client.test.ts b/packages/provider-revyl/src/revyl-client.test.ts index 22ef772f6f..0e958c6fc6 100644 --- a/packages/provider-revyl/src/revyl-client.test.ts +++ b/packages/provider-revyl/src/revyl-client.test.ts @@ -193,6 +193,20 @@ test('replays a retried GET and never a side-effecting action', async () => { assert.equal(attempts, 1, 'a tap is never replayed: it may already have landed'); }); +test('a hierarchy read that Revyl answers with a 500 is replayed', async () => { + // Revyl passes the iOS accessibility service's brief empty answer through as a 500; the next read + // returns the tree. + let attempts = 0; + const client = clientResponding(() => { + attempts += 1; + return attempts === 1 + ? jsonError(500, 'accessibility unavailable') + : new Response('[]', { status: 200 }); + }); + assert.equal(await client.getWorkerHierarchy('run-1'), '[]'); + assert.equal(attempts, 2); +}); + test('a readiness read answers the polling loop on its first attempt', async () => { // The readiness loop owns the poll beat and the deadline, so a transport replay in front of these // two would hide Revyl's not-ready answer and stall the very wait being polled for. diff --git a/packages/provider-revyl/src/revyl-client.ts b/packages/provider-revyl/src/revyl-client.ts index de77fcb587..45bf062ce6 100644 --- a/packages/provider-revyl/src/revyl-client.ts +++ b/packages/provider-revyl/src/revyl-client.ts @@ -255,6 +255,9 @@ function isRetryable(request: RevylRequest, outcome: RevylResponse | Error): boo if (outcome instanceof Error) { return outcome instanceof AppError && outcome.details?.reason === 'provider-unreachable'; } + // A read has no side effect to land twice. Revyl answers `hierarchy` with a 500 while the iOS + // simulator's accessibility service briefly returns nothing, and a replay reads the tree. + if (request.method === 'GET' && outcome.status === 500) return true; return revylFailure(request.route ?? 'general', outcome.status).retryable; } diff --git a/packages/provider-revyl/src/revyl-session.ts b/packages/provider-revyl/src/revyl-session.ts index bbca686632..76792f359e 100644 --- a/packages/provider-revyl/src/revyl-session.ts +++ b/packages/provider-revyl/src/revyl-session.ts @@ -31,6 +31,8 @@ export type RevylSession = Readonly<{ sessionId: string; /** Read from `health`; a snapshot without it cannot measure a keyboard band. */ screen: RevylScreenSize | undefined; + /** Read from `health`: whether `/drag` takes the finger's travel time as `duration_ms`. */ + dragDuration: boolean; device: DeviceInfo; client: RevylClient; lease: DeviceLease; @@ -175,6 +177,7 @@ export async function startRevylSession( runId, sessionId, screen: readRevylScreenSize(health), + dragDuration: health.supports_explicit_drag_duration === true, device: buildRevylDevice(input.platform, lease, runId), client, lease, diff --git a/packages/provider-revyl/src/revyl-types.ts b/packages/provider-revyl/src/revyl-types.ts index ca9d79ec98..28366603ef 100644 --- a/packages/provider-revyl/src/revyl-types.ts +++ b/packages/provider-revyl/src/revyl-types.ts @@ -43,6 +43,8 @@ export type RevylWorkerHealth = Readonly<{ platform?: string; screen_width?: number; screen_height?: number; + /** Set when the worker's `/drag` body accepts `duration_ms`; without it the worker picks the speed. */ + supports_explicit_drag_duration?: boolean; }>; export type RevylDeviceSessionStopResponse = Readonly<{ diff --git a/src/commands/schema/cli-help-topics.test.ts b/src/commands/schema/cli-help-topics.test.ts index ac3ba5af61..644b790efc 100644 --- a/src/commands/schema/cli-help-topics.test.ts +++ b/src/commands/schema/cli-help-topics.test.ts @@ -473,10 +473,7 @@ test('usageForCommand resolves remote help topic', async () => { help.indexOf('Revyl cloud-device flow'), help.indexOf('Local profile flow'), ); - assert.match( - revylFlow, - /connect revyl --platform ios --device "iPhone 16" --provider-os-version 18\.0 --provider-app https:\/\//, - ); + assert.match(revylFlow, /connect revyl --platform ios --provider-app https:\/\//); assert.match(revylFlow, /must be an https URL/); assert.match(revylFlow, /agent-device disconnect/); assert.match(help, /BrowserStack uses BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY/); diff --git a/src/commands/schema/cli-help.ts b/src/commands/schema/cli-help.ts index 1a859e12ff..ba03014ab8 100644 --- a/src/commands/schema/cli-help.ts +++ b/src/commands/schema/cli-help.ts @@ -634,12 +634,12 @@ Limrun direct-device flow: Revyl cloud-device flow (plugin, install separately): agent-device plugins add @agent-device/revyl export REVYL_API_KEY=... - agent-device connect revyl --platform ios --device "iPhone 16" --provider-os-version 18.0 --provider-app https://downloads.example.test/app.zip + agent-device connect revyl --platform ios --provider-app https://downloads.example.test/app.zip agent-device open com.example.app agent-device snapshot -i agent-device close agent-device disconnect - Revyl starts a device from its own pool, so --device and --provider-os-version are preferences it picks from rather than a catalog lookup, and --provider-app must be an https URL it can download. connect verifies the key without renting a device; the device is rented on the first command that needs it and released on close or disconnect. + Revyl starts a device from its own pool, so --device and --provider-os-version are preferences it picks from rather than a catalog lookup; leave them unset to get a simulator that is already warm. --provider-app must be an https URL it can download. connect verifies the key without renting a device; the device is rented on the first command that needs it and released on close or disconnect. Local profile flow: agent-device connect --remote-config ./remote-config.json diff --git a/website/docs/docs/revyl.md b/website/docs/docs/revyl.md index 4b5a47e6d9..854d54cfc6 100644 --- a/website/docs/docs/revyl.md +++ b/website/docs/docs/revyl.md @@ -27,8 +27,6 @@ next device command loads the plugin. export REVYL_API_KEY=... agent-device connect revyl \ --platform ios \ - --device "iPhone 16" \ - --provider-os-version 18.0 \ --provider-app https://apps.example.com/MyApp-simulator.zip ``` @@ -38,6 +36,12 @@ lease, usually `open`. `--device` and `--provider-os-version` are optional; with from its own pool and reports a device agent-device then uses. A model or OS version Revyl has no device for is reported when the session starts, not by `connect`. +To start faster, leave `--device` and `--provider-os-version` unset. Revyl then hands you a +simulator that is already warm. The first session of the day can take over a minute because Revyl +installs the app while it starts the device; later sessions usually start in 15 to 25 seconds. +Start the session early and keep it open between steps. To relaunch the app, run `open` again on +the same session instead of `disconnect` and `connect`. + `--provider-app` is required and must be a public HTTPS URL. Revyl downloads and installs the build when it starts the device, so a local path or a provider-specific app reference has no meaning there. Pass the zipped `.app` for iOS the way Revyl expects it, and the `.apk` URL for Android. @@ -64,8 +68,9 @@ A Revyl session runs the commands that reach a device through Revyl's device act do on a local device. - `click`, `press`, `double tap`, `longpress`, and `fill` by point or by snapshot reference, and `scroll` by direction. `scroll` sends one drag of the planned finger path, so `--pixels` and - `--amount` mean the same distance they mean on a local device. Revyl's drag takes endpoints only, so - `scroll --duration-ms` refuses with that reason rather than running the drag at a speed nobody chose; + `--amount` mean the same distance they mean on a local device. `scroll --duration-ms` sets how long + the drag takes, from 1 to 10000 ms, when Revyl's worker supports it. An older worker picks the + speed itself, so there the flag refuses rather than running the drag at a speed nobody chose. `fill --delay-ms` is paced by typing one character per pause. - `open` (the session's app), `open` with a deep link or URL, and `close` for the app the session opened. - `home`, and `back` on Android. iOS has no system back button; click the app's own back control. @@ -134,8 +139,6 @@ const scope = { const lease = await host.client.leases.allocate({ ...scope, platform: 'ios', - device: 'iPhone 16', - providerOsVersion: '18.0', providerApp: 'https://apps.example.com/MyApp-simulator.zip', }); const client = createAgentDeviceClient({ ...host.clientConfig, ...scope, leaseId: lease.leaseId }); @@ -167,5 +170,7 @@ takes when the daemon loads the plugin from the plugin store. - A start that never becomes ready reports `provider-not-ready` or `provider-start-failed` and stops the run it started, so a failed `open` does not leave a rented device. Retry, then check that Revyl has a device of the requested model and OS version. +- `snapshot` on iOS can fail with HTTP 500 while the simulator's accessibility service briefly + returns nothing. The plugin retries the read; if it still fails, run `snapshot` again. - A device that Revyl released while your session was open reports `provider-session-gone`. Run `close` and `open` again to rent a fresh one. From 6078d103d38a6b7d767ad378496ca9078b402802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Sun, 1 Nov 2026 18:58:48 +0100 Subject: [PATCH 2/2] fix(revyl): scope the 500 replay to the hierarchy read and drop unsourced timings Co-Authored-By: Claude Opus 5.5 --- packages/provider-revyl/src/interactor.test.ts | 5 ++++- packages/provider-revyl/src/revyl-client.test.ts | 8 ++++++++ packages/provider-revyl/src/revyl-client.ts | 15 +++++++++++---- website/docs/docs/revyl.md | 7 +++---- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/packages/provider-revyl/src/interactor.test.ts b/packages/provider-revyl/src/interactor.test.ts index bd2fbfbf75..56c22abe8b 100644 --- a/packages/provider-revyl/src/interactor.test.ts +++ b/packages/provider-revyl/src/interactor.test.ts @@ -328,7 +328,10 @@ test('a zero scroll duration is refused before the drag, since Revyl takes at le const { fixture, interactor } = await liveInteractor('ios', { dragDuration: true }); await assert.rejects( () => interactor.scroll?.('down', { pixels: 300, durationMs: 0 }), - (error: unknown) => error instanceof AppError && error.code === 'INVALID_ARGS', + (error: unknown) => + error instanceof AppError && + error.code === 'INVALID_ARGS' && + error.details?.flag === '--duration-ms', ); assert.equal( fixture.paths().some((request) => request.endsWith('/drag')), diff --git a/packages/provider-revyl/src/revyl-client.test.ts b/packages/provider-revyl/src/revyl-client.test.ts index 0e958c6fc6..02de2166e5 100644 --- a/packages/provider-revyl/src/revyl-client.test.ts +++ b/packages/provider-revyl/src/revyl-client.test.ts @@ -205,6 +205,14 @@ test('a hierarchy read that Revyl answers with a 500 is replayed', async () => { }); assert.equal(await client.getWorkerHierarchy('run-1'), '[]'); assert.equal(attempts, 2); + + attempts = 0; + const screenshot = clientResponding(() => { + attempts += 1; + return jsonError(500, 'worker failed'); + }); + await assert.rejects(async () => await screenshot.captureWorkerScreenshot('run-1')); + assert.equal(attempts, 1, 'only the hierarchy read opts into replaying a 500'); }); test('a readiness read answers the polling loop on its first attempt', async () => { diff --git a/packages/provider-revyl/src/revyl-client.ts b/packages/provider-revyl/src/revyl-client.ts index 45bf062ce6..5b75f6b4e7 100644 --- a/packages/provider-revyl/src/revyl-client.ts +++ b/packages/provider-revyl/src/revyl-client.ts @@ -51,6 +51,12 @@ type RevylRequest = Readonly<{ * idempotent, which `/stop` is; a device action is never replayed. */ retry?: boolean; + /** + * Also replays a 500, which the status table reads as unconfirmed. Only `hierarchy` sets it: Revyl + * answers it with a 500 while the iOS simulator's accessibility service briefly returns nothing, + * and the read has no side effect to land twice. + */ + retryServerError?: boolean; /** A device-proxy action carries the agent header; an execution-API call does not. */ workerAction?: boolean; /** Defaults to `general`, which never reads a 404 or 410 as a gone session. */ @@ -175,7 +181,10 @@ export function createRevylClient(options: RevylClientOptions): RevylClient { }, async getWorkerHierarchy(workflowRunId, signal) { return new TextDecoder().decode( - await body(workerRequest(workflowRunId, 'hierarchy', signal)), + await body({ + ...workerRequest(workflowRunId, 'hierarchy', signal), + retryServerError: true, + }), ); }, async captureWorkerScreenshot(workflowRunId, signal) { @@ -255,9 +264,7 @@ function isRetryable(request: RevylRequest, outcome: RevylResponse | Error): boo if (outcome instanceof Error) { return outcome instanceof AppError && outcome.details?.reason === 'provider-unreachable'; } - // A read has no side effect to land twice. Revyl answers `hierarchy` with a 500 while the iOS - // simulator's accessibility service briefly returns nothing, and a replay reads the tree. - if (request.method === 'GET' && outcome.status === 500) return true; + if (request.retryServerError === true && outcome.status === 500) return true; return revylFailure(request.route ?? 'general', outcome.status).retryable; } diff --git a/website/docs/docs/revyl.md b/website/docs/docs/revyl.md index 854d54cfc6..89c4ce0d44 100644 --- a/website/docs/docs/revyl.md +++ b/website/docs/docs/revyl.md @@ -36,10 +36,9 @@ lease, usually `open`. `--device` and `--provider-os-version` are optional; with from its own pool and reports a device agent-device then uses. A model or OS version Revyl has no device for is reported when the session starts, not by `connect`. -To start faster, leave `--device` and `--provider-os-version` unset. Revyl then hands you a -simulator that is already warm. The first session of the day can take over a minute because Revyl -installs the app while it starts the device; later sessions usually start in 15 to 25 seconds. -Start the session early and keep it open between steps. To relaunch the app, run `open` again on +To start faster, leave `--device` and `--provider-os-version` unset, so Revyl can pick a simulator +that is already running. A session can take longer to start when Revyl also installs the app on the +device. Start the session early and keep it open between steps. To relaunch the app, run `open` again on the same session instead of `disconnect` and `connect`. `--provider-app` is required and must be a public HTTPS URL. Revyl downloads and installs the build