Files
pipelines/app/notes/chat-attachment-thumbnails.md
T
alan 8c421952db feat(chat): show sent images as thumbnails with a full-screen viewer
Operator-attached images render as rounded thumbnails above the user
bubble and open a zoomable Material/Cupertino viewer. Inline data: URIs
decode locally; file:// attachment-store URIs load through the new
chat_attachment_image websocket request, which serves only regular image
files directly inside the private attachment store (os.Root, <= 4 MiB,
sniffed raster types). Missing files show an 'Image no longer available'
placeholder; other files keep the file row.
2026-10-30 20:53:03 +00:00

3.1 KiB

Chat attachment thumbnails

Images the operator sends now show as rounded thumbnails above the user bubble (up to 200x240 logical px). Tapping one opens a full-screen viewer that you can zoom with pinch or scroll. The viewer uses the platform's own close control: an IconButton in the AppBar on Material, and a CupertinoButton in the CupertinoNavigationBar on Cupertino. Other files keep the paperclip row.

How the image bytes are loaded

  • data: URI. Claude Code history stores image blocks inline, so the app decodes these directly.
  • file:// URI. OpenCode and Codex history point at the server's attachment store. The app fetches these with the new websocket request chat_attachment_image:
    • Request: {chat_attachment_image_request: {uri}}.
    • Reply: {chat_attachment_image: {uri, mime, size, data(base64)}}.
    • The server opens the store with os.Root. It serves only regular files that sit directly in that directory and are 4 MiB or smaller. The type is sniffed from the bytes and must be png, jpeg, gif, webp or bmp.
    • It refuses traversal, symlinks, nested paths, other hosts and other schemes.
    • A missing file gets the error "image is no longer available". The app then shows a placeholder that reads "Image no longer available".
  • upload:<stored name>. This is the URI on a just-sent (optimistic) row. The composer gives its own bytes to the cache, so the image shows right away. The same bytes also serve the recorded file:///…/up-… URI after the server records the turn, because the stored file name is the same. Files sent inline use their own data: URI.
  • http(s) URLs. These are never loaded. They stay as file rows.

ChatAttachmentImages is created once per thread view and per gateway. It holds the decoded bytes in memory, keyed by URI, up to 48 MiB, and drops the least recently used first. When the server refuses an image, that answer is kept and the image is not requested again. Transport errors are not kept, so a later build tries again.

Evidence

  • go test ./internal/server/ -run ChatAttachment passes. This covers a stored image, the outside, traversal, encoded, nested, symlink, directory, host, scheme, query, fragment and non-image cases, and the missing, oversize and removed-store cases.
  • flutter test (full suite) passes, including test/features/chat/ui/transcript/chat_attachment_thumbnail_test.dart and test/features/chat/domain/chat_attachment_image_test.dart.
  • flutter analyze reports only the existing info in artifact_viewer_page_test.dart.
  • flutter build web succeeds.
  • No browser or device capture was taken. The rendered look has not been checked outside widget tests.

Known gaps

  • Claude Code history drops an image block whose base64 data is over 512 KiB (internal/claude/transcript.go). After a reload, such an image is missing from the turn entirely, so there is nothing to draw.
  • Images over 4 MiB show "Image too large to preview". The limit exists because the reply is a single websocket frame that the server must write within its 5 s deadline, and the client sends requests one at a time.