@@ -244,38 +244,23 @@ export function newAppBridge(serverInfo: ServerInfo, iframe: HTMLIFrameElement):
244244 log . info ( "Log message from MCP App:" , params ) ;
245245 } ;
246246
247- appBridge . onsizechange = async ( { width , height } ) => {
248- // The MCP App has requested a `width` and ` height`, but if
249- // `box-sizing: border-box` is applied to the outer iframe element, then we
250- // must add border thickness to `width` and ` height` to compute the actual
251- // necessary width and height (in order to prevent a resize feedback loop).
247+ appBridge . onheightchange = ( { height } ) => {
248+ // The MCP App has requested a `height`, but if `box-sizing: border-box` is
249+ // applied to the outer iframe element, then we must add border thickness to
250+ // `height` to compute the actual necessary height ( to prevent a resize
251+ // feedback loop).
252252 const style = getComputedStyle ( iframe ) ;
253253 const isBorderBox = style . boxSizing === "border-box" ;
254254
255- // Animate the change for a smooth transition.
256- const from : Keyframe = { } ;
257- const to : Keyframe = { } ;
258-
259- if ( width !== undefined ) {
260- if ( isBorderBox ) {
261- width += parseFloat ( style . borderLeftWidth ) + parseFloat ( style . borderRightWidth ) ;
262- }
263- // Use min-width instead of width to allow responsive growing.
264- // With auto-resize (the default), the app reports its minimum content
265- // width; we honor that as a floor but allow the iframe to expand when
266- // the host layout allows. And we use `min(..., 100%)` so that the iframe
267- // shrinks with its container.
268- from . minWidth = `${ iframe . offsetWidth } px` ;
269- iframe . style . minWidth = to . minWidth = `min(${ width } px, 100%)` ;
270- }
271- if ( height !== undefined ) {
272- if ( isBorderBox ) {
273- height += parseFloat ( style . borderTopWidth ) + parseFloat ( style . borderBottomWidth ) ;
274- }
275- from . height = `${ iframe . offsetHeight } px` ;
276- iframe . style . height = to . height = `${ height } px` ;
255+ if ( isBorderBox ) {
256+ height += parseFloat ( style . borderTopWidth ) + parseFloat ( style . borderBottomWidth ) ;
277257 }
278258
259+ // Animate the change for a smooth transition.
260+ const from : Keyframe = { height : `${ iframe . offsetHeight } px` } ;
261+ const to : Keyframe = { height : `${ height } px` } ;
262+ iframe . style . height = `${ height } px` ;
263+
279264 iframe . animate ( [ from , to ] , { duration : 300 , easing : "ease-out" } ) ;
280265 } ;
281266
0 commit comments