diff --git a/packages/coding-agent/src/core/export-html/template.js b/packages/coding-agent/src/core/export-html/template.js index b73c9847..6d3e5929 100644 --- a/packages/coding-agent/src/core/export-html/template.js +++ b/packages/coding-agent/src/core/export-html/template.js @@ -19,7 +19,10 @@ // ============================================================ // Parse URL parameters for deep linking: leafId and targetId - const urlParams = new URLSearchParams(window.location.search); + // Check for injected params (when loaded in iframe via srcdoc) or use window.location + const injectedParams = document.querySelector('meta[name="pi-url-params"]'); + const searchString = injectedParams ? injectedParams.content : window.location.search.substring(1); + const urlParams = new URLSearchParams(searchString); const urlLeafId = urlParams.get('leafId'); const urlTargetId = urlParams.get('targetId'); // Use URL leafId if provided, otherwise fall back to session default