Skip to content

Commit 8039c90

Browse files
committed
fix: align optional recording and launch prompt diagnostics with completion
1 parent 3d1ce8d commit 8039c90

6 files changed

Lines changed: 41 additions & 14 deletions

File tree

‎packages/platform-apple/src/launch-confirmation.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,21 @@ test('a runner that cannot be resolved reports an unreadable attempt', async ()
412412
),
413413
).resolves.toEqual({ outcome: 'unreadable', step: 'runner' });
414414
});
415+
416+
test('a confirmed persistent prompt reports its observed outcome without an accept-failure diagnostic', async () => {
417+
vi.mocked(emitDiagnostic).mockClear();
418+
const { port: device } = port(async () => CONFIRMATION, {
419+
acceptAlert: async () => {
420+
throw spawnTimeout();
421+
},
422+
});
423+
await expect(answerLaunchConfirmation(device)).resolves.toEqual({
424+
outcome: 'unanswered',
425+
reason: 'alert-still-present',
426+
});
427+
expect(emitDiagnostic).toHaveBeenCalledExactlyOnceWith({
428+
level: 'debug',
429+
phase: 'ios_launch_confirmation_unanswered',
430+
data: { reason: 'alert-still-present' },
431+
});
432+
});

‎packages/platform-apple/src/launch-confirmation.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,17 @@ async function verifyFailedAcceptance(
106106
original: Record<string, unknown>,
107107
error: unknown,
108108
): Promise<LaunchConfirmationAttempt> {
109-
const failure = unreadable('alert-accept')(error);
110109
const read = await readAlert(port);
111-
if ('outcome' in read) return failure;
112-
return read.alert &&
110+
if ('outcome' in read) return unreadable('alert-accept')(error);
111+
if (
112+
read.alert &&
113113
isLaunchConfirmation(read.alert) &&
114114
read.alert['message'] === original['message']
115-
? { outcome: 'unanswered', reason: 'alert-still-present' }
116-
: failure;
115+
) {
116+
reportUnanswered('alert-still-present', {});
117+
return { outcome: 'unanswered', reason: 'alert-still-present' };
118+
}
119+
return unreadable('alert-accept')(error);
117120
}
118121

119122
async function readAlert(

‎src/daemon/__tests__/selector-recording.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,12 @@ test('sessionless recording cannot acquire a newly published address', () => {
140140
recordIfSession(store, admitted, req('wait'), { waitedMs: 100 });
141141
expect(session.actions).toEqual([]);
142142
});
143+
144+
test('optional recording cannot adopt a successor lifetime', () => {
145+
const store = makeStore();
146+
const retired = store.publish('default', makeIosSession('default'));
147+
store.retire(retired);
148+
const successor = store.publish('default', makeIosSession('default'));
149+
expect(() => recordIfSession(store, retired, req('wait'), { completed: true })).not.toThrow();
150+
expect(store.requireCurrent(successor).actions).toEqual([]);
151+
});

‎src/daemon/__tests__/selector-runtime.test.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,8 @@ test.each(['rebuild', 'retire'] as const)(
129129
expect(current.appName).toBe('Rebuilt during read');
130130
expect(ref.session.actions).toEqual([]);
131131
} else {
132-
expect(response).toMatchObject({
133-
ok: false,
134-
error: { details: { reason: 'session_lifetime_ended' } },
135-
});
132+
expect(response).toMatchObject({ ok: true, data: { text: 'Native value' } });
133+
expect(ref.session.actions).toEqual([]);
136134
expect(current.actions).toEqual([]);
137135
}
138136
},

‎src/daemon/__tests__/wait-runtime.test.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,8 @@ test.each(['rebuild', 'retire'] as const)(
185185
expect(ref.session.actions).toEqual([]);
186186
expect(current.appName).toBe('Updated during sleep');
187187
} else {
188-
expect(response).toMatchObject({
189-
ok: false,
190-
error: { details: { reason: 'session_lifetime_ended' } },
191-
});
188+
expect(response).toMatchObject({ ok: true, data: { waitedMs: 100 } });
189+
expect(ref.session.actions).toEqual([]);
192190
expect(current.actions).toEqual([]);
193191
}
194192
} finally {

‎src/daemon/selector-recording.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ export function recordIfSession(
137137
evidenceMode?: TargetEvidenceMode,
138138
): void {
139139
if (!ref) return;
140-
const session = sessionStore.requireCurrent(ref);
140+
const session = sessionStore.resolveCurrent(ref);
141+
if (!session) return;
141142
const targetEvidence =
142143
isSessionRecording(session) && recordedTarget
143144
? computeTargetEvidence(recordedTarget, { mode: evidenceMode })

0 commit comments

Comments
 (0)