Fix unreliable Duplicate button in My Assets#11485
Merged
Merged
Conversation
Contributor
Author
|
@jwunderl would you mind taking a look when you get a chance? :) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a set of reliability issues in the Asset Editor (“My Assets”), primarily around duplicate/copy/edit/create flows failing silently due to type/boolean edge cases and rebuild/selection state getting wedged or stale.
Changes:
- Makes
isGalleryAsset()always return a strict boolean to prevent click-handler exceptions from.toString()onundefined. - Improves asset selection resiliency across asset-list refreshes and explicitly reselects newly edited/duplicated/created assets.
- Hardens asset rebuild logic (
buildAssetsAsync) to restore the rebuild flag on failure, and adds user-visible error notifications for common asset operations. - Extends
TilemapProject.pushUndo()/cleanupTemporaryAssets()with an optional “protected asset id”, and makescloneAsset()avoid mutating its input.
Show a summary per file
| File | Description |
|---|---|
| webapp/src/package.ts | Adds failure recovery for the asset rebuild flag in buildAssetsAsync(). |
| webapp/src/components/assetEditor/store/assetEditorReducerState.ts | Ensures isGalleryAsset() returns a real boolean. |
| webapp/src/components/assetEditor/store/assetEditorReducer.ts | Improves selection retention by reselecting with (type,id) and preserving selection when not present in refreshed user-asset list. |
| webapp/src/components/assetEditor/assetSidebar.tsx | Protects selected/in-flight assets during undo cleanup; reselects results after edit/duplicate; adds error notifications. |
| webapp/src/components/assetEditor/assetGallery.tsx | Reselects newly created assets and surfaces create failures via error notifications. |
| pxtlib/tilemap.ts | Adds optional protected asset id to undo cleanup; prevents cloneAsset() from mutating its input; avoids deleting a protected temporary image. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 2
- Review effort level: Low
…to a pre-composed message for localization
Contributor
Author
|
@copilot's comments resolved and microsoft:master merged back in so the PR branch is up to date |
Contributor
Author
|
Hey @riknoll - just waiting on that review :) |
riknoll
enabled auto-merge
July 23, 2026 18:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes microsoft/pxt-arcade#7589
Problem
The Duplicate button in the My Assets panel would silently do nothing for:
myTile24)In all cases, reloading the project made duplication work again.
Root causes
isGalleryAsset()could returnundefinedinstead offalsefor any asset whose id doesn't start with"sprites."and has nometa.package(tiles, temporary block-embedded assets, and others).duplicateAssetHandler/copyAssetHandlerthen called.toString()on thatundefined, throwing synchronously before the duplicate/copy logic ever ran. This was the primary cause: a silent, uncaught exception in the click handler.idonly, with notypecheck, and no fallback when a promoted (newly-named) asset's id changed.buildAssetsAsync()cleared its rebuild flag before attempting work and had notry/catch, so any failure silently wedged asset syncing for the rest of the session with no user-visible error.pushUndo()could delete the asset being duplicated via its unconditionalcleanupTemporaryAssets()call, andcloneAsset()mutated its input object in place instead of producing an independent copy.Fix
isGalleryAsset()now always returns a real boolean.buildAssetsAsync()self-heals its rebuild flag on failure, and failures now surface as a visible error notification instead of failing silently.cleanupTemporaryAssets().cloneAsset()no longer mutates its input.API notes
Two
pxt.TilemapProjectmethods gained a new optional trailing parameter, which is non-breaking for all existing callers (all current call sites acrosspxtlib/webapp/pxtblocks/pxteditoralready pass zero args):pushUndo()->pushUndo(protectedAssetId?: string)cleanupTemporaryAssets()(protected) ->cleanupTemporaryAssets(protectedAssetId?: string)cloneAsset()'s signature is unchanged, but its behavior changed: it previously mutated themetaobject on its inputassetas a side effect before returning the clone; it no longer does. Any code relying on that mutation (none found in this repo) would need to be updated, but this was an unintentional side effect of what's documented/named as a pure clone function.Fix was manually verified from a
cd ../pxt-arcade pxt link ../pxt pxt serve