sanity-io / assist

Sanity AI Assist: A plugin for Sanity Studio
MIT License
13 stars 5 forks source link

AI Assist doesn't parse document schemas' `readOnly` function correctly #30

Open hdoro opened 7 months ago

hdoro commented 7 months ago

Describe the bug

Given the schema:

defineField({
  name: 'simpleDocument'
  type: 'document',
  fields: [
    {
      name: 'title',
      type: 'string',
    },
  ],
  readOnly: () => false
  // 👆 not read-only, but AI Assist will not allow to modify this document
})

Even though the document ISN'T read-only, whatever AI instruction you try to run on any field will return Instruction failed. The document is read-only for Al Assist.

2024-03-06-Firefox Developer Edition@2x

Which versions of Sanity are you using?

@sanity/cli (global)                   3.30.1 (latest: 3.32.0)
@sanity/assist                          2.0.1 (up to date)
@sanity/document-internationalization   2.1.0 (up to date)
@sanity/vision                         3.30.1 (latest: 3.32.0)
sanity                                 3.30.1 (latest: 3.32.0)

What operating system are you using?

MacOS, apple silicon

Which versions of Node.js / npm are you running?

10.4.0 v20.11.0

Additional context

My hunch is that @sanity/assist is only checking if documentSchema.readOnly is truthy, hence accepting functions as true instead of executing it and parsing the proper read-only value.