diff --git a/frontend/src/lib/components/FlowPreviewContent.svelte b/frontend/src/lib/components/FlowPreviewContent.svelte index c46f34b92d..ff7bc3591d 100644 --- a/frontend/src/lib/components/FlowPreviewContent.svelte +++ b/frontend/src/lib/components/FlowPreviewContent.svelte @@ -69,6 +69,22 @@ } = getContext('FlowEditorContext') const dispatch = createEventDispatcher() + // Set all modules as initial when flow-level initial becomes true + function setAllModulesInitial(isInitial: boolean) { + if (isInitial) { + // Set all existing modules in flowStateStore to initial: true + for (const moduleId in $flowStateStore) { + if ($flowStateStore[moduleId] && $flowStateStore[moduleId].initial === undefined) { + $flowStateStore[moduleId] = { + ...$flowStateStore[moduleId], + initial: true + } + } + } + $flowStateStore = $flowStateStore + } + } + let renderCount: number = 0 let schemaFormWithArgPicker: SchemaFormWithArgPicker | undefined = undefined let currentJobId: string | undefined = undefined @@ -183,6 +199,9 @@ $: selectedJobStep !== undefined && onSelectedJobStepChange() + // When initial becomes true, mark all modules as initial + $: setAllModulesInitial(initial) + async function loadIndividualStepsStates() { // console.log('loadIndividualStepsStates') dfs(flowStore.val.value.modules, async (module) => { @@ -214,7 +233,8 @@ previewResult: getJobResult.result, previewJobId: previousJobId[0].id, previewWorkspaceId: previousJobId[0].workspace_id, - previewSuccess: getJobResult.success + previewSuccess: getJobResult.success, + initial: true } } } @@ -531,7 +551,6 @@ }} on:jobsLoaded={() => { if (initial) { - console.log('loading initial steps after initial job loaded') loadIndividualStepsStates() } }} diff --git a/frontend/src/lib/components/FlowStatusViewerInner.svelte b/frontend/src/lib/components/FlowStatusViewerInner.svelte index a4a6d9edcd..b50d302f6a 100644 --- a/frontend/src/lib/components/FlowStatusViewerInner.svelte +++ b/frontend/src/lib/components/FlowStatusViewerInner.svelte @@ -583,7 +583,8 @@ previewArgs: job.args, previewJobId: job.id, previewWorkspaceId: job.workspace_id, - previewSuccess: job['success'] + previewSuccess: job['success'], + initial: false } } } diff --git a/frontend/src/lib/components/ModuleTest.svelte b/frontend/src/lib/components/ModuleTest.svelte index 705ef031ca..88721f7dd0 100644 --- a/frontend/src/lib/components/ModuleTest.svelte +++ b/frontend/src/lib/components/ModuleTest.svelte @@ -90,6 +90,7 @@ $flowStateStore[mod.id].previewSuccess = testJob.success $flowStateStore[mod.id].previewJobId = testJob.id $flowStateStore[mod.id].previewWorkspaceId = testJob.workspace_id + $flowStateStore[mod.id].initial = false $flowStateStore = $flowStateStore } } diff --git a/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte b/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte index 70ffe5a3ec..984e8d7d73 100644 --- a/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte +++ b/frontend/src/lib/components/flows/content/FlowModuleComponent.svelte @@ -819,7 +819,23 @@ {#if selected === 'test'} - + + {#if $flowStateStore[flowModule.id]?.initial} + + +
{ + $flowStateStore[flowModule.id]!.initial = false + }} + class="cursor-pointer h-full hover:bg-gray-500/20 dark:hover:bg-gray-500/20 dark:bg-gray-500/80 bg-gray-500/40 absolute top-0 left-0 w-full z-50" + > +
Run loaded from history
+
+ {/if} diff --git a/frontend/src/lib/components/flows/map/FlowModuleSchemaItem.svelte b/frontend/src/lib/components/flows/map/FlowModuleSchemaItem.svelte index 9b05735105..2bb55d52be 100644 --- a/frontend/src/lib/components/flows/map/FlowModuleSchemaItem.svelte +++ b/frontend/src/lib/components/flows/map/FlowModuleSchemaItem.svelte @@ -413,6 +413,12 @@ bind:bottomBarOpen={outputPickerBarOpen} {loopStatus} {onEditInput} + initial={id ? $flowStateStore[id]?.initial : undefined} + onResetInitial={() => { + if (id) { + $flowStateStore[id]!.initial = false + } + }} > {#snippet children({ allowCopy, isConnecting, selectConnection })} void + initial?: boolean + onResetInitial?: () => void } let { @@ -33,7 +35,9 @@ id, bottomBarOpen = $bindable(false), loopStatus, - onEditInput + onEditInput, + initial, + onResetInitial }: Props = $props() const context = getContext('PropPickerContext') @@ -184,7 +188,7 @@ }} bind:this={popover} allowFullScreen - contentClasses="overflow-hidden resize" + contentClasses="overflow-hidden resize relative" contentStyle={`width: calc(${MIN_WIDTH}px); min-width: calc(${MIN_WIDTH}px); height: calc(${MIN_HEIGHT}px); min-height: calc(${MIN_HEIGHT}px); `} extraProps={{ 'data-prop-picker': true }} closeOnOtherPopoverOpen @@ -219,6 +223,22 @@ {/snippet} {#snippet content()} + {#if initial} + + +
{ + onResetInitial?.() + }} + class="cursor-pointer h-full hover:bg-gray-500/20 dark:hover:bg-gray-500/20 dark:bg-gray-500/80 bg-gray-500/40 absolute top-0 left-0 w-full z-50" + > +
Run loaded from history
+
+ {/if} {@render children?.({ allowCopy: !$flowPropPickerConfig, isConnecting: showConnecting, diff --git a/frontend/src/lib/components/flows/utils.ts b/frontend/src/lib/components/flows/utils.ts index 7e433c359b..56228308bc 100644 --- a/frontend/src/lib/components/flows/utils.ts +++ b/frontend/src/lib/components/flows/utils.ts @@ -178,7 +178,8 @@ export function codeToStaticTemplate(code?: string): string | undefined { export function emptyFlowModuleState(): FlowModuleState { return { schema: emptySchema(), - previewResult: NEVER_TESTED_THIS_FAR + previewResult: NEVER_TESTED_THIS_FAR, + initial: false } }