Repository navigation
feat(image): say why a web image failed to load on its placeholder - #94
Merged
Merged
Conversation
A download that failed left the placeholder on "Loading image..." for good. curl now prints the HTTP status, and the reason is kept per URL: an HTTP status such as "HTTP 404", a named curl error such as "timed out", or "not an image" when a 200 brought back something else. The failure rebuilds the content, and the placeholder reads "Failed to load image (HTTP 404)" in the new MdRenderImageError group. A URL that failed is not asked for again on every rebuild or scroll, which would loop; opening the view afresh retries it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
delphinus
force-pushed
the
feat/image-load-error
branch
from
November 26, 2026 12:50
2377c87 to
b893116
Compare
denny0223
added a commit
to denny0223/md-render.nvim
that referenced
this pull request
Nov 26, 2026
Keep a failed download with the open preview so neighbouring images can finish without requesting a broken URL on each layout change. An edit or a fresh preview can retry. Give an existing transfer or completed file precedence when another preview recovers the URL. Preserve direct callers' retry behaviour and the separate limits for images and explicit videos. Native splits can share one render buffer. Hand its failure state and pending layout update to the surviving view so switching focus keeps the document and its inline errors in place. Closing the last view ends that attempt and lets a reopened preview show the latest response. Reuse the Snacks picker's rendered line map while the source file and scratch buffer are current. Detect saves and replacements on disk. Retire placements when the picker rewrites its scratch buffer, before the next source can reuse their extmark IDs. Keep each source's redraw events with its own image state so a delayed terminal probe cannot remove the next preview's handlers. Follow up on #120 and delphinus#94.
denny0223
added a commit
to denny0223/md-render.nvim
that referenced
this pull request
Nov 28, 2026
Keep a failed download with the open preview so neighbouring images can finish without requesting a broken URL on each layout change. An edit or a fresh preview can retry. Give an existing transfer or completed file precedence when another preview recovers the URL. Preserve direct callers' retry behaviour and the separate limits for images and explicit videos. Native splits can share one render buffer. Hand its failure state and pending layout update to the surviving view so switching focus keeps the document and its inline errors in place. Closing the last view ends that attempt and lets a reopened preview show the latest response. Reuse the Snacks picker's rendered line map while the source file and scratch buffer are current. Detect saves and replacements on disk. Retire placements when the picker rewrites its scratch buffer, before the next source can reuse their extmark IDs. Keep each source's redraw events with its own image state so a delayed terminal probe cannot remove the next preview's handlers. Follow up on #120 and delphinus#94.
denny0223
added a commit
to denny0223/md-render.nvim
that referenced
this pull request
Nov 29, 2026
Keep the failed request with the open source so neighbouring images can finish without fetching the broken URL again. Editing the source or closing its last view starts a new attempt. When native splits share one render buffer, hand its failure state and pending layout update to the surviving view. Let a preview join an in-flight transfer or pick up a usable file another process published while its request was failing. Direct download callers still receive their own transfer result. A shared movie can play as video while the image keeps its format error and its separate retry limit. Reuse the Snacks picker's rendered line map while the source and scratch buffer are current. Retire old placements and redraw handlers before a different source can reuse their extmarks. Follow up on #120 and delphinus#94.
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.
Summary
A web image whose download failed sat on "Loading image..." for good. Now the placeholder says why:
HTTP 404(curl is run with-w %{http_code})timed out,could not resolve host,could not connect,file too large(other codes ascurl exit N)not an imagewhen a 200 brought back something else, such as a login pageThe failure rebuilds the content, and the placeholder reads
Failed to load image (HTTP 404)in the newMdRenderImageErrorgroup (fg fromDiagnosticError, on the placeholder's background). When the sentence does not fit, the reason alone is shown.A URL that failed is not asked for again on every rebuild or scroll — the failure rebuilds, and a rebuild that asked again would loop. Opening the view afresh retries it.
Changes
image.lua: keep the reason per URL (get_download_error), cleared on the next successdisplay_utils.lua: rebuild on a failed download; leave failed URLs out of the retriescontent_builder.lua: write the reason on the placeholderinit.lua:MdRenderImageErrorTest plan
make test,stylua --check .tests/image_test.lua(reasons, cleared on success),tests/image_load_error_test.lua(placeholder text and highlights)HTTP 404,not an image,could not connect:MdRender tabheadless: "Loading image..." turns into "Failed to load image (HTTP 404)", and the server sees one request onlyImages inside tables are out of scope: their rows carry no loading message and stay blank.
🤖 Generated with Claude Code