Skip to content

Commit a2ae604

Browse files
committed
fix(replay): defer binding after deep links
1 parent 70887c6 commit a2ae604

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/daemon/__tests__/request-router-open.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,32 @@ test('fresh replay reserves its authored app simulator before any replay step',
168168
);
169169
});
170170

171+
test('fresh replay leaves a first deep-link open unbound when a later app target exists', async () => {
172+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-replay-deep-link-lock-'));
173+
const replayPath = path.join(root, 'flow.ad');
174+
fs.writeFileSync(
175+
replayPath,
176+
'runtime set --platform ios --metro-port 8081\nopen demo://checkout\nopen com.example.demo\n',
177+
);
178+
const sessionStore = makeSessionStore('agent-device-router-replay-deep-link-lock-');
179+
180+
const keys = await resolveRequestExecutionLockKeys({
181+
req: {
182+
token: 'test-token',
183+
session: 'fresh-replay-deep-link',
184+
command: 'replay',
185+
positionals: [replayPath],
186+
flags: {},
187+
meta: { cwd: root },
188+
},
189+
sessionName: 'fresh-replay-deep-link',
190+
sessionStore,
191+
});
192+
193+
expect(keys).toEqual(['session:fresh-replay-deep-link']);
194+
expect(mockResolveTargetDevice).not.toHaveBeenCalled();
195+
});
196+
171197
test('fresh replay preserves an authored Android platform before advisory locking', async () => {
172198
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-replay-android-lock-'));
173199
const replayPath = path.join(root, 'flow.ad');

src/daemon/replay-device-selection.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export type ReplayTargetDeviceResolution = {
1515
};
1616

1717
/**
18-
* Finds the first static app target a fresh replay will open. Request binding
19-
* uses this before any replay action can cache an unqualified device choice.
18+
* Finds a static first app target for fresh replay binding. Request binding
19+
* must leave a first deep-link or dynamic open to normal device resolution.
2020
*/
2121
export function buildReplayTargetDeviceResolution(
2222
req: DaemonRequest,
@@ -84,6 +84,7 @@ function readScriptReplaySelection(actions: SessionAction[]): {
8484
platform = action.runtime?.platform ?? platform;
8585
const target = action.positionals?.[0];
8686
if (isStaticAppTarget(target)) return { appTarget: target, platform };
87+
return { appTarget: undefined, platform };
8788
}
8889
return { appTarget: undefined, platform };
8990
}

0 commit comments

Comments
 (0)