| @@ -1,9 +1,6 @@ | ||
| 1 | 1 | import { isAbilityWorkflow } from '@agent/lib/abilities'; |
| 2 | -import { isChangeSiteDesignWorkflowAvailable } from '@agent/lib/util'; | |
| 3 | 2 | import { AbilityRun } from '@agent/workflows/abilities/components/run'; |
| 4 | -import changeSiteDesignWorkflow from '@agent/workflows/theme/change-site-design'; | |
| 5 | -import variationsWorkflow from '@agent/workflows/theme/change-theme-variation'; | |
| 6 | 3 | import { abilityWorkflows, workflows } from '@agent/workflows/workflows'; |
| 7 | 4 | import { useQuickEditStore } from '@quick-edit/state/store'; |
| 8 | 5 | import { deepMerge } from '@shared/lib/utils'; |
| 9 | 6 | import { create } from 'zustand'; |
| @@ -8,16 +5,8 @@ | ||
| 8 | 5 | import { deepMerge } from '@shared/lib/utils'; |
| 9 | 6 | import { create } from 'zustand'; |
| 10 | 7 | import { devtools, persist } from 'zustand/middleware'; |
| 11 | 8 | |
| 12 | -const agentResponse = isChangeSiteDesignWorkflowAvailable() | |
| 13 | - ? changeSiteDesignWorkflow.example?.agentResponse | |
| 14 | - : variationsWorkflow.example?.agentResponse; | |
| 15 | -const onboardingToolProps = { | |
| 16 | - ...agentResponse.whenFinishedTool, | |
| 17 | - agentResponse, | |
| 18 | -}; | |
| 19 | - | |
| 20 | 9 | // Used to check case-insensitive matches for workflow examples |
| 21 | 10 | const collator = new Intl.Collator(undefined, { |
| 22 | 11 | sensitivity: 'base', |
| 23 | 12 | usage: 'search', |
| @@ -26,8 +15,10 @@ | ||
| 26 | 15 | const state = (set, get) => ({ |
| 27 | 16 | workflow: null, |
| 28 | 17 | // Data for the tool component that shows up at the end of a workflow |
| 29 | 18 | whenFinishedToolProps: null, |
| 19 | + // A staged tool restored from storage; its confirm never renders. | |
| 20 | + reloadedToolProps: null, | |
| 30 | 21 | getWorkflow: () => { |
| 31 | 22 | const curr = get().workflow; |
| 32 | 23 | // Workflows may define a "parent" workflow via templateId |
| 33 | 24 | const currId = curr?.templateId || curr?.id; |
| @@ -123,19 +114,8 @@ | ||
| 123 | 114 | export const useWorkflowStore = create()( |
| 124 | 115 | persist(devtools(state, { name: 'Extendify Agent Workflows' }), { |
| 125 | 116 | name: `extendify-agent-workflows-${window.extSharedData.siteId}`, |
| 126 | 117 | merge: (persistedState, currentState) => { |
| 127 | - // if we are in onboarding mode, add the starting workflow | |
| 128 | - if (window.extAgentData?.startOnboarding) { | |
| 129 | - return { | |
| 130 | - ...currentState, | |
| 131 | - ...persistedState, | |
| 132 | - workflow: isChangeSiteDesignWorkflowAvailable() | |
| 133 | - ? changeSiteDesignWorkflow | |
| 134 | - : variationsWorkflow, | |
| 135 | - whenFinishedToolProps: onboardingToolProps, | |
| 136 | - }; | |
| 137 | - } | |
| 138 | 118 | const merged = { ...currentState, ...persistedState }; |
| 139 | 119 | // A reload can't carry the staged block a block-patching workflow |
| 140 | 120 | // depends on, so a rehydrated-open one is always stale. A canvas |
| 141 | 121 | // session is stale too: its field values never persist. |
| @@ -148,8 +128,9 @@ | ||
| 148 | 128 | whenFinishedToolProps: null, |
| 149 | 129 | workflowData: null, |
| 150 | 130 | }; |
| 151 | 131 | } |
| 152 | - return merged; | |
| 132 | + return { ...merged, reloadedToolProps: merged.whenFinishedToolProps }; | |
| 153 | 133 | }, |
| 134 | + partialize: ({ reloadedToolProps, ...persisted }) => persisted, | |
| 154 | 135 | }), |
| 155 | 136 | ); |