Repository navigation
Conversation
…alog The "Choose a replacement image" dialog listed every asset newest-first with no way to search, which made it impractical to pick an older image in large datasets (e.g. when cleaning up duplicates among ~10k images). The dialog now runs its own search, independent of the browser's search, facets and folder scope: - Search input plus tag and folder filters - Only image assets are queried, honouring `excludeTags` and `showMediaLibraryAssets`; user input is passed as GROQ params - A confirmation step shows the current and replacement image side by side, with the number of documents that will be updated, before any references are rewritten The old save/restore of the browser's search state and the `replace-asset` mode in `CardAsset` are removed.
🦋 Changeset detectedLatest commit: b419fc9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
@trostum is attempting to deploy a commit to the Sanity Sandbox Team on Vercel. A member of the Team first needs to authorize it. |
Returning to earlier filters (load more, search, clear) reused the stale page index stored for those filters, so the first page of results was never fetched again. Reset the stored page request whenever the filters change instead of only deriving page 0.
|
Would love your input on this one also @pedrobonamin :) |
Hi @trostum |
|
I see you are the owner of these files now @jmswrnr |
|
Thanks this looks great. Cursor's flagged one potential issue, could you take a look and see if it needs addressing or if it can be dismissed as false positive, please? Thanks! |
I tested and found no issue, but just to be safe here and in sync with the fix in #2231, i added overflowAnchor: 'none' and a test |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5acde94. Configure here.
Reuse the browser's locale-aware text search field list, so title, alt text, description and credit line match under each configured locale as well as the bare field.
Head branch was pushed to by a user without write access

Description
The Replace action in
sanity-plugin-mediaopens a "Choose a replacement image" dialog that lists every asset newest-first, 100 at a time, with no way to search. In a dataset with ~10,000 images that makes it close to impossible to pick an older image, which is exactly what editors need when cleaning up duplicates by pointing references at an image that already exists. Recently uploaded images are easy to find; older ones are not.This PR gives the dialog its own search and adds a confirmation step:
sanity.imageAsset(excluding the asset being replaced and drafts) and still honoursexcludeTagsandshowMediaLibraryAssets. Previously files were fetched and filtered out client-side, paging until an image turned up. Search text, tag and folder are passed as GROQ params rather than interpolated.Cleanup
replace-assetmode inCardAssetand thesourceprop onAssetGridVirtualizedare no longer used and have been removed, along with their tests.Screenshots
What to review
useReplacementAssetspages through results with local state. Results for previous filters stay visible while new ones load, to avoid flashing an empty grid, and a page that fails to load can be retried.textSearchFieldListfromconstructFilter), so with pluginlocalesset, alt text, title, description and credit line also match under eachfield["localeId"], as in fix(media): search localized alt text, title, description and credit line #2061. The folder filter matches the exact folder, like the browser.Testing
constructReplacementQuery), the picker (ReplaceAssetsOverview) and the dialog flow (DialogAllAssets). All 265 tests insanity-plugin-mediapass.groq-jsagainst a fixture dataset to check paging with[$start...$end], search with quotes and non-ASCII text, the tag and folder filters, and that files, drafts, excluded tags and Media Library assets are left out.Notes for release
Adds search, tag and folder filters to the "Choose a replacement image" dialog, and asks for confirmation before replacing an image.
Screenshots
Prepared with AI assistance (Claude Code); per
AGENTS.mdthis should carry the✨ ailabel, which I can't apply from a fork.Note
Medium Risk
The replace action still bulk-patches every document referencing the image; the new confirmation step reduces accidental writes, but mistaken confirmation remains impactful.
Overview
The Choose a replacement image dialog no longer piggybacks on the media browser’s Redux search, folder scope, or asset grid. It now runs dedicated GROQ (
constructReplacementQuery+useReplacementAssets) for image-only candidates, with debounced search plus optional tag and folder filters, paging, retry, and empty/error states—without mutating the browser’s filters or loaded assets.Selection is two-step: picking a thumbnail opens Confirm replacement (
ReplaceAssetConfirm) with current vs replacement previews and a reference count; Replace image then dispatches the existingupdateImageReferencesflow (blocked while the original is already updating). Back returns to the picker with filter/search state preserved in the dialog.The old instant replace on grid click path is removed (
CardAssetreplace-asset/sourceonAssetGridVirtualized), replaced by a simplerReplacementAssetGridfor the dialog only.Reviewed by Cursor Bugbot for commit b419fc9. Bugbot is set up for automated code reviews on this repo. Configure here.