Repository navigation
Stop the export when a local image cannot be embedded - #3
Merged
Merged
Conversation
A missing, unreadable or over-5MB local image used to produce a warning that Zed auto-dismisses after a few seconds, while the export went ahead and wrote a PDF without that image. Easy to miss, and the PDF looks finished. The export now stops before sending anything, and an error dialog with a Dismiss button (a showMessageRequest, which Zed keeps until dismissed) names each failed reference and its reason so the user can fix or remove it.
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.
Why
Found during the MAK-138 smoke test in Zed. A local image reference that could not be embedded (missing, unreadable, or over 5MB) produced a warning, and the export went ahead and wrote a PDF without that image. Zed auto-dismisses any
window/showMessagenotification after a few seconds, warnings and errors alike, so the warning was easy to miss. A user could share a PDF that is missing images without knowing it.What changed
exportToPdfstops before sending anything wheninlineLocalImagesreports a failure. No request is made and no PDF is written.showMessageRequestwith a Dismiss button. Zed only auto-dismisses messages that have no actions (crates/workspace/src/notifications.rs), so this one stays until the user dismisses it.formatImageNoticeis replaced byformatImageFailure. It names each failed reference and its reason, up to 10 then "and N more", and tells the user to fix or remove the reference. Example:makesPDF: Export stopped, no PDF was written: 1 local image could not be embedded: missing.png (could not be read). Fix or remove the reference and export again.Tests
npm test(typecheck, unit tests, stdio LSP integration tests): all pass./api/v1/md, noreport.pdfis written, exactly one ErrorshowMessageRequestappears with aDismissaction namingmissing.pngand not the readable image, and no auto-dismissing notification is sent.