Skip to content

Commit 5e96fcc

Browse files
Enable responsive width growing in basic-host
Change onsizechange handler to use min-width instead of width, treating the app's reported size as a floor rather than exact. Use min(Xpx, 100%) to allow shrinking with container. Also remove outmost max-width constraint and simplify iframe CSS to allow apps to demonstrate responsive growing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent d97ae07 commit 5e96fcc

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

examples/basic-host/src/implementation.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,13 @@ export function newAppBridge(serverInfo: ServerInfo, iframe: HTMLIFrameElement):
239239
if (isBorderBox) {
240240
width += parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth);
241241
}
242-
from.width = `${iframe.offsetWidth}px`;
243-
iframe.style.width = to.width = `${width}px`;
242+
// Use min-width instead of width to allow responsive growing.
243+
// With auto-resize (the default), the app reports its minimum content
244+
// width; we honor that as a floor but allow the iframe to expand when
245+
// the host layout allows. And we use `min(..., 100%)` so that the iframe
246+
// shrinks with its container.
247+
from.minWidth = `${iframe.offsetWidth}px`;
248+
iframe.style.minWidth = to.minWidth = `min(${width}px, 100%)`;
244249
}
245250
if (height !== undefined) {
246251
if (isBorderBox) {

examples/basic-host/src/index.module.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
.toolCallInfoPanel {
7070
display: flex;
7171
gap: 1rem;
72-
max-width: 1120px;
7372
animation: slideDown 0.3s ease-out;
7473
}
7574

@@ -107,13 +106,10 @@
107106
}
108107

109108
.appIframePanel {
110-
display: flex;
111-
justify-content: center;
112-
width: 100%;
113109
min-height: 200px;
114110

115111
iframe {
116-
flex: 1 0 auto;
112+
width: 100%;
117113
height: 600px;
118114
box-sizing: border-box;
119115
border: 3px dashed #888;

0 commit comments

Comments
 (0)