@@ -60,7 +60,7 @@ function testSession(): RecorderSession {
6060 } ,
6161 schemaVersion : 1 ,
6262 startedAt : "2026-08-15T12:00:00.000Z" ,
63- window : { height : 1000 , width : 650 , x : 635 , y : 40 } ,
63+ window : { height : 1000 , id : "0x04600007" , width : 650 , x : 635 , y : 40 } ,
6464 userDriver : [ "python3" , "driver.py" , "--account" , "qa shared" ] ,
6565 } ;
6666}
@@ -152,7 +152,7 @@ describe("Telegram Desktop recorder CLI", () => {
152152 } ) ;
153153 } ) ;
154154
155- it ( "runs agent-authored actions inside the recorded desktop " , async ( ) => {
155+ it ( "targets the recorded Telegram window instead of the first matching window " , async ( ) => {
156156 const root = makeTempDir ( ) ;
157157 const sessionPath = path . join ( root , "recorder.json" ) ;
158158 const actionsPath = path . join ( root , "click.json" ) ;
@@ -208,6 +208,11 @@ describe("Telegram Desktop recorder CLI", () => {
208208 timeoutMs : 90_000 ,
209209 } ) ,
210210 ) ;
211+ const actionCommand = sshRun . mock . calls [ 0 ] ?. [ 0 ] . command ;
212+ expect ( actionCommand ) . toContain ( "win='0x04600007'" ) ;
213+ expect ( actionCommand ) . toContain ( "tolower($1) == tolower(win)" ) ;
214+ expect ( actionCommand ) . toContain ( '[ "$WIDTH" -ne 650 ]' ) ;
215+ expect ( actionCommand ) . not . toContain ( "{print $1; exit}" ) ;
211216 } ) ;
212217
213218 it ( "requires start inputs and a -100 private-group chat id" , ( ) => {
@@ -540,7 +545,7 @@ describe("Telegram Desktop recorder remote contract", () => {
540545 throw new Error ( "first desktop stayed on QR" ) ;
541546 }
542547 if ( command . includes ( "getwindowgeometry" ) ) {
543- return { stderr : "" , stdout : "635 40 650 1000" } ;
548+ return { stderr : "" , stdout : "0x04600007 635 40 650 1000" } ;
544549 }
545550 return { stderr : "" , stdout : "" } ;
546551 } ) ,
@@ -579,7 +584,7 @@ describe("Telegram Desktop recorder remote contract", () => {
579584 return { stderr : "" , stdout : "tg://login?token=open-target-chat" } ;
580585 }
581586 if ( command . includes ( "getwindowgeometry" ) ) {
582- return { stderr : "" , stdout : "635 40 650 1000" } ;
587+ return { stderr : "" , stdout : "0x04600007 635 40 650 1000" } ;
583588 }
584589 return { stderr : "" , stdout : "" } ;
585590 } ) ;
@@ -860,22 +865,23 @@ describe("Telegram Desktop recorder window geometry", () => {
860865 } ) ;
861866
862867 it ( "parses the measured window and rejects unusable geometry" , ( ) => {
863- expect ( parseWindowGeometry ( " 636 45 648 995 \n" ) ) . toEqual ( {
868+ expect ( parseWindowGeometry ( " 0x04600007 636 45 648 995 \n" ) ) . toEqual ( {
864869 height : 995 ,
870+ id : "0x04600007" ,
865871 width : 648 ,
866872 x : 636 ,
867873 y : 45 ,
868874 } ) ;
869- expect ( ( ) => parseWindowGeometry ( "636 45 648" ) ) . toThrow ( "was not readable" ) ;
870- expect ( ( ) => parseWindowGeometry ( "636 45 10 10" ) ) . toThrow ( "too small to crop" ) ;
875+ expect ( ( ) => parseWindowGeometry ( "0x04600007 636 45 648" ) ) . toThrow ( "was not readable" ) ;
876+ expect ( ( ) => parseWindowGeometry ( "0x04600007 636 45 10 10" ) ) . toThrow ( "too small to crop" ) ;
871877 } ) ;
872878
873879 it ( "crops the recorded window instead of a fixed rectangle" , async ( ) => {
874880 const root = makeTempDir ( ) ;
875881 const sessionPath = path . join ( root , "recorder.json" ) ;
876882 writeRecorderSession ( sessionPath , {
877883 ...testSession ( ) ,
878- window : { height : 995 , width : 648 , x : 636 , y : 45 } ,
884+ window : { height : 995 , id : "0x04600007" , width : 648 , x : 636 , y : 45 } ,
879885 } ) ;
880886 const cropped = vi . fn ( async ( ) => ( { crop : "" , fps : 24 , outputWidth : 648 } ) ) ;
881887 const sshRun = vi . fn < RecorderOperations [ "sshRun" ] > ( async ( ) => ( { stderr : "" , stdout : "" } ) ) ;
0 commit comments