Skip to content

Commit df4c114

Browse files
authored
refactor(apple): simplify snapshot route settlement (#4278)
* refactor(apple): simplify snapshot route settlement * refactor(apple): make every snapshot source declare observe-only support observeOnlySupported was optional, and only an explicit false sent an observe-only capture to the direct fallback. A source that left it out was silently treated as supporting observe-only. The local source now declares true and the runner source false; the type requires it. * docs(apple): keep why the surface and off-route fallback plans settle as they do The merged settlement path dropped the comments of runSurfaceFallback and captureOffRoute. The FallbackPlan members now carry them: the surface plan decides only the reason, and an off-route capture that serves a surface still gets a surface identity (#2438).
1 parent dba8007 commit df4c114

3 files changed

Lines changed: 128 additions & 138 deletions

File tree

‎packages/platform-apple/src/runner-runtime.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ export function createAppleRunnerRuntime(options: {
9393
{
9494
source: bridge.source,
9595
resolveTarget: bridge.resolveTarget,
96-
// The runner answers the target read itself; there is no detached discovery to wait on.
97-
isDiscoveryPending: () => false,
98-
targetFreshness: 'cached',
96+
refreshTarget: (device, appBundleId, signal) =>
97+
bridge.resolveTarget(device, appBundleId, signal, 'refresh'),
98+
observeOnlySupported: false,
9999
sessionChanged: bridge.resetTargets,
100100
},
101101
async (device, input) =>
@@ -116,7 +116,6 @@ export function createAppleRunnerRuntime(options: {
116116
): SnapshotRuntimeOperations => {
117117
const route = routeFor(snapshot.present);
118118
const captureSnapshot = async (input: CaptureSnapshotInput) => {
119-
if (input.options?.observeOnly === true) return await snapshot.capture.captureSnapshot(input);
120119
return await route.capture(
121120
options.device,
122121
input,

‎packages/platform-apple/src/runner-snapshot-bridge.test.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ function bridgeRoute(provider: AppleRunnerProvider, runnerSessionId?: string) {
162162
{
163163
source: bridge.source,
164164
resolveTarget: bridge.resolveTarget,
165-
isDiscoveryPending: () => false,
166-
targetFreshness: 'cached',
165+
refreshTarget: (device, appBundleId, signal) =>
166+
bridge.resolveTarget(device, appBundleId, signal, 'refresh'),
167+
observeOnlySupported: false,
167168
...(runnerSessionId ? { sessionChanged: bridge.resetTargets } : {}),
168169
},
169170
async () =>
@@ -590,8 +591,9 @@ test('a late presentation failure cannot retire the replacement session generati
590591
{
591592
source: bridge.source,
592593
resolveTarget: bridge.resolveTarget,
593-
isDiscoveryPending: () => false,
594-
targetFreshness: 'cached',
594+
refreshTarget: (device, appBundleId, signal) =>
595+
bridge.resolveTarget(device, appBundleId, signal, 'refresh'),
596+
observeOnlySupported: false,
595597
sessionChanged: bridge.resetTargets,
596598
},
597599
async () => ({ foreground: 'background', sessionId }),
@@ -652,8 +654,9 @@ test('a wedge before the runner id is known does not disable a newly identified
652654
{
653655
source: bridge.source,
654656
resolveTarget: bridge.resolveTarget,
655-
isDiscoveryPending: () => false,
656-
targetFreshness: 'cached',
657+
refreshTarget: (device, appBundleId, signal) =>
658+
bridge.resolveTarget(device, appBundleId, signal, 'refresh'),
659+
observeOnlySupported: false,
657660
sessionChanged: bridge.resetTargets,
658661
},
659662
async () => (sessionId ? { foreground: 'background', sessionId } : { foreground: 'unknown' }),

0 commit comments

Comments
 (0)