From 33aecebd79a648c5b7408e43bf73128f6f85be80 Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Wed, 13 May 2026 19:00:19 +0200 Subject: [PATCH] feat(frontend): load URL-encoded scripts on /scripts/add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "Fork" action on run/[...run] and several workspace-settings helper-script templates base64-JSON-encode a NewScript into the URL hash on `/scripts/add#...`. Until now /scripts/add silently dropped that payload — both call sites landed on a blank editor. Decode `page.url.hash` at module top, and if it parses to an object, apply it as `scriptHandle.draft` and surface "Loaded from URL". The URL value wins over local autosave, ?template, ?hub, and YAML imports because the hash represents an explicit "open this script" intent. Parsing is inlined rather than reusing `decodeState` so an unrelated hash (e.g. a future route anchor) doesn't fire its default "Impossible to parse state" error toast. --- .../(root)/(logged)/scripts/add/+page.svelte | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/frontend/src/routes/(root)/(logged)/scripts/add/+page.svelte b/frontend/src/routes/(root)/(logged)/scripts/add/+page.svelte index a2d25c7e09..da01d90026 100644 --- a/frontend/src/routes/(root)/(logged)/scripts/add/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/scripts/add/+page.svelte @@ -34,6 +34,28 @@ const collabLang = page.url.searchParams.get('lang') as ScriptLang | null const wacParam = page.url.searchParams.get('wac') const importParam = page.url.searchParams.get('import') + + /** Some pages (run/[...run]'s "Fork" action, workspace_settings' + * error/success-handler template buttons) base64-JSON-encode a NewScript + * payload into the URL hash. That value is an explicit "open this script" + * intent and wins over local autosave, templates, hubs, and YAML imports. + * + * We can't use `decodeState` from utils.ts directly — it fires its own + * "Impossible to parse state" toast on failure, which would noise up the + * UI when the hash isn't a script payload at all (e.g. a route anchor). + */ + function decodeUrlScript(): Partial