Skip to content

Commit 27a41c3

Browse files
strzhaoclaude
andcommitted
docs(adr): amend 0014 for the multi-ref plan and fix the response identity
The accepted callstack#4476 decision names the multi-ref plan as one logical command. The ADR gains the plan in the logical-command list with its four rules (all members resolve and admit pre-dispatch, the frame expires once at key 1, later keys dispatch their admitted points with no re-resolution or per-key motion screen, and a post-key-1 failure reports dispatchedSteps, refPlanKey and refPlanPending), the admissible-issued list and the consequences widen from one resolved target to N. The response now keeps member 0's ref, point, and evidence baseline instead of the last key's, and the click description carries its plan lead-in. The interval test observes the test clock, the plan tests assert concrete per-member points, and the daemon refusal tests pin dispatched no and the typed reasons. Co-Authored-By: Claude Code <[email protected]>
1 parent 6d68697 commit 27a41c3

5 files changed

Lines changed: 23 additions & 9 deletions

File tree

‎packages/command-runtime/src/commands/interaction/runtime/interactions.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,11 +860,19 @@ test('runtime press plan dispatches every member as an ordinary press and report
860860

861861
test('runtime press plan sleeps intervalMs between keys and passes count to every member', async () => {
862862
const taps: string[] = [];
863+
const sleeps: number[] = [];
863864
const device = createInteractionDevice(pinPadSnapshot(), {
864865
tap: async () => {
865866
taps.push('tap');
866867
return { ok: true };
867868
},
869+
// The test clock observes every inter-key wait the plan asks for.
870+
clock: {
871+
now: () => 0,
872+
sleep: async (ms: number) => {
873+
sleeps.push(ms);
874+
},
875+
},
868876
});
869877

870878
const result = await device.interactions.press(ref('@e1'), {
@@ -875,6 +883,7 @@ test('runtime press plan sleeps intervalMs between keys and passes count to ever
875883
});
876884

877885
assert.equal(taps.length, 2);
886+
assert.deepEqual(sleeps, [1]);
878887
assert.deepEqual(result.sequence?.pressed, 2);
879888
});
880889

‎packages/command-runtime/src/commands/interaction/runtime/interactions.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,10 @@ async function tapRefPlanCommand(
309309
throw attachRefPlanContext(error, plannedRefs, index);
310310
}
311311
}
312-
const last = members.at(-1)!;
313-
const first = members[0]!;
314-
// The plan's evidence compares the pre-command tree member 0 captured with the
315-
// post-command tree, so the baseline rides to the final result.
316-
const finalTarget: ResolvedInteractionTarget =
317-
last.atRest.preAction || !first.atRest.preAction
318-
? last.atRest
319-
: { ...last.atRest, preAction: first.atRest.preAction };
312+
// The response keeps member 0's identity — the first key's ref, point, and
313+
// its captured evidence baseline — while every key's landing stays in
314+
// sequence.points.
315+
const finalTarget: ResolvedInteractionTarget = members[0]!.atRest;
320316
const formattedBackendResult = toBackendResult(lastBackendResult);
321317
const result = await applyPostActionObservation(
322318
runtime,

‎packages/command-surface/src/interaction/metadata.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const FIND_ACTION_VALUES = [
6565

6666
const interactionCommandDescriptions = {
6767
click:
68-
"Activate a UI target by snapshot ref, selector, or coordinates. This can change app state. Success reports dispatch only; settle returns the resulting UI diff and verify returns cheap post-action evidence. A ref or selector target is re-checked for motion before dispatch when the session's previous action just animated the screen, and is dispatched at its resting position; one that has not stopped refuses with target_still_moving rather than acting where it was. dispatches one action per key in order as one command, with the admission, rest, and refusal contract press documents for its sequence.",
68+
"Activate a UI target by snapshot ref, selector, or coordinates. This can change app state. Success reports dispatch only; settle returns the resulting UI diff and verify returns cheap post-action evidence. A ref or selector target is re-checked for motion before dispatch when the session's previous action just animated the screen, and is dispatched at its resting position; one that has not stopped refuses with target_still_moving rather than acting where it was. A comma-separated ref list (target `@e13,@e14`) dispatches one action per key in order as one command, with the admission, rest, and refusal contract press documents for its sequence.",
6969
press:
7070
"Short-press a UI target by snapshot ref, selector, or coordinates. Success reports dispatch only; settle returns the resulting UI diff and verify returns cheap post-action evidence. A ref or selector target is re-checked for motion before dispatch when the session's previous action just animated the screen, and is dispatched at its resting position; one that has not stopped refuses with target_still_moving rather than acting where it was. A comma-separated ref list (target `@e13,@e14,@e15,@e16`) presses each key once in order as one command; pass refs as a list of 2 to 16 snapshot refs (a repeated ref presses the same key twice), and the response carries a sequence summary with the refs, the keys pressed, and where each landed. The plan resolves and admits against the current frame before the first press; key 1 expires the frame, later keys tap where the snapshot showed them, and a later key that refuses carries the keys already sent in details.dispatchedSteps.",
7171
fill: 'Replace text in a UI input selected by snapshot ref, selector, or coordinates. An empty text clears the field. Unconfirmed evidence does not establish the resulting value or screen. The recordAs option keeps sensitive text out of a recorded replay while sending it to the live app.',

‎packages/daemon/src/execution/interaction/internal/__tests__/interaction-touch-targets.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ test('parseTouchTarget keeps a comma token without a leading @ on the selector p
240240
});
241241

242242
test('parseTouchTarget keeps a repeated member and rejects non-ref members', () => {
243+
const empty = parseTouchTarget(['@e1,,@e2'], 'press');
244+
expect(empty.ok).toBe(false);
245+
if (!empty.ok && !empty.response.ok) {
246+
expect(empty.response.error.message).toContain('empty member between commas');
247+
}
243248
// Selector semantics re-resolve per press, so a repeated ref is the PIN
244249
// digit case, not a mistake: @e1,@e1 presses the same key twice.
245250
const repeated = parseTouchTarget(['@e1,@e1'], 'press');

‎packages/daemon/src/execution/interaction/internal/interaction-touch-press-admission.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ test('a plan on an expired frame warns once, not once per member', async () => {
444444
expect(response?.ok).toBe(false);
445445
if (response && !response.ok) {
446446
expect(String(response.error.details?.hint)).toBe(STALE_SNAPSHOT_REFS_WARNING);
447+
expect(response.error.details?.dispatched).toBe('no');
448+
expect(response.error.details?.reason).toBe('ref_frame_expired');
447449
}
448450
});
449451

@@ -499,5 +501,7 @@ test('a multi-ref press plan refuses a replay target guard instead of downgradin
499501
}
500502
expect(response.error.code).toBe('INVALID_ARGS');
501503
expect(response.error.message).toMatch(/cannot carry a replay target guard/);
504+
expect(response.error.details?.reason).toBe('sequence-replay-guard-unsupported');
505+
expect(response.error.details?.dispatched).toBe('no');
502506
expect(mockTapPoint).not.toHaveBeenCalled();
503507
});

0 commit comments

Comments
 (0)