@sanity/assist 2.0.2 → 2.0.4-canary.0

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/dist/index.esm.js CHANGED
@@ -5800,6 +5800,26 @@ const prompt = defineType({
5800
5800
  type: userInput.name,
5801
5801
  }),*/]
5802
5802
  });
5803
+ const outputFieldType = defineType({
5804
+ type: "object",
5805
+ name: outputFieldTypeName,
5806
+ title: "Output field",
5807
+ fields: [defineField({
5808
+ type: "string",
5809
+ name: "path",
5810
+ title: "Path"
5811
+ })]
5812
+ });
5813
+ const outputTypeType = defineType({
5814
+ type: "object",
5815
+ name: outputTypeTypeName,
5816
+ title: "Output type",
5817
+ fields: [defineField({
5818
+ type: "string",
5819
+ name: "type",
5820
+ title: "Type"
5821
+ })]
5822
+ });
5803
5823
  const instruction = defineType({
5804
5824
  type: "object",
5805
5825
  name: instructionTypeName,
@@ -5937,23 +5957,9 @@ const instruction = defineType({
5937
5957
  field: InstructionOutputField
5938
5958
  },
5939
5959
  of: [defineArrayMember({
5940
- type: "object",
5941
- name: outputFieldTypeName,
5942
- title: "Output field",
5943
- fields: [{
5944
- type: "string",
5945
- name: "path",
5946
- title: "Path"
5947
- }]
5960
+ type: outputFieldType.name
5948
5961
  }), defineArrayMember({
5949
- type: "object",
5950
- name: outputTypeTypeName,
5951
- title: "Output type",
5952
- fields: [{
5953
- type: "string",
5954
- name: "type",
5955
- title: "Type"
5956
- }]
5962
+ type: outputTypeType.name
5957
5963
  })]
5958
5964
  })]
5959
5965
  });
@@ -6101,7 +6107,7 @@ function excludeComments(type) {
6101
6107
  };
6102
6108
  }
6103
6109
  const instructionForm = [fieldInstructions, instruction, fieldReference, prompt, userInput, promptContext].map(excludeComments);
6104
- const schemaTypes = [...instructionForm, assistDocumentSchema, documentInstructionStatus, instructionTask, contextDocumentSchema];
6110
+ const schemaTypes = [...instructionForm, outputFieldType, outputTypeType, assistDocumentSchema, documentInstructionStatus, instructionTask, contextDocumentSchema];
6105
6111
  function useAssistSupported(path, schemaType) {
6106
6112
  return useMemo(() => isAssistSupported(schemaType), [schemaType]);
6107
6113
  }
@@ -6173,11 +6179,12 @@ function PrivateIcon() {
6173
6179
  }
6174
6180
  const ImageContext = createContext({});
6175
6181
  function ImageContextProvider(props) {
6176
- var _a;
6182
+ var _a, _b;
6177
6183
  const {
6178
6184
  schemaType,
6179
6185
  path,
6180
- value
6186
+ value,
6187
+ readOnly
6181
6188
  } = props;
6182
6189
  const assetRef = (_a = value == null ? void 0 : value.asset) == null ? void 0 : _a._ref;
6183
6190
  const [assetRefState, setAssetRefState] = useState(assetRef);
@@ -6196,9 +6203,11 @@ function ImageContextProvider(props) {
6196
6203
  const {
6197
6204
  isSyncing
6198
6205
  } = useSyncState(publicId(documentId), documentSchemaType.name);
6206
+ const router = usePaneRouter();
6207
+ const isShowingOlderRevision = !!((_b = router.params) == null ? void 0 : _b.rev);
6199
6208
  useEffect(() => {
6200
6209
  const descriptionField = getDescriptionFieldOption(schemaType);
6201
- if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing) {
6210
+ if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing && !isShowingOlderRevision && !readOnly) {
6202
6211
  setAssetRefState(assetRef);
6203
6212
  if (canUseAssist(status)) {
6204
6213
  generateCaption({
@@ -6207,7 +6216,7 @@ function ImageContextProvider(props) {
6207
6216
  });
6208
6217
  }
6209
6218
  }
6210
- }, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing, status]);
6219
+ }, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing, status, readOnly, isShowingOlderRevision]);
6211
6220
  const context = useMemo(() => {
6212
6221
  const descriptionField = getDescriptionFieldOption(schemaType);
6213
6222
  const imageInstructionField = getImageInstructionFieldOption(schemaType);