Skip to content

fix: replace same-named files in place when uploading to the asset library - #1419

Merged
stevenle merged 1 commit into
mainfrom
claude/asset-uploader-duplicates-ygf89n
Sep 8, 2026
Merged

fix: replace same-named files in place when uploading to the asset library#1419
stevenle merged 1 commit into
mainfrom
claude/asset-uploader-duplicates-ygf89n

Conversation

@stevenle

@stevenle stevenle commented Sep 8, 2026

Copy link
Copy Markdown
Member

Summary

Dropping (or uploading) files into an asset library folder that already contained files with the same names created a second entry per file with a duplicate name, instead of updating the existing asset.

The cause: AssetBrowser.uploadFiles() always called createAssetFile(), which mints a fresh random asset id, and never checked whether the destination folder already had a file with that name.

Changes

  • ui/utils/assets.ts: add findAssetFile(parent, name), an equality query on parent + name (filtered to type: 'file'), with the same parent-path normalization as listAssets().
  • ui/components/AssetBrowser/AssetBrowser.tsx: before creating an asset, look up an existing file by destination folder and filename. If one exists, replace its file in place via replaceAssetFile() and fan the change out with syncAssetToDocs(), matching the "Replace file" action in the asset details modal. The success notification reports how many existing files were replaced, and doc fan-out failures surface the same "Some docs failed to update" notification the details modal uses.
  • Add assets.find.test.ts covering the lookup (folder scoping, case sensitivity, folders excluded, trailing-slash parent normalization).
  • Changeset (patch).

Applies to both the Assets page and the asset picker modal, since both use AssetBrowser.

Test plan

  • vitest run ui/utils/assets.find.test.ts ui/utils/assets.delete.test.ts passes.
  • eslint and prettier --check on changed files pass; tsc --noEmit -p tsconfig.build.json is clean.
  • Manual: drop a file with an existing name into a folder; the existing entry updates (new modifiedAt, new file src) and no duplicate appears. Docs that embed the asset pick up the new file.

🤖 Generated with Claude Code

https://claude.ai/code/session_016L52aaKKrhphsmLBEupcti


Generated by Claude Code

…brary

Dropping or uploading a file into an asset library folder that already
had a file with the same name created a second entry with a duplicate
name instead of updating the existing one. The upload flow now looks up
an existing file by parent folder and name, replaces its file in place
and fans the change out to docs that use the asset, matching the
"Replace file" action in the asset details modal.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016L52aaKKrhphsmLBEupcti
@stevenle
stevenle marked this pull request as ready for review September 8, 2026 16:19
@stevenle
stevenle merged commit 379dc94 into main Sep 8, 2026
1 check passed
@stevenle
stevenle deleted the claude/asset-uploader-duplicates-ygf89n branch September 8, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants