@@ -13,6 +13,7 @@ import {
1313import { useSession } from '@/common/hooks/useSession' ;
1414import { BrowserShell } from './BrowserShell' ;
1515import { FileDisplayMode } from '../types' ;
16+ import { AgentEventStream } from '@tarko/agent-interface' ;
1617
1718interface BrowserControlRendererProps {
1819 panelContent : StandardPanelContent ;
@@ -35,6 +36,7 @@ export const BrowserControlRenderer: React.FC<BrowserControlRendererProps> = ({
3536 x : number ;
3637 y : number ;
3738 } | null > ( null ) ;
39+ const [ devicePixelRatio , setDevicePixelRatio ] = useState < number > ( window . devicePixelRatio ) ;
3840 const imageRef = useRef < HTMLImageElement > ( null ) ;
3941
4042 // Extract the visual operation details from panelContent
@@ -112,6 +114,15 @@ export const BrowserControlRenderer: React.FC<BrowserControlRendererProps> = ({
112114 if ( imgContent && 'image_url' in imgContent && imgContent . image_url . url ) {
113115 setRelatedImage ( imgContent . image_url . url ) ;
114116 foundImage = true ;
117+
118+ // Extract devicePixelRatio from environment input metadata if available
119+ if (
120+ msg . metadata &&
121+ AgentEventStream . isScreenshotMetadata ( msg . metadata ) &&
122+ msg . metadata . devicePixelRatio
123+ ) {
124+ setDevicePixelRatio ( msg . metadata . devicePixelRatio ) ;
125+ }
115126 break ;
116127 }
117128 }
@@ -158,17 +169,17 @@ export const BrowserControlRenderer: React.FC<BrowserControlRendererProps> = ({
158169 initial = {
159170 previousMousePosition
160171 ? {
161- left : `${ ( previousMousePosition . x / imageSize . width ) * 100 * window . devicePixelRatio } %` ,
162- top : `${ ( previousMousePosition . y / imageSize . height ) * 100 * window . devicePixelRatio } %` ,
172+ left : `${ ( previousMousePosition . x / imageSize . width ) * 100 * devicePixelRatio } %` ,
173+ top : `${ ( previousMousePosition . y / imageSize . height ) * 100 * devicePixelRatio } %` ,
163174 }
164175 : {
165- left : `${ ( mousePosition . x / imageSize . width ) * 100 * window . devicePixelRatio } %` ,
166- top : `${ ( mousePosition . y / imageSize . height ) * 100 * window . devicePixelRatio } %` ,
176+ left : `${ ( mousePosition . x / imageSize . width ) * 100 * devicePixelRatio } %` ,
177+ top : `${ ( mousePosition . y / imageSize . height ) * 100 * devicePixelRatio } %` ,
167178 }
168179 }
169180 animate = { {
170- left : `${ ( mousePosition . x / imageSize . width ) * 100 * window . devicePixelRatio } %` ,
171- top : `${ ( mousePosition . y / imageSize . height ) * 100 * window . devicePixelRatio } %` ,
181+ left : `${ ( mousePosition . x / imageSize . width ) * 100 * devicePixelRatio } %` ,
182+ top : `${ ( mousePosition . y / imageSize . height ) * 100 * devicePixelRatio } %` ,
172183 } }
173184 transition = { { duration : 0.5 , ease : [ 0.16 , 1 , 0.3 , 1 ] } }
174185 style = { {
0 commit comments