From 8b963f833a8a35b67c157fa2c938197ed44750c1 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 6 Jan 2026 00:22:32 +0100 Subject: [PATCH] fix: copy link in shared sessions uses correct URL instead of about:srcdoc --- .../coding-agent/src/core/export-html/template.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/src/core/export-html/template.js b/packages/coding-agent/src/core/export-html/template.js index b910bb1e..b73c9847 100644 --- a/packages/coding-agent/src/core/export-html/template.js +++ b/packages/coding-agent/src/core/export-html/template.js @@ -793,13 +793,25 @@ * URL format: base?gistId&leafId=&targetId= */ function buildShareUrl(entryId) { + // Check for injected base URL (used when loaded in iframe via srcdoc) + const baseUrlMeta = document.querySelector('meta[name="pi-share-base-url"]'); + const baseUrl = baseUrlMeta ? baseUrlMeta.content : window.location.href.split('?')[0]; + const url = new URL(window.location.href); // Find the gist ID (first query param without value, e.g., ?abc123) const gistId = Array.from(url.searchParams.keys()).find(k => !url.searchParams.get(k)); - // Build search string manually to preserve ?gistId format (not ?gistId=) + + // Build the share URL const params = new URLSearchParams(); params.set('leafId', currentLeafId); params.set('targetId', entryId); + + // If we have an injected base URL (iframe context), use it directly + if (baseUrlMeta) { + return `${baseUrl}&${params.toString()}`; + } + + // Otherwise build from current location (direct file access) url.search = gistId ? `?${gistId}&${params.toString()}` : `?${params.toString()}`; return url.toString(); }