Skip to content

fix(media): search localized alt text, title, description and credit line - #2061

Merged
pedrobonamin merged 1 commit into
mainfrom
cursor/sieve-1699-6e4f
Oct 29, 2026
Merged

pedrobonamin merged 1 commit into
mainfrom
cursor/sieve-1699-6e4f

Conversation

@pedrobonamin

@pedrobonamin pedrobonamin commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1699

Problem

When the locales option is set, sanity-plugin-media stores altText, title, description and creditLine as per-locale objects (altText: {en: "brass faucet", "zh-CN": "黄铜龙头"}). Search still queried the bare field (altText match '*faucet*'), and GROQ match never matches an object, so both the main search box and the "Alt text" / "Title" / "Description" / "Credit" facets returned nothing for localized values.

Reproduced with groq-js 2.0.0 against the filter constructFilter builds:

Query Result
Reported query (bare altText) ["legacy"] — the localized asset is missing
Fixed main search ["localized", "legacy"]
Fixed "Alt text includes" facet ["localized", "legacy"]
zh-CN value 龙头 ["localized"]

Fix

  • constructFilter takes the configured localeIds. For the four localized fields, the main search and the includes / doesNotInclude facets match field["<localeId>"] for each locale alongside the bare field, so assets not yet migrated from a plain string keep matching.
  • Bracket access is used on purpose: altText.zh-CN parses as subtraction in GROQ. Locale ids are JSON-quoted, deduplicated, and blank ids are skipped.
  • Search text still goes through groqWildcardMatch (from fix(media): keep apostrophes in Media search queries #2082), so an apostrophe in a localized query stays inside one GROQ string.
  • empty / notEmpty facets check the locale keys too, so a localized field counts as empty only when no configured locale has a value.
  • Search reuses state.assets.localeIds, which title sort (feat(media): add sort by title (A to Z / Z to A) #2016) already fills from ToolOptionsContext → Browser → ReduxProvider. Fields that are never localized (e.g. originalFilename) are untouched.

Tests

Changeset: sanity-plugin-media patch.

Rebased onto current main. The conflict with #2016 was the shared localeIds wiring; search now reads the same ids title sort already stores.

Open in Web Open in Cursor 

@pedrobonamin
pedrobonamin requested a review from a team as a code owner September 29, 2026 15:49
@pedrobonamin
pedrobonamin removed the request for review from a team September 29, 2026 15:49
@cursor

cursor Bot commented Sep 29, 2026

Copy link
Copy Markdown

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@changeset-bot

changeset-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ce727c1

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

This PR includes changesets to release 1 package
Name Type
sanity-plugin-media 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

Copilot AI balanced review requested due to automatic review settings September 29, 2026 15:49
@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
plugins-studio Ready Ready Preview Oct 28, 2026 12:45pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
plugins-e2e-test-studio Ignored Ignored Oct 28, 2026 12:45pm UTC

Request Review

@pedrobonamin
pedrobonamin removed the request for review from bjoerge September 29, 2026 15:49
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

✅ E2E Tests

🟢 46 passed • view full report • view run

Studio: https://plugins-e2e-test-studio-qni8qb9xm.sanity.dev

Datasets: pr-2061-chromium-40689885120, pr-2061-firefox-40689885120

@pedrobonamin
pedrobonamin marked this pull request as draft September 29, 2026 15:49
@pedrobonamin pedrobonamin added the 🤖 bot label Sep 29, 2026 — with Cursor
@cursor cursor Bot changed the title sieve #1699 fix(media): search localized alt text, title, description and credit line Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 38.89% 7888 / 20281
🔵 Statements 38.85% 8486 / 21840
🔵 Functions 34.49% 2149 / 6230
🔵 Branches 31.13% 4605 / 14792
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
plugins/sanity-plugin-media/src/modules/assets/index.ts 86.11% 53.46% 84.17% 86.09% 126-128, 144-146, 178, 185, 245-250, 385, 392-393, 415-425, 444, 453, 466, 487, 571, 580-585, 590, 628-631, 649-652, 697, 727-736, 768-777, 812-820, 885-893, 920, 978
plugins/sanity-plugin-media/src/modules/uploads/index.ts 74.71% 36.84% 77.77% 74.41% 52, 56-61, 72-78, 141, 156-194, 239-243, 292-295
plugins/sanity-plugin-media/src/utils/constructFilter.ts 98.68% 89.09% 100% 98.52% 80
Generated in workflow #11442 for commit ce727c1 by the Vitest Coverage Report Action

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.

Copilot review overview

🟡 Changes recommended

Facet matching can incorrectly combine search terms across different translations.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds locale-aware media search to address issue #1699.

Changes:

  • Searches localized metadata fields in main search and facets.
  • Threads locale IDs through Redux query generation.
  • Adds regression tests and a patch changeset.
File Description
.changeset/​media-localized-search.md Documents the localized-search fix.
components/​Browser/​index.tsx Passes configured locale IDs to Redux.
components/​ReduxProvider/​index.tsx Stores locale IDs in initial state.
modules/​assets/​index.ts Uses locale IDs for asset queries.
modules/​assets/​fetchEpic.test.ts Tests locale-aware page fetching.
modules/​folders/​epics.test.ts Updates test state fixtures.
modules/​uploads/​index.ts Uses locale IDs in upload checks.
utils/​constructFilter.ts Builds locale-aware GROQ filters.
utils/​constructFilter.test.ts Tests localized search and facets.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cursor
cursor Bot force-pushed the cursor/sieve-1699-6e4f branch from 3b763d0 to 3243a2e Compare October 26, 2026 09:37
@pedrobonamin
pedrobonamin marked this pull request as ready for review October 26, 2026 09:37
@pedrobonamin
pedrobonamin requested a review from a team as a code owner October 26, 2026 09:37
@pedrobonamin
pedrobonamin requested review from georgedoescode and removed request for a team October 26, 2026 09:37
@georgedoescode

Copy link
Copy Markdown

@pedrobonamin this makes sense, did we wanna solve the conflicts/comment above and get it in?

GROQ match does not look inside objects, so those fields missed every result once locales stored them as per-locale maps. Search now targets each configured locale key and still matches plain strings.

Co-authored-by: Pedro Bonamin <pedrobonamin@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/sieve-1699-6e4f branch from 3243a2e to ce727c1 Compare October 28, 2026 12:41
@cursor

cursor Bot commented Oct 28, 2026

Copy link
Copy Markdown

@georgedoescode rebased onto current main and pushed. The conflict with the title-sort change is resolved: search now uses the same localeIds that sort already stores. Ready for another look when you have a moment.

@pedrobonamin
pedrobonamin merged commit 078ac51 into main Oct 29, 2026
25 checks passed
@pedrobonamin
pedrobonamin deleted the cursor/sieve-1699-6e4f branch October 29, 2026 12:51
@squiggler-app squiggler-app Bot mentioned this pull request Oct 29, 2026
pedrobonamin pushed a commit that referenced this pull request Nov 2, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @sanity/color-input@6.1.9

### Patch Changes

- [#2273](#2273)
[`4651c2d`](4651c2d)
Thanks [@pedrobonamin](https://github.com/pedrobonamin)! - Keep field
group tabs in place when a color field first loads. The color input now
shows its own loading state instead of suspending the document form.
## sanity-plugin-media@6.6.1

### Patch Changes

- [#2061](#2061)
[`078ac51`](078ac51)
Thanks [@pedrobonamin](https://github.com/pedrobonamin)! - Search alt
text, title, description, and credit line when those fields are stored
per locale

- [#2276](#2276)
[`e5b5459`](e5b5459)
Thanks [@coreyward](https://github.com/coreyward)! - Update dependencies
`zod` to ^4.6.7 and `@hookform/resolvers` to ^6.0.2

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Release bookkeeping only; functional changes were merged separately
and this PR mainly versions and publishes documented patches.
> 
> **Overview**
> This is a **Changesets release** PR: it removes the consumed changeset
files and bumps two packages for npm publish.
> 
> **`@sanity/color-input@6.1.9`** — documents a patch fix so field group
tabs stay visible while a color field loads; the input shows its own
loading state instead of suspending the whole document form.
> 
> **`sanity-plugin-media@6.6.1`** — documents Media browser search over
per-locale alt text, title, description, and credit line, plus
dependency updates to **`zod` ^4.6.7** and **`@hookform/resolvers`
^6.0.2** (reflected in `package.json` for media).
> 
> There is **no application source diff** here—only version numbers,
changelogs, and changeset cleanup.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
60474d7. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: squiggler-app[bot] <265501495+squiggler-app[bot]@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview – plugins-studio — ce727c11 Deployed Oct 28, 2026 by vercel[bot]
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.

sanity-plugin-media: alt text search returns nothing when locales are configured

4 participants