@@ -213,29 +213,19 @@ function requireResolvedPoint(result: { point?: Point }): Point {
213213}
214214
215215/**
216- * A multi-ref plan is one ADR 0014 logical command that resolves and admits every member
217- * once against the active frame, then dispatches the admitted points in order — `press
218- * --count` with N points. Key 1's dispatch expires the ref frame, so later keys tap where
219- * the snapshot showed them: no member re-resolves, and the motion screen judges the whole
220- * plan once, before key 1. Every resolution and admission refusal is pre-dispatch
221- * (`dispatched: 'no'`); after key 1, the request dispatch ledger owns the dispatched-steps
222- * disclosure and these details name the key that refused and the keys that did not run.
216+ * Resolves and admits every plan member against the active frame, before key 1. Member 0's
217+ * resolution captures the plan's pre-command evidence baseline. Every refusal here is
218+ * pre-dispatch: nothing has crossed to the device, so the verdict stays `no`.
223219 */
224- async function tapRefPlanCommand (
220+ async function resolveRefPlanMembers (
225221 runtime : AgentDeviceRuntime ,
226222 options : PressCommandOptions ,
227223 action : 'click' | 'press' ,
228- ) : Promise < PressCommandResult > {
229- if ( options . target . kind !== 'ref' ) {
230- throw new AppError ( 'INVALID_ARGS' , 'A multi-ref press plan requires ref targets.' ) ;
231- }
232- if ( ! runtime . backend . tap ) {
233- throw new AppError ( 'UNSUPPORTED_OPERATION' , 'tap is not supported by this backend' ) ;
234- }
235- // The parser emits the full plan in `refs` with `target` kept as member 0's
236- // response identity, so the plan iterates `refs` alone.
237- const plannedRefs = ( options . refs ?? [ ] ) . map ( ( ref ) => ( ref . startsWith ( '@' ) ? ref : `@${ ref } ` ) ) ;
238- const observation = planPostActionObservation ( options ) ;
224+ plannedRefs : readonly string [ ] ,
225+ captureEvidenceBaseline : boolean ,
226+ ) : Promise < Array < { ref : string ; atRest : ResolvedInteractionTarget ; point : Point } > > {
227+ // One request object for the resolution and for the looks admission may spend, so a
228+ // second look is the same question asked again rather than a differently-configured one.
239229 const resolutionRequest : ResolveInteractionTargetParams = {
240230 action,
241231 requireInteractive : true ,
@@ -249,15 +239,48 @@ async function tapRefPlanCommand(
249239 ...resolutionRequest ,
250240 // One pre-command baseline serves the plan's evidence: member 0's resolution
251241 // captures it, and the final result carries it forward.
252- captureEvidenceBaseline : observation . needsPreActionBaseline && index === 0 ,
242+ captureEvidenceBaseline : captureEvidenceBaseline && index === 0 ,
253243 } ) ;
254244 const atRest = await admitResolvedTarget ( runtime , member , resolutionRequest , resolved ) ;
255245 members . push ( { ref, atRest, point : requireResolvedPoint ( atRest ) } ) ;
256246 } catch ( error ) {
257- // Nothing has crossed to the device yet.
258247 throw attachRefPlanContext ( error , plannedRefs , index ) ;
259248 }
260249 }
250+ return members ;
251+ }
252+
253+ /**
254+ * A multi-ref plan is one ADR 0014 logical command that resolves and admits every member
255+ * once against the active frame, then dispatches the admitted points in order — `press
256+ * --count` with N points. Key 1's dispatch expires the ref frame, so later keys tap where
257+ * the snapshot showed them: no member re-resolves, and the motion screen judges the whole
258+ * plan once, before key 1. Every resolution and admission refusal is pre-dispatch
259+ * (`dispatched: 'no'`); after key 1, the request dispatch ledger owns the dispatched-steps
260+ * disclosure and these details name the key that refused and the keys that did not run.
261+ */
262+ async function tapRefPlanCommand (
263+ runtime : AgentDeviceRuntime ,
264+ options : PressCommandOptions ,
265+ action : 'click' | 'press' ,
266+ ) : Promise < PressCommandResult > {
267+ if ( options . target . kind !== 'ref' ) {
268+ throw new AppError ( 'INVALID_ARGS' , 'A multi-ref press plan requires ref targets.' ) ;
269+ }
270+ if ( ! runtime . backend . tap ) {
271+ throw new AppError ( 'UNSUPPORTED_OPERATION' , 'tap is not supported by this backend' ) ;
272+ }
273+ // The parser emits the full plan in `refs` with `target` kept as member 0's
274+ // response identity, so the plan iterates `refs` alone.
275+ const plannedRefs = ( options . refs ?? [ ] ) . map ( ( ref ) => ( ref . startsWith ( '@' ) ? ref : `@${ ref } ` ) ) ;
276+ const observation = planPostActionObservation ( options ) ;
277+ const members = await resolveRefPlanMembers (
278+ runtime ,
279+ options ,
280+ action ,
281+ plannedRefs ,
282+ observation . needsPreActionBaseline ,
283+ ) ;
261284 let lastBackendResult ;
262285 for ( const [ index , member ] of members . entries ( ) ) {
263286 if ( index > 0 && options . intervalMs !== undefined && options . intervalMs > 0 ) {
0 commit comments