Skip to content

Commit b8d7540

Browse files
committed
fix(settle): scope the broad-transition confirmation to presented-surface dismissal
The confirmation #1831 added for a modal dismissal also fired on ordinary navigation, because it armed on any transition sharing under half its node identities with a complete viewport projection - true of most tab switches and pushes. It was also switched off by the requested window, so --settle-quiet 499 behaved differently from 500 and settleQuietMs: 150 callers (tester-army/e2e) never got the guard at all. Arm on the transition the rule was built for: the pre-action tree shows a surface presented over app content, which an interactive capture reports as the surface alone (a handful of nodes, or a blocking prompt's own Alert root). Decided once, from the first capture, never from the requested window; an explicit shorter window keeps the confirmation on its own floor. Closes #3470.
1 parent 41c8a82 commit b8d7540

8 files changed

Lines changed: 554 additions & 214 deletions

File tree

‎packages/command-registry/src/flag-definitions-action.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ export const ACTION_FLAG_DEFINITIONS: readonly FlagDefinition[] = [
210210
type: 'int',
211211
min: 0,
212212
usageLabel: '--settle-quiet <ms>',
213-
usageDescription: 'Settle: quiet window the UI must hold to count as settled (default 500ms)',
213+
usageDescription:
214+
'Settle: quiet window the UI must hold to count as settled (default 500ms). A dismissed modal or alert is confirmed for at least 1500ms regardless',
214215
projectConfig: true,
215216
recorded: false,
216217
},

‎src/commands/interaction/runtime/settle.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,17 @@ test('longpress --settle rides the same observation path', async () => {
307307
const result = await device.interactions.longPress(ref('@e1'), {
308308
session: 'default',
309309
durationMs: 400,
310-
settle: { quietMs: 100, timeoutMs: 1_000 },
310+
// The 1-node baseline is a presented-surface shape, so the dismissal confirmation applies and
311+
// its 1.5 s floor, not the requested 100 ms window, sets the wait (#3470). Budget for it.
312+
settle: { quietMs: 100, timeoutMs: 2_000 },
311313
});
312314

313315
assert.equal(result.kind, 'ref');
314316
const settle = result.settle;
315317
assert.ok(settle);
316318
assert.equal(settle.settled, true);
317319
assert.equal(settle.quietMs, 100);
318-
assert.equal(settle.timeoutMs, 1_000);
320+
assert.equal(settle.timeoutMs, 2_000);
319321
assert.ok(settle.diff);
320322
});
321323

