fix(ui): respect width parameter in MCP app size-changed notifications (#6376)
Signed-off-by: Abhijay007 <Abhijay007j@gmail.com>
This commit is contained in:
@@ -61,6 +61,7 @@ export default function McpAppRenderer({
|
|||||||
});
|
});
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [iframeHeight, setIframeHeight] = useState(DEFAULT_IFRAME_HEIGHT);
|
const [iframeHeight, setIframeHeight] = useState(DEFAULT_IFRAME_HEIGHT);
|
||||||
|
const [iframeWidth, setIframeWidth] = useState<number | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!sessionId) {
|
if (!sessionId) {
|
||||||
@@ -200,9 +201,10 @@ export default function McpAppRenderer({
|
|||||||
[append, sessionId, extensionName]
|
[append, sessionId, extensionName]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleSizeChanged = useCallback((height: number, _width?: number) => {
|
const handleSizeChanged = useCallback((height: number, width?: number) => {
|
||||||
const newHeight = Math.max(DEFAULT_IFRAME_HEIGHT, height);
|
const newHeight = Math.max(DEFAULT_IFRAME_HEIGHT, height);
|
||||||
setIframeHeight(newHeight);
|
setIframeHeight(newHeight);
|
||||||
|
setIframeWidth(width ?? null);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const { iframeRef, proxyUrl } = useSandboxBridge({
|
const { iframeRef, proxyUrl } = useSandboxBridge({
|
||||||
@@ -264,7 +266,8 @@ export default function McpAppRenderer({
|
|||||||
ref={iframeRef}
|
ref={iframeRef}
|
||||||
src={proxyUrl}
|
src={proxyUrl}
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: iframeWidth ? `${iframeWidth}px` : '100%',
|
||||||
|
maxWidth: '100%',
|
||||||
height: `${iframeHeight}px`,
|
height: `${iframeHeight}px`,
|
||||||
border: 'none',
|
border: 'none',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
|
|||||||
Reference in New Issue
Block a user