From c0e08efc4fe4cfb46a389f71de2305d172c94c30 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Mon, 3 Aug 2026 17:36:07 -0400 Subject: [PATCH] fix: adapt live-artifact tests and iframe guard to upstream drift - create_file tool arg is `path` upstream, not `file_path`; the outbound codeapi payload keeps `file_path`. - Capture `contentWindow` once in the handshake guard: the old check passed when both it and `event.source` were null. --- client/src/components/Artifacts/LiveArtifactPreview.tsx | 6 +++--- packages/api/src/agents/handlers.spec.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/src/components/Artifacts/LiveArtifactPreview.tsx b/client/src/components/Artifacts/LiveArtifactPreview.tsx index c1baec4c9a..e9cff64595 100644 --- a/client/src/components/Artifacts/LiveArtifactPreview.tsx +++ b/client/src/components/Artifacts/LiveArtifactPreview.tsx @@ -132,8 +132,8 @@ export default function LiveArtifactPreview({ // page can't produce the token, so it can never drive the bridge. useEffect(() => { const onMessage = (event: MessageEvent) => { - const frame = iframeRef.current; - if (!frame || event.source !== frame.contentWindow) { + const frameWindow = iframeRef.current?.contentWindow; + if (!frameWindow || event.source !== frameWindow) { return; } if (event.data?.type !== 'librechat:ready' || event.data.token !== token) { @@ -160,7 +160,7 @@ export default function LiveArtifactPreview({ requestTool({ id: data.id, name: data.name, args: data.args ?? {}, port: channel.port1 }); } }; - frame.contentWindow.postMessage({ type: 'librechat:init', token }, '*', [channel.port2]); + frameWindow.postMessage({ type: 'librechat:init', token }, '*', [channel.port2]); }; window.addEventListener('message', onMessage); return () => { diff --git a/packages/api/src/agents/handlers.spec.ts b/packages/api/src/agents/handlers.spec.ts index 12a8017427..ccdf5b32d5 100644 --- a/packages/api/src/agents/handlers.spec.ts +++ b/packages/api/src/agents/handlers.spec.ts @@ -2268,7 +2268,7 @@ describe('createToolExecuteHandler', () => { id: 'call_create_html', name: 'create_file', args: { - file_path: '/mnt/data/dash.html', + path: '/mnt/data/dash.html', content: '

hi

', mcp_tools: ['list_prs_mcp_github', 'not-an-mcp-tool', 'send_msg_mcp_slack'], }, @@ -2298,7 +2298,7 @@ describe('createToolExecuteHandler', () => { id: 'call_create_escalate', name: 'create_file', args: { - file_path: '/mnt/data/dash.html', + path: '/mnt/data/dash.html', content: '

hi

', // delete_repo_mcp_github is not in the agent's toolRegistry → dropped. mcp_tools: ['list_prs_mcp_github', 'delete_repo_mcp_github'], @@ -2326,7 +2326,7 @@ describe('createToolExecuteHandler', () => { id: 'call_create_txt', name: 'create_file', args: { - file_path: '/mnt/data/data.txt', + path: '/mnt/data/data.txt', content: 'plain', mcp_tools: ['list_prs_mcp_github'], },