Skip to content

Commit 00e4185

Browse files
committed
fix(ios): disclose a skipped bridge when the surface probe cannot answer
Routing an unprovable probe to the runner is right, but the early return also skipped runFallback, so the response lost its warning and kept an identity that could still be compared against a bridge publication. An unknown probe now falls back through the same disclosed path as a bridge failure, with its own reason.
1 parent f118602 commit 00e4185

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

‎packages/platform-apple/src/snapshot-route.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,29 @@ test.for(['present', 'unknown'] as const)(
8080
},
8181
);
8282

83+
// Losing the bridge fast path must never be silent: an unprovable probe still owes the caller a
84+
// warning and an identity that cannot be compared against a bridge publication.
85+
test('a probe that cannot answer discloses the skipped bridge and stays incomparable', async () => {
86+
const route = createAppleSnapshotRoute(platformRuntimeHostFixture(), {
87+
source: sourceReturning(bridgeAcquisition()),
88+
resolveTarget: vi.fn(async () => target),
89+
systemSurfacePresent: async () => 'unknown',
90+
});
91+
92+
const result = await route.capture(ios, input, signal(), async () => runnerResult());
93+
94+
expect(result.warnings).toEqual([
95+
'Simulator AX snapshot unavailable (system-surface-probe-unavailable); used XCTest for an unverified app generation.',
96+
]);
97+
expect(result.comparisonIdentity).toMatchObject({
98+
producer: 'apple-runner',
99+
residue: [
100+
{ kind: 'unknown-generation', captureId: expect.any(String) },
101+
{ kind: 'fallback-source', producer: 'apple-runner' },
102+
],
103+
});
104+
});
105+
83106
test('typed bridge failure falls back once and disables retries for that app generation', async () => {
84107
const source = sourceReturning({
85108
stage: 'failed',

‎packages/platform-apple/src/snapshot-route.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,21 @@ export function createAppleSnapshotRoute(
9292
// otherwise serves the app, so this is correct even while a dismissed host lingers. Anything
9393
// but a proven `absent` takes the runner: an unproven probe must not fall through to a bridge
9494
// capture that would answer confidently from the occluded app tree.
95-
if ((await systemSurfacePresent(device, signal)) !== 'absent') return await fallback(input);
95+
const surfacePresence = await systemSurfacePresent(device, signal);
96+
if (surfacePresence === 'present') return await fallback(input);
97+
if (surfacePresence === 'unknown') {
98+
// The probe could not answer. Take the runner rather than a bridge capture that would
99+
// answer confidently from the occluded app tree — but say so: silently losing the bridge
100+
// fast path, with no warning and a comparable identity, would be its own defect.
101+
return await runFallback(
102+
input,
103+
fallback,
104+
{ targetId: `${device.id}:${input.options!.appBundleId!}` },
105+
requestFor(input),
106+
'system-surface-probe-unavailable',
107+
[unknownGenerationResidue()],
108+
);
109+
}
96110
let target: SimulatorSnapshotTarget;
97111
try {
98112
target = await resolveTargetForObservation(host, resolveTarget, device, input, signal);

0 commit comments

Comments
 (0)