@@ -149,16 +149,11 @@ export async function invokeMaestroAssertNotVisible(params: {
149149 let hiddenSamples = 0 ;
150150 let lastVisibleResponse : DaemonResponse | undefined ;
151151 while ( Date . now ( ) - startedAt <= MAESTRO_ASSERTION_POLICY . assertNotVisibleTimeoutMs ) {
152- const response = await params . invoke ( {
153- ...params . baseReq ,
154- command : 'is' ,
155- positionals : [ 'visible' , selector ] ,
156- flags : { ...params . baseReq . flags , noRecord : true } ,
157- } ) ;
158- if ( response . ok ) {
152+ const attempt = await readAssertNotVisibleAttempt ( params , selector ) ;
153+ if ( attempt . visible ) {
159154 hiddenSamples = 0 ;
160- lastVisibleResponse = response ;
161- } else if ( isMaestroVisibilityMiss ( response ) ) {
155+ lastVisibleResponse = attempt . response ;
156+ } else if ( attempt . hidden ) {
162157 hiddenSamples += 1 ;
163158 const waitedMs = Date . now ( ) - startedAt ;
164159 if (
@@ -177,7 +172,7 @@ export async function invokeMaestroAssertNotVisible(params: {
177172 } ;
178173 }
179174 } else {
180- return response ;
175+ return attempt . response ;
181176 }
182177 await sleep ( MAESTRO_ASSERTION_POLICY . assertNotVisiblePollMs ) ;
183178 }
@@ -188,6 +183,59 @@ export async function invokeMaestroAssertNotVisible(params: {
188183 } ) ;
189184}
190185
186+ async function readAssertNotVisibleAttempt (
187+ params : {
188+ baseReq : ReplayBaseRequest ;
189+ positionals : string [ ] ;
190+ invoke : MaestroRuntimeInvoke ;
191+ } ,
192+ selector : string ,
193+ ) : Promise <
194+ | { visible : true ; hidden : false ; response : DaemonResponse }
195+ | { visible : false ; hidden : true ; response : DaemonResponse }
196+ | { visible : false ; hidden : false ; response : DaemonResponse }
197+ > {
198+ const response = await captureMaestroRawSnapshot ( params ) ;
199+ if ( ! response . ok ) return { visible : false , hidden : false , response } ;
200+ const snapshot = readSnapshotState ( response . data ) ;
201+ if ( ! snapshot ) {
202+ return {
203+ visible : false ,
204+ hidden : false ,
205+ response : errorResponse ( 'COMMAND_FAILED' , 'Unable to read snapshot data for assertNotVisible.' ) ,
206+ } ;
207+ }
208+ const target = resolveVisibleMaestroNodeFromSnapshot (
209+ snapshot ,
210+ selector ,
211+ readMaestroSelectorPlatform ( params . baseReq . flags ) ,
212+ getSnapshotReferenceFrame ( snapshot ) ,
213+ ) ;
214+ if ( ! target . ok ) {
215+ return {
216+ visible : false ,
217+ hidden : true ,
218+ response : errorResponse ( 'COMMAND_FAILED' , target . message , { selector } ) ,
219+ } ;
220+ }
221+ return {
222+ visible : true ,
223+ hidden : false ,
224+ response : {
225+ ok : true ,
226+ data : {
227+ selector,
228+ matches : target . matches ,
229+ nodeIndex : target . node . index ,
230+ nodeType : target . node . type ,
231+ nodeLabel : target . node . label ,
232+ nodeIdentifier : target . node . identifier ,
233+ rect : target . rect ,
234+ } ,
235+ } ,
236+ } ;
237+ }
238+
191239export async function invokeMaestroWaitForAnimationToEnd ( params : {
192240 baseReq : ReplayBaseRequest ;
193241 positionals : string [ ] ;
@@ -215,14 +263,6 @@ export async function invokeMaestroWaitForAnimationToEnd(params: {
215263 : { ok : true , data : { stable : false , timeoutMs } } ;
216264}
217265
218- function isMaestroVisibilityMiss ( response : Extract < DaemonResponse , { ok : false } > ) : boolean {
219- const details = response . error . details ;
220- return (
221- details ?. command === 'is' &&
222- ( details . reason === 'selector_not_found' || details . reason === 'predicate_failed' )
223- ) ;
224- }
225-
226266function readAnimationPollResult (
227267 response : DaemonResponse ,
228268 previousSignature : string | undefined ,
0 commit comments