diff --git a/apps/mobile/src/features/threads/McpAppWebView.tsx b/apps/mobile/src/features/threads/McpAppWebView.tsx index 203343eb5a680..642837f4fdffd 100644 --- a/apps/mobile/src/features/threads/McpAppWebView.tsx +++ b/apps/mobile/src/features/threads/McpAppWebView.tsx @@ -494,7 +494,7 @@ export function ThreadMcpApp(props: { if (presentedFullscreen) { return ( @@ -507,7 +507,7 @@ export function ThreadMcpApp(props: { if (closed) { return ( The {app.server} app was closed @@ -526,7 +526,11 @@ export function ThreadMcpApp(props: { } return ( - + 0 ? ROW_BOTTOM_MARGIN : 0 } + } + > {navigatedAway ? ( diff --git a/apps/web/src/components/chat/McpAppFrame.tsx b/apps/web/src/components/chat/McpAppFrame.tsx index fc20323c1c449..cd15caa830566 100644 --- a/apps/web/src/components/chat/McpAppFrame.tsx +++ b/apps/web/src/components/chat/McpAppFrame.tsx @@ -448,7 +448,10 @@ export function McpAppFrame(props: { data-mcp-app-fullscreen={fullscreen ? "" : undefined} className={cn( "relative size-full overflow-hidden", - app.prefersBorder === true && !fullscreen && "rounded-lg border border-border", + app.prefersBorder === true && + !fullscreen && + height > 0 && + "rounded-lg border border-border", fullscreen ? "fixed inset-0 m-0 flex h-dvh max-h-none w-dvw max-w-none flex-col border-0 bg-background p-0" : "block! static! m-0 border-0 bg-transparent p-0 text-inherit", diff --git a/packages/shared/src/mcpApp.test.ts b/packages/shared/src/mcpApp.test.ts index 9f4fb151398d7..1a7b1cb4c83d2 100644 --- a/packages/shared/src/mcpApp.test.ts +++ b/packages/shared/src/mcpApp.test.ts @@ -5,6 +5,7 @@ import { injectMcpAppCsp, injectMcpAppThemeBootstrap, injectMcpAppCookieBootstrap, + clampMcpAppHeight, MCP_APP_COLOR_SCHEME_PARAM, mcpAppContentSecurityPolicy, mcpAppToolCallableByApp, @@ -252,11 +253,15 @@ describe("mcpAppFromToolItem", () => { describe("MCP App cookie bootstrap", () => { const vendor = ``; - const execute = (html: string, document: object) => { + const execute = (html: string, document: object, self: object = {}) => { for (const script of html.matchAll(/`; + const bootstrap = ``; // Preserve captured CSP ahead of executable code, including this bootstrap. const prefix = /^(?:\uFEFF?\s*]*>\s*)?(?:)?/i.exec( @@ -262,6 +262,8 @@ export function mcpAppAllowAttribute(permissions: McpAppPermissions | undefined) export function clampMcpAppHeight(height: number): number { if (!Number.isFinite(height)) return MCP_APP_DEFAULT_HEIGHT; + // Apps report 0 when a result has nothing to render; keep them mounted but invisible. + if (height <= 0) return 0; return Math.round(Math.min(MCP_APP_MAX_HEIGHT, Math.max(MCP_APP_MIN_HEIGHT, height))); }