Skip to content

Commit 1e75ce4

Browse files
committed
fix(ios): skip the readiness preflight for observe-only snapshots
The observe-only uptime probe has already proved the pinned runner session ready, so the conservative preflight sent a second identical uptime without adding evidence. An observe-only snapshot is now readiness-preflight exempt through its command traits, so the healthy path sends exactly the probe and the snapshot.
1 parent f9acee9 commit 1e75ce4

3 files changed

Lines changed: 45 additions & 3 deletions

File tree

‎packages/platform-apple/src/runner/__tests__/runner-command-traits.test.ts‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ test('runner command trait table pins lifecycle-sensitive command groups', () =>
3939
'querySelector',
4040
'readText',
4141
'screenshot',
42-
'snapshot',
4342
],
44-
payloadDependent: ['alert'],
43+
payloadDependent: ['alert', 'snapshot'],
4544
readOnlyReadinessProbe: ['status', 'uptime'],
4645
readinessPreflightExemptMutation: ['activate', 'targetReset', 'terminate'],
4746
default: [
@@ -65,6 +64,18 @@ test('runner command trait table pins lifecycle-sensitive command groups', () =>
6564
assert.deepEqual(Object.values(groups).flat().sort(), [...RUNNER_COMMANDS].sort());
6665
});
6766

67+
test('only an observe-only snapshot is exempt from the readiness preflight', () => {
68+
assert.deepEqual(readRunnerCommandTraits({ command: 'snapshot' }), readOnly());
69+
assert.deepEqual(
70+
readRunnerCommandTraits({ command: 'snapshot', observeOnly: false }),
71+
readOnly(),
72+
);
73+
assert.deepEqual(readRunnerCommandTraits({ command: 'snapshot', observeOnly: true }), {
74+
...readOnly(),
75+
readinessPreflightExempt: true,
76+
});
77+
});
78+
6879
test('alert actions match the native read-only golden table', () => {
6980
// The fixture's `query` column records whether the alert request changes anything — `get` is the
7081
// one action that is side-effect-free — and each side consumes it under its own name: `readOnly`

‎packages/platform-apple/src/runner/__tests__/runner-exchange.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,27 @@ test('the exchange preflights a mutation and settles only its answer', async ()
5757
assert.deepEqual(invalidations, []);
5858
});
5959

60+
test('the exchange sends an observe-only snapshot without a readiness preflight', async () => {
61+
server = await startFakeRunnerServer({
62+
snapshot: [{ kind: 'ok', data: { nodes: [] } }],
63+
});
64+
const session = sessionFor(server.port);
65+
66+
await executeRunnerExchange(
67+
IOS_SIMULATOR,
68+
session,
69+
{ command: 'snapshot', observeOnly: true, appBundleId: 'com.example.app' },
70+
undefined,
71+
10_000,
72+
async () => {},
73+
);
74+
75+
assert.deepEqual(
76+
server.requests.map(({ command }) => command),
77+
['snapshot'],
78+
);
79+
});
80+
6081
test('the readiness probe preserves its main-thread busy report when the command omits it', async () => {
6182
server = await startFakeRunnerServer({
6283
uptime: [{ kind: 'ok', data: { runnerMainThreadBusy: true } }],

‎packages/platform-apple/src/runner/runner-command-traits.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ const READ_ONLY_TRAITS: RunnerCommandTraits = {
2424
readOnly: true,
2525
};
2626

27+
const READ_ONLY_READINESS_PREFLIGHT_EXEMPT_TRAITS: RunnerCommandTraits = {
28+
...READ_ONLY_TRAITS,
29+
readinessPreflightExempt: true,
30+
};
31+
2732
const READ_ONLY_READINESS_PROBE_TRAITS: RunnerCommandTraits = {
2833
...READ_ONLY_TRAITS,
2934
readinessProbe: true,
@@ -47,6 +52,11 @@ type RunnerCommandTraitsEntry =
4752
const readAlertActionTraits = (command: RunnerCommand): RunnerCommandTraits =>
4853
(command.action ?? 'get').toLowerCase() === 'get' ? READ_ONLY_TRAITS : DEFAULT_TRAITS;
4954

55+
// An observe-only snapshot is pinned to the session its own observe-only uptime probe just proved
56+
// ready, so a second readiness probe would add a request without adding evidence.
57+
const readSnapshotTraits = (command: RunnerCommand): RunnerCommandTraits =>
58+
command.observeOnly === true ? READ_ONLY_READINESS_PREFLIGHT_EXEMPT_TRAITS : READ_ONLY_TRAITS;
59+
5060
/**
5161
* Traits of every runner command the daemon can send. A command whose traits depend on its
5262
* payload maps to a function of the command instead of a fixed trait set.
@@ -64,7 +74,7 @@ export const RUNNER_COMMAND_TRAITS = {
6474
findText: READ_ONLY_TRAITS,
6575
querySelector: READ_ONLY_TRAITS,
6676
readText: READ_ONLY_TRAITS,
67-
snapshot: READ_ONLY_TRAITS,
77+
snapshot: readSnapshotTraits,
6878
screenshot: READ_ONLY_TRAITS,
6979
backInApp: DEFAULT_TRAITS,
7080
backSystem: DEFAULT_TRAITS,

0 commit comments

Comments
 (0)