fix(ui): prevent MCP app iframe from staying stuck at compressed width#7256
fix(ui): prevent MCP app iframe from staying stuck at compressed width#7256clayarnoldg2m wants to merge 1 commit intoblock:mainfrom
Conversation
The size-changed notification from MCP apps set a fixed pixel width on the container, which never grew back when the window expanded because the app couldn't detect size changes beyond its own container bounds. Use the app-reported width as maxWidth instead of width, so the container stays fluid and naturally expands with the window while still respecting the app's preferred maximum width. Fixes block#6818 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: clayarnoldg2m <carnold@g2m.ai>
|
I'm not seeing this issue on main with my toy MCP app, it just always the width of the screen. thoughts @aharvard ? |
|
@DOsinga it depends on how the app is sending width data in the size change message. Regardless, what we have for goose right now is incorrect. Will share notes! |
aharvard
left a comment
There was a problem hiding this comment.
Thanks for looking into this @clayarnoldg2m, but I don't think this is the right fix. The underlying issue is that PR #6376 should be reverted entirely.
Why this PR doesn't solve the problem
Swapping width → maxWidth still lets the app drive the container width. If an app reports width: 400 when compressed, the container gets maxWidth: 400px — which caps it at that size even when the chat window is wider. The feedback loop is still there, just inverted.
The actual problem with #6376
For the inline chat view, the host owns the width and the app owns the height. The app should always render at width: 100% and adapt responsively. The width value in ui/notifications/size-changed should be ignored in this display mode.
This was the consensus from the upstream spec discussion in modelcontextprotocol/ext-apps#153. The spec defines containerDimensions to communicate the sizing model to apps — for inline mode that means something like { width: <fixed> } (host controls) with flexible height (app controls). The original proposal to rename size-changed to height-changed was only dropped to stay extensible for other display modes (sidebar, popup) — not because inline apps should control their width.
What we should do instead
- Revert #6376 — remove iframeWidth state and always use width: 100% for inline mode
- Properly send containerDimensions in the host context so apps know the sizing model (there's already a TODO for this in the code... coming soon!)
See also: owtaylor's analysis on #6818
Summary
size-changednotification from MCP apps was setting a fixed pixelwidthon the container, which never grew back when the window expanded (the app can't detect size changes beyond its own container bounds)maxWidthinstead ofwidth, so the container stays fluid (width: 100%) and naturally expands with the window while still respecting the app's preferred maximumRoot cause
PR #6376 introduced width tracking from
ui/notifications/size-changed. When an app reported its width (e.g.,400pxwhen compressed), the container was pinned to that exact width. Since the app is inside the container, it couldn't detect the window growing beyond400pxto send a larger width notification — a feedback loop that kept it stuck.Test plan
maxWidthcappingnpx tsc --noEmitpassescargo clippyclean🤖 Generated with Claude Code