diff --git a/frontend/src/lib/components/RunForm.svelte b/frontend/src/lib/components/RunForm.svelte
index 2ae75f3c47..7be09785b1 100644
--- a/frontend/src/lib/components/RunForm.svelte
+++ b/frontend/src/lib/components/RunForm.svelte
@@ -152,8 +152,8 @@
* form is embedded in a page that is not the runnable's own — an AI session preview
* tab — since there the fragment would land on an unrelated URL. */
syncArgsToUrl?: boolean
- /** Controls beside the Run button of a form that cannot schedule, in the row a
- * schedulable one gives its Advanced options. */
+ /** Controls beside the Run button: left of Advanced on a schedulable form, in
+ * Advanced's place on one that cannot schedule. */
actions?: import('svelte').Snippet
}
@@ -405,6 +405,7 @@
{/snippet}
+ {@render actions?.()}
{@render unparseableError()}
{#if overrideTag}
diff --git a/frontend/src/lib/components/copilot/AIFormAssistant.svelte b/frontend/src/lib/components/copilot/AIFormAssistant.svelte
index 72ab57cab6..b4526f1153 100644
--- a/frontend/src/lib/components/copilot/AIFormAssistant.svelte
+++ b/frontend/src/lib/components/copilot/AIFormAssistant.svelte
@@ -8,10 +8,13 @@
import { useOperatingWorkspace } from '$lib/components/operatingWorkspace.svelte'
import { copilotInfo } from '$lib/aiStore'
import { logFeatureUsage } from '$lib/utils/featureUsage'
+ import { pageHref } from '$lib/components/sessions/previewPaths'
interface Props {
/** Unset for a viewer who cannot edit the item: the card then offers no way to the editor. */
onEditInstructions: (() => void) | undefined
+ /** Empty renders the AI button alone, sized for the run form's action row, which
+ * is where the host places it; a prompt makes this a card of its own. */
instructions: string
runnableType: 'script' | 'flow'
path: string | undefined
@@ -37,72 +40,52 @@
aiChatManager.askAi(`Analyze the ${runnableType} form on this page and fill the inputs for me`)
}
- // A session cannot reach this page's form (the preview is a separate editor,
- // and form filling drives the DOM through NAVIGATOR mode), so the hand-off
- // asks it to run the item instead. Naming the DEPLOYED version matters: the
- // test_run_* tools prefer drafts, which is not what this page runs.
+ // The session's preview opens on this same deployed page (`/get/`), not the item's
+ // editor: someone on a run page came to run the item, not to change it.
const sessionSource = $derived(
path
? {
- target: { kind: runnableType, path } as const,
+ page: () => pageHref(`/${runnableType}s/get/${path}`),
workspaceId: $operatingWorkspace ?? undefined,
- beforeOpen: logAsked,
- seedPrompt:
- `Run the deployed ${runnableType} \`${path}\` for me. Pick sensible inputs, ` +
- `tell me what you chose, then run it.` +
- (instructions ? `\n\nHow to choose the inputs:\n${instructions}` : '')
+ beforeOpen: logAsked
}
: undefined
)
-{#if !$copilotInfo.workspaceDisabled}
+{#snippet aiButton(unifiedSize: 'sm' | 'md')}
+
+