@@ -246,7 +246,7 @@ export class CmuxTab {
246246 #lastViewport: ReadyInfo [ "viewport" ] = DEFAULT_VIEWPORT ;
247247 #runContext: RunContext | undefined ;
248248 #runtime: JsRuntime | undefined ;
249- readonly #elementRefs = new Map < number , CachedElementRef > ( ) ;
249+ readonly #elementRefs = new Map < string , CachedElementRef > ( ) ;
250250 #pageFacade: CmuxPageFacade | undefined ;
251251 #browserFacade: CmuxBrowserFacade | undefined ;
252252 constructor ( opts : { client : CmuxSocketClient ; surfaceId : string ; url ?: string ; title ?: string } ) {
@@ -278,7 +278,6 @@ export class CmuxTab {
278278 this . #lastViewport = {
279279 width : viewport . width ,
280280 height : viewport . height ,
281- deviceScaleFactor : viewport . deviceScaleFactor ,
282281 } ;
283282 }
284283
@@ -298,9 +297,7 @@ export class CmuxTab {
298297 this . #lastUrl = urlResult . url ;
299298 }
300299 const geometry = await this . #readGeometry( ) . catch ( ( ) => undefined ) ;
301- this . #lastViewport = geometry
302- ? { width : geometry . innerWidth , height : geometry . innerHeight , deviceScaleFactor : geometry . dpr }
303- : viewport ;
300+ this . #lastViewport = geometry ? { width : geometry . innerWidth , height : geometry . innerHeight } : viewport ;
304301 await this . title ( ) . catch ( ( ) => "" ) ;
305302 return {
306303 url : this . #lastUrl,
@@ -342,7 +339,6 @@ export class CmuxTab {
342339 const viewport = {
343340 width : geometry . innerWidth ,
344341 height : geometry . innerHeight ,
345- deviceScaleFactor : geometry . dpr ,
346342 } ;
347343 this . #lastViewport = viewport ;
348344 const observation = cmuxSnapshotToObservation ( snapshot as CmuxSnapshotResult , viewport , geometry ) ;
@@ -575,8 +571,8 @@ export class CmuxTab {
575571 throw new ToolError ( `tab.waitForResponse() timed out after ${ timeoutMs } ms` ) ;
576572 }
577573
578- async id ( id : number ) : Promise < CmuxElementHandle > {
579- const ref = this . #elementRefs. get ( id ) ?. ref ?? `@e ${ id } ` ;
574+ async id ( id : string ) : Promise < CmuxElementHandle > {
575+ const ref = this . #elementRefs. get ( id ) ?. ref ?? `@${ id } ` ;
580576 await this . #waitForSelector( ref , this . #runContext?. timeoutMs ?? 30_000 ) ;
581577 return new CmuxElementHandle ( this , ref ) ;
582578 }
@@ -808,7 +804,7 @@ export class CmuxTab {
808804 }
809805
810806 async #selectorExists( spec : SelectorSpec ) : Promise < boolean > {
811- if ( spec . kind === "ref" ) return this . #elementRefs. has ( Number ( spec . value ) ) ;
807+ if ( spec . kind === "ref" ) return this . #elementRefs. has ( spec . value ) ;
812808 const script = `(() => {
813809 const spec = ${ JSON . stringify ( spec ) } ;
814810 ${ PAGE_SELECTOR_HELPERS }
@@ -893,8 +889,8 @@ export class CmuxTab {
893889 else if ( normalized . startsWith ( "p-aria/" ) ) normalized = `aria/${ normalized . slice ( "p-aria/" . length ) } ` ;
894890 else if ( normalized . startsWith ( "p-xpath/" ) ) normalized = `xpath/${ normalized . slice ( "p-xpath/" . length ) } ` ;
895891 else if ( normalized . startsWith ( "p-pierce/" ) ) normalized = `pierce/${ normalized . slice ( "p-pierce/" . length ) } ` ;
896- const ref = / ^ @ ? e ( \d + ) $ / . exec ( normalized ) ;
897- if ( ref ) return { kind : "ref" , value : ref [ 1 ] ! , raw, ref : `@e ${ ref [ 1 ] } ` } ;
892+ const ref = / ^ @ ? ( e \d + ) $ / . exec ( normalized ) ;
893+ if ( ref ) return { kind : "ref" , value : ref [ 1 ] ! , raw, ref : `@${ ref [ 1 ] } ` } ;
898894 const slash = normalized . indexOf ( "/" ) ;
899895 if ( slash > 0 ) {
900896 const prefix = normalized . slice ( 0 , slash ) ;
@@ -916,7 +912,7 @@ export class CmuxTab {
916912 this . #elementRefs. clear ( ) ;
917913 for ( const element of observation . elements ) {
918914 this . #elementRefs. set ( element . id , {
919- ref : `@e ${ element . id } ` ,
915+ ref : `@${ element . id } ` ,
920916 name : element . name ,
921917 role : element . role ,
922918 } ) ;
0 commit comments