| @@ -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,17 +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 onboarding = window.extAgentData.chatHistory?.length === 0; | |
| 13 | -const agentResponse = isChangeSiteDesignWorkflowAvailable() | |
| 14 | - ? changeSiteDesignWorkflow.example?.agentResponse | |
| 15 | - : variationsWorkflow.example?.agentResponse; | |
| 16 | -const onboardingToolProps = { | |
| 17 | - ...agentResponse.whenFinishedTool, | |
| 18 | - agentResponse, | |
| 19 | -}; | |
| 20 | - | |
| 21 | 9 | // Used to check case-insensitive matches for workflow examples |
| 22 | 10 | const collator = new Intl.Collator(undefined, { |
| 23 | 11 | sensitivity: 'base', |
| 24 | 12 | usage: 'search', |
| @@ -49,8 +37,9 @@ | ||
| 49 | 37 | const wf = workflows.find( |
| 50 | 38 | ({ example: ex }) => collator.compare(ex?.text, example) === 0, |
| 51 | 39 | ); |
| 52 | 40 | if (!wf?.id) return null; |
| 41 | + if (!wf.available()) return null; | |
| 53 | 42 | return wf; |
| 54 | 43 | }, |
| 55 | 44 | // Gets the workflows available to the user |
| 56 | 45 | // TODO: maybe we need to have a way to include a |
| @@ -123,23 +112,15 @@ | ||
| 123 | 112 | export const useWorkflowStore = create()( |
| 124 | 113 | persist(devtools(state, { name: 'Extendify Agent Workflows' }), { |
| 125 | 114 | name: `extendify-agent-workflows-${window.extSharedData.siteId}`, |
| 126 | 115 | merge: (persistedState, currentState) => { |
| 127 | - // if we are in onboarding mode, add the starting workflow | |
| 128 | - if (onboarding) { | |
| 129 | - return { | |
| 130 | - ...currentState, | |
| 131 | - ...persistedState, | |
| 132 | - workflow: isChangeSiteDesignWorkflowAvailable() | |
| 133 | - ? changeSiteDesignWorkflow | |
| 134 | - : variationsWorkflow, | |
| 135 | - whenFinishedToolProps: onboardingToolProps, | |
| 136 | - }; | |
| 137 | - } | |
| 138 | 116 | const merged = { ...currentState, ...persistedState }; |
| 139 | 117 | // A reload can't carry the staged block a block-patching workflow |
| 140 | - // depends on, so a rehydrated-open one is always stale. | |
| 141 | - if (merged.workflow?.id === 'block-patching') { | |
| 118 | + // depends on, so a rehydrated-open one is always stale. A canvas | |
| 119 | + // session is stale too: its field values never persist. | |
| 120 | + const id = merged.workflow?.templateId || merged.workflow?.id; | |
| 121 | + const registered = workflows.find((wf) => wf.id === id); | |
| 122 | + if (id === 'block-patching' || registered?.whenFinished?.canvas) { | |
| 142 | 123 | return { |
| 143 | 124 | ...merged, |
| 144 | 125 | workflow: null, |
| 145 | 126 | whenFinishedToolProps: null, |