Skip to content

fix(app): preview image attachments delivered by path - #57249

Merged
Hona merged 1 commit into
betafrom
path-image-preview
Oct 20, 2026
Merged

Hona merged 1 commit into
betafrom
path-image-preview

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

Problem

The composer only shows a thumbnail for images whose bytes are in the draft store. An image attached as a path attachment shows a text card with the filename and PNG instead. That happens when the image is a file the server reads by path rather than inline: it is too large to send inline, the selected model has no image input, or the composer had no resolved model when the file was added.

Fix

  • Path attachments with an image/* MIME type now render the same thumbnail as inline images. The bytes are read through the server's fs/read (readLocalImage, the same route Markdown images use), so both local source paths and paths uploaded to a remote server work.
  • Clicking the thumbnail opens the existing image preview for both kinds of attachment.
  • If the file can't be read (for example, it was deleted), the chip falls back to the existing filename card instead of showing an empty box.
  • Object URLs are cached per path in the composer and revoked when it unmounts. Pending reads are aborted.
  • Thumbnail loading reads resource state instead of suspending, which keeps the existing focus-preserving behavior without the local Suspense.
  • readLocalImage now accepts Windows drive paths that use backslashes (C:\Users\...\image.png). Previously it rejected them as a URL scheme, so a file reference on Windows couldn't load.

Verification

  • bun run typecheck in packages/app.
  • image.test.ts: a new backslash drive-path case, which fails before the fix.
  • The composer mixed-attachments story now includes a path image attachment, and its existing component test asserts the thumbnail renders. That assertion fails before the editor change. I checked it against Storybook in Chromium; the full Playwright component harness couldn't launch a browser on my host.
  • Not run on a real Windows desktop: the Windows dev box was unreachable.

Requested by: @Hona (Hona via Slack)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant