Skip to content

docs(assist): fix README markdown formatting and document English-only image descriptions#1628

Merged
stipsan merged 4 commits into
mainfrom
cursor/fix-image-caption-language-0b81
Jul 17, 2026
Merged

docs(assist): fix README markdown formatting and document English-only image descriptions#1628
stipsan merged 4 commits into
mainfrom
cursor/fix-image-caption-language-0b81

Conversation

@stipsan

@stipsan stipsan commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

Docs-only PR addressing #1606 and the broken README rendering on sanity.io.

Why docs-only: end-to-end testing against the hosted AI Assist backend showed the generate-caption task always writes English descriptions, no matter what the client sends (languagePath, ad-hoc instruction overrides — all ignored). Since the backend won't be changed, the earlier client-side languagePath plumbing from this branch has been reverted; documenting the limitation clearly is the fix.

README cleanup

The README relied on markdown block elements (headings, lists, code fences, images) interrupting paragraphs without blank lines. GitHub renders that fine, but stricter renderers (like the plugin listing on sanity.io) join everything into walls of text with literal ### Configure and - list item fragments inline. Changes:

  • Blank-line separation between all block elements throughout, verified with a strict CommonMark renderer (zero heading/list/fence fragments leak into paragraphs after the fix)
  • New Known limitations section (with TOC entry) documenting that image descriptions are always generated in English regardless of translate.document.languageField, linking AI assist Image description generation language #1606, with two workarounds: the Transform Agent Action image-description operation with a custom instruction, or translating the generated English description via the existing document/field translation actions
  • Short note in the Image description generation section pointing at Known limitations
  • Fixed broken links: empty-href [### Full field translation configuration example]() heading, HOW-TO-USE pointing at the old standalone-repo layout (../studio/...), LICENSE pointing at a file that doesn't exist in the plugin directory, and the #usefieldaction TOC anchor
  • Fixed escaped-asterisk bold markup (\*the sparkle icon\*\*) in the setup steps, added missing TOC entries for Caveats and Third party sub-processors

Rendering before/after (strict CommonMark renderer)

Before After
Broken rendering before Fixed rendering after

New Known limitations section:

Known limitations section

Testing

  • ✅ Rendered the README with a strict CommonMark renderer before/after: before shows literal ### Configure / list fragments inline in paragraphs; after renders proper headings, lists, and code blocks (screenshots above)
  • ✅ Script-verified all 48 in-document anchor links resolve against the 62 generated heading anchors
  • pnpm format (no diff), pnpm lint, pnpm --filter @sanity/assist build, pnpm vitest run --project '@sanity/assist' (33 tests), pnpm knip
  • ✅ Backend behavior evidence (from earlier testing on this branch): generate-caption produced identical English captions for the same image on language: "en" and language: "fr" documents, with languagePath and instruction request fields ignored by the API

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

…descriptions

Pass the configured translate.document.languageField as languagePath to the
generate-caption task (both the automatic generation triggered on image
change, and the manual 'Generate image description' field action), so
generated alt text/captions are written in the document's language instead
of always defaulting to English.

Fixes #1606
@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 56dbebd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@sanity/assist Patch
sanity-plugin-internationalized-array Patch
@sanity/document-internationalization Patch
@sanity/sfcc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@stipsan stipsan added the 🤖 bot label Jul 17, 2026 — with Cursor
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
plugins-studio Ready Ready Preview, Comment Jul 17, 2026 10:51am

Request Review

@stipsan
stipsan marked this pull request as ready for review July 17, 2026 09:21
@stipsan
stipsan requested a review from a team as a code owner July 17, 2026 09:21
@stipsan
stipsan requested review from Copilot and pedrobonamin and removed request for a team and Copilot July 17, 2026 09:21
@stipsan
stipsan enabled auto-merge (squash) July 17, 2026 09:21
Testing against the live AI Assist backend confirms that the generate-caption
task currently always writes descriptions in English, regardless of the
languagePath sent from the client (this matches Sanity's own documentation,
which states the automatic image description feature is English-only today
and recommends the Transform Agent Action's image-description operation as a
workaround). Update the changeset and README to accurately describe the
change as forward-compatible plumbing rather than a full fix, and point users
at the documented workaround for non-English alt text today.
Copilot AI review requested due to automatic review settings July 17, 2026 09:31
@stipsan
stipsan removed the request for review from Copilot July 17, 2026 09:31
@cursor cursor Bot changed the title fix(@sanity/assist): respect document language when generating image descriptions docs+fix(@sanity/assist): thread document language to caption generation (backend still English-only today) Jul 17, 2026
Compute languagePath from config.translate.document.languageField once
inside useGenerateCaption itself (via useAiAssistanceConfig), instead of
requiring every call site to read the config and thread it through as an
argument. This removes the duplicated config lookup from both
ImageContextProvider and generateCaptionsActions, and matches the cleaner
approach used in #1627.

Also documents in translate/types.ts JSDoc that languageField is reused
for image description generation.
Copilot AI review requested due to automatic review settings July 17, 2026 10:04
@stipsan
stipsan removed the request for review from Copilot July 17, 2026 10:04
@stipsan
stipsan disabled auto-merge July 17, 2026 10:16
@stipsan
stipsan marked this pull request as draft July 17, 2026 10:16
The README relied on markdown block elements (headings, lists, code
fences, images) interrupting paragraphs without blank lines between
them. GitHub tolerates this, but stricter renderers (e.g. the plugin
listing on sanity.io) join everything into unreadable walls of text
with literal '### Heading' and '- list item' fragments inline.

- Separate all block elements with blank lines throughout
- Add a 'Known limitations' section documenting that image descriptions
  are always generated in English regardless of
  translate.document.languageField (backend limitation, see #1606),
  with Transform Agent Action and translate-after workarounds
- Fix broken links: empty-href heading, HOW-TO-USE pointing at the old
  standalone repo layout, LICENSE pointing at a non-existent file
- Fix broken bold markup in the 'Enabling the AI Assist API' steps and
  the useExampleFieldActions TOC anchor
- Add missing TOC entries (Known limitations, Caveats, Third party
  sub-processors)

Also reverts the languagePath client plumbing from this branch: the
backend ignores it, so the plugin change had no effect. This PR is now
docs-only.
@cursor cursor Bot changed the title docs+fix(@sanity/assist): thread document language to caption generation (backend still English-only today) docs(assist): fix README markdown formatting and document English-only image descriptions Jul 17, 2026
@stipsan
stipsan marked this pull request as ready for review July 17, 2026 11:30
Copilot AI review requested due to automatic review settings July 17, 2026 11:30
@stipsan
stipsan merged commit 735b86a into main Jul 17, 2026
14 checks passed
@stipsan
stipsan deleted the cursor/fix-image-caption-language-0b81 branch July 17, 2026 11:32
@squiggler-app squiggler-app Bot mentioned this pull request Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Docs-only update to @sanity/assist aimed at fixing broken README rendering in stricter CommonMark environments (e.g. sanity.io plugin listing) and clearly documenting a backend limitation where image descriptions are generated in English regardless of document language configuration (refs #1606).

Changes:

  • Normalize README markdown formatting by adding blank-line separation between block elements, fixing several broken/incorrect links and TOC anchors.
  • Add a Known limitations section documenting the English-only image description behavior and suggested workarounds.
  • Add a changeset to ship the README/documentation update as a patch release for @sanity/assist.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
plugins/@sanity/assist/README.md Markdown rendering fixes, TOC/link corrections, and new “Known limitations” documentation about English-only image descriptions.
.changeset/assist-caption-language-GH-1606.md Patch changeset describing the README formatting fix and the documented image-description language limitation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

##### Example
Starting from v3.0.0, AI Assist can write to date and datetime fields. Instructions can use language like "tomorrow at noon" or
"next year", and when Assist writes to the field, it will be converted to a field-compatible value.
Language about time is locale and timeZone dependant. By default instructions will use the locale and timezone provided

By providing a function to `translate.field.translationOutputs`, you have complete control over which fields belong to which language.
`translationOutputs` is used when an editor uses the **Translate fields** instruction.
It determines the relationships between document paths: Given a document path and a language, it should return the approriate sibling paths into which translations are output.
The action will:

- create the document as a draft if it does not exist, respecting initial values (`targetDocument`)
- use existing document state to determine what should be put in the the field (`instruction`, `instructionParams`)

- create the document as a draft if it does not exist, respecting initial values (`targetDocument`)
- use existing document state to determine what should be put in the the field (`instruction`, `instructionParams`)
- pass the current readOnly and hidden state currently use by the document form to the Agent Action, so it respects it (`conditionalPaths`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants