Skip to content

Images show 'Failed to load image' after closing and reopening a tab #83

@reddpy

Description

@reddpy

Description

When a user closes a tab containing images and reopens the same note from the sidebar, all images display "Failed to load image" instead of rendering correctly. The images work fine on initial paste and while the tab stays open.

Root Cause

The image node serializes only imageId to JSON (not src / local file path). On fresh mount from DB, ImageComponent resolves imageId → filePath via images.getPath IPC, then converts it to a lychee-image://image/{filename} URL. The custom protocol handler appears to fail to resolve the file at this point, causing the <img> preload to error and the component to show the error state.

Reproduction

  1. Create a new note
  2. Paste an image (any image)
  3. Wait for it to save
  4. Close the tab (click the X on the tab)
  5. Click the note in the sidebar to reopen it
  6. The image shows "Failed to load image" with the ImageOff icon

Expected Behavior

The image should load and display correctly after reopening, just as it did before closing the tab.

Context

  • Discovered while writing e2e tests for the editor auto-focus fix (Editor doesn't auto-scroll when dragging blocks near viewport edges #75 area)
  • The editor.update() for path resolution still fires correctly — only the subsequent image render via the custom protocol fails
  • exportJSON() in image-node.tsx intentionally omits __src (only persists imageId), so path resolution on reopen is the expected flow

Files

  • src/components/editor/nodes/image-component.tsx — path resolution logic (line ~104)
  • src/components/editor/nodes/image-node.tsx — serialization (exportJSON / importJSON)
  • Main process custom protocol handler for lychee-image://

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions