Skip to content

Commit d969e79

Browse files
committed
fix(settle): rule the dismissed-surface check out once, and qualify its help
Review on #3512: - the null answer is a real answer: '??=' reran the chrome classification on every poll for the ordinary full-screen baseline, which is the case the whole point is to keep cheap - the 1500ms floor is iOS XCTest-only and bounded by the settle deadline, so neither the CLI flag nor the MCP schema field may state it as universal - the comment said a short-window caller is held to 'its own window rather than the fixed floor', which is the opposite of what Math.max(requested, 1500) does - the navigation fixtures are compact projections, not the 24-34 nodes a live screen reports; the comment claimed otherwise - the longpress case budgets for the confirmation without asserting it, so it could not catch the baseline failing to reach the loop
1 parent b8d7540 commit d969e79

5 files changed

Lines changed: 30 additions & 19 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export const ACTION_FLAG_DEFINITIONS: readonly FlagDefinition[] = [
211211
min: 0,
212212
usageLabel: '--settle-quiet <ms>',
213213
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',
214+
'Settle: quiet window the UI must hold to count as settled (default 500ms). On iOS, dismissing a presented surface (alert or sheet) holds at least 1500ms, within the --timeout settle deadline',
215215
projectConfig: true,
216216
recorded: false,
217217
},

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,7 @@ 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-
// 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.
310+
// Budget for the confirmation floor this shape now triggers (asserted below).
312311
settle: { quietMs: 100, timeoutMs: 2_000 },
313312
});
314313

@@ -318,6 +317,12 @@ test('longpress --settle rides the same observation path', async () => {
318317
assert.equal(settle.settled, true);
319318
assert.equal(settle.quietMs, 100);
320319
assert.equal(settle.timeoutMs, 2_000);
320+
// The wait itself is the point: the 1-node pre-action tree is a presented-surface shape, so the
321+
// dismissal confirmation, not the requested 100 ms window, sets the floor (#3470).
322+
assert.ok(
323+
settle.waitedMs >= 1_500,
324+
`dismissal confirmation did not extend the settle: waitedMs=${settle.waitedMs}`,
325+
);
321326
assert.ok(settle.diff);
322327
});
323328

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,13 @@ export const elementSettledRoomSnapshot = makeSnapshotState(
134134
{ backend: 'xctest', snapshotQuality: { state: 'healthy', backend: 'tree' } },
135135
);
136136

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).
137+
// Screen-replacement fixtures in the SHAPE a live iPhone 17 (iOS 27) session projects — an
138+
// `Application` root, the screen's own content, and a tab bar whose buttons keep the same identities
139+
// across tabs — kept compact on purpose: a live screen of this app reports 24-34 nodes and the same
140+
// proportion here is 18 (`snapshot -i`, October 2026). What the tests need is the ratio, not the
141+
// volume: each fixture is a BROAD replacement of its siblings — fewer than half the node identities
142+
// survive — which is what made the old complete-viewport-projection arm treat an ordinary tab switch
143+
// or push as a screen replacement (#3470).
142144

143145
const TAB_BAR_LABELS = ['Home', 'Catalog', 'Form', 'Settings'];
144146

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ export async function runStableCaptureLoop(
190190
*
191191
* Arming never consults the requested quiet window: the old `requestedQuietMs <
192192
* DEFAULT_STABLE_QUIET_MS` bar is what made `--settle-quiet 499` behave differently from 500 and left
193-
* `settleQuietMs: 150` callers without the guard at all. An explicit shorter window still gets the
194-
* confirmation, on the caller's own window rather than the fixed 1.5 s floor: it asks for a tighter
195-
* verdict, not for a different set of transitions to distrust (#3470).
193+
* `settleQuietMs: 150` callers without the guard at all. A confirmed dismissal is held for at least
194+
* the caller's own window, floored at 1.5 s: `--settle-quiet` asks for a tighter verdict, not for a
195+
* different set of transitions to distrust (#3470).
196196
*/
197197
function presentedSurfaceConfirmation(params: {
198198
baselineNodes: SnapshotNode[] | undefined;
@@ -212,13 +212,17 @@ function presentedSurfaceConfirmation(params: {
212212
// parent links, and >1px-free geometry, all of which the chrome classifier reads, and one pass
213213
// costs tens of microseconds against the 300 ms poll cadence.
214214
requiredQuietMs(snapshot, currentQuietMs) {
215-
dismissedSurface ??= dismissedPresentedSurface({
216-
baselineNodes: params.baselineNodes,
217-
capture: snapshot,
218-
platform: params.platform,
219-
appBundleId: params.appBundleId,
220-
});
221-
if (!dismissedSurface) return currentQuietMs;
215+
// Not `??=`: that operator re-runs the right side whenever it resolves to `null`, which is
216+
// exactly the ruled-out answer a full-screen baseline gives, on every single poll.
217+
if (dismissedSurface === undefined) {
218+
dismissedSurface = dismissedPresentedSurface({
219+
baselineNodes: params.baselineNodes,
220+
capture: snapshot,
221+
platform: params.platform,
222+
appBundleId: params.appBundleId,
223+
});
224+
}
225+
if (dismissedSurface === null) return currentQuietMs;
222226
const candidate = stableCaptureSurfaceSignal(snapshot, snapshot.nodes, params.appBundleId);
223227
return stableCaptureSignalsHaveBroadReplacement(dismissedSurface, candidate)
224228
? Math.max(currentQuietMs, confirmationQuietMs)

‎src/commands/post-action-observation-grammar.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const settleFields = () => ({
3434
'After the action, wait for the UI to go quiet and return the settled diff vs the pre-action tree in the same response. Best-effort; never fails the action.',
3535
),
3636
settleQuietMs: integerField(
37-
'Settle: quiet window in milliseconds (default 500). A dismissed modal or alert is confirmed for at least 1500 regardless.',
37+
'Settle: quiet window in milliseconds (default 500). On iOS, dismissing a presented surface (alert or sheet) holds at least 1500, within the timeoutMs settle deadline.',
3838
{ min: 0 },
3939
),
4040
timeoutMs: integerField('Settle: wait deadline in milliseconds (default 10000).', { min: 1 }),

0 commit comments

Comments
 (0)