PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 All 128 releases
← All changes | src/Agent/state/workflows.js +10 -26 3.1.4 → 3.2.2 View file →
@@ -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',
@@ -27,8 +15,10 @@
27 15 const state = (set, get) => ({
28 16 workflow: null,
29 17 // Data for the tool component that shows up at the end of a workflow
30 18 whenFinishedToolProps: null,
19 + // A staged tool restored from storage; its confirm never renders.
20 + reloadedToolProps: null,
31 21 getWorkflow: () => {
32 22 const curr = get().workflow;
33 23 // Workflows may define a "parent" workflow via templateId
34 24 const currId = curr?.templateId || curr?.id;
@@ -49,8 +39,9 @@
49 39 const wf = workflows.find(
50 40 ({ example: ex }) => collator.compare(ex?.text, example) === 0,
51 41 );
52 42 if (!wf?.id) return null;
43 + if (!wf.available()) return null;
53 44 return wf;
54 45 },
55 46 // Gets the workflows available to the user
56 47 // TODO: maybe we need to have a way to include a
@@ -123,23 +114,15 @@
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 (onboarding) {
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 - // depends on, so a rehydrated-open one is always stale.
141 - if (merged.workflow?.id === 'block-patching') {
120 + // depends on, so a rehydrated-open one is always stale. A canvas
121 + // session is stale too: its field values never persist.
122 + const id = merged.workflow?.templateId || merged.workflow?.id;
123 + const registered = workflows.find((wf) => wf.id === id);
124 + if (id === 'block-patching' || registered?.whenFinished?.canvas) {
142 125 return {
143 126 ...merged,
144 127 workflow: null,
145 128 whenFinishedToolProps: null,
@@ -145,8 +128,9 @@
145 128 whenFinishedToolProps: null,
146 129 workflowData: null,
147 130 };
148 131 }
149 - return merged;
132 + return { ...merged, reloadedToolProps: merged.whenFinishedToolProps };
150 133 },
134 + partialize: ({ reloadedToolProps, ...persisted }) => persisted,
151 135 }),
152 136 );