@sanity/assist 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/assist",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "You create the instructions; Sanity AI Assist does the rest.",
5
5
  "keywords": [
6
6
  "sanity",
@@ -244,6 +244,7 @@ function FieldsInitializer({
244
244
  _key: pathKey,
245
245
  _type: assistFieldTypeName,
246
246
  path: pathKey,
247
+ instructions: [],
247
248
  }),
248
249
  ],
249
250
  'after',
@@ -251,6 +252,11 @@ function FieldsInitializer({
251
252
  )
252
253
  )
253
254
  }
255
+
256
+ if (!existingField?.instructions?.length) {
257
+ event = event.append([setIfMissing([], ['fields', {_key: pathKey}, 'instructions'])])
258
+ }
259
+
254
260
  if (missingPresetInstructions?.length) {
255
261
  event = event.append(
256
262
  insert(
@@ -28,16 +28,11 @@ export function ImageContextProvider(props: InputProps) {
28
28
 
29
29
  useEffect(() => {
30
30
  const descriptionField = getDescriptionFieldOption(schemaType)
31
- if (
32
- assetRef &&
33
- documentId &&
34
- descriptionField &&
35
- assetRef !== assetRefState &&
36
- !isSyncing &&
37
- canUseAssist(status)
38
- ) {
31
+ if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing) {
39
32
  setAssetRefState(assetRef)
40
- generateCaption({path: pathToString([...path, descriptionField]), documentId: documentId})
33
+ if (canUseAssist(status)) {
34
+ generateCaption({path: pathToString([...path, descriptionField]), documentId: documentId})
35
+ }
41
36
  }
42
37
  }, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing, status])
43
38