Skip to content

Commit c7bacbf

Browse files
committed
fix(interaction): report a refused press as an unconfirmed position, not as measured motion (#3471)
A `target_still_moving` refusal covers two outcomes and all three of its surfaces described only one. The gate also refuses when a re-observation never measured a position at all — the `@ref` case where reconciliation kept the authorized frame node — so "the target was still moving" reported an observation the gate had not made, in the message, in the published hint, and in the website paragraph. A caller told the target is moving waits for movement; the actual recovery there is to re-resolve the target. All three now state the confirmation that failed. The reason literal is untouched: `reason` is the branch point, and the prose around it is not allowed to be more specific than the code that raised it. The unmeasured `@ref` refusal asserts both halves of that — the new wording present, the motion claim absent — so the text cannot drift back into a claim this path cannot support.
1 parent d7517b1 commit c7bacbf

6 files changed

Lines changed: 23 additions & 14 deletions

File tree

‎src/commands/interaction/runtime/moving-target-gate.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ test('a ref the second observation cannot re-measure is refused, never self-agre
278278
// hint's only test was the contracts unit suite, and the hint now lives beside this refusal.
279279
assert.match(String(details?.hint), /snapshot -i/);
280280
assert.match(String(details?.hint), /ref frame/);
281+
// And no motion claim: this is the shape that measured NOTHING.
282+
assert.match(String(details?.hint), /no confirmed resting position/);
283+
assert.doesNotMatch(String(details?.hint), /was still moving/);
281284
return true;
282285
},
283286
);

‎src/commands/interaction/runtime/moving-target-gate.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ function targetStillMovingHint(params: { selector: string | undefined }): string
276276
? `Run wait ${shellQuoteIfNeeded(params.selector)} and retry with the same selector`
277277
: 'Run snapshot -i and retry with a selector (text=/id=) rather than this @ref — re-observing retires the ref frame';
278278
return (
279-
'The target was still moving when the transition window after the previous action ran out, so no resting ' +
280-
`position could be confirmed and nothing was tapped. ${reobserve}; or pass --settle to have the action itself ` +
281-
'wait for the UI to go quiet.'
279+
'The target had no confirmed resting position when the transition window after the previous action ran ' +
280+
`out, so nothing was dispatched. ${reobserve}; or pass --settle to have the action itself wait for the ` +
281+
'UI to go quiet.'
282282
);
283283
}
284284

@@ -301,8 +301,8 @@ function motionRefusal(
301301
new AppError(
302302
'COMMAND_FAILED',
303303
selector
304-
? `Selector ${selector} is still moving, so no resting position could be confirmed to press`
305-
: `Ref ${ref} is still moving, so no resting position could be confirmed to press`,
304+
? `Selector ${selector} had no confirmed resting position when the transition window ran out`
305+
: `Ref ${ref} had no confirmed resting position when the transition window ran out`,
306306
{
307307
reason: INTERACTION_ERROR_REASONS.targetStillMoving,
308308
...(selector !== undefined ? { selector } : { ref }),

‎src/daemon/__tests__/moving-target-baseline.test.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,9 @@ function settleMark(params: { settled: boolean; diff: boolean }): SettleObservat
223223
}
224224

225225
test('a settle that stored its settled tree records that tree, not the tree the press started from', () => {
226-
// The loop stopped because two reads agreed, and the tree it published became the session
227-
// snapshot. That tree IS the resting surface, and the follow-up press is contractually supposed to
228-
// spend a tap and nothing else (test/integration/provider-scenarios/settle-observation.test.ts);
229-
// screening it against the pre-action tree re-observes a surface the settle already proved quiet.
226+
// The loop stopped because two reads agreed and that tree became the session snapshot, so it IS
227+
// the resting surface — and the follow-up press is contractually supposed to spend a tap and
228+
// nothing else (provider-scenarios/settle-observation.test.ts).
230229
const session = makeSession('android');
231230
const settled = appTree('Settled');
232231
session.snapshot = settled;

‎src/daemon/session-state.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ export type InteractionSurfaceEntry = {
8585
* animating (#3471). The next action that resolves a target asks the tree it recorded whether its
8686
* coordinates are still in play; captures stay plain, because nothing here is owed a wait.
8787
*
88-
* `markedAt` is the instant the mutation finished, not when it began, so the moving-target window
89-
* waits out only what is LEFT of it. Writing either variant retires the other, which is also how a
90-
* gesture takes over a surface a press had left mid-animation.
88+
* `markedAt` is when the mutation FINISHED, so the window waits out only what is left of it, and
89+
* writing either variant retires the other.
9190
*/
9291
export type DeferredSurface =
9392
| {

‎test/integration/interaction-contract/runtime-ref.contract.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ test(scenarioNames(RUNTIME_REF_COVERAGE, 'targetStability')[0]!, async () => {
151151
() => device.interactions.click(ref('@e1'), { session: 'default' }),
152152
(error: unknown) => {
153153
assert.ok(error instanceof Error);
154-
assert.match(error.message, /still moving/);
154+
// One message for both refusal shapes: the confirmation that failed, not motion.
155+
assert.match(
156+
error.message,
157+
/Ref @e1 had no confirmed resting position when the transition window ran out/,
158+
);
155159
const details = (error as { details?: Record<string, unknown> }).details;
156160
assert.equal(details?.reason, 'target_still_moving');
157161
assert.equal(details?.dispatched, 'no');

‎test/integration/interaction-contract/runtime-selector.contract.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,11 @@ test(scenarioNames(RUNTIME_SELECTOR_COVERAGE, 'targetStability')[1]!, async () =
291291
() => device.interactions.press(selector('label=Continue'), { session: 'default' }),
292292
(error: unknown) => {
293293
assert.ok(error instanceof Error);
294-
assert.match(error.message, /label=Continue is still moving/);
294+
// Names the failed confirmation, not motion: the unmeasured shape cannot claim that.
295+
assert.match(
296+
error.message,
297+
/label=Continue had no confirmed resting position when the transition window ran out/,
298+
);
295299
const details = (error as { details?: Record<string, unknown> }).details;
296300
assert.equal(details?.reason, INTERACTION_ERROR_REASONS.targetStillMoving);
297301
assert.equal(details?.dispatched, 'no');

0 commit comments

Comments
 (0)