Skip to content

Stop the export when a local image cannot be embedded - #3

Merged
lecstor merged 1 commit into
mainfrom
fail-export-on-unembeddable-images
Oct 5, 2026
Merged

lecstor merged 1 commit into
mainfrom
fail-export-on-unembeddable-images

Conversation

@lecstor

@lecstor lecstor commented Oct 5, 2026

Copy link
Copy Markdown
Member

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/showMessage notification 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

  • exportToPdf stops before sending anything when inlineLocalImages reports a failure. No request is made and no PDF is written.
  • The error is a showMessageRequest with 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.
  • formatImageNotice is replaced by formatImageFailure. 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.
  • README and the unreleased 0.1.0 CHANGELOG entry describe the new behaviour.

Tests

  • npm test (typecheck, unit tests, stdio LSP integration tests): all pass.
  • New integration test: with one readable and one missing image, nothing is sent to /api/v1/md, no report.pdf is written, exactly one Error showMessageRequest appears with a Dismiss action naming missing.png and not the readable image, and no auto-dismissing notification is sent.
  • Tested by hand in Zed 1.22 with a dev extension against the local server build: the error stays until dismissed, and the export succeeds once the bad reference is removed.

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.
@lecstor
lecstor merged commit 859deb7 into main Oct 5, 2026
2 checks passed
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.

1 participant