‎src/commands/interaction/runtime/settle.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ async function settleAfterAction(
134134
quietMs,
135135
timeoutMs,
136136
resetBudgetOnPrivateAxRecovery: true,
137-
broadTransitionBaselineNodes: params.baseline.nodes,
137+
transitionBaselineNodes: params.baseline.nodes,
138138
});
139139
return await readSettledOutcome(runtime, options, params, base, outcome);
140140
} catch (error) {

‎src/commands/interaction/runtime/stable-capture.fixtures.ts‎

Lines changed: 174 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { SnapshotState } from '@agent-device/kernel/snapshot';
1+
import type { RawSnapshotNode, Rect, SnapshotState } from '@agent-device/kernel/snapshot';
22
import { makeSnapshotState } from '@agent-device/selectors/snapshot-geometry-fixtures';
33

44
export function elementSettingsSnapshot(offscreenRowYs: number[]): SnapshotState {
@@ -133,3 +133,176 @@ export const elementSettledRoomSnapshot = makeSnapshotState(
133133
],
134134
{ backend: 'xctest', snapshotQuality: { state: 'healthy', backend: 'tree' } },
135135
);
136+
137+
// The three screen-replacement fixtures below are in the shape a live iPhone 17 (iOS 27) session
138+
// projects (`snapshot -i` on the RN test app: 24-34 nodes per screen, and the tab bar's buttons are
139+
// the only identities two tabs share). Each is a BROAD replacement of its siblings — fewer than half
140+
// the node identities survive — which is what made the old complete-viewport-projection arm treat an
141+
// ordinary tab switch or push as a screen replacement (#3470).
142+
143+
const TAB_BAR_LABELS = ['Home', 'Catalog', 'Form', 'Settings'];
144+
145+
function iosScreenSnapshot(
146+
content: Array<{ type: string; label: string; rect: Rect }>,
147+
): SnapshotState {
148+
const nodes: RawSnapshotNode[] = [
149+
{
150+
index: 0,
151+
depth: 0,
152+
type: 'Application',
153+
label: 'Agent Device Tester',
154+
rect: { x: 0, y: 0, width: 402, height: 874 },
155+
},
156+
...content.map((node, offset) => ({
157+
index: offset + 1,
158+
depth: 1,
159+
parentIndex: 0,
160+
...node,
161+
})),
162+
];
163+
const tabBarIndex = nodes.length;
164+
nodes.push({
165+
index: tabBarIndex,
166+
depth: 1,
167+
parentIndex: 0,
168+
type: 'TabBar',
169+
label: 'Tab Bar',
170+
rect: { x: 0, y: 791, width: 402, height: 83 },
171+
});
172+
TAB_BAR_LABELS.forEach((label, offset) => {
173+
nodes.push({
174+
index: nodes.length,
175+
depth: 2,
176+
parentIndex: tabBarIndex,
177+
type: 'Button',
178+
label,
179+
rect: { x: 12 + offset * 96, y: 795, width: 92, height: 54 },
180+
});
181+
});
182+
return makeSnapshotState(nodes, {
183+
backend: 'xctest',
184+
snapshotQuality: { state: 'healthy', backend: 'tree' },
185+
});
186+
}
187+
188+
/** A tab's list screen: the shared tab bar plus that tab's own rows. */
189+
export function elementCatalogTabSnapshot(): SnapshotState {
190+
return iosScreenSnapshot(
191+
Array.from({ length: 12 }, (_, offset) => ({
192+
type: 'Cell',
193+
label: `Catalog product ${offset + 1}`,
194+
rect: { x: 0, y: 120 + offset * 90, width: 402, height: 84 },
195+
})),
196+
);
197+
}
198+
199+
/** The tab you switch to: different rows, same tab bar, same app root. */
200+
export function elementSettingsTabSnapshot(): SnapshotState {
201+
return iosScreenSnapshot(
202+
Array.from({ length: 12 }, (_, offset) => ({
203+
type: 'Button',
204+
label: `Open settings fixture ${offset + 1}`,
205+
rect: { x: 16, y: 120 + offset * 60, width: 370, height: 45 },
206+
})),
207+
);
208+
}
209+
210+
/** The screen a push opens: its own nav bar and content, and the tab bar's row is gone. */
211+
export function elementPushedDetailSnapshot(): SnapshotState {
212+
return makeSnapshotState(
213+
[
214+
{
215+
index: 0,
216+
depth: 0,
217+
type: 'Application',
218+
label: 'Agent Device Tester',
219+
rect: { x: 0, y: 0, width: 402, height: 874 },
220+
},
221+
{
222+
index: 1,
223+
depth: 1,
224+
parentIndex: 0,
225+
type: 'NavigationBar',
226+
label: 'Automation',
227+
rect: { x: 0, y: 62, width: 402, height: 54 },
228+
},
229+
{
230+
index: 2,
231+
depth: 2,
232+
parentIndex: 1,
233+
type: 'Button',
234+
label: '(tabs)',
235+
rect: { x: 16, y: 62, width: 44, height: 44 },
236+
},
237+
...['Open automation sheet', 'Press canary', 'Long press canary'].map((label, offset) => ({
238+
index: 3 + offset,
239+
depth: 1,
240+
parentIndex: 0,
241+
type: 'Button',
242+
label,
243+
rect: { x: 16, y: 240 + offset * 120, width: 370, height: 45 },
244+
})),
245+
],
246+
{ backend: 'xctest', snapshotQuality: { state: 'healthy', backend: 'tree' } },
247+
);
248+
}
249+
250+
/**
251+
* A system permission prompt's own projection: the runner roots it at an `Alert` node and the app
252+
* content it presents over is not in the tree. Larger than `TINY_STABLE_TREE_NODE_COUNT`, so only the
253+
* root names it (#2660).
254+
*/
255+
export function systemPermissionPromptSnapshot(): SnapshotState {
256+
return makeSnapshotState(
257+
[
258+
{
259+
index: 0,
260+
depth: 0,
261+
type: 'Alert',
262+
label: 'Allow “Agent Device Tester” to access your microphone?',
263+
rect: { x: 40, y: 309, width: 322, height: 283 },
264+
},
265+
{
266+
index: 1,
267+
depth: 1,
268+
parentIndex: 0,
269+
type: 'StaticText',
270+
label: 'Allow Agent Device Tester to exercise microphone permissions.',
271+
rect: { x: 60, y: 420, width: 282, height: 42 },
272+
},
273+
{
274+
index: 2,
275+
depth: 1,
276+
parentIndex: 0,
277+
type: 'StaticText',
278+
label: 'Microphone access lets the lab record a clip.',
279+
rect: { x: 60, y: 470, width: 282, height: 38 },
280+
},
281+
{
282+
index: 3,
283+
depth: 1,
284+
parentIndex: 0,
285+
type: 'Button',
286+
label: 'Don’t Allow',
287+
rect: { x: 60, y: 528, width: 130, height: 48 },
288+
},
289+
{
290+
index: 4,
291+
depth: 1,
292+
parentIndex: 0,
293+
type: 'Button',
294+
label: 'Allow',
295+
rect: { x: 212, y: 528, width: 130, height: 48 },
296+
},
297+
{
298+
index: 5,
299+
depth: 1,
300+
parentIndex: 0,
301+
type: 'Button',
302+
label: 'Learn More',
303+
rect: { x: 136, y: 580, width: 130, height: 48 },
304+
},
305+
],
306+
{ backend: 'xctest', snapshotQuality: { state: 'healthy', backend: 'tree' } },
307+
);
308+
}

0 commit comments

Comments
 (0)