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.
This commit is contained in:
Danny Avila 2026-08-03 17:36:07 -04:00
parent 9bcc2572d6
commit c0e08efc4f
2 changed files with 6 additions and 6 deletions

View file

@ -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 () => {

View file

@ -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: '<h1>hi</h1>',
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: '<h1>hi</h1>',
// 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'],
},