The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(conversations): transparent widget frames sized to their content width
oxoxDev29bb9ef9c746
diff --git a/app/src/features/conversations/tools/mcpUi/McpAppFrame.test.tsx b/app/src/features/conversations/tools/mcpUi/McpAppFrame.test.tsxindex e954afa082..2edcdae665 100644--- a/app/src/features/conversations/tools/mcpUi/McpAppFrame.test.tsx+++ b/app/src/features/conversations/tools/mcpUi/McpAppFrame.test.tsx@@ -114,3 +114,17 @@ describe('McpAppFrame tool decisions', () => {expect(bridges.updates.at(-1)).toEqual({ q: 2 });});});++describe('McpAppFrame sizing', () => {+ it('fills the column, then fits the reported content width, left-aligned', async () => {+ const { handlers } = await mountFrame();+ const frame = screen.getByTestId('mcp-ui-iframe');+ expect(frame.style.width).toBe('100%');+ expect(frame.getAttribute('allowtransparency')).toBe('true');+ expect(frame.getAttribute('src')).toContain('theme=light');+ expect(frame.className).toContain('self-start');++ act(() => handlers.fitWidth(480));+ expect(frame.style.width).toBe('488px');+ });+});diff --git a/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsx b/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsxindex f10ef9b200..2ab7b7d25e 100644--- a/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsx+++ b/app/src/features/conversations/tools/mcpUi/McpAppFrame.tsx@@ -10,7 +10,7 @@ import { requestComposerPrefill } from './composerPrefill';import { QrHandoff } from './LinkActions';import { McpAppBridge } from './mcpAppBridge';import type { McpUiPresentation, McpUiResource } from './types';-import { isWindowsHost, PROXY_FRAME_SANDBOX, widgetProxyUrl } from './widgetUrl';+import { frameWidth, isWindowsHost, PROXY_FRAME_SANDBOX, widgetProxyUrl } from './widgetUrl';const log = debug('mcp-ui:frame');@@ -37,6 +37,7 @@ export function McpAppFrame({ presentation }: { presentation: McpUiPresentationconst frameRef = useRef<HTMLIFrameElement>(null);const [state, setState] = useState<LoadState>({ status: 'loading' });const [height, setHeight] = useState(DEFAULT_HEIGHT);+ const [contentWidth, setContentWidth] = useState<number | null>(null);const [pending, setPending] = useState<PendingCall | null>(null);const [handoffUrl, setHandoffUrl] = useState<string | null>(null);const decisionsRef = useRef(new Map<string, Promise<void>>());@@ -70,9 +71,10 @@ export function McpAppFrame({ presentation }: { presentation: McpUiPresentation}, [serverId, presentation.resource_uri, presentation.inline_id]);const resource = state.status === 'ready' ? state.resource : null;+ const theme = useMemo(() => (resource ? currentTheme() : null), [resource]);const src = useMemo(- () => (resource ? widgetProxyUrl(resource.csp, isWindowsHost()) : null),- [resource]+ () => (resource && theme ? widgetProxyUrl(resource.csp, isWindowsHost(), theme) : null),+ [resource, theme]);useEffect(() => {@@ -80,7 +82,7 @@ export function McpAppFrame({ presentation }: { presentation: McpUiPresentationconst bridge = new McpAppBridge({presentation: presentationRef.current,html: resource.html,- theme: currentTheme(),+ theme: theme ?? currentTheme(),locale,source: () => frameRef.current?.contentWindow,handlers: {@@ -109,6 +111,10 @@ export function McpAppFrame({ presentation }: { presentation: McpUiPresentationreturn { contents: [{ uri, mimeType: read.mime_type, text: read.html }] };},resize: next => setHeight(next),+ fitWidth: next => {+ log('content width %d', next);+ setContentWidth(next);+ },},});bridgeRef.current = bridge;@@ -120,7 +126,7 @@ export function McpAppFrame({ presentation }: { presentation: McpUiPresentationwindow.removeEventListener('message', onMessage);if (bridgeRef.current === bridge) bridgeRef.current = null;};- }, [resource, serverId, locale]);+ }, [resource, theme, serverId, locale]);if (state.status === 'unavailable') {return (@@ -144,10 +150,11 @@ export function McpAppFrame({ presentation }: { presentation: McpUiPresentationallow=""className={resource?.prefers_border- ? 'w-full rounded-lg border border-line bg-transparent'- : 'w-full bg-transparent'+ ? 'max-w-full self-start rounded-lg border border-line bg-transparent'+ : 'max-w-full self-start bg-transparent'}- style={{ height }}+ style={{ height, width: frameWidth(contentWidth), colorScheme: theme ?? undefined }}+ {...{ allowtransparency: 'true' }}data-testid="mcp-ui-iframe"/>)}diff --git a/app/src/features/conversations/tools/mcpUi/frameFit.test.ts b/app/src/features/conversations/tools/mcpUi/frameFit.test.tsnew file mode 100644index 0000000000..6277da26b9--- /dev/null+++ b/app/src/features/conversations/tools/mcpUi/frameFit.test.ts@@ -0,0 +1,157 @@+import { afterEach, describe, expect, it, vi } from 'vitest';++import { FILL_WIDTH, frameFitSource } from './frameFit';++interface Rect {+ left: number;+ width: number;+}++function setRect(el: Element, rect: () => Rect) {+ Object.defineProperty(el, 'getBoundingClientRect', {+ configurable: true,+ value: () => {+ const { left, width } = rect();+ return { left, top: 0, width, height: 100, right: left + width, bottom: 100 };+ },+ });+}++const settle = () => new Promise(resolve => setTimeout(resolve, 200));++let posted: Array<Record<string, unknown>> = [];++afterEach(() => {+ vi.restoreAllMocks();+ posted = [];+ for (const frame of Array.from(window.document.querySelectorAll('iframe'))) frame.remove();+});++async function mount(+ html: string,+ layout: (document: Document) => void,+ theme: 'light' | 'dark' = 'dark'+) {+ const frame = window.document.createElement('iframe');+ window.document.body.appendChild(frame);+ const win = frame.contentWindow as Window & typeof globalThis;+ const document = win.document;+ document.body.innerHTML = html;+ setRect(document.body, () => ({ left: 0, width: 800 }));+ Object.defineProperty(document.documentElement, 'clientWidth', {+ configurable: true,+ value: 800,+ });+ layout(document);+ vi.spyOn(win.parent, 'postMessage').mockImplementation((message: unknown) => {+ posted.push(message as Record<string, unknown>);+ });+ new Function('window', 'document', frameFitSource(theme))(win, document);+ await settle();+ return document;+}++const widths = () =>+ posted+ .filter(message => message.method === 'ui/notifications/size-changed')+ .map(message => (message.params as { width: number; fit: boolean }).width);++describe('frameFitSource', () => {+ it('makes the page canvas transparent in the host scheme, last in head', async () => {+ const document = await mount('<div>x</div>', () => undefined, 'light');+ const head = document.head;+ const extra = document.createElement('style');+ head.appendChild(extra);+ await settle();+ const style = head.lastElementChild as HTMLStyleElement;+ expect(style.hasAttribute('data-oh-host')).toBe(true);+ expect(style.textContent).toContain('html,body{background:transparent!important;}');+ expect(style.textContent).toContain(':root{color-scheme:light!important;}');+ });++ it('reports a card narrower than the page at its own width', async () => {+ await mount('<div id="card"></div>', document => {+ setRect(document.getElementById('card')!, () => ({ left: 0, width: 480 }));+ });+ expect(widths()).toEqual([480]);+ expect(posted[0]).toMatchObject({+ jsonrpc: '2.0',+ params: { fit: true, height: expect.any(Number) },+ });+ });++ it('reports a centred card symmetrically', async () => {+ await mount('<div id="card" style="margin-left:160px;margin-right:160px"></div>', document => {+ setRect(document.body, () => ({ left: 8, width: 784 }));+ setRect(document.getElementById('card')!, () => ({ left: 160, width: 480 }));+ });+ expect(widths()).toEqual([496]);+ });++ it('reports a full-width box at its max-width', async () => {+ await mount('<div id="card" style="max-width:480px"></div>', document => {+ setRect(document.getElementById('card')!, () => ({ left: 0, width: 800 }));+ });+ expect(widths()).toEqual([480]);+ });++ it('counts the padding of a content-box max-width box, the same at any frame width', async () => {+ let bodyWidth = 784;+ const style = 'max-width:480px;padding:0 16px';+ const document = await mount(`<div id="card" style="${style}"></div>`, document => {+ setRect(document.body, () => ({ left: 8, width: bodyWidth }));+ setRect(document.getElementById('card')!, () => ({+ left: 8,+ width: Math.min(bodyWidth, 512),+ }));+ });+ expect(widths()).toEqual([528]);++ bodyWidth = 512;+ Object.defineProperty(document.documentElement, 'clientWidth', { value: 528 });+ document.body.appendChild(document.createElement('span'));+ await settle();+ expect(widths()).toEqual([528]);+ });++ it('descends full-width wrappers to the content', async () => {+ await mount('<div id="wrap"><div id="card"></div></div>', document => {+ setRect(document.getElementById('wrap')!, () => ({ left: 0, width: 800 }));+ setRect(document.getElementById('card')!, () => ({ left: 0, width: 400 }));+ });+ expect(widths()).toEqual([400]);+ });++ it('asks for the whole column for running text or a scrolling row', async () => {+ await mount('<p id="text">hello</p>', document => {+ setRect(document.getElementById('text')!, () => ({ left: 0, width: 800 }));+ });+ expect(widths()).toEqual([FILL_WIDTH]);++ posted = [];+ await mount('<div id="card"><div id="row" style="overflow-x:auto"></div></div>', document => {+ setRect(document.getElementById('card')!, () => ({ left: 0, width: 480 }));+ const row = document.getElementById('row')!;+ setRect(row, () => ({ left: 0, width: 300 }));+ Object.defineProperty(row, 'scrollWidth', { configurable: true, value: 1000 });+ Object.defineProperty(row, 'clientWidth', { configurable: true, value: 300 });+ });+ expect(widths()).toEqual([FILL_WIDTH]);+ });++ it('ignores changes smaller than its hysteresis step', async () => {+ let width = 480;+ const document = await mount('<div id="card"></div>', document => {+ setRect(document.getElementById('card')!, () => ({ left: 0, width }));+ });+ width = 484;+ document.body.appendChild(document.createElement('span'));+ await settle();+ expect(widths()).toEqual([480]);++ width = 600;+ document.body.appendChild(document.createElement('span'));+ await settle();+ expect(widths()).toEqual([480, 600]);+ });+});diff --git a/app/src/features/conversations/tools/mcpUi/frameFit.ts b/app/src/features/conversations/tools/mcpUi/frameFit.tsnew file mode 100644index 0000000000..a96b580dd5--- /dev/null+++ b/app/src/features/conversations/tools/mcpUi/frameFit.ts@@ -0,0 +1,151 @@+/** A reported width at or above this asks for the whole column. */+export const FILL_WIDTH = 100000;++/**+ * The host script that makes a widget sit in the chat like native content: a+ * transparent page canvas in the host's color scheme, and the width its+ * content actually uses, reported as `ui/notifications/size-changed` with+ * `fit: true`.+ *+ * The width is measured from the content, not the viewport: a box narrower+ * than its container counts at its own width (a centred box symmetrically), a+ * full-width box with a `max-width` counts at that, and a full-width wrapper+ * is descended into. Running text, media, or a horizontally scrolling row+ * asks for the whole column, so narrowing the frame cannot narrow what is+ * measured.+ */+export function frameFitSource(theme: 'light' | 'dark'): string {+ return FRAME_FIT_TEMPLATE.replace('__THEME__', theme).replace('__FILL__', String(FILL_WIDTH));+}++const FRAME_FIT_TEMPLATE = `(function () {+ 'use strict';+ if (window.__ohFrameFit) return;+ window.__ohFrameFit = true;+ var THEME = '__THEME__';+ var FILL = __FILL__;+ var MIN_ROW = 240;+ var STEP = 8;+ var MAX_DEPTH = 8;+ var LEAVES = ['IMG', 'VIDEO', 'CANVAS', 'SVG', 'svg', 'TABLE', 'IFRAME', 'PRE', 'TEXTAREA'];+ var host = window.parent;+ var style = null;+ var last = 0;+ var timer = null;++ function applyStyle() {+ var parent = document.head || document.documentElement;+ if (!parent) return;+ if (!style) {+ style = document.createElement('style');+ style.setAttribute('data-oh-host', '');+ style.textContent = 'html,body{background:transparent!important;}' ++ ':root{color-scheme:' + THEME + '!important;}';+ }+ if (style.parentNode !== parent || parent.lastChild !== style) parent.appendChild(style);+ }+ function px(value) {+ var n = parseFloat(value);+ return isFinite(n) ? n : 0;+ }+ function hasScrollRow() {+ if (!document.body) return false;+ var all = document.body.getElementsByTagName('*');+ for (var i = 0; i < all.length; i++) {+ var el = all[i];+ var x = window.getComputedStyle(el).overflowX;+ if ((x === 'auto' || x === 'scroll') && el.scrollWidth > el.clientWidth + 4 &&+ el.getBoundingClientRect().width >= MIN_ROW) {+ return true;+ }+ }+ return false;+ }+ function hasText(el) {+ for (var node = el.firstChild; node; node = node.nextSibling) {+ if (node.nodeType === 3 && node.nodeValue.trim()) return true;+ }+ return false;+ }+ function contentBox(el) {+ var rect = el.getBoundingClientRect();+ var cs = window.getComputedStyle(el);+ var left = rect.left + px(cs.paddingLeft) + px(cs.borderLeftWidth);+ var right = rect.right - px(cs.paddingRight) - px(cs.borderRightWidth);+ return { left: left, width: Math.max(0, right - left) };+ }+ function extent(el, container, depth) {+ var rect = el.getBoundingClientRect();+ if (rect.width <= 0 || rect.height <= 0) return 0;+ var cs = window.getComputedStyle(el);+ if (cs.position === 'fixed' || cs.position === 'absolute') return 0;+ var lead = container.left;+ var trail = Math.max(0, document.documentElement.clientWidth - container.left - container.width);+ if (rect.width < container.width - 1) {+ var ml = px(cs.marginLeft);+ var centred = ml > 0 && Math.abs(ml - px(cs.marginRight)) < 1;+ return (centred ? lead + rect.width : rect.right) + trail;+ }+ var maxWidth = cs.maxWidth === 'none' ? 0 : px(cs.maxWidth);+ if (maxWidth > 0) {+ if (cs.boxSizing !== 'border-box') {+ maxWidth += px(cs.paddingLeft) + px(cs.paddingRight) ++ px(cs.borderLeftWidth) + px(cs.borderRightWidth);+ }+ return lead + maxWidth + trail;+ }+ if (hasText(el) || LEAVES.indexOf(el.tagName) !== -1 || depth >= MAX_DEPTH) return FILL;+ var inner = contentBox(el);+ var widest = 0;+ for (var child = el.firstElementChild; child; child = child.nextElementSibling) {+ widest = Math.max(widest, extent(child, inner, depth + 1));+ }+ return widest > 0 ? widest : FILL;+ }+ function measure() {+ if (!document.body) return 0;+ if (hasScrollRow()) return FILL;+ var root = document.documentElement;+ if (root.scrollWidth > root.clientWidth + 1) return FILL;+ var body = contentBox(document.body);+ var widest = 0;+ for (var child = document.body.firstElementChild; child; child = child.nextElementSibling) {+ widest = Math.max(widest, extent(child, body, 0));+ }+ if (widest === 0 && hasText(document.body)) return FILL;+ return widest;+ }+ function report() {+ timer = null;+ applyStyle();+ var width = Math.ceil(measure());+ if (!width || (last && Math.abs(width - last) < STEP)) return;+ last = width;+ if (!host || host === window) return;+ host.postMessage({+ jsonrpc: '2.0',+ method: 'ui/notifications/size-changed',+ params: { width: width, height: Math.ceil(document.documentElement.scrollHeight), fit: true }+ }, '*');+ }+ function schedule() {+ if (timer !== null) return;+ timer = setTimeout(report, 150);+ }+ applyStyle();+ document.addEventListener('DOMContentLoaded', schedule);+ window.addEventListener('load', schedule);+ window.addEventListener('resize', schedule);+ if (typeof MutationObserver === 'function') {+ new MutationObserver(schedule).observe(document.documentElement, {+ childList: true,+ subtree: true,+ attributes: true,+ attributeFilter: ['class', 'hidden']+ });+ }+ if (typeof ResizeObserver === 'function') {+ new ResizeObserver(schedule).observe(document.documentElement);+ }+ schedule();+})();`;diff --git a/app/src/features/conversations/tools/mcpUi/mcpAppBridge.test.ts b/app/src/features/conversations/tools/mcpUi/mcpAppBridge.test.tsindex 893fc41917..c6ecb7ba70 100644--- a/app/src/features/conversations/tools/mcpUi/mcpAppBridge.test.ts+++ b/app/src/features/conversations/tools/mcpUi/mcpAppBridge.test.ts@@ -26,6 +26,7 @@ function setup(prefillMessage: vi.fn(),readResource: vi.fn(async () => ({ contents: [] })),resize: vi.fn(),+ fitWidth: vi.fn(),...handlerOverrides,};let clock = 0;@@ -83,12 +84,14 @@ describe('McpAppBridge', () => {expect(html.endsWith('</head><body>cart</body></html>')).toBe(true);});- it('injects the scroll affordance for both flavors, the shim only for Apps SDK', () => {+ it('injects the host scripts for both flavors, the shim only for Apps SDK', () => {for (const flavor of ['mcp_apps', 'apps_sdk'] as const) {const { send, posted } = setup({ flavor });send({ jsonrpc: '2.0', method: 'ui/notifications/sandbox-proxy-ready' });const html = (posted[0].params as { html: string }).html;expect(html).toContain(SCROLL_AFFORDANCE_SOURCE.slice(0, 40));+ expect(html).toContain('html,body{background:transparent!important;}');+ expect(html).toContain("var THEME = 'dark';");expect(html.includes('window.openai')).toBe(flavor === 'apps_sdk');expect(html.lastIndexOf('</script>')).toBeLessThan(html.indexOf('cart'));}@@ -252,6 +255,32 @@ describe('McpAppBridge', () => {expect(handlers.resize).toHaveBeenCalledWith(MAX_FRAME_HEIGHT);});+ it('takes width only from the host fit report, height only from the widget', () => {+ const { send, handlers } = setup();+ send({+ jsonrpc: '2.0',+ method: 'ui/notifications/size-changed',+ params: { width: 480.4, height: 900, fit: true },+ });+ expect(handlers.fitWidth).toHaveBeenCalledWith(481);+ expect(handlers.resize).not.toHaveBeenCalled();++ send({+ jsonrpc: '2.0',+ method: 'ui/notifications/size-changed',+ params: { width: 300, height: 200 },+ });+ expect(handlers.fitWidth).toHaveBeenCalledTimes(1);+ expect(handlers.resize).toHaveBeenCalledWith(200);++ send({+ jsonrpc: '2.0',+ method: 'ui/notifications/size-changed',+ params: { width: 'x', fit: true },+ });+ expect(handlers.fitWidth).toHaveBeenCalledTimes(1);+ });+it('rejects unknown requests', async () => {const { send, posted } = setup();send({ jsonrpc: '2.0', id: 9, method: 'ui/eval', params: {} });diff --git a/app/src/features/conversations/tools/mcpUi/mcpAppBridge.ts b/app/src/features/conversations/tools/mcpUi/mcpAppBridge.tsindex c2735980d4..51f278cc23 100644--- a/app/src/features/conversations/tools/mcpUi/mcpAppBridge.ts+++ b/app/src/features/conversations/tools/mcpUi/mcpAppBridge.ts@@ -11,6 +11,7 @@ import debug from 'debug';import { classifyHref } from '../../utils/format';import { APPS_SDK_SHIM_SOURCE, injectScript } from './appsSdkShim';+import { frameFitSource } from './frameFit';import { SCROLL_AFFORDANCE_SOURCE } from './scrollAffordance';import type { McpUiPresentation } from './types';@@ -40,6 +41,8 @@ export interface BridgeHandlers {readResource(uri: string): Promise<unknown>;/** The widget asked for this content height. */resize(height: number): void;+ /** The widget's content uses this width. */+ fitWidth(width: number): void;}export interface BridgeOptions {@@ -185,6 +188,11 @@ export class McpAppBridge {this.sendToolData();return;case 'ui/notifications/size-changed': {+ if (params.fit === true) {+ const width = Number(params.width);+ if (Number.isFinite(width) && width > 0) this.options.handlers.fitWidth(Math.ceil(width));+ return;+ }const height = Number(params.height);if (Number.isFinite(height) && height > 0) {this.options.handlers.resize(@@ -201,7 +209,10 @@ export class McpAppBridge {private deliverDocument(): void {if (this.delivered) return;this.delivered = true;- const withAffordance = injectScript(this.options.html, SCROLL_AFFORDANCE_SOURCE);+ const withAffordance = injectScript(+ injectScript(this.options.html, SCROLL_AFFORDANCE_SOURCE),+ frameFitSource(this.options.theme)+ );const html =this.flavor === 'apps_sdk'? injectScript(withAffordance, APPS_SDK_SHIM_SOURCE)diff --git a/app/src/features/conversations/tools/mcpUi/widgetUrl.test.ts b/app/src/features/conversations/tools/mcpUi/widgetUrl.test.tsindex 6f63c862d6..e90d81e21a 100644--- a/app/src/features/conversations/tools/mcpUi/widgetUrl.test.ts+++ b/app/src/features/conversations/tools/mcpUi/widgetUrl.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from 'vitest';-import { PROXY_FRAME_SANDBOX, widgetProxyUrl } from './widgetUrl';+import { FILL_WIDTH } from './frameFit';+import { frameWidth, PROXY_FRAME_SANDBOX, widgetProxyUrl } from './widgetUrl';describe('widgetProxyUrl', () => {it('uses the platform origin and carries the declared origins', () => {@@ -17,6 +18,24 @@ describe('widgetProxyUrl', () => {'http://ohwidget.localhost/proxy?connect=https%3A%2F%2Fapi.example.com&resource=https%3A%2F%2Fcdn.example.com');});++ it('carries the host theme', () => {+ expect(widgetProxyUrl(undefined, false, 'dark')).toBe('ohwidget://localhost/proxy?theme=dark');+ });+});++describe('frameWidth', () => {+ it('fills the column until a content width is known, or when content fills', () => {+ expect(frameWidth(null)).toBe('100%');+ expect(frameWidth(Number.NaN)).toBe('100%');+ expect(frameWidth(FILL_WIDTH)).toBe('100%');+ });++ it('fits the content with a margin, never below the minimum', () => {+ expect(frameWidth(480)).toBe('488px');+ expect(frameWidth(479.2)).toBe('488px');+ expect(frameWidth(100)).toBe('320px');+ });});describe('PROXY_FRAME_SANDBOX', () => {diff --git a/app/src/features/conversations/tools/mcpUi/widgetUrl.ts b/app/src/features/conversations/tools/mcpUi/widgetUrl.tsindex 5b957b43ee..bb9e51bbef 100644--- a/app/src/features/conversations/tools/mcpUi/widgetUrl.ts+++ b/app/src/features/conversations/tools/mcpUi/widgetUrl.ts@@ -1,3 +1,4 @@+import { FILL_WIDTH } from './frameFit';import type { McpUiResource } from './types';/**@@ -7,10 +8,18 @@ import type { McpUiResource } from './types';*/export const PROXY_FRAME_SANDBOX = 'allow-scripts allow-same-origin allow-forms';-/** The sandbox proxy URL on the widget origin, carrying the declared CSP. */-export function widgetProxyUrl(csp: McpUiResource['csp'] | undefined, windows: boolean): string {+export const MIN_FRAME_WIDTH = 320;+export const FRAME_WIDTH_MARGIN = 8;++/** The sandbox proxy URL on the widget origin, carrying the declared CSP and theme. */+export function widgetProxyUrl(+ csp: McpUiResource['csp'] | undefined,+ windows: boolean,+ theme?: 'light' | 'dark'+): string {const base = windows ? 'http://ohwidget.localhost/proxy' : 'ohwidget://localhost/proxy';const query = new URLSearchParams();+ if (theme) query.set('theme', theme);for (const origin of csp?.connect_domains ?? []) query.append('connect', origin);for (const origin of csp?.resource_domains ?? []) query.append('resource', origin);const encoded = query.toString();@@ -20,3 +29,10 @@ export function widgetProxyUrl(csp: McpUiResource['csp'] | undefined, windows: bexport function isWindowsHost(): boolean {return typeof navigator !== 'undefined' && /Windows/i.test(navigator.userAgent);}++/** The frame's CSS width for a reported content width; the frame's max-width keeps it in the column. */+export function frameWidth(reported: number | null): string {+ if (reported === null || !Number.isFinite(reported) || reported >= FILL_WIDTH) return '100%';+ const width = Math.max(MIN_FRAME_WIDTH, Math.ceil(reported) + FRAME_WIDTH_MARGIN);+ return `${width}px`;+}