Skip to content

Commit fbeba2f

Browse files
agentthymikee
authored andcommitted
refactor(daemon): apply the seam addendum after #1876 was re-scoped
Two edits, per find's ADDENDUM.md: 1. `includeRects` returns to `buildRuntimeCaptureInput`. It was removed from #1876 as unconsumed; the selector capture path is genuinely its first consumer (a Web rect capture requests bounds explicitly), so it lands here under the same rule that moved the seam. `snapshot`/`diff` pass nothing. 2. The per-capture `signal` is dropped, not restored. `CaptureSnapshotInput` has no such field on this stack — it moved to `wait` (#1875) with the regression that proves per-poll abort and quiescence. `get` captures once per resolution and never polls, so nothing here needs it. The seam test and fixture coverage for it moves with the contract rather than being kept against a field that no longer exists.
1 parent 50f66c3 commit fbeba2f

13 files changed

Lines changed: 14 additions & 30 deletions

packages/contracts/src/platform-runtime-unavailable.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ test('generic unavailable binding preserves exact provider ownership and mode',
4545
assert.deepEqual(binding.facts.operations.captureScreenshot, {
4646
available: false,
4747
reason: 'unsupported-device-kind',
48+
});
4849
assert.deepEqual(binding.facts.operations.readTextAtPoint, {
4950
available: false,
5051
reason: 'unsupported-provider-mode',

packages/contracts/src/platform-runtime-unavailable.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ function freezeUnavailableFacts(
144144
readiness: orNetwork(unavailable.readiness),
145145
shutdown: orNetwork(unavailable.shutdown),
146146
elementText: Object.freeze({ ...unavailable.elementText }),
147-
readiness: Object.freeze({ ...(unavailable.readiness ?? unavailable.network) }),
148-
shutdown: Object.freeze({ ...(unavailable.shutdown ?? unavailable.network) }),
149147
lifecycle: applicationLifecycleOperationFacts(unavailable.lifecycle),
150148
});
151149
}

packages/platform-android/src/runtime.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export function createAndroidPlatformRuntime(host: PlatformRuntimeHost): Platfor
218218
signal: request.scope.signal,
219219
resolveInteractor: host.localInteractors.resolve,
220220
})
221+
: {}),
221222
...(facts.operations.readTextAtPoint.available
222223
? bindElementTextRuntime({ device: request.device, host: host.elementText })
223224
: {}),

packages/platform-apple/src/runtime.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ export function createApplePlatformRuntime(host: PlatformRuntimeHost): PlatformR
286286
signal: request.scope.signal,
287287
resolveInteractor: host.localInteractors.resolve,
288288
})
289+
: {}),
289290
...(facts.operations.readTextAtPoint.available
290291
? bindElementTextRuntime({ device: request.device, host: host.elementText })
291292
: {}),

packages/platform-linux/src/runtime.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export function createLinuxPlatformRuntime(host: PlatformRuntimeHost): PlatformR
9595
signal: request.scope.signal,
9696
resolveInteractor: host.localInteractors.resolve,
9797
})
98+
: {}),
9899
...(facts.operations.readTextAtPoint.available
99100
? bindElementTextRuntime({ device: request.device, host: host.elementText })
100101
: {}),
@@ -140,6 +141,7 @@ function linuxFacts(device: DeviceInfo): RuntimeFacts<PlatformRuntimeOperations>
140141
}),
141142
...screenshotRuntimeOperationFacts({
142143
capture: device.kind === 'device' ? supported : screenshotKindUnavailable,
144+
}),
143145
// The Linux read is value-first (AXValue/title/description) where the captured tree is
144146
// label-first, so the desktop row genuinely reads differently from its snapshot text.
145147
...elementTextRuntimeOperationFacts({

src/daemon/__tests__/selector-capture-binding.test.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { expect, test } from 'vitest';
2-
import type { CaptureSnapshotInput } from '@agent-device/contracts/platform';
32
import { ANDROID_EMULATOR, IOS_SIMULATOR } from '../../__tests__/test-utils/device-fixtures.ts';
43
import {
54
makeAndroidSession,
@@ -48,23 +47,6 @@ test('repeated captures reuse the one binding the plan was admitted for', async
4847
expect(fixture.captures).toHaveLength(2);
4948
});
5049

51-
test('a per-capture signal reaches the bound operation for a poll deadline', async () => {
52-
const fixture = selectorCaptureFixture();
53-
const bound = await resolveBoundSelectorCapture({
54-
command: 'wait',
55-
device: ANDROID_EMULATOR,
56-
session: makeAndroidSession('selector'),
57-
inspectFacts: fixture.inspectFacts,
58-
bindDevice: fixture.bindDevice,
59-
});
60-
if (!bound.ok) throw new Error('expected an admitted capture');
61-
const deadline = new AbortController();
62-
deadline.abort(new Error('poll deadline'));
63-
64-
const input: CaptureSnapshotInput = { signal: deadline.signal };
65-
await expect(bound.operations.capture(input)).rejects.toThrow(/poll deadline/);
66-
});
67-
6850
test('an unavailable required operation refuses before any bind', async () => {
6951
const fixture = selectorCaptureFixture({
7052
capture: { available: false, reason: 'unsupported-platform-leaf' },

src/daemon/__tests__/selector-capture-fixture.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export function selectorCaptureFixture(
6161
const captureSnapshot = async (input: CaptureSnapshotInput): Promise<SnapshotResult> => {
6262
const index = captures.length;
6363
captures.push(input);
64-
input.signal?.throwIfAborted();
6564
return params.snapshot?.(input, index) ?? { nodes: [], backend: 'xctest' };
6665
};
6766

src/daemon/handlers/__tests__/interaction-get-runtime-fixture.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function elementReadFacts(device: DeviceInfo): RuntimeFacts<PlatformRuntimeOpera
5858
network: unavailable,
5959
viewport: unavailable,
6060
elementText: unavailable,
61+
screenshot: unavailable,
6162
lifecycle: applicationLifecycleOperationFacts({
6263
resolveOpenTarget: unavailable,
6364
prepareApplicationOpen: unavailable,

src/daemon/handlers/__tests__/session-capabilities.fixtures.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ function createAdmissionFacts(
8585
sendPushNotification: cell(options.pushAvailable),
8686
networkDump: cell(options.networkAvailable),
8787
readTextAtPoint: unavailable,
88-
deployApp: options.deployAvailable ? available : unavailable,
89-
materializeAppSource: options.sourceAvailable ? available : unavailable,
90-
deployMaterializedApp: options.sourceAvailable ? available : unavailable,
91-
sendPushNotification: options.pushAvailable ? available : unavailable,
92-
networkDump: options.networkAvailable ? available : unavailable,
9388
screenRecordingStart: unavailable,
9489
screenRecordingReattach: unavailable,
9590
screenRecordingCleanup: unavailable,

src/daemon/selector-capture-binding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type SelectorCaptureCommand = 'find' | 'get' | 'is' | 'wait';
1414
/**
1515
* One request's bound accessibility capture. Selector commands capture repeatedly under one
1616
* binding (polling, sparse recovery), so the operation is parametrized by intent rather than
17-
* frozen at bind time and `input.signal` carries a poll's remaining budget.
17+
* frozen at bind time.
1818
*/
1919
export type BoundSelectorCapture = (input: CaptureSnapshotInput) => Promise<SnapshotResult>;
2020

0 commit comments

Comments
 (0)