Repository navigation
Conversation
Choosing or dropping a file whose MIME type is image/* but whose bytes cannot be decoded (for example a text file renamed to .png) went straight into the image history. `CanvasPreview` then failed to load it and only cleared its loaded flag, so the user saw no feedback and the old pixels stayed on screen even though the app state now pointed at the broken URL: swatches had been invalidated, the undo stack had gained an entry, and later operations ran against an image that did not exist. `handleFiles` now decodes the file before touching any state. An unreadable file revokes its object URL, leaves the current image, undo history, and swatches untouched, and shows a dismissible, localized notice at the bottom of the 2D preview (clear of the preview toolbar). Non-image files use the same notice instead of a blocking browser alert, and the next successful import clears it. The notice stores the error kind and file name rather than a translated string so it follows language changes while open. A request counter ensures only the most recent pick or drop is committed if decodes overlap. The resize path already decoded through an inline promise; it now shares the same `decodeImage` helper. Add the three new strings to all 12 locales and a browser regression that imports a corrupt PNG and a text file after a valid image, checks the notice, the retained image, the unchanged undo history, dismissal, and that a successful import clears the error. Fixes vycdev#107
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 936854630a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const image = await decodeImage(url); | ||
| if (request !== imageImportRequestRef.current) { |
There was a problem hiding this comment.
Invalidate pending imports after image edits
If a large image takes time to decode, the editor remains interactive while this await is pending. The request token advances only when another file is selected, so if the user clears, undoes, or crops the current image during this gap, the pending import still completes and replaces that later result. Invalidate pending imports when other image-changing actions occur or gate completion on the image state remaining unchanged.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Note
🤖 Claude Opus 5.5 responding on behalf of Victor Sandu
Fixed in 336d29f. useImageHistory runs onBeforeSet on every set, clear, undo, and redo, and App now passes a callback there that advances the import token. Any image change during a pending import therefore cancels it: Remove image, Undo/Redo, crop, resize, bake, dedither, touch-up, swatch edits, and quantize. A cancelled import revokes its object URL and shows no notice.
The new e2e test image edits made while an import is being checked cancel that import holds createImageBitmap, then undoes or removes the image while the import is pending. It checks that the import is discarded and the history is unchanged. Each phase fails without the fix and passes with it.
An <img> still loads a truncated or partly damaged raster file and shows only the rows it could decode, so such files replaced the current image with a partial one and no notice. After the <img> decode succeeds, handleFiles now also requires createImageBitmap to accept the file. SVGs skip that check because Chrome's createImageBitmap does not accept SVG blobs. The decode error said "Your current image was kept" even when there was no current image. Add an imageDecodeFailedNoImage variant without that sentence in all 12 locales. Removing the image also clears the notice. Mention the behavior in the Loading Images guide in all 12 languages and fold the changes into the existing changelog entry. Extend the browser regression with a truncated PNG (and its effect on undo history), the no-image wording after Remove image, and valid JPEG and SVG imports.
handleFiles awaits the decode and createImageBitmap checks before it commits, and the editor stays interactive meanwhile. The request token only advanced on another file pick or drop, so Remove image, Undo, Redo, crop, resize, bake, dedither, touch-up, swatch edits, or quantize during that gap were overwritten when the import finished. Pass a callback that advances the token as useImageHistory's onBeforeSet, which runs on every set, clear, undo, and redo. A cancelled import revokes its object URL and shows no notice, as before. Add a browser regression that holds createImageBitmap, then undoes or removes the image while the import is pending, and checks that the import is discarded and the history is unchanged.
Quantize and dedither commit their result through image history, which cancels any pending import. A file chosen or dropped while one of them ran was therefore discarded without any notice once it finished. Disable Choose file, the file input, and the drop zone while they run instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
WebKit, used by the macOS and Linux desktop apps, decodes truncated files to a partial image in both <img> and createImageBitmap, so the createImageBitmap check only caught them in Chrome. Check the file structure for its end marker first: PNG must reach IEND, JPEG must reach EOI after its scans, and WebP must match its RIFF size. Other formats are still left to the decoder. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The notice read the live image to decide whether to say the current image was kept, and stayed open through undo, redo, and edits. After Remove image, a failed import, and Undo, it claimed an image had been kept. Record the image on screen when the import fails, word the notice from it, and close the notice once the image changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # CHANGELOG.md
Some platforms and desktop WebViews report an empty File.type for valid images, which the main import rejected as "Please upload an image file". Move the Stack Matrix photo picker's isImageFile helper, which falls back to the extension, into src/lib and use it for the main import too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Undo and redo called onBeforeSet from inside their setPast/setFuture updaters, which React may run later or twice. Pending image imports now rely on it for cancellation, so call it in the handler instead, and skip it when there is nothing to undo or redo. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The cats fixtures recorded the SHA-256 of profile.kfil from a CRLF checkout, so the immutability check only passed on Windows with core.autocrlf=true. Mark .kfil files and performance fixture JSON as -text so every platform checks out the committed bytes, record the LF hash, and document that archived results hold the CRLF form. Cached multi-head preparation accepts either line-ending form of the same committed profile so archived evidence stays usable. Closes vycdev#130 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Note 🤖 Claude Opus 5.5 responding on behalf of Victor Sandu Thanks for this, @officialasishkumar. I reviewed it and pushed a few fixes to your branch, one commit each, then merged the latest
Each fix has a regression test that fails without it. The follow-ups that didn't belong in this PR are in #131 (repeated decoding), #132 (shared image-loading helper), and #133 (moving import handling into a hook and validating Stack Matrix photos the same way). |
|
Added Problem: Changes:
Verified locally on macOS (no GitHub checks run for PRs into
#130 needs to be closed by hand after merge, because |
Choosing or dropping a file labelled
image/*that cannot be decoded (for example plain text saved as.png) showed no feedback. It also replaced the current image in app state.handleFilesinvalidated the swatches and pushed the broken object URL into history.CanvasPreviewthen failed to load it and only cleared its loaded flag. The old pixels stayed on screen, but undo, swatches, and later operations pointed at an image that did not exist.handleFilesnow decodes the file before touching any state:alert(). The next successful import clears it.decodeImagehelper instead of its inline copy.The three new strings are added to all 12 locales, and there is an Unreleased changelog entry.
Fixes #107.
Validation:
tests/e2e/image-import-error.spec.ts(@smoke): after a valid 1000×835 import, a corrupt PNG and then a text file each show the notice. The 1000×835 image is kept, dismissal works, one Undo returns to the starter image with Undo then disabled (no history entry for failed files), and a later valid import clears the notice. The spec fails on currentdevelop(no notice appears) and passes with this change.tests/e2e/image-reimport.spec.ts: passed.npx eslint src --max-warnings=0,npx tsc -b,npm run check:i18n, and Prettier on changed files: passed.tests/e2e/i18n.spec.tsunderplaywright.i18n.config.ts: 16 passed, 1 failed. The failing test,desktop release notes switch languages…, times out the same way on unmodifieddevelopin my environment.